From the course: Unity: Integrating GPS and Points of Interest
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Dynamic button listeners, part 1 - Unity Tutorial
From the course: Unity: Integrating GPS and Points of Interest
Dynamic button listeners, part 1
- Okay guys, let's get this button working now. Now, what I've done is I've dragged back out the prefab so that I can give you a bit of a visual example of what's actually happening here. Now, we have the listing prefab which is getting duplicated as we go down. We have the icon, the first text item, the second text item, and then we have this button which, within it, has its own little text item. Now, what I'm actually trying to do is dynamically change the onclick event. Now, normally you just click add, drag in a function and decide where to go, but the problem is we don't actually know where we want to go until the data has been loaded dynamically on the loop. So, for that what we're going to do is we're going to write some code and add a listener using script so we can dynamically call the function when we click it. Therefore, we're using code to set the onclick event listener. Okay, so how do we do that? Well, first of all we need to get a hold of the button. I'll just delete…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Creating a Google Cloud live account9m 31s
-
(Locked)
App layout and scrolling menu buttons9m 22s
-
(Locked)
Project setup7m 18s
-
Create a scene controller13m 34s
-
(Locked)
Connect the GPS class to the place finder app11m 14s
-
(Locked)
Load data from a website URL, part 1 from inside Unity8m 43s
-
(Locked)
Load data from a website URL from inside Unity, part 29m 48s
-
(Locked)
Refactor code to improve functionality3m 56s
-
(Locked)
Process the JSON code from a URL11m 23s
-
(Locked)
Populate a virtual object with JSON data16m 1s
-
(Locked)
Use the real names on prefabs3m 31s
-
(Locked)
Calculate distance using GPS14m 27s
-
(Locked)
Dynamic button listeners, part 14m 16s
-
(Locked)
Dynamic button listeners, part 211m 54s
-
(Locked)
Sort results by nearest first, part 110m 12s
-
(Locked)
Sort results by nearest first, part 28m 43s
-
(Locked)
Sort results by nearest first, part 39m 56s
-
(Locked)
-