Ejemplo n.º 1
0
    static int set_luaUIComArray(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("Framework.LuaUIPanel.luaUIComArray");
#endif
        object o = null;

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

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaUIPanel obj = (Framework.LuaUIPanel)o;
            Framework.LuaUICom[] ret = obj.luaUIComArray;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index luaUIComArray on a nil value"));
        }
    }
    static int set_LuaUIPanel(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("Framework.LuaUICom.LuaUIPanel");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Framework.LuaUICom   obj  = (Framework.LuaUICom)o;
            Framework.LuaUIPanel arg0 = (Framework.LuaUIPanel)ToLua.CheckObject <Framework.LuaUIPanel>(L, 2);
            obj.LuaUIPanel = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index LuaUIPanel on a nil value"));
        }
    }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            var originalColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("\r\n" + "更新Prefab信息" + "\r\n"))
            {
                LuaUIPanel ctrl = target as LuaUIPanel;
                if (null == ctrl)
                {
                    return;
                }
                LuaUICom[] comArray = ctrl.gameObject.GetComponentsInChildren <LuaUICom>();
                Dictionary <string, List <int> > repeatNameDict = new Dictionary <string, List <int> >();
                for (int i = 0; i < comArray.Length; i++)
                {
                    comArray[i].LuaUIPanel = ctrl;
                    if (string.IsNullOrEmpty(comArray[i].LuaUIComName))
                    {
                        comArray[i].LuaUIComName = checkInvalidFormatName(comArray[i].gameObject.name);
                    }
                    var name = comArray[i].LuaUIComName;
                    for (int j = i + 1; j < comArray.Length; j++)
                    {
                        var str = comArray[j].LuaUIComName;
                        if (name == str)
                        {
                            List <int> list;
                            if (!repeatNameDict.TryGetValue(name, out list))
                            {
                                list = new List <int>();
                                repeatNameDict[name] = list;
                                list.Add(j);
                            }
                            list.Add(i);
                        }
                    }
                }
                if (repeatNameDict.Count > 0)
                {
                    StringBuilder builder = new StringBuilder();
                    foreach (var temp in repeatNameDict)
                    {
                        if (temp.Value.Count > 0)
                        {
                            temp.Value.Sort();

                            for (int i = 0; i < temp.Value.Count; i++)
                            {
                                builder.Append(temp.Value[i].ToString() + ",");
                            }
                            builder.Append("name repeat:" + temp.Key);
                        }
                        builder.AppendLine(" ");
                    }
                    EditorUtility.DisplayDialog("Dialog", builder.ToString(), "确认");
                    return;
                }
                ctrl.luaUIComArray = new LuaUICom[comArray.Length];
                for (int i = 0; i < ctrl.luaUIComArray.Length; i++)
                {
                    ctrl.luaUIComArray[i] = comArray[i];
                }
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("\r\n" + "创建Controller" + "\r\n"))
            {
                LuaUIPanel ctrl = target as LuaUIPanel;
                if (null == ctrl)
                {
                    LogHelper.PrintError("[LuaUIPanelEditor]LuaUIPanel is null.");
                    return;
                }
                string name     = ctrl.gameObject.name;
                string fileName = _ctrlPath + name + "Ctrl.lua";
                string allText  = _ctrlBuilder.ToString().Replace("ModuleName", name);
                if (File.Exists(fileName))
                {
                    GUIUtility.systemCopyBuffer = allText;
                    EditorUtility.DisplayDialog("Dialog", "file:" + name + "Ctrl.lua" + " 已存在,成功复制到剪切板!", "确认");
                    return;
                }
                TextWriter tw = new StreamWriter(fileName);
                tw.Close();
                File.WriteAllText(fileName, allText);
                EditorUtility.DisplayDialog("Dialog", "file:" + name + "Ctrl.lua" + " 生成成功!", "确认");
                AssetDatabase.Refresh();
            }
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("\r\n" + "更新Panel" + "\r\n"))
            {
                LuaUIPanel ctrl = target as LuaUIPanel;
                if (null == ctrl)
                {
                    LogHelper.PrintError("[LuaUIPanelEditor]LuaUIPanel 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.luaUIComArray.Length; i++)
                {
                    comStr = comStr + _luaCom.Replace("ComName", ctrl.luaUIComArray[i].LuaUIComName).Replace("index", i.ToString());
                }
                string allText = tempStr.Replace("#List#", comStr);
                File.WriteAllText(fileName, allText);
                EditorUtility.DisplayDialog("Dialog", "file:" + name + "Panel.lua" + " 生成成功!", "确认");
                AssetDatabase.Refresh();
            }
            GUI.backgroundColor = Color.blue;

            GUI.backgroundColor = originalColor;
        }