Added defualt graph properties inspector;
Added sticky note; Changed the name of BaseNode to SlotContainerNode in case we need other type of nodes in the future;
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.GraphView.Sample.Editor
|
||||
{
|
||||
[CustomEditor(typeof(SampleGraphAsset))]
|
||||
public class SampleGraphAssetEditor : UnityEditor.Editor
|
||||
{
|
||||
[OnOpenAsset]
|
||||
public static bool OnOpenAsset(int instanceID, int line)
|
||||
{
|
||||
var asset = EditorUtility.InstanceIDToObject(instanceID) as SampleGraphAsset;
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
SampleGraphEditor.Open(asset);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (GUILayout.Button("Execute"))
|
||||
{
|
||||
var asset = target as SampleGraphAsset;
|
||||
asset?.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Sample/Editor/View.meta
Normal file
3
Sample/Editor/View.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6196bfe4913b43c48a128bc5d8a94a51
|
||||
timeCreated: 1730603519
|
||||
45
Sample/Editor/View/SampleGraphAssetEditor.cs
Normal file
45
Sample/Editor/View/SampleGraphAssetEditor.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Misaki.GraphView.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.GraphView.Sample.Editor
|
||||
{
|
||||
[CustomEditor(typeof(SampleGraphAsset))]
|
||||
public class SampleGraphAssetEditor : GraphObjectEditor
|
||||
{
|
||||
[OnOpenAsset]
|
||||
public static bool OnOpenAsset(int instanceID, int line)
|
||||
{
|
||||
var asset = EditorUtility.InstanceIDToObject(instanceID) as SampleGraphAsset;
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
SampleGraphEditor.Open(asset);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
var root = new VisualElement();
|
||||
var graphProperties = CreateInspectorProperty();
|
||||
|
||||
var executeButton = new Button(() =>
|
||||
{
|
||||
var graph = target as SampleGraphAsset;
|
||||
graph?.Execute();
|
||||
})
|
||||
{
|
||||
text = "Execute"
|
||||
};
|
||||
|
||||
root.Add(graphProperties);
|
||||
root.Add(executeButton);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ namespace Misaki.GraphView.Sample.Editor
|
||||
{
|
||||
public class SampleGraphEditor : EditorWindow
|
||||
{
|
||||
private const string Icon_Path = "Packages/com.misaki.graph-view/Sample/Icon/icons8-workflow-96.png";
|
||||
|
||||
[SerializeField]
|
||||
private StyleSheet _styleSheet;
|
||||
|
||||
@@ -21,15 +23,15 @@ namespace Misaki.GraphView.Sample.Editor
|
||||
private static void Open()
|
||||
{
|
||||
var window = CreateWindow<SampleGraphEditor>(typeof(SceneView));
|
||||
window.titleContent = new GUIContent("Sample Graph Editor");
|
||||
window.titleContent = new GUIContent("Sample Graph Editor", EditorGUIUtility.IconContent(Icon_Path).image);
|
||||
}
|
||||
|
||||
public static void Open(GraphObject asset)
|
||||
{
|
||||
var window = GetWindow<SampleGraphEditor>(typeof(SceneView));
|
||||
window.titleContent = new GUIContent(asset.name, EditorGUIUtility.IconContent(Icon_Path).image);
|
||||
window.Clear();
|
||||
window.LoadAsset(asset);
|
||||
window.titleContent = new GUIContent(asset.name);
|
||||
window.DrawGraph();
|
||||
window.Focus();
|
||||
}
|
||||
Reference in New Issue
Block a user