Skip to content

Instantly share code, notes, and snippets.

@lain-dono
Created April 23, 2015 06:43
Show Gist options
  • Save lain-dono/8e5f59382e90b6180fd3 to your computer and use it in GitHub Desktop.
Save lain-dono/8e5f59382e90b6180fd3 to your computer and use it in GitHub Desktop.
SwitchActive for Unity3D
using UnityEngine;
public class SwitchActive : MonoBehaviour {
public enum ModeType { Toggle, On, Off };
public GameObject Object;
public ModeType Mode;
public void UserInteraction() {
switch(Mode) {
case ModeType.Off:
if (Object.activeSelf)
Object.SetActive (false);
break;
case ModeType.On:
if (!Object.activeSelf)
Object.SetActive (true);
break;
case ModeType.Toggle:
Object.SetActive(!Object.activeSelf);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment