Created
May 16, 2016 10:34
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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