public override object OnGUI(Rect _position, GUIContent _label)
        {
            base.OnGUI(_position, _label);

            Rect preRect = new Rect(0, _position.y, _position.width / 3, _position.height);

            var target = Target as PropertyInfo;

            GUILayoutExtension.VerticalGroup(() =>
            {
                int maxValue = EditorGUILayout.IntField(GUIHelper.TextContent("Max:", $"{_label.text}最大值"), target.Max);
                if (maxValue != target.Max)
                {
                    target.SetMax(maxValue);
                }

                int minValue = EditorGUILayout.IntField(GUIHelper.TextContent("Min:", $"{_label.text}最小值"), target.Min);
                if (minValue != target.Min)
                {
                    target.SetMin(minValue);
                }

                int currValue = EditorGUILayout.IntField(GUIHelper.TextContent("Curr:", $"{_label.text}初始值"), target.Curr);
                if (currValue != target.Curr)
                {
                    target.Curr = currValue;
                }
            });

            return(Target);
        }
Example #2
0
        private void DrawRequestSort(RequestSort sort)
        {
            GUILayoutExtension.VerticalGroup(() =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.TextField(sort.key);
                sort.name = EditorGUILayout.TextField(sort.name);

                if (!sort.isCover && !sort.isCustom)
                {
                    MiscHelper.Btn("Up", 50, 35, () =>
                    {
                        sort.sort--;
                        UpdateSystemSort();
                    });
                    MiscHelper.Btn("Down", 50, 35, () =>
                    {
                        sort.sort++;
                        UpdateSystemSort();
                    });
                    MiscHelper.Btn("Del", 50, 35, () =>
                    {
                        sortAsset.requests.Remove(sort);
                        UpdateSystemSort();
                    });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("覆盖:");
                bool isCover = EditorGUILayout.Toggle(sort.isCover);
                if (isCover != sort.isCover)
                {
                    sort.isCover = isCover;
                    if (sort.isCover)
                    {
                        sort.isCustom = false;
                    }
                    UpdateSystemSort();
                }

                GUILayout.Label("自定义:");
                bool isCustom = EditorGUILayout.Toggle(sort.isCustom);
                if (isCustom != sort.isCustom)
                {
                    sort.isCustom = isCustom;
                    if (sort.isCustom)
                    {
                        sort.isCover = false;
                    }
                    UpdateSystemSort();
                }
                EditorGUILayout.EndHorizontal();
            });
        }
 private void DrawGraphPath(TimelineGroupPath path)
 {
     GUILayoutExtension.VerticalGroup(() =>
     {
         GUILayout.Label($"{path.typeName}", BigLabel.value);
         string newPath = MiscHelper.FolderPath("分组目录:", path.searchPath);
         if (newPath != path.searchPath)
         {
             path.searchPath = newPath;
             EditorUtility.SetDirty(settingAsset);
         }
     });
 }
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label("Graph", bigLabel.value);
            });

            if (Target is BaseGraphView view && view.Model != null)
            {
                GUILayoutExtension.VerticalGroup(() =>
                {
                    GUILayout.Label(string.Concat("Nodes:", view.Model.Nodes.Count), bigLabel.value);
                    GUILayout.Label(string.Concat("Connections:", view.Model.Connections.Count), bigLabel.value);
                });

                EditorGUI.BeginChangeCheck();
                GUILayoutExtension.VerticalGroup(() => {
                    foreach (var property in view.Model)
                    {
                        if (IgnoreProperties.Contains(property.Key))
                        {
                            continue;
                        }

                        object newValue = GUILayoutExtension.DrawField(property.Value.ValueType, property.Value.ValueBoxed, GraphProcessorEditorUtility.GetDisplayName(property.Key), property.Value.ValueTooltip);
                        if (newValue == null || !newValue.Equals(property.Value.ValueBoxed))
                        {
                            view.CommandDispacter.Do(new BindableChangeValueCommand(property.Value, newValue));
                            //property.Value.ValueBoxed = newValue;
                        }
                    }
                });
                if (EditorGUI.EndChangeCheck())
                {
                }
            }
        }
Example #5
0
        private void OnGUI()
        {
            GUILayoutExtension.VerticalGroup(() =>
            {
                InputStr = EditorGUILayout.TextField("请输入:", InputStr);

                EditorGUILayout.Space();

                MiscHelper.Btn("确定", position.width * 0.9f, position.height * 0.5f, () => {
                    if (CallBack != null && InputStr != "")
                    {
                        CallBack(InputStr);
                        Close();
                    }
                });
            });
        }
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            ClipModel clipModel = Target as ClipModel;

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label("Clip:" + clipModel.TitleName, bigLabel.value);
            });

            float tStart = EditorGUILayout.FloatField("Start", clipModel.StartTime);

            if (tStart != clipModel.StartTime)
            {
                clipModel.SetStart((float)tStart);
            }

            float tEnd = EditorGUILayout.FloatField("End", clipModel.EndTime);

            if (tEnd != clipModel.EndTime)
            {
                clipModel.SetEnd((float)tEnd);
            }

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.FloatField("Duration", clipModel.DurationTime);
            EditorGUI.EndDisabledGroup();

            foreach (var field in Fields)
            {
                if (field.Name == "StartTime" || field.Name == "EndTime" || field.Name == "DurationTime")
                {
                    continue;
                }
                DrawFields(field);
            }
        }
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }
            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label("Connection", bigLabel.value);
            });

            if (Target is BaseConnectionView view && view.Model != null)
            {
                GUILayoutExtension.VerticalGroup(() => {
                    GUILayout.Label(string.Concat(view.output?.node.title, ":", view.Model.FromPortName, "  >>  ", view.input?.node.title, ":", view.Model.ToPortName), bigLabel.value);
                });

                EditorGUI.BeginChangeCheck();
                GUILayoutExtension.VerticalGroup(() => {
                    foreach (var property in view.Model)
                    {
                        if (IgnoreProperties.Contains(property.Key))
                        {
                            continue;
                        }

                        object newValue = GUILayoutExtension.DrawField(property.Value.ValueType, property.Value.ValueBoxed, GraphProcessorEditorUtility.GetDisplayName(property.Key), property.Value.ValueTooltip);
                        if (!newValue.Equals(property.Value.ValueBoxed))
                        {
                            property.Value.ValueBoxed = newValue;
                        }
                    }
                });

                if (EditorGUI.EndChangeCheck())
                {
                }
            }
        }
Example #8
0
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            TrackModel trackModel = Target as TrackModel;

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label("Track:" + trackModel.TitleName, bigLabel.value);
            });

            base.OnInspectorGUI();
        }
Example #9
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            InternalTimelineGraphGroupAsset groupAsset = target as InternalTimelineGraphGroupAsset;

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"{groupAsset.DisplayName}:{groupAsset.name}", bigLabel.value);
            });

            GUILayoutExtension.VerticalGroup(() => {
                List <InternalTimelineGraphAsset> graphs = groupAsset.GetAllGraph();
                for (int i = 0; i < graphs.Count; i++)
                {
                    DrawGraph(groupAsset, graphs[i]);
                }
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                if (GUILayout.Button($"创建{groupAsset.DisplayName}", GUILayout.Height(50)))
                {
                    groupAsset.OnClickCreateBtn();
                }

                if (GUILayout.Button($"导出{groupAsset.DisplayName}配置", GUILayout.Height(50)))
                {
                    groupAsset.OnClickExport();
                }
            });
        }
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out BigLabel))
            {
                BigLabel.value              = new GUIStyle(GUI.skin.label);
                BigLabel.value.fontSize     = 18;
                BigLabel.value.fontStyle    = FontStyle.Bold;
                BigLabel.value.alignment    = TextAnchor.MiddleLeft;
                BigLabel.value.stretchWidth = true;
            }

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"视图路径设置", BigLabel.value);
            });

            foreach (var item in settingAsset.groupPaths)
            {
                DrawGraphPath(item);
            }
        }
Example #11
0
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            MiscHelper.Btn("清除废弃系统", 250, 35, () =>
            {
                for (int i = 0; i < sortAsset.updateSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.updateSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.updateSystems.RemoveAt(i);
                    }
                }

                for (int i = 0; i < sortAsset.fixedUpdateSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.fixedUpdateSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.fixedUpdateSystems.RemoveAt(i);
                    }
                }

                for (int i = 0; i < sortAsset.threadSystems.Count; i++)
                {
                    SystemSort sort = sortAsset.threadSystems[i];
                    if (ReflectionHelper.GetType(sort.typeFullName) == null)
                    {
                        sortAsset.threadSystems.RemoveAt(i);
                    }
                }

                UpdateSystemSort();
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"系统运行排序", bigLabel.value);
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label(" ----------- Update ----------- ", bigLabel.value);
                List <SystemSort> upSorts = sortAsset.GetSystemSorts(SystemType.Update);
                for (int i = 0; i < upSorts.Count; i++)
                {
                    DrawSystemSort(upSorts[i], SystemType.Update);
                }

                GUILayout.Label(" ----------- FixedUpdate ----------- ", bigLabel.value);
                List <SystemSort> fixedSorts = sortAsset.GetSystemSorts(SystemType.FixedUpdate);
                for (int i = 0; i < fixedSorts.Count; i++)
                {
                    DrawSystemSort(fixedSorts[i], SystemType.FixedUpdate);
                }

                //GUILayout.Label(" ----------- Thread ----------- ", bigLabel.value);
                //List<SystemSort> threadSorts = sortAsset.GetSystemSorts(SystemType.Thread);
                //for (int i = 0; i < threadSorts.Count; i++)
                //{
                //    DrawSystemSort(threadSorts[i], SystemType.Thread);
                //}
            });
        }
Example #12
0
        private void OnGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            //工具栏
            GUILayoutExtension.HorizontalGroup(() =>
            {
                string selMap = currSelMap == null ? "Null" : currSelMap.mapId.ToString();
                GUILayout.Label($"当前地图:{selMap}", bigLabel.value);

                if (GUILayout.Button("加载地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    List <string> mapNames = new List <string>();
                    for (int i = 0; i < maps.Count; i++)
                    {
                        mapNames.Add(maps[i].mapId.ToString());
                    }
                    MiscHelper.Menu(mapNames, (string selMap) =>
                    {
                        ED_MapCom mapAsset = GetMap(int.Parse(selMap));
                        GameObject mapGo   = (GameObject)PrefabUtility.InstantiatePrefab(mapAsset.gameObject);
                        OnChangeMap(mapGo.GetComponent <ED_MapCom>());
                    });
                }

                if (currSelMap != null)
                {
                    if (GUILayout.Button("保存地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                    {
                        SaveMap(currSelMap);
                        Refresh();
                    }
                }

                if (GUILayout.Button("新建地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    MiscHelper.Input("输入地图Id", (string x) =>
                    {
                        if (GetMap(int.Parse(x)) != null)
                        {
                            Debug.LogError($"地图Id重复>>>>{x}");
                            return;
                        }
                        SaveMap(currSelMap);
                        ED_MapCom mapCom = MapEditorDef.CreateMapGo(x);
                        mapCom.SetUid(GetMapStartUid());
                        OnChangeMap(mapCom);
                    });
                }

                if (GUILayout.Button("导出所有配置", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    ED_MapCom.ActorCnfs   = MapEditorWindow.ActorCnfs;
                    List <ED_MapCom> maps = MapSetting.GetAllMaps();
                    for (int i = 0; i < maps.Count; i++)
                    {
                        GameObject mapGo    = GameObject.Instantiate(maps[i].gameObject);
                        ED_MapCom eD_MapCom = mapGo.GetComponent <ED_MapCom>();
                        MapModel model      = eD_MapCom.ExportData();

                        string filePath = MapSetting.GetMapModelSavePath(model.mapId.ToString());
                        IOHelper.WriteText(JsonMapper.ToJson(model), filePath);

                        DestroyImmediate(eD_MapCom.gameObject);
                        Debug.Log($"地图配置生成成功>>>>{filePath}");
                    }
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }, GUILayout.Height(50));

            GUILayoutExtension.HorizontalGroup(() =>
            {
                //演员分组列表
                GUILayoutExtension.VerticalGroup(() =>
                {
                    GUILayout.Label("演员列表", bigLabel.value);
                    for (int i = 0; i < ActorCnfs.Count; i++)
                    {
                        if (GUILayout.Button($"{ActorCnfs[i].name}-{ActorCnfs[i].id}", GUILayout.Width(100), GUILayout.Height(BtnHeight)))
                        {
                            ED_ActorCom actorCom   = currSelMap.CreateActor(ActorCnfs[i]);
                            Selection.activeObject = actorCom;
                        }
                    }
                }, GUILayout.Width(50));
            });
        }
Example #13
0
        public override void OnInspectorGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            MiscHelper.Btn("清除废弃请求", 250, 35, () =>
            {
                for (int i = 0; i < sortAsset.requests.Count; i++)
                {
                    RequestSort request = sortAsset.requests[i];
                    if (!Enum.TryParse <RequestId>(request.key, out RequestId id))
                    {
                        sortAsset.requests.RemoveAt(i);
                    }
                }
                UpdateSystemSort();
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"请求排序", bigLabel.value);
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label(" ----------- 覆盖请求 ----------- ", bigLabel.value);
                for (int i = 0; i < coverReqests.Count; i++)
                {
                    DrawRequestSort(coverReqests[i]);
                }

                GUILayout.Label(" ----------- 自定义规则请求 ----------- ", bigLabel.value);
                for (int i = 0; i < customReqests.Count; i++)
                {
                    DrawRequestSort(customReqests[i]);
                }

                GUILayout.Label(" ----------- 排序请求 ----------- ", bigLabel.value);
                for (int i = 0; i < sortReqests.Count; i++)
                {
                    DrawRequestSort(sortReqests[i]);
                }

                if (GUILayout.Button("创建请求", GUILayout.Height(50)))
                {
                    MiscHelper.Input("输入请求名", (x) =>
                    {
                        if (sortAsset.GetSort(x) != null)
                        {
                            Debug.LogError($"请求重复>>>>{x}");
                            return;
                        }
                        RequestSort sort = new RequestSort();
                        sort.key         = x;
                        sort.name        = x;
                        sort.sort        = sortAsset.requests.Count;
                        sortAsset.requests.Add(sort);
                        GenCode();
                    });
                }

                if (GUILayout.Button("生成请求代码", GUILayout.Height(50)))
                {
                    GenCode();
                }
            });
        }
Example #14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            ConfigAssetGroup groupAsset = target as ConfigAssetGroup;

            GUILayoutExtension.VerticalGroup(() =>
            {
                GUILayout.Label($"Config:{groupAsset.name}", bigLabel.value);
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                List <Type> cnfTypes   = new List <Type>();
                List <string> cnfNames = new List <string>();
                foreach (var item in ReflectionHelper.GetChildTypes <IConfig>())
                {
                    string displayName = item.Name;
                    if (AttributeHelper.TryGetTypeAttribute(item, out ConfigAttribute attr))
                    {
                        displayName = attr.DisplayName;
                    }
                    cnfNames.Add(displayName);
                    cnfTypes.Add(item);
                }
                if (groupAsset.configTypeFullName == null)
                {
                    EditorGUILayout.HelpBox("没有选择配置类!!!", MessageType.Error);
                    MiscHelper.Dropdown($"选择的配置类", cnfNames, (int a) => {
                        groupAsset.configTypeFullName = cnfTypes[a].FullName;
                        groupAsset.configTypeName     = cnfTypes[a].Name;
                    }, 300);
                }
                else
                {
                    MiscHelper.Dropdown(groupAsset.configTypeFullName, cnfNames, (int a) => {
                        groupAsset.configTypeFullName = cnfTypes[a].FullName;
                        groupAsset.configTypeName     = cnfTypes[a].Name;
                    }, 300);
                }
            });

            GUILayoutExtension.VerticalGroup(() => {
                List <ConfigAsset> assets = groupAsset.GetAllAsset();
                for (int i = 0; i < assets.Count; i++)
                {
                    DrawGraph(groupAsset, assets[i]);
                }
            });

            GUILayoutExtension.VerticalGroup(() =>
            {
                if (GUILayout.Button($"创建配置", GUILayout.Height(50)))
                {
                    MiscHelper.Input($"输入配置名:", (string name) =>
                    {
                        groupAsset.CreateAsset(name);
                    });
                }
            });
        }