Inheritance: MonoBehaviour
    private static int RemoveExtendEvent(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            LuaTypes luaTypes = LuaDLL.lua_type(L, 1);
            LuaBehaviour.UiExtendEventDeal func;
            if (luaTypes != LuaTypes.LUA_TFUNCTION)
            {
                func = (LuaBehaviour.UiExtendEventDeal)ToLua.CheckObject(L, 1, typeof(LuaBehaviour.UiExtendEventDeal));
            }
            else
            {
                LuaFunction func2 = ToLua.ToLuaFunction(L, 1);
                func = (DelegateFactory.CreateDelegate(typeof(LuaBehaviour.UiExtendEventDeal), func2) as LuaBehaviour.UiExtendEventDeal);
            }
            LuaBehaviour.RemoveExtendEvent(func);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 2
0
 public static void SA(LuaBehaviour lb, bool isActive)
 {
     if (lb != null)
     {
         lb.gameObject.SetActive(isActive);
     }
 }
Exemplo n.º 3
0
        public void Awake()
        {
            behaviour  = target as LuaBehaviour;
            monoScript = MonoScript.FromMonoBehaviour(behaviour);
            if (behaviour.regLuaObject != null && behaviour.regLuaObject.Length > 0)
            {
                luaObjList.AddRange(behaviour.regLuaObject);
            }

            if (behaviour.regLuaBehaviour != null && behaviour.regLuaBehaviour.Length > 0)
            {
                luaBehList.AddRange(behaviour.regLuaBehaviour);
            }

            if (behaviour.regLuaBehaviourArr != null && behaviour.regLuaBehaviourArr.Length > 0)
            {
                luaBehArrList.AddRange(behaviour.regLuaBehaviourArr);
            }

            if (behaviour.regLuaObjectArr != null && behaviour.regLuaObjectArr.Length > 0)
            {
                luaObjArrList.AddRange(behaviour.regLuaObjectArr);
            }

            if (!string.IsNullOrEmpty(behaviour.scriptShortPath))
            {
                scriptAssetPath = LuaScriptPathDir + behaviour.scriptShortPath;
            }
        }
Exemplo n.º 4
0
 public static void HandlePanel(LuaBehaviour lb, bool isShow, float duration)
 {
     // float alpha = isShow ? 1 : 0;
     if (isShow)
     {
         UIWidget widget = lb.GetComponent <UIWidget>();
         if (widget != null)
         {
             widget.alpha = widget.alpha >= 0.8f ? 0 : widget.alpha;
         }
         UIPanel panel = lb.GetComponent <UIPanel>();
         if (panel != null)
         {
             panel.alpha = panel.alpha >= 0.8f ? 0 : panel.alpha;
         }
         SA(lb, true);
         TweenAlpha.Begin(lb.gameObject, duration, 1);
     }
     else
     {
         TweenAlpha.Begin(lb.gameObject, duration, 0).AddOnFinished(() =>
         {
             SA(lb, false);
             UnityEngine.Object.Destroy(lb.GetComponent <TweenAlpha>());
         });
     }
 }
Exemplo n.º 5
0
 public static void Set(LuaBehaviour lb, string name)
 {
     if (lb != null)
     {
         Set(lb.gameObject, name);
     }
 }
Exemplo n.º 6
0
 void Awake()
 {
     if (lua_behaviour_ == null)
     {
         lua_behaviour_ = gameObject.GetComponent <LuaBehaviour>();
     }
 }
Exemplo n.º 7
0
    public void InitFilename(LuaBehaviour lb)
    {
        GameObject    go            = lb.gameObject;
        string        fileFullname  = "UI";
        string        fileShortname = go.transform.name.Trim().Replace("Clone", "");
        List <string> ps            = new List <string>();

        Transform p = go.transform.parent;

        while (p != null && p.transform.parent != p)
        {
            if (p.name != "Camera" && p.name != "UI Root")
            {
                ps.Add(p.name);
                p = p.parent;
            }
            else
            {
                break;
            }
        }
        for (int i = ps.Count - 1; i >= 0; i--)
        {
            fileFullname  = fileFullname + "/" + ps[i];
            fileShortname = fileShortname + "_" + ps[i];
        }
        oldTablename = lb.tableName;
        curTablename = fileShortname;

        oldFileFullname = lb.luaFilename;
        curFileFullname = fileFullname + "/" + curTablename + ".lua";
    }
Exemplo n.º 8
0
        /// <summary>
        /// 修改lua文件前做的一些参数校验
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="filename"></param>
        /// <param name="respath"></param>
        /// <param name="alert"></param>
        static public void ModificationLuaFile(GameObject obj, string filename, string respath, bool alert)
        {
            if (obj == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(filename))
            {
                filename = obj.name;
            }
            if (string.IsNullOrEmpty(respath))
            {
                respath = GetResPath(obj);
            }
            string       buildPath = "";
            LuaBehaviour behaviour = obj.GetComponent <LuaBehaviour>();

            if (behaviour != null)
            {
                buildPath = constLuaPath + behaviour.luaFile;
            }
            else
            {
                buildPath = EditorUtility.OpenFilePanel("选择更改文件:", constPath, "lua");
            }
            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }
            ModificationLuaFileByPath(obj, buildPath, respath, alert);
        }
Exemplo n.º 9
0
    private void SetCachedCellState(bool isSpringEnd = false)
    {
        foreach (KeyValuePair <int, GameObject> kvp in m_cachedCellsDic)
        {
            if (kvp.Key != m_currentPage)
            {
                GameObject cell = m_cachedCellsDic[kvp.Key];
                if (cell.activeSelf)
                {
                    cell.SetActive(false);

                    if (isSpringEnd)
                    {
                        LuaBehaviour cellLuaBehaviour = cell.GetComponent <LuaBehaviour>();
                        if (cell != null)
                        {
                            lua_.GetGlobal(cellLuaBehaviour.ScriptName);
                            lua_.GetField(-1, "OnPageDisable");
                            lua_.RawGetI(LuaAPI.LUA_REGISTRYINDEX, cellLuaBehaviour.Object_ref);
                            lua_.RawGetI(LuaAPI.LUA_REGISTRYINDEX, controller.Object_ref);
                            lua_.PushNumber(kvp.Key);
                            lua_.PCall(3, 0, 0);
                            lua_.Pop(1);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
 static public int CallMethod(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             LuaBehaviour  self = (LuaBehaviour)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             var ret = self.CallMethod(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             LuaBehaviour  self = (LuaBehaviour)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             System.Object[] a2;
             checkParams(l, 3, out a2);
             var ret = self.CallMethod(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 11
0
    void Control_All_Lines()
    {
        string data_receive = recvQueue.Dequeue();

        if (data_receive.Equals(""))
        {
            return;
        }
        string[] arrReceiveData = data_receive.Split('|');


        int msgType;

        if (int.TryParse(arrReceiveData[0], out msgType) == false)
        {
            return;
        }



        if (reciveEvent != null)
        {
            reciveEvent.Invoke(arrReceiveData);
        }

        //if (msgType < 100)
        LuaBehaviour.sockerSendMsg(data_receive);
    }
Exemplo n.º 12
0
 protected void OnEnable()
 {
     m_LuaScriptPath = serializedObject.FindProperty("LuaScriptPath");
     mLuaBehaviour   = target as LuaBehaviour;
     lastWriteTime   = 0;
     infoList        = new List <SerializedInfo>();
 }
Exemplo n.º 13
0
        void Create(int dataIndex, bool isBottom)
        {
            if (onWillCreateItem == null)
            {
                return;
            }

            LuaBehaviour lb  = onWillCreateItem(this.transform, dataIndex);
            GameObject   obj = lb.gameObject;

            if (obj == null)
            {
                return;
            }
            var item = new TempItem();

            item.go        = obj;
            item.luaTable  = lb.GetSelf();
            item.trans     = obj.GetComponent <RectTransform>();
            item.dataIndex = dataIndex;
            if (isBottom)
            {
                itemList.Add(item);
            }
            else
            {
                item.trans.SetAsFirstSibling();
                itemList.Insert(0, item);
            }
            onInitializeItem(item.luaTable, dataIndex);
        }
Exemplo n.º 14
0
        public override void OnInspectorGUI()
        {
            if (__target == null)
            {
                __target = (LuaBehaviour)target;
            }
            GUILayout.Space(5);
            //Lua Script
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Lua Script:", GUILayout.Width(85));
            __target.LuaScript = (TextAsset)EditorGUILayout.ObjectField(__target.LuaScript, typeof(TextAsset), true);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            //Update Time
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Update Order:", GUILayout.Width(120));
            __target.UpdateOrder = EditorGUILayout.IntField(__target.UpdateOrder, GUILayout.Width(35));
            EditorGUILayout.EndHorizontal();

            //LateUpdate Time
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("LateUpdate Order:", GUILayout.Width(120));
            __target.LateUpdateOrder = EditorGUILayout.IntField(__target.LateUpdateOrder, GUILayout.Width(35));
            EditorGUILayout.EndHorizontal();

            //FixedUpdate Time
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("FixedUpdate Order:", GUILayout.Width(120));
            __target.FixedUpdateOrder = EditorGUILayout.IntField(__target.FixedUpdateOrder, GUILayout.Width(35));
            EditorGUILayout.EndHorizontal();

            base.OnInspectorGUI();
        }
Exemplo n.º 15
0
    static int Tween_Scale(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 3)
        {
            LuaBehaviour arg0 = (LuaBehaviour)LuaScriptMgr.GetUnityObject(L, 1, typeof(LuaBehaviour));
            float        arg1 = (float)LuaScriptMgr.GetNumber(L, 2);
            float        arg2 = (float)LuaScriptMgr.GetNumber(L, 3);
            UITools.Tween_Scale(arg0, arg1, arg2);
            return(0);
        }
        else if (count == 5)
        {
            LuaBehaviour arg0 = (LuaBehaviour)LuaScriptMgr.GetUnityObject(L, 1, typeof(LuaBehaviour));
            float        arg1 = (float)LuaScriptMgr.GetNumber(L, 2);
            float        arg2 = (float)LuaScriptMgr.GetNumber(L, 3);
            float        arg3 = (float)LuaScriptMgr.GetNumber(L, 4);
            float        arg4 = (float)LuaScriptMgr.GetNumber(L, 5);
            UITools.Tween_Scale(arg0, arg1, arg2, arg3, arg4);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UITools.Tween_Scale");
        }

        return(0);
    }
Exemplo n.º 16
0
    static int OnCommand(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            LuaBehaviour obj  = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "LuaBehaviour");
            string       arg0 = LuaScriptMgr.GetLuaString(L, 2);
            obj.OnCommand(arg0);
            return(0);
        }
        else if (count == 3)
        {
            LuaBehaviour obj  = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "LuaBehaviour");
            string       arg0 = LuaScriptMgr.GetLuaString(L, 2);
            object       arg1 = LuaScriptMgr.GetVarObject(L, 3);
            obj.OnCommand(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: LuaBehaviour.OnCommand");
        }

        return(0);
    }
Exemplo n.º 17
0
    static int SA(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(bool)))
        {
            GameObject arg0 = (GameObject)LuaScriptMgr.GetLuaObject(L, 1);
            bool       arg1 = LuaDLL.lua_toboolean(L, 2);
            UITools.SA(arg0, arg1);
            return(0);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(LuaBehaviour), typeof(bool)))
        {
            LuaBehaviour arg0 = (LuaBehaviour)LuaScriptMgr.GetLuaObject(L, 1);
            bool         arg1 = LuaDLL.lua_toboolean(L, 2);
            UITools.SA(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UITools.SA");
        }

        return(0);
    }
Exemplo n.º 18
0
    static int AddToggleClick(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes <UnityEngine.GameObject, LuaInterface.LuaFunction>(L, 2))
            {
                LuaBehaviour           obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2);
                LuaFunction            arg1 = ToLua.ToLuaFunction(L, 3);
                obj.AddToggleClick(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.UI.Toggle, LuaInterface.LuaFunction>(L, 2))
            {
                LuaBehaviour          obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.UI.Toggle arg0 = (UnityEngine.UI.Toggle)ToLua.ToObject(L, 2);
                LuaFunction           arg1 = ToLua.ToLuaFunction(L, 3);
                obj.AddToggleClick(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaBehaviour.AddToggleClick"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 19
0
    static int AddPartEvent(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 5);
            LuaBehaviour           obj  = (LuaBehaviour)ToLua.CheckObject(L, 1, typeof(LuaBehaviour));
            UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject));
            LuaFunction            arg1 = ToLua.CheckLuaFunction(L, 3);
            System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction> arg2 = (System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction>)ToLua.CheckObject(L, 4, typeof(System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction>));
            UITriggerListener.VoideDelegate arg3 = null;
            LuaTypes funcType5 = LuaDLL.lua_type(L, 5);

            if (funcType5 != LuaTypes.LUA_TFUNCTION)
            {
                arg3 = (UITriggerListener.VoideDelegate)ToLua.CheckObject(L, 5, typeof(UITriggerListener.VoideDelegate));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 5);
                arg3 = DelegateFactory.CreateDelegate(typeof(UITriggerListener.VoideDelegate), func) as UITriggerListener.VoideDelegate;
            }

            obj.AddPartEvent(arg0, arg1, arg2, ref arg3);
            ToLua.Push(L, arg3);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    private static int AddToggleClick(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(LuaBehaviour), typeof(Transform), typeof(LuaFunction)))
            {
                LuaBehaviour luaBehaviour = (LuaBehaviour)ToLua.ToObject(L, 1);
                Transform    transform    = (Transform)ToLua.ToObject(L, 2);
                LuaFunction  luafunc      = ToLua.ToLuaFunction(L, 3);
                luaBehaviour.AddToggleClick(transform, luafunc);
                result = 0;
            }
            else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(LuaBehaviour), typeof(GameObject), typeof(LuaFunction)))
            {
                LuaBehaviour luaBehaviour2 = (LuaBehaviour)ToLua.ToObject(L, 1);
                GameObject   go            = (GameObject)ToLua.ToObject(L, 2);
                LuaFunction  luafunc2      = ToLua.ToLuaFunction(L, 3);
                luaBehaviour2.AddToggleClick(go, luafunc2);
                result = 0;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: LuaFramework.LuaBehaviour.AddToggleClick");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 21
0
    static int SetY(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            LuaBehaviour obj  = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "LuaBehaviour");
            float        arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            obj.SetY(arg0);
            return(0);
        }
        else if (count == 3)
        {
            LuaBehaviour obj  = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "LuaBehaviour");
            float        arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            bool         arg1 = LuaScriptMgr.GetBoolean(L, 3);
            obj.SetY(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: LuaBehaviour.SetY");
        }

        return(0);
    }
Exemplo n.º 22
0
 /// <summary>
 /// 把拆分好的变量设置到luabehaviour里面
 /// </summary>
 /// <param name="Obj"></param>
 /// <param name="buildPath"></param>
 static private void SetLuaBehaviour(UnityEngine.GameObject Obj, string buildPath)
 {
     if (Obj != null)
     {
         LuaBehaviour luaBehaviour = Obj.transform.GetComponent <LuaBehaviour>();
         if (luaBehaviour == null)
         {
             luaBehaviour = Obj.AddComponent <LuaBehaviour>();
         }
         if (luaBehaviour != null)
         {
             List <BindItem> lst = new List <BindItem>();
             if (luaBehaviourDefine != null)
             {
                 foreach (KeyValuePair <string, UnityEngine.Object> pair in luaBehaviourDefine)
                 {
                     string             name  = pair.Key;
                     UnityEngine.Object obj   = pair.Value;
                     BindItem           bItem = new BindItem();
                     bItem.name = name;
                     bItem.obj  = obj;
                     lst.Add(bItem);
                 }
                 string luaFilePath = buildPath.Replace(constLuaPath, "");
                 luaBehaviour.SetInitInfo(luaFilePath, lst);
             }
         }
     }
 }
Exemplo n.º 23
0
    static int AddClick(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                LuaBehaviour           obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
                LuaFunction            arg1 = ToLua.CheckLuaFunction(L, 3);
                obj.AddClick(arg0, arg1);
                return(0);
            }
            else if (count == 4)
            {
                LuaBehaviour           obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
                LuaFunction            arg1 = ToLua.CheckLuaFunction(L, 3);
                LuaTable arg2 = ToLua.CheckLuaTable(L, 4);
                obj.AddClick(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaBehaviour.AddClick"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 24
0
    static int OnInit(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                LuaBehaviour            obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.AssetBundle arg0 = (UnityEngine.AssetBundle)ToLua.CheckObject(L, 2, typeof(UnityEngine.AssetBundle));
                obj.OnInit(arg0);
                return(0);
            }
            else if (count == 3)
            {
                LuaBehaviour            obj  = (LuaBehaviour)ToLua.CheckObject <LuaBehaviour>(L, 1);
                UnityEngine.AssetBundle arg0 = (UnityEngine.AssetBundle)ToLua.CheckObject(L, 2, typeof(UnityEngine.AssetBundle));
                string arg1 = ToLua.CheckString(L, 3);
                obj.OnInit(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaBehaviour.OnInit"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 25
0
    static int Set(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(LuaBehaviour), typeof(string)))
        {
            LuaBehaviour arg0 = (LuaBehaviour)LuaScriptMgr.GetLuaObject(L, 1);
            string       arg1 = LuaScriptMgr.GetString(L, 2);
            UITools.Set(arg0, arg1);
            return(0);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(object)))
        {
            GameObject arg0 = (GameObject)LuaScriptMgr.GetLuaObject(L, 1);
            object     arg1 = LuaScriptMgr.GetVarObject(L, 2);
            UITools.Set(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UITools.Set");
        }

        return(0);
    }
Exemplo n.º 26
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        serializedObject.Update();

        LuaBehaviour behaviour = (target as LuaBehaviour);

        if (GUILayout.Button("GetArgs"))
        {
            reflectDict.Clear();
            keyDic.Clear();

            LuaState luaState = new LuaState();
            luaState.Start();

            luaState.OpenLibs(LuaDLL.luaopen_pb);
            luaState.OpenLibs(LuaDLL.luaopen_struct);
            luaState.OpenLibs(LuaDLL.luaopen_lpeg);

            luaState.LuaGetField(LuaIndexes.LUA_REGISTRYINDEX, "_LOADED");
            luaState.OpenLibs(LuaDLL.luaopen_cjson);
            luaState.LuaSetField(-2, "cjson");

            luaState.OpenLibs(LuaDLL.luaopen_cjson_safe);
            luaState.LuaSetField(-2, "cjson.safe");

            LuaBinder.Bind(luaState);
            LuaSupport.AddSearchPath(luaState);
            luaState.Require("Define");

            luaState.DoFile(behaviour.luaFileName);

            string ctorName = behaviour.luaFileName + ".create";

            LuaFunction luaClassCreate = luaState.GetFunction(ctorName);
            LuaTable    luaClass       = luaClassCreate.Call(behaviour.gameObject)[0] as LuaTable;
            LuaTable    luaClassArgs   = luaClass["initParamNames"] as LuaTable;

            for (int i = 1; i <= luaClassArgs.Length; i++)
            {
                Debug.Log("show args:" + i + ",args:" + luaClassArgs[i]);
                string             fullArgs = Convert.ToString(luaClassArgs[i]);
                string[]           typeArr  = fullArgs.Split(new char[] { '=' });
                string             typeName = typeArr[0];
                string             t        = typeArr[1];
                UnityEngine.Object obj      = default(UnityEngine.Object);

                if (!reflectDict.ContainsKey(typeName))
                {
                    reflectDict.Add(typeName, obj);
                    keyDic.Add(typeName, t);
                }
            }
            luaState.Dispose();
        }
        Save();
        Load();
        Draw();
    }
Exemplo n.º 27
0
 void Awake()
 {
     lua_behaviour_ = gameObject.GetComponent <LuaBehaviour>();
     if (lua_behaviour_ == null)
     {
         enabled = false;
     }
 }
Exemplo n.º 28
0
    static int Send(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        LuaBehaviour obj = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "LuaBehaviour");

        obj.Send();
        return(0);
    }
    private static int ClearClick(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        LuaBehaviour luaBehaviour = (LuaBehaviour)LuaScriptMgr.GetUnityObjectSelf(L, 1, "SimpleFramework.LuaBehaviour");

        luaBehaviour.ClearClick();
        return(0);
    }
Exemplo n.º 30
0
 void Update()
 {
     if (isInitOk)
     {
         isInitOk = false;
         LuaBehaviour.AddComponent(gameObject, "luaTest1");
     }
 }