Exemplo n.º 1
0
//        该函数在调用前,必须保证当前lua栈顶有一个lua的Prefab对象。也就是说,栈不为空!
        private void BindLuaClass()
        {
            var luaState = MainGame.Ins.LuaState;

            if (luaState.LuaIsNil(-1))
            {
                BTLog.Error("该函数在调用前必须保证lua栈顶上有一个lua的Prefab对象");
                return;
            }
//            TODO 这里考虑有没有必要把这个gameObject传给lua
            luaState.PushVariant(gameObject);
            luaState.LuaSetField(-2, "gameObject");
            BindFieldsOnTrans(transform, luaState.LuaGetTop());
//            完成绑定之后,广播complete事件
            luaState.LuaGetField(-1, "DispatchMessage");
            if (luaState.LuaIsNil(-1))
            {
                luaState.LuaPop(1);
                BTLog.Warning("Prefab Lua must has Method:DispatchMessage");
                return;
            }
            luaState.LuaInsert(-2);
            luaState.Push("COMPLETE");
            luaState.LuaCall(2, 0);
        }
Exemplo n.º 2
0
        public static Type GetTypeByComponentSuffix(string suffix)
        {
            switch (suffix)
            {
            case ComponentSuffix.Text:
                return(typeof(UnityEngine.UI.Text));

            case ComponentSuffix.Button:
                return(typeof(Framework.UI.Button));

            default:
                BTLog.Warning("未定义的后缀名");
                return(null);
            }
        }
Exemplo n.º 3
0
        public static string GetTypeNameByComponentSuffix(string suffix, Transform trans)
        {
            switch (suffix)
            {
            case ComponentSuffix.Text:
                return("UnityEngine.UI.Text");

            case ComponentSuffix.Button:
                return("Framework.UI.Button");

            case ComponentSuffix.Doc:
                var doc = trans.GetComponent <DocumentClass>();
                if (doc == null)
                {
                    BTLog.Error("以Doc为后缀的名称的组件,必须拥有DocumentClass组件");
                    return("");
                }
                return(doc.GetLuaClassName());

            default:
                BTLog.Warning("未定义的后缀名");
                return(null);
            }
        }