Exploring the code

Unlike Android, we were able to easily modify our Unity app right in the editor without writing code. In fact, given the right Unity extensions, you can make a working game in Unity without any code. However, for us, we want to get into the nitty-gritty details of ARCore, and that will require writing some code. Jump back to the Unity editor, and let's look at how we can modify some code by implementing the following exercise:

  1. From the Hierarchy window, select the ExampleController object. This will pull up the object in the Inspector window.
  2. Select the Gear icon beside Hello AR Controller (Script) and from the context menu, select Edit Script, as in the following excerpt:
Editing a script in Unity
  1. This will open your script editor and load the script, by default, MonoDevelop.
Unity supports a number of Integrated Development Environments (IDEs) for writing C# scripts. Some popular options are Visual Studio 2015-2017 (Windows), VS Code (All), JetBrains Rider (Mac), and even Notepad++(All). Do yourself a favor and try one of the options listed for your OS.
  1. Scroll down in the script until you see the following block of code:
public void Update ()
{
_QuitOnConnectionErrors();
  1. After the _QuitOnConnectionErrors(); line of code, add the following code:
Debug.Log("Unity Update Method");
  1. Save the file and then go back to Unity. Unity will automatically recompile the file. If you made any errors, you will see red error messages in the status bar or console.
  2. From the menu, select File | Build and Run. As long as your device is still connected via TCP/IP, this will work. If your connection broke, just go back to the previous section and reset it.
  3. Run the app on the device.
  4. Direct your attention to Android Device Monitor and see whether you can spot those log messages.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.60