Beispiel #1
0
        internal void Start()
        {
            while (startQueue.Count > 0)
            {
                ScriptingComponent sc = startQueue.Dequeue();
                var act = GetMessage(sc, "Start");
                if (act != null)
                {
                    act.Invoke();
                }

                var mess = GetMessage(sc, "Update");
                if (mess != null)
                {
                    updates.Add(new Message(sc, mess));
                }
                mess = GetMessage(sc, "PreRender");
                if (mess != null)
                {
                    preRender.Add(new Message(sc, mess));
                }

                mess = GetMessage(sc, "PostRender");
                if (mess != null)
                {
                    postRender.Add(new Message(sc, mess));
                }

                mess = GetMessage(sc, "OnDestroy");
                if (mess != null)
                {
                    onDestroy.Add(new Message(sc, mess));
                }
            }
        }
Beispiel #2
0
        Action GetMessage(ScriptingComponent sc, string name)
        {
            MethodInfo method  = sc.Type.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance);
            Action     message = null;

            if (method != null && method.GetGenericArguments().Length == 0)
            {
                message = (Action)Delegate.CreateDelegate(typeof(Action), sc, method);
            }

            return(message);
        }
Beispiel #3
0
 internal void Awake()
 {
     while (awakeQueue.Count > 0)
     {
         ScriptingComponent sc = awakeQueue.Dequeue();
         var act = GetMessage(sc, "Awake");
         if (act != null)
         {
             act.Invoke();
         }
         sc.IsInstalized = true;
         startQueue.Enqueue(sc);
     }
 }
Beispiel #4
0
 public Message(ScriptingComponent sc, Action method)
 {
     Method          = method;
     ScriptingObject = sc;
 }
Beispiel #5
0
 internal void RemoveScript(ScriptingComponent sc)
 {
     scripts.Remove(sc);
     updates.RemoveAll((m) => m.ScriptingObject == sc);
     preRender.RemoveAll((m) => m.ScriptingObject == sc);
 }
Beispiel #6
0
 internal void AddScript(ScriptingComponent sc)
 {
     scripts.Add(sc);
     awakeQueue.Enqueue(sc);
 }