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:
Misaki
2024-11-04 01:02:30 +09:00
parent 5a9d8b9420
commit 7eec130b39
53 changed files with 517 additions and 436 deletions

View File

@@ -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
View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6196bfe4913b43c48a128bc5d8a94a51
timeCreated: 1730603519

View 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;
}
}
}

View File

@@ -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();
}

View File

@@ -17,6 +17,18 @@ MonoBehaviour:
- rid: 299037523270959197
- rid: 299037523270959199
- rid: 299037535202443351
_stickyNotes:
- _id: 940a3025-e571-4b33-8d7c-c86761a95017
title: Title
contents: Test
position:
serializedVersion: 2
x: 764.2733
y: 223.30664
width: 164
height: 156.66666
theme: 0
fontSize: 1
_connections:
- _inputSlotData:
slotName: a
@@ -56,8 +68,8 @@ MonoBehaviour:
valueType: System.Single
_exposedProperties:
- rid: 299037523270959195
graphPosition: {x: -76.666664, y: -113.333336, z: 0}
graphScale: {x: 1.21, y: 1.21, z: 1}
graphPosition: {x: 72, y: 28.666666, z: 0}
graphScale: {x: 1, y: 1, z: 1}
references:
version: 2
RefIds:
@@ -67,6 +79,7 @@ MonoBehaviour:
id: facf43a4-c260-4e6a-a767-85cdbe63505e
propertyName: Float Field
propertyType: Misaki.GraphView.Sample.FloatProperty
showInInspector: 1
value: 1
- rid: 299037523270959196
type: {class: PropertyInputNode, ns: Misaki.GraphView, asm: GraphView}
@@ -120,8 +133,8 @@ MonoBehaviour:
_id: e630425e-5b42-4839-9e4a-9b134c1e497c
position:
serializedVersion: 2
x: 840.6667
y: 437.3333
x: 847.9999
y: 437.3332
width: 124.66669
height: 78.66666
- rid: 299037523270959199
@@ -170,10 +183,10 @@ MonoBehaviour:
_id: b055be5b-5e72-4715-8981-d38913599762
position:
serializedVersion: 2
x: 507.88882
y: 437.76617
width: 0
height: 0
x: 495.33328
y: 437.3333
width: 116.66666
height: 102.66666
a: 1
b: 0
- rid: 299037535202443351
@@ -222,9 +235,9 @@ MonoBehaviour:
_id: c45162b3-f131-44ac-a36f-26b579c4626c
position:
serializedVersion: 2
x: 673.3334
x: 679.3334
y: 437.3333
width: 116.666626
width: 116.66669
height: 102.66666
a: 0
a: 1
b: 0

8
Sample/Icon.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6437de69d83b04b44b43fb449f5cbf8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 63281bb8d4b34874296d5ab5ba173840
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: ac32d6575dcf0a643a0b1cd3b2b24740
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -13,7 +13,7 @@ namespace Misaki.GraphView.Sample
{
}
public void Execute(ReadOnlyCollection<BaseNode> nodes)
public void Execute(ReadOnlyCollection<SlotContainerNode> nodes)
{
_isRunning = true;
nodes.ClearAllExecuteFlag();

View File

@@ -7,24 +7,29 @@ namespace Misaki.GraphView.Sample
{
private readonly List<string> _logs = new ();
public Action<BaseNode, string, LogType> OnLog { get; set; }
public Action<SlotContainerNode, string, LogType> OnLog { get; set; }
public void LogInfo(BaseNode node, string message)
public void LogInfo(SlotContainerNode node, string message)
{
_logs.Add($"Log Info from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Info);
}
public void LogWarning(BaseNode node, string message)
public void LogWarning(SlotContainerNode node, string message)
{
_logs.Add($"Log Warning from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Warning);
}
public void LogError(BaseNode node, string message)
public void LogError(SlotContainerNode node, string message)
{
_logs.Add($"Log Error from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Error);
}
public void ClearLogs()
{
_logs.Clear();
}
}
}

View File

@@ -5,7 +5,7 @@ using Misaki.GraphView.Editor;
namespace Misaki.GraphView.Sample
{
[NodeInfo("Add", "Math")]
public class AddNode : BackTraceBaseNode
public class AddNode : BackTraceNode
{
[NodeInput]
#if UNITY_EDITOR

View File

@@ -1,6 +1,6 @@
namespace Misaki.GraphView.Sample
{
public abstract class BackTraceBaseNode : BaseNode
public abstract class BackTraceNode : SlotContainerNode
{
protected override void OnPullData(Slot input)
{

View File

@@ -3,7 +3,7 @@ using UnityEngine;
namespace Misaki.GraphView.Sample
{
[NodeInfo("Output Node", "Output")]
public class OutputNode : BackTraceBaseNode
public class OutputNode : BackTraceNode
{
[NodeInput]
private float _input;

View File

@@ -1,2 +1,11 @@
fileFormatVersion: 2
guid: a6ff09617d9e7ad4db1c77355ecb6ee1
guid: a6ff09617d9e7ad4db1c77355ecb6ee1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 63281bb8d4b34874296d5ab5ba173840, type: 3}
userData:
assetBundleName:
assetBundleVariant: