コード例 #1
0
 public virtual void OnInspectorGUI()
 {
     EditorGUI.BeginDisabledGroup(true);
     EditorGUILayout.ObjectField("Script", Script, typeof(MonoScript), false);
     EditorGUI.EndDisabledGroup();
     foreach (var field in Fields)
     {
         GUILayoutExtension.DrawField(field, Target);
     }
 }
コード例 #2
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;
            }

            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())
                {
                }
            }
        }
コード例 #3
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;
            }
            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())
                {
                }
            }
        }
コード例 #4
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;
            }
            if (window == null && config == null)
            {
                return;
            }
            GUILayoutExtension.VerticalGroup(() =>
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Script", Script, typeof(MonoScript), false);
                EditorGUI.EndDisabledGroup();

                bigLabel.value.alignment = TextAnchor.MiddleLeft;
                GUILayout.Label(string.Concat("配置项:", window.currSelAsset.name), bigLabel.value);

                GUILayoutExtension.VerticalGroup(() => {
                    foreach (var field in Fields)
                    {
                        if (AttributeHelper.TryGetFieldAttribute(field, out ConfigValueAttribute attr))
                        {
                            GUILayoutExtension.DrawField(field, Target, GUIHelper.TextContent(attr.Name, attr.Tooltip));
                        }
                        else
                        {
                            GUILayoutExtension.DrawField(field, Target);
                        }
                    }
                });
            });
        }
コード例 #5
0
 public virtual void DrawFields(FieldInfo fieldInfo)
 {
     GUILayoutExtension.DrawField(fieldInfo, Target);
 }
コード例 #6
0
        private void DrawCom(BaseCom baseCom)
        {
            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;
            }

            List <FieldInfo> serFields   = new List <FieldInfo>();
            List <FieldInfo> noSerFields = new List <FieldInfo>();

            foreach (var item in ReflectionHelper.GetFieldInfos(baseCom.GetType()))
            {
                bool ignore = false;
                foreach (var ignoreName in IgnoreFieldName)
                {
                    if (item.Name.Contains(ignoreName))
                    {
                        ignore = true;
                        continue;
                    }
                }
                if (ignore)
                {
                    continue;
                }

                if (AttributeHelper.TryGetFieldAttribute(item, out NonSerializedAttribute attr))
                {
                    noSerFields.Add(item);
                }
                else
                {
                    serFields.Add(item);
                }
            }

            _serFoldout = EditorGUILayout.Foldout(_serFoldout, "Serialized:");
            if (_serFoldout)
            {
                foreach (var item in serFields)
                {
                    object newValue = GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), "");
                    if (newValue == null || !newValue.Equals(item.GetValue(baseCom)))
                    {
                        item.SetValue(baseCom, newValue);
                    }
                }
            }

            _noSerFoldout = EditorGUILayout.Foldout(_noSerFoldout, "NoSerialized:");
            if (_noSerFoldout)
            {
                EditorGUI.BeginDisabledGroup(true);
                foreach (var item in noSerFields)
                {
                    GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), "");
                }
                EditorGUI.EndDisabledGroup();
            }
        }