/// <summary> 加载Graph </summary> /// <param name="_graph"></param> public static BaseGraphWindow LoadGraph(BaseGraph _graph) { Type windowType = GraphProcessorEditorUtility.GetGraphWindowType(_graph.GetType()); 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 = CreateInstance(windowType) as BaseGraphWindow; window.SetUp(_graph); window.Show(); } else { window.Focus(); if (window.Graph != _graph) { window.SetUp(_graph); } } return(window); }
/// <summary> 从GraphAsset中加载 </summary> public static BaseGraphWindow LoadGraphFromAsset(IGraphAsset _graphAsset) { BaseGraphWindow graphWindow = LoadGraph(_graphAsset.Graph); graphWindow.GraphAsset = _graphAsset as UnityObject; return(graphWindow); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Edit", GUILayout.Height(30))) { BaseGraphWindow.LoadGraphFromAsset(target as IGraphAsset); } }
public BaseGraphView(BaseGraph _graph, CommandDispatcher _commandDispatcher, BaseGraphWindow _window) : this() { Model = _graph; CommandDispatcher = _commandDispatcher; GraphWindow = _window; EditorCoroutine coroutine = GraphWindow.StartCoroutine(Init()); RegisterCallback <DetachFromPanelEvent>(evt => { GraphWindow.StopCoroutine(coroutine); }); }
/// <summary> 从GraphAssetOwner中加载 </summary> public static BaseGraphWindow LoadGraphFromAssetOwner(GraphAssetOwner _graphAssetOwner) { BaseGraphWindow graphWindow = LoadGraph(_graphAssetOwner.Graph); graphWindow.GraphAsset = _graphAssetOwner.GraphAsset; graphWindow.GraphView.Model.InitializePropertyMapping(_graphAssetOwner); graphWindow.GraphOwner = _graphAssetOwner; return(graphWindow); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.BeginHorizontal(); // ***** //if (GUILayout.Button(new GUIContent("Flush", "清理空数据(空节点,空连接等)"), GUILayout.Height(30))) //{ // (target as BaseGraphAsset).Graph.Flush(); // EditorUtility.SetDirty(target); //} if (GUILayout.Button("Open", GUILayout.Height(30))) { BaseGraphWindow.LoadGraphFromAsset(target as BaseGraphAsset); } EditorGUILayout.EndHorizontal(); }
protected override void RegisterDrawers() { base.RegisterDrawers(); RegisterDrawer("serializedVariables", DrawSerialziedVaraibles); RegisterDrawer("variablesUnityReference", property => { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(property); EditorGUI.EndDisabledGroup(); }); RegisterDrawer("graphAsset", property => { EditorGUILayout.BeginHorizontal(); GraphAssetOwner owner = target as GraphAssetOwner; owner.GraphAsset = EditorGUILayout.ObjectField(graphContent, (target as GraphAssetOwner).GraphAsset, owner.GraphAssetType, false) as BaseGraphAsset; if (GUILayout.Button("Edit", GUILayout.Width(50))) { BaseGraphWindow.LoadGraphFromAssetOwner(target as GraphAssetOwner); } EditorGUILayout.EndHorizontal(); }); }
public DefaultGraphView(BaseGraph _graph, CommandDispatcher _commandDispatcher, BaseGraphWindow _window) : base(_graph, _commandDispatcher, _window) { }