10 #if UNITY_2017_2_OR_NEWER 11 private Material[] defaultMaterials = null;
18 defaultMaterials = GetComponent<Renderer>().materials;
20 int colorPropertyId = Shader.PropertyToID(
"_Color");
24 Debug.LogFormat(
"Object {0} is within established boundary. Position: {1}", name, gameObject.transform.position);
26 for (
int i = 0; i < defaultMaterials.Length; i++)
29 defaultMaterials[i].SetColor(colorPropertyId, Color.green);
34 Debug.LogFormat(
"Object {0} is outside established boundary. Position: {1}", name, gameObject.transform.position);
36 for (
int i = 0; i < defaultMaterials.Length; i++)
39 defaultMaterials[i].SetColor(colorPropertyId, Color.red);
44 private void OnDestroy()
46 for (
int i = 0; i < defaultMaterials.Length; i++)
48 Destroy(defaultMaterials[i]);