using UnityEngine;
using System.Collections;
using UnityEditor;

[AddComponentMenu("MGUB Event Editor/Sub Event")]
public class SubEvent : SceneEvent {
    public SceneEvent parent;

	// Update is called once per frame
	void Update () {
        if (running) {
            Run();
        }
	}

    private void Reset() {
        looping = true;
    }

    public override void OnEventEnd() {
        base.OnEventEnd();
        if (parent != null) {
            parent.OnEventEnd();
            parent = null;
        }
    }

    /*
    #if UNITY_EDITOR
        [MenuItem("GameObject/MGUB Event System/Sub Event", false, 10)]
        static void CreateSubEvent(MenuCommand menuCommand) {
            GameObject parent = menuCommand.context as GameObject;
            if (parent != null) {
                GameObject go = new GameObject(parent.name.Replace(" ", "") + "SubEvent");
                go.AddComponent<SubEvent>();
                GameObjectUtility.SetParentAndAlign(go, parent);
                Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
                Selection.activeObject = go;
            }
        }
    #endif
    */
}
