Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class TestStates : StateMachineBehaviourEx {
- public enum MyStates {
- A,
- B,
- }
- // Use this for initialization
- void Start () {
- useGUI = true;
- currentState = MyStates.A;
- }
- // Update is called once per frame
- void Update () {
- }
- void OnGUI() {
- GUILayout.Space(20f);
- GUILayout.BeginHorizontal();
- if (GUILayout.Button("action 1", GUILayout.Height(20f))) {
- currentState = MyStates.A;
- }
- if (GUILayout.Button("action 2", GUILayout.Height(20f))) {
- currentState = MyStates.B;
- }
- GUILayout.EndHorizontal();
- }
- IEnumerator A_EnterState() {
- Debug.Log("entered A");
- yield return null;
- }
- IEnumerator A_ExitState() {
- Debug.Log("exited A");
- yield return null;
- }
- IEnumerator B_EnterState() {
- Debug.Log("entered B");
- yield return null;
- }
- IEnumerator B_ExitState() {
- Debug.Log("exited B");
- yield return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement