Created
April 23, 2015 06:43
-
-
Save lain-dono/8e5f59382e90b6180fd3 to your computer and use it in GitHub Desktop.
SwitchActive for Unity3D
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; | |
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