示例#1
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 = currSelAsset == null ? "Null" : currSelAsset.name;
                GUILayout.Label($"µ±Ç°ÅäÖÃ:{selMap}", bigLabel.value);

                if (currSelAsset != null)
                {
                    if (GUILayout.Button("±£´æÅäÖÃ", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                    {
                        SaveAsset(currSelAsset);
                    }
                }
            }, GUILayout.Height(50));

            if (currSelAsset != null)
            {
                GUILayoutExtension.ScrollView(ref ScrollPos, () =>
                {
                    GUILayoutExtension.HorizontalGroup(() =>
                    {
                        EditorGUILayout.Space(35);
                        //×Ö¶Î
                        foreach (var fieldInfo in fields.Keys)
                        {
                            ConfigValueAttribute attr = fields[fieldInfo];
                            Rect rect = GetFieldRect(fieldInfo);
                            EditorGUI.LabelField(rect, GUIHelper.TextContent(attr.Name, attr.Tooltip), bigLabel.value);
                        }
                    });

                    for (int i = 0; i < configs.Count; i++)
                    {
                        IConfig config = configs[i];
                        GUILayoutExtension.HorizontalGroup(() =>
                        {
                            GUI.color = Color.white;
                            if (IsInSel(config))
                            {
                                GUI.color = SelectColor;
                            }
                            MiscHelper.Btn("Ñ¡Ôñ", 35, 35, () =>
                            {
                                OnClickSelBtn(config);
                            });
                            foreach (var fieldInfo in fields.Keys)
                            {
                                object value = fieldInfo.GetValue(config);
                                //float height = GUIExtension.GetHeight(fieldInfo.FieldType, value, GUIHelper.TextContent(""));
                                object newValue = GUIExtension.DrawField(GetFieldRect(fieldInfo), value, GUIHelper.TextContent(""));
                                if (newValue == null || !newValue.Equals(value))
                                {
                                    CommandDispacter.Do(new ChangeValueCommand(config, fieldInfo, newValue));
                                }
                            }
                            GUI.color = Color.white;
                        });
                    }
                });
            }
            OnHandleEvent(Event.current);
        }