예제 #1
0
파일: FLuaManager.cs 프로젝트: mengtest/x1
 public static FLuaManager getInstance()
 {
     if (m_luaManager == null)
     {
         m_luaManager = new FLuaManager();
     }
     return(m_luaManager);
 }
예제 #2
0
        void Awake()
        {
            m_className  = gameObject.name;
            m_luaManager = FLuaManager.getInstance();
            LuaEnv luaEnv = m_luaManager.getEnv();

            LuaTable viewTable = luaEnv.Global.Get <LuaTable> (m_className);
            LuaTable ctrlTable = luaEnv.Global.Get <LuaTable> (m_className + "Ctrl");

            if (viewTable == null)
            {
                Debug.Log("not found " + m_className + " with in lua scripts");
                return;
            }
            if (ctrlTable == null)
            {
                Debug.Log("not found " + m_className + "Ctrl with in lua scripts");
                return;
            }

            viewTable.Set("gameObject", gameObject);
            viewTable.Set("transform", transform);

            m_luaInit               = viewTable.Get <Action> ("init");
            m_luaAwake              = viewTable.Get <Action> ("Awake");
            m_luaOnEnable           = viewTable.Get <Action> ("OnEnable");
            m_luaOnDisable          = viewTable.Get <Action> ("OnDisable");
            m_luaStart              = viewTable.Get <Action> ("Start");
            m_luaUpdate             = viewTable.Get <Action> ("Update");
            m_luaFixedUpdate        = viewTable.Get <Action> ("FixedUpdate");
            m_luaOnDestroy          = viewTable.Get <Action> ("OnDestroy");
            m_luaOnApplicationPause = viewTable.Get <Action> ("OnApplicationPause");
            m_luaOnApplicationFocus = viewTable.Get <Action> ("OnApplicationFocus");
            m_luaOnApplicationQuit  = viewTable.Get <Action> ("OnApplicationQuit");

            // 注册按钮的回调函数
            var btns = transform.GetComponentsInChildren <Button> (true);

            foreach (var btn in btns)
            {
                FLuaButtonEvent buttnEvent = btn.GetComponent <FLuaButtonEvent> ();
                if (buttnEvent == null)
                {
                    buttnEvent = btn.gameObject.AddComponent <FLuaButtonEvent> ();
                }
            }

            if (m_luaInit != null)
            {
                m_luaInit();
            }

            if (m_luaAwake != null)
            {
                m_luaAwake();
            }
        }
예제 #3
0
        void Awake()
        {
            m_pivot       = gameObject.GetComponentInParent <FLuaBehaviour> ();
            m_button      = gameObject.GetComponent <Button> ();
            m_luaEnv      = FLuaManager.getInstance().getEnv();
            m_buttonEvent = m_luaEnv.Global.Get <LuaTable> ("ButtonEvent");

            m_luaFunc = m_buttonEvent.Get <System.Action <System.Object, System.Object> > ("onClick");
            m_button.onClick.AddListener(onClick);
        }