Unity Fails to Build iOS Game due to “LocationService” being used

Ran into an interesting problem while trying to compile a Unity project for iOS. It failed to build because

“LocationService class is used but Locations Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)”

LocationService class is used but Locations Usage Description is empty

Well as far as I know there is not anything calling or requesting location services. I probably could have just put a reason for requesting the service under the build options in Project Settings. But why “use” something we don’t need?

Using the handy grep tool from a terminal, I was able to search through the project for “LocationService” and that returned a couple hits for files in the PlayMaker folder.

Looks like PlayMaker has a couple preconfigured “scripts” for Starting, Stopping, and Requesting Location.

Deleting the following four C# files resolved the error and it built fine afterwards.

GetLocationInfo
StopLocationServiceUpdates
StartLocationServiceUpdates
ProjectLocationToMap

You can find these files in your project under Assets > PlayMaker > Actions > Device

Unity 3D – Changing color on game object changes color on other objects in scene

Problem: When changing the shader color on a game object, the color on other game objects changes.

Reason: This happens because the other game objects are using the same Mesh Renderer as the game object your modifying.  So when your changing the shader, your actually modifying the Mesh Renderer, not the game object.

Fix: Change the Mesh Renderer for the game object.

In the example picture below, when you change the color on the cube (highlighted red) the color on the capsule changes, because they both are using the same Mesh Renderer (highlighted green).  To fix, change either the Cube or Capsule to a different Mesh Renderer (highlighted green)

Unity 2D C# Script to Spawn Object on Screen at Touch Position

You’ll need a touch screen to test this out.  Easiest way is to use the Unity Remote 5 app.  It allows you to use your Android device as a touch screen input.

Start by creating a new empty C# script named “TouchScript” and paste in the following code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TouchScript : MonoBehaviour {

public GameObject bullet;

void Start () {

}

void Update () {
Touch myTouch = Input.GetTouch (0);
for(int i =0; i < Input.touchCount; i++)
if (myTouch.phase == TouchPhase.Began) {
{
Debug.Log ("Touch Position" + myTouch.position);
SpawnBullet (myTouch);
}
}
}

void SpawnBullet(Touch fireTouch) {
Vector3 touchPos = Camera.main.ScreenToWorldPoint (fireTouch.position);
touchPos.z = 1; // Puts the z coordinates at 1 so it is visible to the camera.
Debug.Log("Vector3 Pos" + touchPos);
Instantiate (bullet, touchPos, Quaternion.identity);
}
}

Now you’ll need to put your script on a game object.  You should be able to drag and drop it on any game object, in this case the Main Camera “green”.

Next drag and drop the game object prefab to the script “red”.  This tells the script which game object to spawn or instantiate when you touch the screen.

Run the scene.  It should now create a game object where you touch on the screen.