/// <summary> 从Graph类型获取对应的GraphWindow </summary> public static BaseGraphWindow GetGraphWindow(Type graphType) { var windowType = GraphProcessorEditorUtility.GetGraphWindowType(graphType); UnityObject[] objs = Resources.FindObjectsOfTypeAll(windowType); BaseGraphWindow window = null; foreach (var obj in objs) { if (obj.GetType() == windowType) { window = obj as BaseGraphWindow; break; } } if (window == null) { window = GetWindow(windowType) as BaseGraphWindow; } window.Focus(); return(window); }
protected virtual Type GetNodeViewType(BaseNode node) { return(GraphProcessorEditorUtility.GetNodeViewType(node.GetType())); }
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(); } }
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()) { } } }
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()) { } } }