No edit summary |
m (Protected "Example Scripts" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))) |
(No difference)
|
Revision as of 06:47, 26 July 2014
Activate an Array of Lights at Night
JavaScript:
private var uniStormSystem : GameObject; var hourOfEvent : int; var eventTestBool : boolean; var lightParent : GameObject; function Awake () { //Find the UniStorm Weather System Editor, this must match the UniStorm Editor name uniStormSystem = GameObject.Find("UniStormSystemEditor"); } function Start () { if (uniStormSystem == null) { //Error Log if script is unable to find UniStorm Editor Debug.LogError("<color=red>Null Reference:</color> You must have the UniStorm Editor in your scene and named 'UniStormSystemEditor'. Make sure your C# UniStorm Editor has this name. "); } } function Update () { if (uniStormSystem != null) { if (uniStormSystem.GetComponent(UniStormWeatherSystem_JS).hourCounter >= hourOfEvent && eventTestBool == false) { for(var gameObj : Light in lightParent.FindObjectsOfType(Light)) { gameObj.enabled = true; eventTestBool = true; } } if (uniStormSystem.GetComponent(UniStormWeatherSystem_JS).hourCounter >= 6 && uniStormSystem.GetComponent(UniStormWeatherSystem_JS).hourCounter <= 7 && eventTestBool == true) { for(var gameObj : Light in lightParent.FindObjectsOfType(Light)) { gameObj.enabled = false; eventTestBool = false; } } } }
C#
private GameObject uniStormSystem; public int hourOfEvent; public bool eventTestBool; public GameObject lightParent; void Awake () { //Find the UniStorm Weather System Editor, this must match the UniStorm Editor name uniStormSystem = GameObject.Find("UniStormSystemEditor"); } void Start () { if (uniStormSystem == null) { //Error Log if script is unable to find UniStorm Editor Debug.LogError("<color=red>Null Reference:</color> You must have the UniStorm Editor in your scene and named 'UniStormSystemEditor'. Make sure your C# UniStorm Editor has this name. "); } } void Update () { if (uniStormSystem != null) { if (uniStormSystem.GetComponent<UniStormWeatherSystem_JS>().hourCounter >= hourOfEvent && eventTestBool == false) { for each(var gameObj : Light in lightParent.FindObjectsOfType(Light)) { gameObj.enabled = true; eventTestBool = true; } } if (uniStormSystem.GetComponent<UniStormWeatherSystem_C>().hourCounter >= 6 && uniStormSystem.GetComponent<UniStormWeatherSystem_C>().hourCounter <= 7 && eventTestBool == true) { for each(var gameObj : Light in lightParent.FindObjectsOfType(Light)) { gameObj.enabled = false; eventTestBool = false; } } } }