Exemple #1
0
 protected void Awake()
 {
     BloxGlobal.Instance = this;
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     base.gameObject.name = "BloxGlobal";
     this.CleanupBloxDefsListAndBuildCache();
 }
 protected void Awake()
 {
     Debug.Log("Container awake", this);
     BloxGlobal.Create(this.bloxGlobalPrefab);
     this.customEvents = new Dictionary <string, List <BloxEvent> >();
     this.bloxVarCache = new Dictionary <string, BloxVariables>();
     Debug.Log("生成事件和变量缓存");
     for (int i = 0; i < this.bloxVars.Count; i++)
     {
         Debug.Log("添加变量缓存" + this.bloxVars[i].bloxIdent + " 值 " + this.bloxVars[i]);
         this.bloxVarCache.Add(this.bloxVars[i].bloxIdent, this.bloxVars[i]);
         this.CheckVariables(this.bloxVars[i], BloxGlobal.Instance.FindBloxDef(this.bloxIdents[i]));
         this.bloxVars[i].BuildCache();
     }
     for (int j = 0; j < this.bloxIdents.Count; j++)
     {
         Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdents[j]);
         if (!((UnityEngine.Object)blox == (UnityEngine.Object)null))
         {
             if (!this.bloxVarCache.ContainsKey(this.bloxIdents[j]))
             {
                 BloxVariables bloxVariables = new BloxVariables();
                 bloxVariables.bloxIdent = this.bloxIdents[j];
                 this.bloxVars.Add(bloxVariables);
                 this.bloxVarCache.Add(bloxVariables.bloxIdent, bloxVariables);
                 this.CheckVariables(bloxVariables, blox);
                 bloxVariables.BuildCache();
             }
             this.AttachComponents(blox);
         }
     }
 }
Exemple #3
0
 private static void RegisterEventsHandlers()
 {
     BloxGlobal.RegisterEventHandlerType("Custom", typeof(Custom_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/Awake", typeof(Common_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/Start", typeof(Common_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/OnDestroy", typeof(Common_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/OnEnable", typeof(Common_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/OnDisable", typeof(Common_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/Update", typeof(Update_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/LateUpdate", typeof(UpdateLate_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Common/FixedUpdate", typeof(UpdateFixed_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionEnter", typeof(Collision3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionExit", typeof(Collision3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionStay", typeof(Collision3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionEnter(...)", typeof(Collision3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionExit(...)", typeof(Collision3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionStay(...)", typeof(Collision3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionEnter2D", typeof(Collision2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionExit2D", typeof(Collision2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnCollisionStay2D", typeof(Collision2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionEnter2D(...)", typeof(Collision2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionExit2D(...)", typeof(Collision2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/with Info/OnCollisionStay2D(...)", typeof(Collision2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnControllerColliderHit", typeof(CharController_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Collision/OnParticleCollision", typeof(Particle_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerEnter", typeof(Trigger3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerExit", typeof(Trigger3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerStay", typeof(Trigger3D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerEnter(...)", typeof(Trigger3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerExit(...)", typeof(Trigger3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerStay(...)", typeof(Trigger3D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerEnter2D", typeof(Trigger2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerExit2D", typeof(Trigger2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/OnTriggerStay2D", typeof(Trigger2D_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerEnter2D(...)", typeof(Trigger2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerExit2D(...)", typeof(Trigger2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Trigger/with Info/OnTriggerStay2D(...)", typeof(Trigger2D_nfo_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseDrag", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseEnter", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseExit", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseOver", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseUp", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseDown", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Input/OnMouseUpAsButton", typeof(Mouse_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnApplicationFocus", typeof(Application_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnApplicationPause", typeof(Application_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnApplicationQuit", typeof(Application_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnLevelWasLoaded", typeof(Application_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnAnimatorMove", typeof(Animator_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnAnimatorIK", typeof(Animator_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnAudioFilterRead", typeof(Audio_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnBecameInvisible", typeof(Renderer_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnBecameVisible", typeof(Renderer_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnJointBreak", typeof(Joint_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnTransformParentChanged", typeof(Transform_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnTransformChildrenChanged", typeof(Transform_BloxEventHandler));
     BloxGlobal.RegisterEventHandlerType("Misc/OnGUI", typeof(OnGUI_BloxEventHandler));
 }
        private void AttachEventHandlers(Blox b)
        {
            if (!b.bloxLoaded)
            {
                b.Deserialize();
            }
            Common_BloxEventHandler common_BloxEventHandler = null;

            for (int i = 0; i < b.events.Length; i++)
            {
                if (b.events[i].active)
                {
                    b.events[i].Init(this);
                    if (b.events[i].ident.Equals("Custom"))
                    {
                        if (!this.customEvents.ContainsKey(b.events[i].screenName))
                        {
                            this.customEvents.Add(b.events[i].screenName, new List <BloxEvent>());
                        }
                        this.customEvents[b.events[i].screenName].Add(b.events[i]);
                    }
                    else
                    {
                        Type type = BloxGlobal.FindEventHandlerType(b.events[i].ident);
                        if (type == null)
                        {
                            Debug.LogWarning("Could not find a handler for: " + b.events[i].ident, base.gameObject);
                        }
                        else
                        {
                            BloxEventHandler bloxEventHandler = (BloxEventHandler)base.gameObject.GetComponent(type);
                            if ((UnityEngine.Object)bloxEventHandler == (UnityEngine.Object)null)
                            {
                                bloxEventHandler           = (BloxEventHandler)base.gameObject.AddComponent(type);
                                bloxEventHandler.container = this;
                                if (bloxEventHandler.GetType() == typeof(Common_BloxEventHandler))
                                {
                                    common_BloxEventHandler = (Common_BloxEventHandler)bloxEventHandler;
                                }
                            }
                            bloxEventHandler.AddEvent(b.events[i]);
                        }
                    }
                }
            }
            if ((UnityEngine.Object)common_BloxEventHandler != (UnityEngine.Object)null)
            {
                common_BloxEventHandler.Awake();
                common_BloxEventHandler.OnEnable();
            }
        }
Exemple #5
0
 protected void Awake()
 {
     BloxGlobal.Create(this.bloxGlobalPrefab);
     this.customEvents = new Dictionary <string, List <BloxEvent> >();
     this.BuildVarCache();
     for (int i = 0; i < this.bloxIdents.Count; i++)
     {
         Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdents[i]);
         if (!((UnityEngine.Object)blox == (UnityEngine.Object)null))
         {
             if (!this.bloxVarCache.ContainsKey(this.bloxIdents[i]))
             {
                 BloxVariables bloxVariables = new BloxVariables();
                 bloxVariables.bloxIdent = this.bloxIdents[i];
                 this.bloxVars.Add(bloxVariables);
                 this.bloxVarCache.Add(bloxVariables.bloxIdent, bloxVariables);
                 this._CheckVariables(bloxVariables, blox);
                 bloxVariables.BuildCache();
             }
             this.AttachComponents(blox);
         }
     }
 }