From the course: Unity: Integrating GPS and Points of Interest
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Refactor code to improve functionality - Unity Tutorial
From the course: Unity: Integrating GPS and Points of Interest
Refactor code to improve functionality
- Okay guys, welcome back. Now, this video's a little bit different because what I've actually done is I've jumped back through in the course slightly to refactor this code a little bit to make it a little bit better. Refactor basically means rejig or move around if you are unfamiliar with the term. Now what we've just done, if I just open up the scene controller for a second, here we go, we are setting the ask Google command on click of the button, and we're overwriting the keyword and calling the request. Then what the existing video would have told you to do would be to create another variable and pass this text element, this string, through to the following script. But there's a better way of doing things. So what we're going to do is, inside Unity, let's just create inside the scripts folder which is inside pack. I'm just going to create a new C sharp script which we would have done anyway for the list view. Okay, now let's open up the list bar. In fact, let's switch scenes…
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
-
-
-
-
Creating a Google Cloud live account9m 31s
-
App layout and scrolling menu buttons9m 22s
-
Project setup7m 18s
-
Create a scene controller13m 34s
-
Connect the GPS class to the place finder app11m 14s
-
Load data from a website URL, part 1 from inside Unity8m 43s
-
Load data from a website URL from inside Unity, part 29m 48s
-
Refactor code to improve functionality3m 56s
-
Process the JSON code from a URL11m 23s
-
Populate a virtual object with JSON data16m 1s
-
Use the real names on prefabs3m 31s
-
Calculate distance using GPS14m 27s
-
Dynamic button listeners, part 14m 16s
-
Dynamic button listeners, part 211m 54s
-
Sort results by nearest first, part 110m 12s
-
Sort results by nearest first, part 28m 43s
-
Sort results by nearest first, part 39m 56s
-
-