Exemplo n.º 1
0
    static int set_componentArray(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaController  obj  = (Framework.LuaController)o;
            Framework.LuaComponent[] arg0 = ToLua.CheckObjectArray <Framework.LuaComponent>(L, 2);
            obj.componentArray = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index componentArray on a nil value"));
        }
    }
Exemplo n.º 2
0
    static int get_componentArray(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaController  obj = (Framework.LuaController)o;
            Framework.LuaComponent[] ret = obj.componentArray;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index componentArray on a nil value"));
        }
    }
Exemplo n.º 3
0
    static int set_componentArray(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("Framework.LuaController.componentArray");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaController  obj  = (Framework.LuaController)o;
            Framework.LuaComponent[] arg0 = ToLua.CheckObjectArray <Framework.LuaComponent>(L, 2);
            obj.componentArray = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index componentArray on a nil value"));
        }
    }
Exemplo n.º 4
0
    static int get_componentArray(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("Framework.LuaController.componentArray");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaController  obj = (Framework.LuaController)o;
            Framework.LuaComponent[] ret = obj.componentArray;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index componentArray on a nil value"));
        }
    }
Exemplo n.º 5
0
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     if (GUILayout.Button("\r\n" + "更新Prefab信息"))
     {
         LuaController ctrl = target as LuaController;
         if (null == ctrl)
         {
             return;
         }
         LuaComponent[] componentArray = ctrl.gameObject.GetComponentsInChildren <LuaComponent>();
         List <string>  nameList       = new List <string>();
         for (int i = 0; i < componentArray.Length; i++)
         {
             if (string.IsNullOrEmpty(componentArray[i].ComponentName))
             {
                 componentArray[i].ComponentName =
                     componentArray[i].gameObject.name.Replace(" ", "").Replace("(", "").Replace("(", "").Replace(")", "").Replace(")", "").Replace("{", "").Replace("}", "").Replace(".", "");
                 if (nameList.Contains(componentArray[i].ComponentName))
                 {
                     LogHelper.PrintError("[LuaControllerEditor]名字重复:" + componentArray[i].ComponentName);
                 }
                 nameList.Add(componentArray[i].ComponentName);
             }
             else
             {
                 if (nameList.Contains(componentArray[i].ComponentName))
                 {
                     LogHelper.PrintError("[LuaControllerEditor]名字重复:" + componentArray[i].ComponentName);
                 }
                 nameList.Add(componentArray[i].ComponentName);
             }
         }
         nameList.Clear();
         ctrl.componentArray = new LuaComponent[componentArray.Length];
         for (int i = 0; i < ctrl.componentArray.Length; i++)
         {
             ctrl.componentArray[i] = componentArray[i];
         }
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
     }
     if (GUILayout.Button("\r\n" + "创建Controller"))
     {
         LuaController ctrl = target as LuaController;
         if (null == ctrl)
         {
             LogHelper.PrintError("[LuaControllerEditor]LuaController is null.");
             return;
         }
         string name     = ctrl.gameObject.name;
         string fileName = _ctrlPath + name + "Ctrl.lua";
         if (File.Exists(fileName))
         {
             EditorUtility.DisplayDialog("Lua文件生成提示", "Lua文件: " + name + "Ctrl.lua" + " 已存在!", "确认");
             return;
         }
         TextWriter tw = new StreamWriter(fileName);
         tw.Close();
         string allText = _ctrlBuilder.ToString().Replace("ModuleName", name);
         File.WriteAllText(fileName, allText);
         EditorUtility.DisplayDialog("Lua文件生成提示", "Lua文件: " + name + "Ctrl.lua" + " 生成成功!", "确认");
         AssetDatabase.Refresh();
     }
     if (GUILayout.Button("\r\n" + "更新 Panel"))
     {
         LuaController ctrl = target as LuaController;
         if (null == ctrl)
         {
             LogHelper.PrintError("[LuaControllerEditor]LuaController is null.");
             return;
         }
         string name     = ctrl.gameObject.name;
         string fileName = _panelPath + name + "Panel.lua";
         if (File.Exists(fileName))
         {
             File.Delete(fileName);
         }
         TextWriter tw = new StreamWriter(fileName);
         tw.Close();
         string tempStr = _panelBuilder.ToString().Replace("ModuleName", name);
         string comStr  = "";
         for (int i = 0; i < ctrl.componentArray.Length; i++)
         {
             comStr = comStr + _luaCom.Replace("ComName", ctrl.componentArray[i].ComponentName).Replace("index", i.ToString());
         }
         string allText = tempStr.Replace("#List#", comStr);
         File.WriteAllText(fileName, allText);
         EditorUtility.DisplayDialog("Lua文件生成提示", "Lua文件: " + name + "Panel.lua" + " 生成成功!", "确认");
         AssetDatabase.Refresh();
     }
     if (GUILayout.Button("\r\n" + "创建 Data"))
     {
         LuaController ctrl = target as LuaController;
         if (null == ctrl)
         {
             LogHelper.PrintError("[LuaControllerEditor]LuaController is null.");
             return;
         }
         string name     = ctrl.gameObject.name;
         string fileName = _dataPath + name + "Data.lua";
         if (File.Exists(fileName))
         {
             EditorUtility.DisplayDialog("Lua文件生成提示", "Lua文件: " + name + "Data.lua" + " 已存在!", "确认");
             return;
         }
         TextWriter tw = new StreamWriter(fileName);
         tw.Close();
         string allText = _dataBuilder.ToString().Replace("ModuleName", name);
         File.WriteAllText(fileName, allText);
         EditorUtility.DisplayDialog("Lua文件生成提示", "Lua文件: " + name + "Data.lua" + " 生成成功!", "确认");
         AssetDatabase.Refresh();
     }
 }