private void ExecuteEvent(MonoBehaviourEvent mbe)
 {
     if (m_Actions.ContainsKey(mbe))
     {
         m_Actions[mbe].ForEach((a) => { a(); });
     }
 }
Пример #2
0
        public virtual void SetViewAsset(GameObject gameObject)
        {
            gameObject.name = config.viewName;
            this.transform  = gameObject.transform;
            ViewModelBinding binding = gameObject.GetComponent <ViewModelBinding>();

            if (binding != null)
            {
                binding.view = this;
                if (model != null)
                {
                    binding.SetModel(model);
                }
            }
            MonoBehaviourEvent objectEvent = gameObject.AddComponent <MonoBehaviourEvent>();

            objectEvent.onStartEvent   += OnCreated;
            objectEvent.onEnableEvent  += OnShow;
            objectEvent.onDisableEvent += OnHide;
            objectEvent.onDestroyEvent += OnDestroyed;
            isLoadingAsset              = false;
            if (OnLoadAsset != null)
            {
                OnLoadAsset();
            }
            if (delayShow)
            {
                Show();
            }
            delayShow = false;
        }
        public void Add(MonoBehaviourEvent mbe, Action action)
        {
            if (!m_Actions.ContainsKey(mbe))
            {
                m_Actions.Add(mbe, new List<Action>());
            }

            m_Actions[mbe].Add(action);
        }
Пример #4
0
        public virtual void SetViewAsset(GameObject gameObject)
        {
            gameObject.name = config.name;
            this.transform  = gameObject.transform;
            ViewModelBinding binding = gameObject.GetComponent <ViewModelBinding>();

            binding.view = this;
            MonoBehaviourEvent objectEvent = gameObject.AddComponent <MonoBehaviourEvent>();

            objectEvent.onStartEvent   += OnCreated;
            objectEvent.onEnableEvent  += OnShow;
            objectEvent.onDisableEvent += OnHide;
            objectEvent.onDestroyEvent += OnDestroyed;
        }
Пример #5
0
 void OnDestroy()
 {
     if (mLuaOnDestroy != null)
     {
         mLuaOnDestroy(mLuaModule, mLuaObject);
     }
     if (mLuaObject != null)
     {
         mLuaObject.Dispose();
         mLuaObject = null;
     }
     mLuaModule    = null;
     mLuaUpdate    = null;
     mLuaOnDestroy = null;
     mLuaStart     = null;
 }
Пример #6
0
    public void SetLuaModule(LuaTable module, LuaTable data = null)
    {
        mLuaModule      = module;
        mLuaStart       = module.Get <string, MonoBehaviourEvent>("Start");
        mLuaUpdate      = module.Get <string, MonoBehaviourEvent>("Update");
        mLuaFixedUpdate = module.Get <string, MonoBehaviourEvent>("FixedUpdate");
        mLuaLateUpdate  = module.Get <string, MonoBehaviourEvent>("LateUpdate");
        mLuaOnDisable   = module.Get <string, MonoBehaviourEvent>("OnDisable");
        mLuaOnEnable    = module.Get <string, MonoBehaviourEvent>("OnEnable");
        mLuaOnDestroy   = module.Get <string, MonoBehaviourEvent>("OnDestroy");
        mLuaOnGUI       = module.Get <string, MonoBehaviourEvent>("OnGUI");

        mLuaObject = LuaMgr.Instance.Env.NewTable();
        mLuaObject.Set <string, GameObject>("gameObject", gameObject);
        mLuaObject.Set <string, Transform>("transform", transform);
        mLuaObject.Set <string, LuaTable>("data", data);
        mLuaObject.Set <string, LuaBehaviour>("view", this);
    }
Пример #7
0
    public static int SetListener(IntPtr l)
    {
        int result;

        try
        {
            MonoBehaviourEvent          monoBehaviourEvent = (MonoBehaviourEvent)LuaObject.checkSelf(l);
            IMonoBehaviourEventListener listener;
            LuaObject.checkType <IMonoBehaviourEventListener>(l, 2, out listener);
            monoBehaviourEvent.SetListener(listener);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }