Skip to content

Instantly share code, notes, and snippets.

@marcosecchi
Created May 16, 2016 10:34
Show Gist options
  • Save marcosecchi/4664df4496db28c3abf885c7962e2ee2 to your computer and use it in GitHub Desktop.
Save marcosecchi/4664df4496db28c3abf885c7962e2ee2 to your computer and use it in GitHub Desktop.
If in Unity Play Mode, parses through a series of objects and assigns a material to them (to let them stand out in the scene).
using UnityEngine;
using System.Collections;
namespace TheBitCave {
public class PlayModeDetector : MonoBehaviour {
public Material material;
public GameObject[] gameObjects;
void Start () {
if(Application.isPlaying && Application.isEditor) {
foreach(GameObject go in gameObjects) {
if(go.GetComponent<Renderer>() != null)
go.GetComponent<Renderer>().material = material;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment