Compare commits
19 Commits
main
...
ScaryTestB
Author | SHA1 | Date | |
---|---|---|---|
|
a17b04566e | ||
|
7fcd596a16 | ||
|
687c52df62 | ||
|
1b941d6531 | ||
|
679f93c04d | ||
|
0b7696fc79 | ||
|
2e32a83484 | ||
|
fa5cba5ded | ||
|
020d29a6fe | ||
|
e3e851e9db | ||
|
9e512b8e8e | ||
|
fb800946ab | ||
|
c1d99aa06e | ||
|
ceac1eeba5 | ||
|
b1e0767d91 | ||
|
8d629e5cd3 | ||
|
c08c554aa4 | ||
|
f1824f8b5e | ||
|
f5c9b2833c |
@ -1,52 +1,56 @@
|
||||
using ImageProcessingGraph.Editor.Windows;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using AssetGraph.Core.GraphElements;
|
||||
using AssetGraph.Nodes;
|
||||
using ImageProcessingGraph.Editor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ImageProcessingGraph.Editor
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Image Processing Graph/New Graph")]
|
||||
public class ImageProcessingGraphAsset : ScriptableObject
|
||||
public class AssetGraphData : ScriptableObject
|
||||
{
|
||||
[SerializeReference] private List<BaseImageNode> nodes;
|
||||
[SerializeReference] private List<AssetGraphNode> nodes;
|
||||
[SerializeField] private List<GraphConnection> connections;
|
||||
[SerializeReference] public List<BaseImageNode> runOrder;
|
||||
[SerializeField] public List<StickyNote> stickyNotes;
|
||||
[SerializeReference] public List<AssetGraphNode> runOrder;
|
||||
[SerializeField] public List<AssetGraphStickyNoteData> stickyNotes;
|
||||
|
||||
public List<BaseImageNode> Nodes => nodes;
|
||||
public List<AssetGraphNode> Nodes => nodes;
|
||||
public List<GraphConnection> Connections => connections;
|
||||
|
||||
public delegate void OnRunEvent();
|
||||
public event OnRunEvent OnRun;
|
||||
public OnRunEvent OnRunEnd;
|
||||
|
||||
public ImageProcessingGraphAsset()
|
||||
public AssetGraphData()
|
||||
{
|
||||
nodes = new List<BaseImageNode>();
|
||||
nodes = new List<AssetGraphNode>();
|
||||
connections = new List<GraphConnection>();
|
||||
stickyNotes = new List<AssetGraphStickyNoteData>();
|
||||
}
|
||||
|
||||
|
||||
[OnOpenAsset(1)]
|
||||
public static bool OpenGraphAsset(int instanceID, int line)
|
||||
{
|
||||
var asset = EditorUtility.InstanceIDToObject(instanceID) as ImageProcessingGraphAsset;
|
||||
var asset = EditorUtility.InstanceIDToObject(instanceID) as AssetGraphData;
|
||||
if (asset != null)
|
||||
{
|
||||
ImageProcessingGraphEditorWindow.Open(asset);
|
||||
return true;
|
||||
}
|
||||
AssetGraphEditorWindow.Open(asset);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RunGraph()
|
||||
{
|
||||
var bleh = GetAllVariableNodesWithTypes();
|
||||
OnRun?.Invoke();
|
||||
|
||||
// Create and start the stopwatch to measure time
|
||||
@ -55,24 +59,19 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
runOrder = GetExecutionOrder(this.nodes, this.connections);
|
||||
|
||||
bool failed = false;
|
||||
|
||||
foreach (var VARIABLE in runOrder)
|
||||
{
|
||||
if (!VARIABLE.RunNode())
|
||||
{
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var VARIABLE in runOrder)
|
||||
{
|
||||
if(!VARIABLE.RunCleanUp())
|
||||
failed = true;
|
||||
VARIABLE.RunCleanUp();
|
||||
}
|
||||
|
||||
// Stop the stopwatch after running the nodes
|
||||
stopwatch.Stop();
|
||||
|
||||
// Log the elapsed time
|
||||
@ -81,15 +80,32 @@ namespace ImageProcessingGraph.Editor
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public List<(AssetGraphNode node, System.Type type)> GetAllVariableNodesWithTypes()
|
||||
{
|
||||
var result = new List<(AssetGraphNode node, System.Type type)>();
|
||||
|
||||
/// <summary>
|
||||
/// Computes a topological execution order of nodes based on their dependencies.
|
||||
/// Throws if a cycle is detected or nodes are missing from the input list.
|
||||
/// </summary>
|
||||
public List<BaseImageNode> GetExecutionOrder(List<BaseImageNode> nodes, List<GraphConnection> connections, bool debug = false)
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
var nodeType = node.GetType();
|
||||
var baseType = nodeType.BaseType;
|
||||
|
||||
if (baseType != null && baseType.IsGenericType)
|
||||
{
|
||||
if (baseType.GetGenericTypeDefinition() == typeof(VariableNode<>))
|
||||
{
|
||||
var genericArgument = baseType.GetGenericArguments()[0];
|
||||
result.Add((node, genericArgument));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<AssetGraphNode> GetExecutionOrder(List<AssetGraphNode> nodes, List<GraphConnection> connections, bool debug = false)
|
||||
{
|
||||
// === Initialization ===
|
||||
var nodeMap = new Dictionary<string, BaseImageNode>(nodes.Count);
|
||||
var nodeMap = new Dictionary<string, AssetGraphNode>(nodes.Count);
|
||||
var adjList = new Dictionary<string, List<string>>(nodes.Count);
|
||||
var inDegree = new Dictionary<string, int>(nodes.Count);
|
||||
|
||||
@ -126,7 +142,7 @@ namespace ImageProcessingGraph.Editor
|
||||
}
|
||||
|
||||
// === Topological Sort (Kahn's Algorithm) ===
|
||||
var executionOrder = new List<BaseImageNode>(nodes.Count);
|
||||
var executionOrder = new List<AssetGraphNode>(nodes.Count);
|
||||
var queue = new Queue<string>(nodes.Count);
|
||||
|
||||
foreach (var kvp in inDegree)
|
3
Editor/Scripts/Editor/Attributes.meta
Normal file
3
Editor/Scripts/Editor/Attributes.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43834c706e924da6b7f11712b89420bc
|
||||
timeCreated: 1747472390
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.NodeAttributes
|
||||
namespace AssetGraph.Core.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class NodeInfoAttribute : Attribute
|
||||
@ -10,18 +9,21 @@ namespace ImageProcessingGraph.Editor.Nodes.NodeAttributes
|
||||
private string menuItem;
|
||||
private string ussPath;
|
||||
private Type editorType;
|
||||
private string docuementationURL;
|
||||
|
||||
public string Title => name;
|
||||
public string MenuItem => menuItem;
|
||||
public string UssPath => ussPath;
|
||||
public Type EditorType => editorType;
|
||||
public string DocumentationationURL => docuementationURL;
|
||||
|
||||
public NodeInfoAttribute(string name, string menuItem = "", bool requiresImage = false, string ussPath = null, Type editorType = null)
|
||||
public NodeInfoAttribute(string name, string menuItem = "", bool requiresImage = false, string ussPath = null, Type editorType = null, string docuementationURL = null)
|
||||
{
|
||||
this.name = name;
|
||||
this.menuItem = menuItem;
|
||||
this.ussPath = ussPath;
|
||||
this.editorType = editorType;
|
||||
this.docuementationURL = docuementationURL;
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
public class IPTPort : Port
|
||||
{
|
||||
public FieldInfo fieldInfo;
|
||||
private VisualElement _exposedPropertyContainer;
|
||||
|
||||
public delegate void OnPortConnectedEvent();
|
||||
public OnPortConnectedEvent OnPortConnected;
|
||||
|
||||
public delegate void OnPortDisconnectedEvent();
|
||||
public OnPortDisconnectedEvent OnPortDisconnected;
|
||||
|
||||
public VisualElement ExposedPropertyContainer
|
||||
{
|
||||
set
|
||||
{
|
||||
_exposedPropertyContainer = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return _exposedPropertyContainer;
|
||||
}
|
||||
}
|
||||
|
||||
protected IPTPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Connect(Edge edge)
|
||||
{
|
||||
base.Connect(edge);
|
||||
OnPortConnected?.Invoke();
|
||||
}
|
||||
|
||||
public override void Disconnect(Edge edge)
|
||||
{
|
||||
base.Disconnect(edge);
|
||||
OnPortDisconnected?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
private void PublicOnConnected(Port obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static IPTPort Create(IEdgeConnectorListener connectorListener, bool isInput, Type type)
|
||||
{
|
||||
var port = new IPTPort(Orientation.Horizontal, isInput ? Direction.Input : Direction.Output,
|
||||
isInput ? Capacity.Single : Capacity.Multi, type)
|
||||
{
|
||||
m_EdgeConnector = new EdgeConnector<Edge>(connectorListener),
|
||||
};
|
||||
port.AddManipulator(port.m_EdgeConnector);
|
||||
return port;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
public class IPT_Preferences : ScriptableObject
|
||||
{
|
||||
public bool debugMode = false;
|
||||
}
|
||||
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80dcc02594d68e3439df7dc743c9d4b2
|
@ -3,29 +3,17 @@ using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// A structure that holds image pixel data and its dimensions.
|
||||
/// </summary>
|
||||
|
||||
namespace AssetGraph.Core.DataTypes
|
||||
{
|
||||
[Serializable]
|
||||
|
||||
public struct ImageData
|
||||
{
|
||||
/// <summary>
|
||||
/// The pixel data of the image in Color32 format.
|
||||
/// </summary>
|
||||
public NativeArray<Color32> PixelData;
|
||||
|
||||
/// <summary>
|
||||
/// The width and height of the image (width, height).
|
||||
/// </summary>
|
||||
public (int width, int height) Dimensions;
|
||||
|
||||
public bool isRGBA;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageData"/> struct using existing pixel data and dimensions.
|
||||
/// </summary>
|
||||
/// <param name="imageData">The pixel data as a NativeArray of Color32.</param>
|
||||
/// <param name="widthHeight">A tuple containing the width and height of the image.</param>
|
||||
public ImageData(NativeArray<Color32> imageData, (int width, int height) widthHeight, bool isRgba)
|
||||
{
|
||||
PixelData = imageData;
|
||||
@ -33,10 +21,6 @@ public struct ImageData
|
||||
isRGBA = isRgba;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageData"/> struct from a Texture2D object.
|
||||
/// </summary>
|
||||
/// <param name="sourceTexture">The source texture to extract pixel data from.</param>
|
||||
public ImageData(Texture2D sourceTexture)
|
||||
{
|
||||
PixelData = new NativeArray<Color32>(sourceTexture.GetPixelData<Color32>(0), Allocator.Persistent);
|
||||
@ -44,20 +28,9 @@ public struct ImageData
|
||||
isRGBA = sourceTexture.format == TextureFormat.RGBA32;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of the image.
|
||||
/// </summary>
|
||||
public int Width => Dimensions.width;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the image.
|
||||
/// </summary>
|
||||
public int Height => Dimensions.height;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the ImageData back into a new Texture2D.
|
||||
/// </summary>
|
||||
/// <returns>A Texture2D object created from the stored pixel data.</returns>
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
var texture = new Texture2D(Width, Height, TextureFormat.RGBA32, false);
|
||||
@ -73,7 +46,8 @@ public struct ImageData
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
System.IO.File.WriteAllBytes(path, data);
|
||||
File.WriteAllBytes(path, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,46 +2,22 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single image channel (e.g., Red, Green, Blue, Alpha) as a 1D byte array,
|
||||
/// along with the original image dimensions.
|
||||
/// </summary>
|
||||
namespace AssetGraph.Core.DataTypes
|
||||
{
|
||||
public struct SplitChannelData
|
||||
{
|
||||
/// <summary>
|
||||
/// The 8-bit intensity values for a single image channel, stored in row-major order.
|
||||
/// </summary>
|
||||
public byte[] ChannelData;
|
||||
|
||||
/// <summary>
|
||||
/// The width and height of the channel data (width, height).
|
||||
/// </summary>
|
||||
public (int width, int height) Dimensions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SplitChannelData"/> struct
|
||||
/// using channel data and dimensions.
|
||||
/// </summary>
|
||||
/// <param name="channelData">The byte array representing the single channel values.</param>
|
||||
/// <param name="widthHeight">A tuple of (width, height) representing the dimensions.</param>
|
||||
public SplitChannelData(byte[] channelData, (int width, int height) widthHeight)
|
||||
{
|
||||
ChannelData = channelData;
|
||||
Dimensions = widthHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of the channel data.
|
||||
/// </summary>
|
||||
public int Width => Dimensions.width;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the channel data.
|
||||
/// </summary>
|
||||
public int Height => Dimensions.height;
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the channel data is valid (non-null and matches the expected size).
|
||||
/// </summary>
|
||||
public bool IsValid => ChannelData != null && ChannelData.Length == Width * Height;
|
||||
}
|
||||
|
||||
}
|
3
Editor/Scripts/Editor/GraphElements.meta
Normal file
3
Editor/Scripts/Editor/GraphElements.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 458de9252a6744148203b96771e2ad90
|
||||
timeCreated: 1747472377
|
68
Editor/Scripts/Editor/GraphElements/AssetGraphStickyNote.cs
Normal file
68
Editor/Scripts/Editor/GraphElements/AssetGraphStickyNote.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetGraph.Core.GraphElements
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AssetGraphStickyNoteData
|
||||
{
|
||||
[SerializeField] private string guid;
|
||||
[SerializeField] private string title;
|
||||
[SerializeField] private string content;
|
||||
[SerializeField] private Rect position;
|
||||
[SerializeField] private Vector2 size;
|
||||
|
||||
|
||||
public string GUID { get => guid; }
|
||||
|
||||
public string Title { get => title; set => title = value; }
|
||||
|
||||
public string Content { get => content; set => content = value; }
|
||||
public Rect Position { get => position; set => position = value; }
|
||||
public Vector2 Size { get => size; set => size = value; }
|
||||
|
||||
public AssetGraphStickyNoteData(string title)
|
||||
{
|
||||
this.guid = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class AssetGraphStickyNote : StickyNote
|
||||
{
|
||||
private AssetGraphStickyNoteData data;
|
||||
public AssetGraphStickyNoteData Data => data;
|
||||
|
||||
private AssetGraphViewWindow window;
|
||||
|
||||
public AssetGraphStickyNote(AssetGraphStickyNoteData data, AssetGraphViewWindow window)
|
||||
{
|
||||
this.theme = StickyNoteTheme.Black;
|
||||
this.window = window;
|
||||
this.data = data;
|
||||
|
||||
this.title = data.Title;
|
||||
this.contents = data.Content;
|
||||
this.SetPosition(data.Position);
|
||||
|
||||
var le = this.Q<TextField>("contents-field");
|
||||
|
||||
le.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
this.data.Content = evt.newValue;
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnResized()
|
||||
{
|
||||
base.OnResized();
|
||||
data.Size = new Vector2(this.resolvedStyle.width, this.resolvedStyle.height);
|
||||
}
|
||||
|
||||
public void SavePosition() => data.Position = GetPosition();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 119eef6b9f4b410da217f8a12be9973d
|
||||
timeCreated: 1746345401
|
@ -6,7 +6,7 @@ using UnityEditor.UIElements;
|
||||
#endif
|
||||
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
namespace AssetGraph.Core.GraphElements
|
||||
{
|
||||
[Serializable]
|
||||
public class GreyscaleValue
|
3
Editor/Scripts/Editor/GraphViewOverwrites.meta
Normal file
3
Editor/Scripts/Editor/GraphViewOverwrites.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1403355e956148e3a298f151e782e76c
|
||||
timeCreated: 1747472333
|
10
Editor/Scripts/Editor/GraphViewOverwrites/AssetGraphEdge.cs
Normal file
10
Editor/Scripts/Editor/GraphViewOverwrites/AssetGraphEdge.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public class AssetGraphEdge : Edge
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76cd012b608644caa127970fd3caf115
|
||||
timeCreated: 1746343590
|
104
Editor/Scripts/Editor/GraphViewOverwrites/AssetGraphPort.cs
Normal file
104
Editor/Scripts/Editor/GraphViewOverwrites/AssetGraphPort.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public class AssetGraphPort : Port
|
||||
{
|
||||
public FieldInfo fieldInfo;
|
||||
private VisualElement _exposedPropertyContainer;
|
||||
|
||||
public delegate void OnPortConnectedEvent();
|
||||
public OnPortConnectedEvent OnPortConnected;
|
||||
|
||||
public delegate void OnPortDisconnectedEvent();
|
||||
public OnPortDisconnectedEvent OnPortDisconnected;
|
||||
|
||||
public VisualElement ExposedPropertyContainer
|
||||
{
|
||||
set
|
||||
{
|
||||
_exposedPropertyContainer = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return _exposedPropertyContainer;
|
||||
}
|
||||
}
|
||||
|
||||
protected AssetGraphPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type)
|
||||
{
|
||||
this.tooltip = $"{this.portType.ToString()}";
|
||||
}
|
||||
|
||||
public override void Connect(Edge edge)
|
||||
{
|
||||
if (this.node is AssetGraphNodeEditor IPTVis && IPTVis.GraphNode is GenericConnection)
|
||||
{
|
||||
foreach (var port in IPTVis.AllPorts)
|
||||
{
|
||||
port.portType = edge.output.portType;
|
||||
}
|
||||
}
|
||||
|
||||
base.Connect(edge);
|
||||
OnPortConnected?.Invoke();
|
||||
}
|
||||
|
||||
public override void Disconnect(Edge edge)
|
||||
{
|
||||
AssetGraphNodeEditor IPTVis = this.node as AssetGraphNodeEditor;
|
||||
|
||||
if (IPTVis != null && IPTVis.GraphNode is GenericConnection bleh)
|
||||
{
|
||||
bool allPortsDisconnected = true;
|
||||
|
||||
foreach (var port in IPTVis.AllPorts)
|
||||
{
|
||||
if (port.connections != null && port.connections.Any())
|
||||
{
|
||||
allPortsDisconnected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allPortsDisconnected)
|
||||
{
|
||||
foreach (var port in IPTVis.AllPorts)
|
||||
{
|
||||
port.portType = typeof(object);
|
||||
}
|
||||
|
||||
bleh.InternalType = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
base.Disconnect(edge);
|
||||
OnPortDisconnected?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
private void PublicOnConnected(Port obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static AssetGraphPort Create(IEdgeConnectorListener connectorListener, bool isInput, Type type)
|
||||
{
|
||||
var port = new AssetGraphPort(Orientation.Horizontal, isInput ? Direction.Input : Direction.Output,
|
||||
isInput ? Capacity.Single : Capacity.Multi, type)
|
||||
{
|
||||
m_EdgeConnector = new EdgeConnector<Edge>(connectorListener),
|
||||
};
|
||||
port.AddManipulator(port.m_EdgeConnector);
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -2,16 +2,18 @@ using System;
|
||||
using System.Configuration;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using System.Collections.Generic;
|
||||
using Input = ImageProcessingGraph.Editor.Nodes.NodeAttributes.Input;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AssetGraph.Core;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using ImageProcessingGraph.Editor;
|
||||
using Input = AssetGraph.Core.Attributes.Input;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[System.Serializable]
|
||||
public abstract class BaseImageNode
|
||||
public abstract class AssetGraphNode
|
||||
{
|
||||
[SerializeField] private string guid;
|
||||
|
||||
@ -24,17 +26,14 @@ namespace ImageProcessingGraph.Editor
|
||||
public string ID => guid;
|
||||
public Rect Position => position;
|
||||
|
||||
public ImageProcessingGraphAsset asset;
|
||||
public AssetGraphData asset;
|
||||
|
||||
public delegate void OnFailed();
|
||||
public event OnFailed onFailed;
|
||||
|
||||
public BaseImageNode()
|
||||
public AssetGraphNode()
|
||||
{
|
||||
guid = Guid.NewGuid().ToString();
|
||||
|
||||
/*Type t = this.GetType();
|
||||
Debug.Log(t.Name);*/
|
||||
}
|
||||
|
||||
public void SetNodeInputs()
|
||||
@ -51,7 +50,7 @@ namespace ImageProcessingGraph.Editor
|
||||
// Find the connection that leads to this input property
|
||||
GraphConnection connection = default;
|
||||
|
||||
foreach (var conn in asset.Connections)
|
||||
foreach (GraphConnection conn in asset.Connections)
|
||||
{
|
||||
if (conn.inputPort.nodeID == this.ID)
|
||||
{
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
public class ExposedPropertyPort : Port
|
||||
{
|
||||
protected ExposedPropertyPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31313dec455d4407bb6fffc7b167dabb
|
||||
timeCreated: 1743744035
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbd7cd37cae147f3a54f12c52ef54217
|
||||
timeCreated: 1742158168
|
@ -1,17 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class NewMonoBehaviour : MonoBehaviour
|
||||
{
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78c0de359ceae406cb2985637a2e6c97
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 587f3b2d6fad453fbf6664066f807f21
|
||||
timeCreated: 1745299284
|
@ -1,18 +0,0 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.String_Nodes
|
||||
{
|
||||
[NodeInfo("String Append", "String/Append")]
|
||||
public class StringAppend : BaseImageNode
|
||||
{
|
||||
[NodeAttributes.Input("String A")] public string baseString;
|
||||
[NodeAttributes.Input("String B")] public string appendString;
|
||||
|
||||
[NodeAttributes.Output("Appended String")] public string output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
this.output = baseString + appendString;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfoAttribute("Invert Channel", "Adjustments/InvertChannel", true)]
|
||||
public class ChannelInvertNode : BaseImageNode
|
||||
[NodeInfo("Invert Channel", "Adjustments/InvertChannel", true, docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FInvertChannel")]
|
||||
public class ChannelInvertNode : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("Input Channel")]
|
||||
[Core.Attributes.Input("Input Channel")]
|
||||
public SplitChannelData inputChannel;
|
||||
|
||||
[NodeAttributes.Output("Output Channel")]
|
||||
[Core.Attributes.Output("Output Channel")]
|
||||
public SplitChannelData outputChannel;
|
||||
|
||||
public override void Process()
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
@ -6,16 +7,16 @@ using UnityEngine;
|
||||
|
||||
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfoAttribute("Desaturate", "Adjustments/Desaturate", true)]
|
||||
public class Texture2DDesaturate : BaseImageNode
|
||||
[NodeInfo("Desaturate", "Adjustments/Desaturate", true, docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FDesaturate")]
|
||||
public class Texture2DDesaturate : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")]
|
||||
public ImageData inputTexture; // Changed to ImageData
|
||||
[Core.Attributes.Input("")]
|
||||
public ImageData inputTexture;
|
||||
|
||||
[NodeAttributes.Output("")]
|
||||
public ImageData outputTexture; // Changed to ImageData
|
||||
[Core.Attributes.Output("")]
|
||||
public ImageData outputTexture;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
|
@ -1,26 +1,25 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfoAttribute("Invert", "Adjustments/Invert", true)]
|
||||
public class Texture2DInvert : BaseImageNode
|
||||
[NodeInfo("Invert", "Adjustments/Invert", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FInvert")]
|
||||
public class Texture2DInvert : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")]
|
||||
public ImageData inputTexture; // Changed to ImageData
|
||||
[Core.Attributes.Input("")]
|
||||
public ImageData inputTexture;
|
||||
|
||||
[NodeAttributes.Output("")]
|
||||
public ImageData outputTexture; // Changed to ImageData
|
||||
[Core.Attributes.Output("")]
|
||||
public ImageData outputTexture;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
// Create an empty NativeArray for the output
|
||||
NativeArray<Color32> output = new NativeArray<Color32>(inputTexture.PixelData.Length, Allocator.Persistent);
|
||||
|
||||
// Create and run the InvertJob
|
||||
InvertJob job = new InvertJob
|
||||
{
|
||||
pixels = inputTexture.PixelData,
|
||||
@ -29,7 +28,6 @@ namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
|
||||
job.Run();
|
||||
|
||||
// Store the result in the outputImage as an ImageData instance
|
||||
outputTexture = new ImageData(output, (inputTexture.Width, inputTexture.Height), inputTexture.isRGBA);
|
||||
}
|
||||
}
|
||||
@ -37,14 +35,13 @@ namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
[BurstCompile]
|
||||
public struct InvertJob : IJob
|
||||
{
|
||||
[ReadOnly] public NativeArray<Color32> pixels; // Input pixels
|
||||
[WriteOnly] public NativeArray<Color32> outputPixels; // Output pixels
|
||||
[ReadOnly] public NativeArray<Color32> pixels;
|
||||
[WriteOnly] public NativeArray<Color32> outputPixels;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
int length = pixels.Length;
|
||||
|
||||
// Invert each pixel color
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Color32 pixel = pixels[i];
|
||||
|
@ -1,27 +1,28 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("RGBA Combine", "Channels/RGBA Combine", true)]
|
||||
public class RGBASCombine : BaseImageNode
|
||||
[NodeInfo("RGBA Combine", "Channels/RGBA Combine", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FRGBACombine")]
|
||||
public class RGBASCombine : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("R")]
|
||||
[Core.Attributes.Input("R")]
|
||||
public SplitChannelData r;
|
||||
|
||||
[NodeAttributes.Input("G")]
|
||||
[Core.Attributes.Input("G")]
|
||||
public SplitChannelData g;
|
||||
|
||||
[NodeAttributes.Input("B")]
|
||||
[Core.Attributes.Input("B")]
|
||||
public SplitChannelData b;
|
||||
|
||||
[NodeAttributes.Input("A")]
|
||||
[Core.Attributes.Input("A")]
|
||||
public SplitChannelData a;
|
||||
|
||||
[NodeAttributes.Output("")]
|
||||
[Core.Attributes.Output("")]
|
||||
public ImageData inputTexture;
|
||||
|
||||
// Job struct for combining RGBA channels
|
||||
|
@ -1,24 +1,25 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfoAttribute("RGBA Split", "Channels/RGBA Split", true)]
|
||||
public class RGBASplit : BaseImageNode
|
||||
[NodeInfo("RGBA Split", "Channels/RGBA Split", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FRGBASplit")]
|
||||
public class RGBASplit : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")]
|
||||
[Core.Attributes.Input("")]
|
||||
public ImageData inputTexture;
|
||||
|
||||
[NodeAttributes.Output("R")]
|
||||
[Core.Attributes.Output("R")]
|
||||
public SplitChannelData r;
|
||||
[NodeAttributes.Output("G")]
|
||||
[Core.Attributes.Output("G")]
|
||||
public SplitChannelData g;
|
||||
[NodeAttributes.Output("B")]
|
||||
[Core.Attributes.Output("B")]
|
||||
public SplitChannelData b;
|
||||
[NodeAttributes.Output("A")]
|
||||
[Core.Attributes.Output("A")]
|
||||
public SplitChannelData a;
|
||||
|
||||
public override void Process()
|
||||
|
@ -1,21 +1,22 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfoAttribute("Get Dimensions", "Dimensions/Get Dimensions", false)]
|
||||
public class TextureGetDimensions : BaseImageNode
|
||||
[NodeInfo("Get Dimensions", "Dimensions/Get Dimensions", false, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FGetDimensions")]
|
||||
public class TextureGetDimensions : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")]
|
||||
[Core.Attributes.Input("")]
|
||||
public ImageData inputTexture;
|
||||
|
||||
[NodeAttributes.Output("Width")]
|
||||
[Core.Attributes.Output("Width")]
|
||||
public int width;
|
||||
|
||||
[NodeAttributes.Output("Height")]
|
||||
[Core.Attributes.Output("Height")]
|
||||
public int height;
|
||||
|
||||
public override void Process()
|
||||
|
@ -1,17 +1,18 @@
|
||||
using System.ComponentModel.Composition.Primitives;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Output
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("Texture Export", "Export/Texture Export", true)]
|
||||
public class Texture2DOutput : BaseImageNode
|
||||
[NodeInfo("Texture Export", "Export/Texture Export", true,docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FTexture2DOutput")]
|
||||
public class Texture2DOutput : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")] public ImageData inputPixels;
|
||||
[NodeAttributes.Input("File Name")] public string fileName;
|
||||
[NodeAttributes.Input("File Directory")] public string fileDirectory;
|
||||
[Core.Attributes.Input("")] public ImageData inputPixels;
|
||||
[Core.Attributes.Input("File Name")] public string fileName;
|
||||
[Core.Attributes.Input("File Directory")] public string fileDirectory;
|
||||
|
||||
public enum ExportType
|
||||
{
|
||||
@ -19,10 +20,10 @@ namespace ImageProcessingGraph.Editor.Nodes.Output
|
||||
PNG
|
||||
}
|
||||
|
||||
[NodeAttributes.Input("Export Type")] public ExportType exportType;
|
||||
[NodeAttributes.Input("Texture Type")] public TextureImporterType textureType;
|
||||
[Core.Attributes.Input("Export Type")] public ExportType exportType;
|
||||
[Core.Attributes.Input("Texture Type")] public TextureImporterType textureType;
|
||||
|
||||
[NodeAttributes.Output("Output Texture")] public Texture2D textureOutput;
|
||||
[Core.Attributes.Output("Output Texture")] public Texture2D textureOutput;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077795206494544448685fbd8458fa0c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd58cf45d01e429abcb9b8f4e3894b7a
|
||||
timeCreated: 1746240608
|
@ -0,0 +1,43 @@
|
||||
using System.IO;
|
||||
using System.Security.Policy;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
public class FromPathNode<T> : AssetGraphNode where T : UnityEngine.Object
|
||||
{
|
||||
[Core.Attributes.Input("Path")] public string path;
|
||||
[Core.Attributes.Output("Output")] public T output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new System.ArgumentException("Path is empty or null. Cannot load asset.");
|
||||
}
|
||||
|
||||
output = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
|
||||
if (output == null)
|
||||
{
|
||||
throw new System.Exception($"Failed to load asset of type {typeof(T)} at path: {path}.");
|
||||
}
|
||||
}
|
||||
|
||||
public override void CleanUp()
|
||||
{
|
||||
output = null;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("Load Texture2D From path", "Load From Path/Texture2D", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImages%2FFromPathNode")]
|
||||
public class Texture2DFromPath : FromPathNode<Texture2D> { }
|
||||
|
||||
[NodeInfo("Load Mesh From path", "Load From Path/Mesh", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImages%2FFromPathNode")]
|
||||
public class MeshFromPath : FromPathNode<Mesh> { }
|
||||
|
||||
[NodeInfo("Load Prefab From path", "Load From Path/Prefab", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImages%2FFromPathNode")]
|
||||
public class PrefabFromPath : FromPathNode<GameObject> { }
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbdf66c38fa94127a4665bf6fd1ac011
|
||||
timeCreated: 1746240631
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2fcf5cdfdc07ba479efe9544501e5e6
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,22 +1,23 @@
|
||||
using System.IO;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using Unity.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Import_Nodes
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("Texture Import", "Imports/Import Texture")]
|
||||
public class Texture2DImport : BaseImageNode
|
||||
[NodeInfo("Texture Import", "Imports/Import Texture", docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FTexture2DImport")]
|
||||
public class Texture2DImport : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("")]
|
||||
[Core.Attributes.Input("")]
|
||||
public Texture2D textureImport;
|
||||
|
||||
[NodeAttributes.Output("")]
|
||||
[Core.Attributes.Output("")]
|
||||
public ImageData textureOutput;
|
||||
[NodeAttributes.Output("File Name")]
|
||||
[Core.Attributes.Output("File Name")]
|
||||
public string fileName;
|
||||
[NodeAttributes.Output("File Directory")]
|
||||
[Core.Attributes.Output("File Directory")]
|
||||
public string filePath;
|
||||
|
||||
public override void Process()
|
||||
|
@ -1,23 +1,25 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using AssetGraph.Core.GraphElements;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
public class SingleChannelColor
|
||||
{
|
||||
[NodeInfoAttribute("Channel Color", "Utility/Channel Color", false)]
|
||||
public class SingleColorChannel : BaseImageNode
|
||||
[NodeInfo("Channel Color", "Utility/Channel Color", false, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImages%2FSingleChannelColor")]
|
||||
public class SingleColorChannel : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("Color")] public GreyscaleValue range;
|
||||
[Core.Attributes.Input("Color")] public GreyscaleValue range;
|
||||
|
||||
[NodeAttributes.Input("Width")] public int Width;
|
||||
[Core.Attributes.Input("Width")] public int Width;
|
||||
|
||||
[NodeAttributes.Input("Height")] public int Height;
|
||||
[Core.Attributes.Input("Height")] public int Height;
|
||||
|
||||
[NodeAttributes.Output("Color")] public SplitChannelData OutputColor;
|
||||
[Core.Attributes.Output("Color")] public SplitChannelData OutputColor;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
|
@ -1,16 +1,17 @@
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.DataTypes;
|
||||
using UnityEngine;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using Unity.Burst;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities.ViewNode
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("View Texture", "Utility/View Texture", false, null , editorType: typeof(ViewTextureNodeEditor))]
|
||||
public partial class ViewTextureNode : BaseImageNode
|
||||
[NodeInfo("View Texture", "Utility/View Texture", false, null , editorType: typeof(ViewTextureNodeEditor), docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FViewImageNode")]
|
||||
public partial class ViewTextureNode : AssetGraphNode
|
||||
{
|
||||
[NodeAttributes.Input("Texture")] public Texture2D texture;
|
||||
[NodeAttributes.Input("Image Data")] public ImageData imageData;
|
||||
[Core.Attributes.Input("Texture")] public Texture2D texture;
|
||||
[Core.Attributes.Input("Image Data")] public ImageData imageData;
|
||||
|
||||
public delegate void OnImageUpdated();
|
||||
public OnImageUpdated onImageUpdated;
|
||||
|
@ -1,22 +1,23 @@
|
||||
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows;
|
||||
using AssetGraph.Core;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities.ViewNode
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
public class ViewTextureNodeEditor : ImageProcessingGraphNodeVisual
|
||||
public class ViewTextureNodeEditor : AssetGraphNodeEditor
|
||||
{
|
||||
private UnityEngine.UIElements.Image viewableImage;
|
||||
private Foldout foldout;
|
||||
private VisualElement buttonRow;
|
||||
|
||||
public ViewTextureNodeEditor(BaseImageNode node, ImageProcessingGraphViewWindow window) : base(node, window)
|
||||
public ViewTextureNodeEditor(AssetGraphNode node, AssetGraphViewWindow window) : base(node, window)
|
||||
{
|
||||
//Port 0 is Texture2D
|
||||
//Port 1 is ImageData
|
||||
|
||||
IPTPort tex2DPort = InputPorts[0] as IPTPort;
|
||||
IPTPort imageDataPort = InputPorts[1] as IPTPort;
|
||||
AssetGraphPort tex2DPort = InputPorts[0] as AssetGraphPort;
|
||||
AssetGraphPort imageDataPort = InputPorts[1] as AssetGraphPort;
|
||||
|
||||
tex2DPort.OnPortConnected += () => { imageDataPort.style.display = DisplayStyle.None; };
|
||||
|
||||
@ -50,6 +51,9 @@ namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities.ViewNode
|
||||
|
||||
viewImageNode.onImageUpdated += () => { viewableImage.image = viewImageNode.texture; };
|
||||
|
||||
Toolbar tb = new Toolbar();
|
||||
tb.style.height = 32;
|
||||
|
||||
buttonRow = new VisualElement
|
||||
{
|
||||
style =
|
||||
@ -70,10 +74,11 @@ namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities.ViewNode
|
||||
text = channel
|
||||
};
|
||||
btn.style.flexGrow = 1;
|
||||
buttonRow.Add(btn);
|
||||
tb.Add(btn);
|
||||
}
|
||||
|
||||
foldout.Add(buttonRow);
|
||||
// foldout.Add(buttonRow);
|
||||
foldout.Add(tb);
|
||||
}
|
||||
|
||||
private void OnChannelClicked(ViewTextureNode viewNode, string channel)
|
||||
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 899a77acab6b46d9af23756a397e7eea
|
||||
timeCreated: 1746228396
|
@ -0,0 +1,41 @@
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEngine;
|
||||
using AssetGraph.Core;
|
||||
using AssetGraph.Core.Attributes;
|
||||
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
public class VariableNodeBase : AssetGraphNode
|
||||
{
|
||||
[Core.Attributes.Input("Variable Name")] public string variableName;
|
||||
}
|
||||
|
||||
public class VariableNode<T> : VariableNodeBase
|
||||
{
|
||||
public T input;
|
||||
[Core.Attributes.Output("Output")] public T output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if(input != null)
|
||||
this.output = input;
|
||||
else
|
||||
throw new System.NullReferenceException($"Input to VariableNode<{typeof(T).Name}> is null");
|
||||
}
|
||||
|
||||
public override void CleanUp()
|
||||
{
|
||||
input = default;
|
||||
output = default;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("Texture2D Variable", "Variable/Texture2D", docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FVariableNode")]
|
||||
public class Texture2DVariableNode : VariableNode<Texture2D> { }
|
||||
|
||||
[NodeInfo("Mesh Variable", "Variable/Mesh", docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FVariableNode")]
|
||||
public class MeshVariableNode : VariableNode<Mesh> { }
|
||||
|
||||
[NodeInfo("Prefab Variable", "Variable/Prefab", docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FVariableNode")]
|
||||
public class PrefabVariableNode : VariableNode<GameObject> { }
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b10ad5cecfc74b548431deb876d3cb9a
|
||||
timeCreated: 1746228592
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35175651a2c0f6947b7cc63fde04829f
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
58
Editor/Scripts/Editor/Nodes/Types/String/DebugLogNode.cs
Normal file
58
Editor/Scripts/Editor/Nodes/Types/String/DebugLogNode.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System.IO;
|
||||
using AssetGraph.Core;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Debug Log", "Debug/Debug Log", editorType: typeof(DebugLogNodeEditor))]
|
||||
public class DebugLogNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("Log Text")]
|
||||
public string logText;
|
||||
|
||||
public delegate void OnNodeUpdated();
|
||||
public OnNodeUpdated onNodeUpdated;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
Debug.Log(logText);
|
||||
onNodeUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public class DebugLogNodeEditor : AssetGraphNodeEditor
|
||||
{
|
||||
DebugLogNode logNode;
|
||||
Label label;
|
||||
|
||||
public DebugLogNodeEditor(AssetGraphNode node, AssetGraphViewWindow window) : base(node, window)
|
||||
{
|
||||
logNode = node as DebugLogNode;
|
||||
logNode.onNodeUpdated += UpdateEditor;
|
||||
label = new Label();
|
||||
label.style.flexGrow = 1;
|
||||
label.style.flexShrink = 1;
|
||||
label.style.paddingBottom = label.style.paddingTop = label.style.paddingLeft = label.style.paddingRight = 6;
|
||||
label.style.backgroundColor = new Color(0.24705f, 0.24705f, 0.24705f, 0.8039216f);
|
||||
label.style.whiteSpace = WhiteSpace.Normal;
|
||||
|
||||
VisualElement bar = new VisualElement();
|
||||
bar.name = "divider";
|
||||
bar.AddToClassList("horizontal");
|
||||
|
||||
var contents = this.Q("contents");
|
||||
|
||||
contents.Add(bar);
|
||||
contents.Add(label);
|
||||
}
|
||||
|
||||
public void UpdateEditor()
|
||||
{
|
||||
label.text = logNode.logText;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee2323729ea6fa84788137af3807d8b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Editor/Scripts/Editor/Nodes/Types/String/ImportTextNode.cs
Normal file
26
Editor/Scripts/Editor/Nodes/Types/String/ImportTextNode.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.IO;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Import Text", "Imports/Import Text")]
|
||||
public class ImportTextNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("File Name")]
|
||||
public string fileName;
|
||||
|
||||
[AssetGraph.Core.Attributes.Input("Directory")]
|
||||
public string directory;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Text")]
|
||||
public string outputText;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
outputText = File.ReadAllText(Path.Combine(directory, fileName));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 455f8a7df4c9c2e4691f68b537e29573
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
69
Editor/Scripts/Editor/Nodes/Types/String/StringNodes.cs
Normal file
69
Editor/Scripts/Editor/Nodes/Types/String/StringNodes.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using AssetGraph.Core.Attributes;
|
||||
|
||||
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("String Append", "String/Append", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes/String/Append")]
|
||||
public class StringAppend : AssetGraphNode
|
||||
{
|
||||
[Core.Attributes.Input("String A")] public string baseString;
|
||||
[Core.Attributes.Input("String B")] public string appendString;
|
||||
|
||||
[Core.Attributes.Output("Appended String")] public string output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
this.output = baseString + appendString;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("String Replace", "String/Replace", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes/String/Replace")]
|
||||
public class StringReplace : AssetGraphNode
|
||||
{
|
||||
[Core.Attributes.Input("Original String")] public string original;
|
||||
[Core.Attributes.Input("Old Value")] public string oldValue;
|
||||
[Core.Attributes.Input("New Value")] public string newValue;
|
||||
|
||||
[Core.Attributes.Output("Replaced String")] public string output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(original) && oldValue != null)
|
||||
output = original.Replace(oldValue, newValue);
|
||||
else
|
||||
output = original;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("String Split", "String/Split", docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes/String/Split")]
|
||||
public class StringSplit : AssetGraphNode
|
||||
{
|
||||
[Input("Source String")] public string source;
|
||||
[Input("Delimiter")] public string delimiter;
|
||||
|
||||
[Core.Attributes.Output("Before Delimiter")] public string before;
|
||||
[Core.Attributes.Output("After Delimiter")] public string after;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(delimiter))
|
||||
{
|
||||
before = source;
|
||||
after = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
int index = source.IndexOf(delimiter);
|
||||
if (index >= 0)
|
||||
{
|
||||
before = source.Substring(0, index);
|
||||
after = source.Substring(index + delimiter.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
before = source;
|
||||
after = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Editor/Scripts/Editor/Nodes/Types/Utils.meta
Normal file
3
Editor/Scripts/Editor/Nodes/Types/Utils.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4a21d5960ac4b858705aec0bdaddab4
|
||||
timeCreated: 1746343737
|
3
Editor/Scripts/Editor/Nodes/Types/Utils/Connector.meta
Normal file
3
Editor/Scripts/Editor/Nodes/Types/Utils/Connector.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b77f4983d61d4a2ab1916ea59a0ec6fa
|
||||
timeCreated: 1746343741
|
@ -0,0 +1,31 @@
|
||||
using AssetGraph.Core;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetGraph.Nodes
|
||||
{
|
||||
[NodeInfo("", "Utility/Connection", false, null , editorType: typeof(GenericConnectionEditor), docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FUtils%2FGenericConnection")]
|
||||
public class GenericConnection : AssetGraphNode
|
||||
{
|
||||
private System.Type internalType;
|
||||
public System.Type InternalType { get { return internalType; } set { internalType = value; } }
|
||||
|
||||
[Core.Attributes.Input(" ")] public object input;
|
||||
[Core.Attributes.Output(" ")] public object output;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
this.output = this.input;
|
||||
}
|
||||
}
|
||||
|
||||
public class GenericConnectionEditor : AssetGraphNodeEditor
|
||||
{
|
||||
public GenericConnectionEditor(AssetGraphNode node, AssetGraphViewWindow window) : base(node, window)
|
||||
{
|
||||
this.Q("title").style.display = DisplayStyle.None;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3fb7dc03aa647a8a99146ef19bb663e
|
||||
timeCreated: 1746343749
|
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Create Directory", "Directory/Create Directory")]
|
||||
public class CreateDirectoryNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("Directory")] public string inputDirectory;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Directory")] public string outputDirectory;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if (!Directory.Exists(inputDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(inputDirectory);
|
||||
}
|
||||
outputDirectory = inputDirectory;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a32e947621c08940b8f9c68c3bc0bdc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
62
Editor/Scripts/Editor/Nodes/Types/Utils/CreatePrefabNode.cs
Normal file
62
Editor/Scripts/Editor/Nodes/Types/Utils/CreatePrefabNode.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Create Prefab", "Prefab/Create")]
|
||||
public class CreatePrefabNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("Prefab Name")]
|
||||
public string prefabName;
|
||||
|
||||
[AssetGraph.Core.Attributes.Input("Directory")]
|
||||
public string directory;
|
||||
|
||||
[AssetGraph.Core.Attributes.Input("")]
|
||||
public Mesh mesh;
|
||||
|
||||
[AssetGraph.Core.Attributes.Input("Submesh Count")]
|
||||
public int submeshCount = 1;
|
||||
|
||||
[AssetGraph.Core.Attributes.Input("")]
|
||||
public Material material;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Prefab")]
|
||||
public GameObject prefab;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
GameObject newGO = new GameObject(prefabName);
|
||||
var prefabPath = Path.Combine(directory, $"{prefabName}.prefab");
|
||||
PrefabUtility.SaveAsPrefabAsset(newGO, prefabPath);
|
||||
Object.DestroyImmediate(newGO);
|
||||
|
||||
using (var editScope = new PrefabUtility.EditPrefabContentsScope(prefabPath))
|
||||
{
|
||||
var root = editScope.prefabContentsRoot;
|
||||
var meshRenderer = root.AddComponent<MeshRenderer>();
|
||||
var meshFilter = root.AddComponent<MeshFilter>();
|
||||
meshFilter.sharedMesh = mesh;
|
||||
if (submeshCount > 1)
|
||||
{
|
||||
Material[] materials = new Material[submeshCount];
|
||||
for (int i = 0; i < submeshCount; i++)
|
||||
{
|
||||
materials[i] = material;
|
||||
}
|
||||
|
||||
meshRenderer.sharedMaterials = materials;
|
||||
}
|
||||
else
|
||||
{
|
||||
meshRenderer.sharedMaterial = material;
|
||||
}
|
||||
}
|
||||
|
||||
prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 851727f1cfe10de4b8073aa6a334518c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
69
Editor/Scripts/Editor/Nodes/Types/Utils/ModelImportNode.cs
Normal file
69
Editor/Scripts/Editor/Nodes/Types/Utils/ModelImportNode.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System.IO;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
using ImageProcessingGraph.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Model Import", "Imports/Import Model", true)]
|
||||
public class ModelImportNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("Model")]
|
||||
public GameObject modelImport;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("")]
|
||||
public Mesh mesh;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("")]
|
||||
public Material material;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Model Name")]
|
||||
public string modelName;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Directory")]
|
||||
public string directory;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
var modelPath = AssetDatabase.GetAssetPath(modelImport);
|
||||
var allAssets = AssetDatabase.LoadAllAssetsAtPath(modelPath);
|
||||
|
||||
material = null;
|
||||
mesh = null;
|
||||
foreach (var asset in allAssets)
|
||||
{
|
||||
if (material && mesh) break;
|
||||
|
||||
if (!material && asset is Material foundMaterial)
|
||||
{
|
||||
material = foundMaterial;
|
||||
}
|
||||
if (!mesh && asset is Mesh foundMesh)
|
||||
{
|
||||
mesh = foundMesh;
|
||||
}
|
||||
}
|
||||
|
||||
modelName = modelImport.name;
|
||||
directory = Path.GetDirectoryName(modelPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NodeInfo("Mesh Info", "Mesh/Mesh Info", true)]
|
||||
public class MeshInfo : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("")]
|
||||
public Mesh mesh;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Submeshes")]
|
||||
public int submeshes;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
submeshes = mesh.subMeshCount;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 612cfa8fb6e00e14d9f78091cb61cdde
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
60
Editor/Scripts/Editor/Nodes/Types/Utils/ObjectGetNameNode.cs
Normal file
60
Editor/Scripts/Editor/Nodes/Types/Utils/ObjectGetNameNode.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System.IO;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||
{
|
||||
[NodeInfo("Material Get Name", "Material/Material Get Name")]
|
||||
public class MaterialGetNameNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("")] public Material inputObject;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
objectName = inputObject.name;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("Mesh Get Name", "Mesh/Mesh Get Name")]
|
||||
public class MeshGetNameNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("")] public Mesh inputObject;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
objectName = inputObject.name;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("Texture Get Name", "Texture/Texture Get Name")]
|
||||
public class TextureGetNameNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("")] public Texture2D inputObject;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
objectName = inputObject.name;
|
||||
}
|
||||
}
|
||||
|
||||
[NodeInfo("GameObject Get Name", "GameObject/GameObject Get Name")]
|
||||
public class GameObjectGetNameNode : AssetGraphNode
|
||||
{
|
||||
[AssetGraph.Core.Attributes.Input("")] public GameObject inputObject;
|
||||
|
||||
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
objectName = inputObject.name;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79f6818ae71efcd48a44d3fb422891bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,30 +1,36 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Windows
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
[CustomEditor(typeof(ImageProcessingGraphAsset))]
|
||||
public class ImageProcessingGraphAssetEditorWindow : UnityEditor.Editor
|
||||
[CustomEditor(typeof(AssetGraphData))]
|
||||
public class AssetGraphDataEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (GUILayout.Button("Open"))
|
||||
{
|
||||
ImageProcessingGraphEditorWindow.Open((ImageProcessingGraphAsset)target);
|
||||
AssetGraphEditorWindow.Open((AssetGraphData)target);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Calculate Dependancy Graph"))
|
||||
{
|
||||
var bleh = (ImageProcessingGraphAsset)target;
|
||||
var bleh = (AssetGraphData)target;
|
||||
bleh.runOrder = bleh.GetExecutionOrder(bleh.Nodes, bleh.Connections, true);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Run Graph"))
|
||||
{
|
||||
var bleh = (ImageProcessingGraphAsset)target;
|
||||
var bleh = (AssetGraphData)target;
|
||||
bleh.RunGraph();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MenuItem("Test/TEser", false, 1)]
|
||||
public static void OpenBatchingWindow()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using ImageProcessingGraph.Editor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEditor.MemoryProfiler;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
|
||||
public class ImageProcessingGraphEdgeConnectorListener : IEdgeConnectorListener
|
||||
public class AssetGraphEdgeConnector : IEdgeConnectorListener
|
||||
{
|
||||
private GraphViewChange m_GraphViewChange;
|
||||
private List<Edge> m_EdgesToCreate;
|
||||
private List<GraphElement> m_EdgesToDelete;
|
||||
|
||||
private ImageProcessingGraphViewWindow window;
|
||||
private AssetGraphViewWindow window;
|
||||
|
||||
public ImageProcessingGraphEdgeConnectorListener(ImageProcessingGraphViewWindow window)
|
||||
public AssetGraphEdgeConnector(AssetGraphViewWindow window)
|
||||
{
|
||||
this.m_EdgesToCreate = new List<Edge>();
|
||||
this.m_EdgesToDelete = new List<GraphElement>();
|
||||
@ -27,8 +28,17 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
{
|
||||
window.searchProvider.target = (VisualElement)window.focusController.focusedElement;
|
||||
|
||||
// ⚡ Override the search window open with a customized search tree
|
||||
SearchWindow.Open(new SearchWindowContext(position), new ImageProcessingGraphSearchProvider.CustomSearchProviderForEdge(window.searchProvider, edge, (IPTPort)edge.input, (IPTPort)edge.output));
|
||||
var mousePos =
|
||||
window.ChangeCoordinatesTo(window, window.cachedMousePos - window.Window.position.position);
|
||||
var graphMousePosition = window.contentViewContainer.WorldToLocal(mousePos);
|
||||
|
||||
var searchProviderInstance = ScriptableObject.CreateInstance<AssetGraphSearchProvider.CustomSearchProviderForEdge>();
|
||||
searchProviderInstance.Init(window.searchProvider, edge, (AssetGraphPort)edge.input, (AssetGraphPort)edge.output);
|
||||
|
||||
SearchWindow.Open(
|
||||
new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)),
|
||||
searchProviderInstance
|
||||
);
|
||||
|
||||
// Remove connections as you did
|
||||
List<GraphConnection> connections = new List<GraphConnection>();
|
||||
@ -44,7 +54,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
if (edge.input != null)
|
||||
if (edge.input.node != null)
|
||||
((ImageProcessingGraphNodeVisual)edge.input.node).ToggleExposedVariable((IPTPort)edge.input, true);
|
||||
((AssetGraphNodeEditor)edge.input.node).ToggleExposedVariable((AssetGraphPort)edge.input, true);
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +76,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
window.asset.Connections.Remove(VARIABLE);
|
||||
}
|
||||
|
||||
((ImageProcessingGraphNodeVisual)edge.input.node).ToggleExposedVariable((IPTPort)edge.input, true);
|
||||
((AssetGraphNodeEditor)edge.input.node).ToggleExposedVariable((AssetGraphPort)edge.input, true);
|
||||
|
||||
|
||||
this.m_EdgesToCreate.Clear();
|
@ -3,18 +3,18 @@ using UnityEditor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Windows
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public class ImageProcessingGraphEditorWindow : EditorWindow
|
||||
public class AssetGraphEditorWindow : EditorWindow
|
||||
{
|
||||
[SerializeField] private ImageProcessingGraphAsset currentGraph;
|
||||
[SerializeField] private AssetGraphData currentGraph;
|
||||
[SerializeField] private SerializedObject serializedObject;
|
||||
[SerializeField] private ImageProcessingGraphViewWindow currentView;
|
||||
public ImageProcessingGraphAsset CurrentGraph => currentGraph;
|
||||
[SerializeField] private AssetGraphViewWindow currentView;
|
||||
public AssetGraphData CurrentGraph => currentGraph;
|
||||
|
||||
public static void Open(ImageProcessingGraphAsset asset)
|
||||
public static void Open(AssetGraphData asset)
|
||||
{
|
||||
var existingWindows = Resources.FindObjectsOfTypeAll<ImageProcessingGraphEditorWindow>();
|
||||
var existingWindows = Resources.FindObjectsOfTypeAll<AssetGraphEditorWindow>();
|
||||
foreach (var w in existingWindows)
|
||||
{
|
||||
if (w.CurrentGraph == asset)
|
||||
@ -24,9 +24,9 @@ namespace ImageProcessingGraph.Editor.Windows
|
||||
}
|
||||
}
|
||||
|
||||
var window = CreateWindow<ImageProcessingGraphEditorWindow>(typeof(SceneView));
|
||||
var window = CreateWindow<AssetGraphEditorWindow>(typeof(SceneView));
|
||||
window.titleContent = new GUIContent($"{asset.name}",
|
||||
EditorGUIUtility.ObjectContent(null, typeof(ImageProcessingGraphAsset)).image);
|
||||
EditorGUIUtility.ObjectContent(null, typeof(AssetGraphData)).image);
|
||||
window.Load(asset);
|
||||
window.Focus();
|
||||
}
|
||||
@ -50,7 +50,7 @@ namespace ImageProcessingGraph.Editor.Windows
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(ImageProcessingGraphAsset asset)
|
||||
public void Load(AssetGraphData asset)
|
||||
{
|
||||
currentGraph = asset;
|
||||
DrawGraph();
|
||||
@ -59,8 +59,9 @@ namespace ImageProcessingGraph.Editor.Windows
|
||||
public void DrawGraph()
|
||||
{
|
||||
serializedObject = new SerializedObject(currentGraph);
|
||||
currentView = new ImageProcessingGraphViewWindow(serializedObject, this);
|
||||
currentView = new AssetGraphViewWindow(serializedObject, this);
|
||||
currentView.graphViewChanged += OnChange;
|
||||
rootVisualElement.style.flexGrow = 1;
|
||||
rootVisualElement.Add(currentView);
|
||||
}
|
||||
|
@ -2,30 +2,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.GraphElements;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Input = ImageProcessingGraph.Editor.Nodes.NodeAttributes.Input;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public class ImageProcessingGraphNodeVisual : Node
|
||||
public class AssetGraphNodeEditor : Node
|
||||
{
|
||||
private BaseImageNode graphNode;
|
||||
public BaseImageNode GraphNode => graphNode;
|
||||
private AssetGraphNode graphNode;
|
||||
public AssetGraphNode GraphNode => graphNode;
|
||||
|
||||
public List<Port> AllPorts = new List<Port>();
|
||||
public List<Port> InputPorts { get; }
|
||||
public List<Port> OutputPorts { get; }
|
||||
|
||||
private ImageProcessingGraphViewWindow window;
|
||||
public AssetGraphViewWindow window;
|
||||
|
||||
private StyleSheet defaaStyleSheet;
|
||||
private StyleSheet errorStyleSheet;
|
||||
private NodeInfoAttribute info;
|
||||
|
||||
public ImageProcessingGraphNodeVisual(BaseImageNode node, ImageProcessingGraphViewWindow window)
|
||||
public AssetGraphNodeEditor(AssetGraphNode node, AssetGraphViewWindow window)
|
||||
{
|
||||
this.AddToClassList("image-node-visual");
|
||||
this.window = window;
|
||||
@ -33,10 +36,11 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
|
||||
Type typeInfo = node.GetType();
|
||||
NodeInfoAttribute info = typeInfo.GetCustomAttribute<NodeInfoAttribute>();
|
||||
info = typeInfo.GetCustomAttribute<NodeInfoAttribute>();
|
||||
title = info.Title;
|
||||
this.name = typeInfo.Name;
|
||||
|
||||
|
||||
string[] depths = info.MenuItem.Split('/');
|
||||
foreach (var depth in depths)
|
||||
{
|
||||
@ -46,16 +50,16 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
this.InputPorts = new List<Port>();
|
||||
this.OutputPorts = new List<Port>();
|
||||
|
||||
List<Input> inputs = new List<Input>();
|
||||
List<AssetGraph.Core.Attributes.Input> inputs = new List<AssetGraph.Core.Attributes.Input>();
|
||||
List<FieldInfo> inputFieldInfo = new List<FieldInfo>();
|
||||
List<FieldInfo> outputFieldInfo = new List<FieldInfo>();
|
||||
|
||||
FieldInfo[] fields = typeInfo.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.GetCustomAttribute(typeof(Input)) != null)
|
||||
if (field.GetCustomAttribute(typeof(AssetGraph.Core.Attributes.Input)) != null)
|
||||
{
|
||||
Input input = field.GetCustomAttribute<Input>();
|
||||
AssetGraph.Core.Attributes.Input input = field.GetCustomAttribute<AssetGraph.Core.Attributes.Input>();
|
||||
inputs.Add(input);
|
||||
inputFieldInfo.Add(field);
|
||||
}
|
||||
@ -101,12 +105,13 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
for (var index = 0; index < fields.Count; index++)
|
||||
{
|
||||
var field = fields[index];
|
||||
var port = IPTPort.Create(window.edgeConnectorListener, true, field.FieldType);
|
||||
var port = AssetGraphPort.Create(window.edgeConnectorListener, true, field.FieldType);
|
||||
|
||||
string label = field.GetCustomAttribute<Input>().Label;
|
||||
string label = field.GetCustomAttribute<Core.Attributes.Input>().Label;
|
||||
if (label != "")
|
||||
port.portName = label;
|
||||
InputPorts.Add(port);
|
||||
AllPorts.Add(port);
|
||||
|
||||
|
||||
inputContainer.Add(port);
|
||||
@ -121,12 +126,13 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
for (var index = 0; index < fields.Count; index++)
|
||||
{
|
||||
var field = fields[index];
|
||||
var port = IPTPort.Create(window.edgeConnectorListener, false, field.FieldType);
|
||||
var port = AssetGraphPort.Create(window.edgeConnectorListener, false, field.FieldType);
|
||||
|
||||
string label = field.GetCustomAttribute<Output>().Label;
|
||||
if (label != "")
|
||||
port.portName = label;
|
||||
OutputPorts.Add(port);
|
||||
AllPorts.Add(port);
|
||||
outputContainer.Add(port);
|
||||
|
||||
port.fieldInfo = field;
|
||||
@ -137,7 +143,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
public void ExposeVariableToPort(Port port, FieldInfo field)
|
||||
{
|
||||
VisualElement NewElement = new VisualElement();
|
||||
var ExposedPropertyContainer = ((IPTPort)port).ExposedPropertyContainer;
|
||||
var ExposedPropertyContainer = ((AssetGraphPort)port).ExposedPropertyContainer;
|
||||
Type containerType = null;
|
||||
|
||||
if (ExposedPropertyContainer == null)
|
||||
@ -149,8 +155,8 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
containerType = the.GetType();
|
||||
|
||||
NewElement.Add(the);
|
||||
((IPTPort)port).ExposedPropertyContainer = the;
|
||||
ExposedPropertyContainer = ((IPTPort)port).ExposedPropertyContainer;
|
||||
((AssetGraphPort)port).ExposedPropertyContainer = the;
|
||||
ExposedPropertyContainer = ((AssetGraphPort)port).ExposedPropertyContainer;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -244,9 +250,9 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
public void ToggleExposedVariable(Port port, bool value)
|
||||
{
|
||||
IPTPort iptPort = port as IPTPort;
|
||||
if(iptPort.ExposedPropertyContainer != null)
|
||||
iptPort.ExposedPropertyContainer.style.display = value ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
AssetGraphPort assetGraphPort = port as AssetGraphPort;
|
||||
if(assetGraphPort.ExposedPropertyContainer != null)
|
||||
assetGraphPort.ExposedPropertyContainer.style.display = value ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
}
|
||||
|
||||
private VisualElement CreatePropertyFieldForType(Type type, object value)
|
||||
@ -308,8 +314,6 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
var objectField = new ObjectField { value = (UnityEngine.Object)value, objectType = typeof(UnityEngine.Object) };
|
||||
return objectField;
|
||||
}
|
||||
|
||||
// Add more types as needed
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -322,7 +326,14 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
private void OpenDocumentation(DropdownMenuAction obj)
|
||||
{
|
||||
|
||||
if (info.DocumentationationURL != null || !string.IsNullOrEmpty(info.DocumentationationURL))
|
||||
{
|
||||
Application.OpenURL(info.DocumentationationURL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"No documentation URL provided for node {this.graphNode.asset.name}!");
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePosition() => graphNode.SetPosition(GetPosition());
|
@ -2,15 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Codice.Client.Common;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Nodes;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Input = ImageProcessingGraph.Editor.Nodes.NodeAttributes.Input;
|
||||
|
||||
namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public struct SearchContextElement
|
||||
{
|
||||
@ -32,9 +31,9 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
}
|
||||
}
|
||||
|
||||
public class ImageProcessingGraphSearchProvider : ScriptableObject, ISearchWindowProvider
|
||||
public class AssetGraphSearchProvider : ScriptableObject, ISearchWindowProvider
|
||||
{
|
||||
public ImageProcessingGraphViewWindow graph;
|
||||
public AssetGraphViewWindow graph;
|
||||
public VisualElement target;
|
||||
|
||||
public static List<SearchContextElement> elements;
|
||||
@ -60,7 +59,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
foreach (var field in Fields)
|
||||
{
|
||||
if (field.GetCustomAttribute<Input>() != null)
|
||||
if (field.GetCustomAttribute<Core.Attributes.Input>() != null)
|
||||
ImportPortTypes.Add(ImportPortTypes.Count, field.FieldType);
|
||||
if (field.GetCustomAttribute<Output>() != null)
|
||||
OutputPortTypes.Add(OutputPortTypes.Count, field.FieldType);
|
||||
@ -128,7 +127,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
SearchContextElement element = (SearchContextElement)SearchTreeEntry.userData;
|
||||
|
||||
BaseImageNode node = (BaseImageNode)element.target;
|
||||
AssetGraphNode node = (AssetGraphNode)element.target;
|
||||
node.SetPosition(new Rect(graphMousePosition, new Vector2()));
|
||||
graph.Add(node);
|
||||
node.asset = graph.asset;
|
||||
@ -146,7 +145,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
var sourcePort = edge.output ?? edge.input;
|
||||
bool isSourceOutput = edge.output != null;
|
||||
Type targetType = (sourcePort as IPTPort)?.portType;
|
||||
Type targetType = (sourcePort as AssetGraphPort)?.portType;
|
||||
|
||||
if (targetType == null)
|
||||
{
|
||||
@ -163,7 +162,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
var fields = type.GetFields();
|
||||
|
||||
// Get all ports
|
||||
var inputPorts = fields.Where(f => f.GetCustomAttribute<Input>() != null).ToList();
|
||||
var inputPorts = fields.Where(f => f.GetCustomAttribute<Core.Attributes.Input>() != null).ToList();
|
||||
var outputPorts = fields.Where(f => f.GetCustomAttribute<Output>() != null).ToList();
|
||||
|
||||
// REVERSED LOGIC:
|
||||
@ -206,7 +205,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
// Add compatible port entries
|
||||
foreach (var portField in compatiblePorts)
|
||||
{
|
||||
var portList = portField.GetCustomAttribute<Input>() != null ? inputPorts : outputPorts;
|
||||
var portList = portField.GetCustomAttribute<Core.Attributes.Input>() != null ? inputPorts : outputPorts;
|
||||
int portIndex = portList.IndexOf(portField);
|
||||
|
||||
var portTitle = $"{attr.Title}: {portField.Name}";
|
||||
@ -228,12 +227,21 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
public class CustomSearchProviderForEdge : ScriptableObject, ISearchWindowProvider
|
||||
{
|
||||
private readonly ImageProcessingGraphSearchProvider original;
|
||||
private readonly Edge edge;
|
||||
private readonly IPTPort inputPort;
|
||||
private readonly IPTPort outputPort;
|
||||
private AssetGraphSearchProvider original;
|
||||
private Edge edge;
|
||||
private AssetGraphPort inputPort;
|
||||
private AssetGraphPort outputPort;
|
||||
|
||||
public CustomSearchProviderForEdge(ImageProcessingGraphSearchProvider original, Edge edge, IPTPort inputPort, IPTPort outputPort)
|
||||
public CustomSearchProviderForEdge(AssetGraphSearchProvider original, Edge edge, AssetGraphPort inputPort, AssetGraphPort outputPort)
|
||||
{
|
||||
this.original = original;
|
||||
this.edge = edge;
|
||||
this.inputPort = inputPort;
|
||||
this.outputPort = outputPort;
|
||||
}
|
||||
|
||||
public void Init(AssetGraphSearchProvider original, Edge edge, AssetGraphPort inputPort,
|
||||
AssetGraphPort outputPort)
|
||||
{
|
||||
this.original = original;
|
||||
this.edge = edge;
|
||||
@ -254,7 +262,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
|
||||
|
||||
SearchContextElement element = (SearchContextElement)selectedEntry.userData;
|
||||
|
||||
BaseImageNode node = (BaseImageNode)element.target;
|
||||
AssetGraphNode node = (AssetGraphNode)element.target;
|
||||
node.SetPosition(new Rect(graphMousePosition, new Vector2()));
|
||||
original.graph.Add(node);
|
||||
node.asset = original.graph.asset;
|
@ -2,53 +2,61 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
|
||||
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows;
|
||||
using ImageProcessingGraph.Editor.Windows;
|
||||
using AssetGraph.Core.Attributes;
|
||||
using AssetGraph.Core.GraphElements;
|
||||
using AssetGraph.Nodes;
|
||||
using ImageProcessingGraph.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
namespace AssetGraph.Core
|
||||
{
|
||||
public class ImageProcessingGraphViewWindow : GraphView
|
||||
public class AssetGraphViewWindow : GraphView
|
||||
{
|
||||
internal ImageProcessingGraphAsset asset;
|
||||
internal AssetGraphData asset;
|
||||
private SerializedObject serializedObject;
|
||||
private ImageProcessingGraphEditorWindow window;
|
||||
public ImageProcessingGraphEditorWindow Window => window;
|
||||
private AssetGraphEditorWindow window;
|
||||
public AssetGraphEditorWindow Window => window;
|
||||
|
||||
public List<ImageProcessingGraphNodeVisual> graphNodes;
|
||||
public Dictionary<string, ImageProcessingGraphNodeVisual> nodeDictionary;
|
||||
public List<AssetGraphNodeEditor> graphNodes;
|
||||
public Dictionary<string, AssetGraphNodeEditor> nodeDictionary;
|
||||
public Dictionary<Edge, GraphConnection> connectionDictionary;
|
||||
public Dictionary<string, AssetGraphStickyNote> stickyNoteDictionary;
|
||||
|
||||
internal ImageProcessingGraphSearchProvider searchProvider;
|
||||
internal ImageProcessingGraphEdgeConnectorListener edgeConnectorListener;
|
||||
internal AssetGraphSearchProvider searchProvider;
|
||||
public AssetGraphEdgeConnector edgeConnectorListener;
|
||||
|
||||
private bool isDropdownEnabled = false;
|
||||
public Vector2 cachedMousePos;
|
||||
|
||||
|
||||
private Button debugModeButton;
|
||||
private Button outputRunOrder;
|
||||
private Button makeStickyNode;
|
||||
|
||||
public ImageProcessingGraphViewWindow(SerializedObject obeject, ImageProcessingGraphEditorWindow window)
|
||||
public AssetGraphViewWindow(SerializedObject obeject, AssetGraphEditorWindow window)
|
||||
{
|
||||
this.serializedObject = obeject;
|
||||
this.asset = obeject.targetObject as ImageProcessingGraphAsset;
|
||||
this.asset = obeject.targetObject as AssetGraphData;
|
||||
|
||||
this.graphNodes = new List<ImageProcessingGraphNodeVisual>();
|
||||
nodeDictionary = new Dictionary<string, ImageProcessingGraphNodeVisual>();
|
||||
this.graphNodes = new List<AssetGraphNodeEditor>();
|
||||
nodeDictionary = new Dictionary<string, AssetGraphNodeEditor>();
|
||||
stickyNoteDictionary = new Dictionary<string, AssetGraphStickyNote>();
|
||||
connectionDictionary = new Dictionary<Edge, GraphConnection>();
|
||||
|
||||
searchProvider = ScriptableObject.CreateInstance<ImageProcessingGraphSearchProvider>();
|
||||
searchProvider = ScriptableObject.CreateInstance<AssetGraphSearchProvider>();
|
||||
searchProvider.graph = this;
|
||||
|
||||
edgeConnectorListener = new ImageProcessingGraphEdgeConnectorListener(this);
|
||||
edgeConnectorListener = new AssetGraphEdgeConnector(this);
|
||||
|
||||
this.nodeCreationRequest = ShowSearchWindow;
|
||||
|
||||
this.window = window;
|
||||
|
||||
|
||||
|
||||
StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Unity Image Processing/GraphView.uss");
|
||||
if (styleSheet == null)
|
||||
{
|
||||
@ -58,7 +66,7 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
GridBackground background = new GridBackground();
|
||||
background.name = "Grid";
|
||||
Add(background);
|
||||
this.Add(background);
|
||||
background.SendToBack();
|
||||
|
||||
CreateButtons();
|
||||
@ -72,16 +80,25 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
DrawNodes();
|
||||
DrawConnections();
|
||||
DrawStickyNotes();
|
||||
|
||||
graphViewChanged += OnGraphViewChanged;
|
||||
|
||||
Undo.undoRedoPerformed += UndoRedoPerformed;
|
||||
RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
||||
}
|
||||
|
||||
private void OnMouseMove(MouseMoveEvent evt)
|
||||
{
|
||||
cachedMousePos = evt.localMousePosition;
|
||||
}
|
||||
|
||||
|
||||
private void UndoRedoPerformed()
|
||||
{
|
||||
DrawNodes();
|
||||
DrawConnections();
|
||||
DrawStickyNotes();
|
||||
}
|
||||
|
||||
private void CreateButtons()
|
||||
@ -147,6 +164,27 @@ namespace ImageProcessingGraph.Editor
|
||||
asset.runOrder = asset.GetExecutionOrder(asset.Nodes, asset.Connections);
|
||||
};
|
||||
|
||||
makeStickyNode = new Button
|
||||
{
|
||||
text = "Make Sticky Node",
|
||||
style =
|
||||
{
|
||||
width = 120,
|
||||
height = 40,
|
||||
position = Position.Absolute,
|
||||
top = 55+45,
|
||||
right = 10,
|
||||
fontSize = 9
|
||||
}
|
||||
};
|
||||
|
||||
makeStickyNode.clicked += () =>
|
||||
{
|
||||
var noteData = new AssetGraphStickyNoteData("");
|
||||
asset.stickyNotes.Add(noteData);
|
||||
this.DrawStickyNote(noteData);
|
||||
};
|
||||
|
||||
|
||||
Button dropdownButton = new Button
|
||||
{
|
||||
@ -169,6 +207,7 @@ namespace ImageProcessingGraph.Editor
|
||||
Add(debugModeButton);
|
||||
#endif
|
||||
Add(outputRunOrder);
|
||||
Add(makeStickyNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -176,6 +215,7 @@ namespace ImageProcessingGraph.Editor
|
||||
Remove(debugModeButton);
|
||||
#endif
|
||||
Remove(outputRunOrder);
|
||||
Remove(makeStickyNode);
|
||||
}
|
||||
|
||||
isDropdownEnabled = !isDropdownEnabled;
|
||||
@ -185,9 +225,9 @@ namespace ImageProcessingGraph.Editor
|
||||
Add(dropdownButton);
|
||||
}
|
||||
|
||||
private ImageProcessingGraphNodeVisual GetNode(string NodeID)
|
||||
private AssetGraphNodeEditor GetNode(string NodeID)
|
||||
{
|
||||
ImageProcessingGraphNodeVisual node = null;
|
||||
AssetGraphNodeEditor node = null;
|
||||
nodeDictionary.TryGetValue(NodeID, out node);
|
||||
return node;
|
||||
}
|
||||
@ -196,33 +236,53 @@ namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
List<Port> compatiblePorts = new List<Port>();
|
||||
|
||||
|
||||
foreach (var node in graphNodes)
|
||||
{
|
||||
// Prevent connections to self
|
||||
if (node == startPort.node)
|
||||
continue;
|
||||
|
||||
foreach (var port in node.inputContainer.Children().Concat(node.outputContainer.Children()).OfType<Port>())
|
||||
var ports = node.inputContainer.Children()
|
||||
.Concat(node.outputContainer.Children())
|
||||
.OfType<Port>();
|
||||
|
||||
foreach (var port in ports)
|
||||
{
|
||||
// Prevent connecting input to input or output to output
|
||||
if (port.direction == startPort.direction)
|
||||
if (startPort.direction == port.direction)
|
||||
continue;
|
||||
|
||||
if (port.portType != startPort.portType)
|
||||
{
|
||||
if (DoesConversionNodeExist())
|
||||
{
|
||||
Type typeA = GetPortEffectiveType(startPort);
|
||||
Type typeB = GetPortEffectiveType(port);
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
// if (typeA == typeof(object))
|
||||
// {
|
||||
// var BaseGenPort = startPort.node as ImageProcessingGraphNodeVisual;
|
||||
// var GenPort = BaseGenPort.GraphNode as GenericConnection;
|
||||
//
|
||||
// if (GenPort.InternalType != null)
|
||||
// {
|
||||
// if(!GenPort.InternalType.IsAssignableFrom(typeB))
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (typeB == typeof(object))
|
||||
// {
|
||||
// var BaseGenPort = port.node as ImageProcessingGraphNodeVisual;
|
||||
// var GenPort = BaseGenPort.GraphNode as GenericConnection;
|
||||
//
|
||||
// if (GenPort.InternalType != null)
|
||||
// {
|
||||
// if(!GenPort.InternalType.IsAssignableFrom(typeA))
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!typeA.IsAssignableFrom(typeB) && !typeB.IsAssignableFrom(typeA))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prevent connection if it creates a cycle
|
||||
if (startPort.direction == Direction.Output && CreatesCycle(startPort, port))
|
||||
continue;
|
||||
|
||||
if (startPort.direction == Direction.Input && CreatesCycle(port, startPort))
|
||||
continue;
|
||||
|
||||
@ -233,13 +293,37 @@ namespace ImageProcessingGraph.Editor
|
||||
return compatiblePorts;
|
||||
}
|
||||
|
||||
|
||||
private Type GetPortEffectiveType(Port port)
|
||||
{
|
||||
if (port is AssetGraphPort iptPort)
|
||||
{
|
||||
if (iptPort.node is AssetGraphNodeEditor vis &&
|
||||
vis.GraphNode is GenericConnection conn &&
|
||||
conn.InternalType != null)
|
||||
{
|
||||
return conn.InternalType;
|
||||
}
|
||||
return port.portType ?? typeof(object);
|
||||
}
|
||||
|
||||
return port.portType ?? typeof(object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private GraphViewChange OnGraphViewChanged(GraphViewChange graphviewchange)
|
||||
{
|
||||
|
||||
if (graphviewchange.movedElements != null)
|
||||
{
|
||||
Undo.RecordObject(serializedObject.targetObject, "Moved Graph Elements");
|
||||
foreach (var VARIABLE in graphviewchange.movedElements.OfType<ImageProcessingGraphNodeVisual>())
|
||||
foreach (var VARIABLE in graphviewchange.movedElements.OfType<AssetGraphNodeEditor>())
|
||||
{
|
||||
VARIABLE.SavePosition();
|
||||
}
|
||||
|
||||
foreach (var VARIABLE in graphviewchange.movedElements.OfType<AssetGraphStickyNote>())
|
||||
{
|
||||
VARIABLE.SavePosition();
|
||||
}
|
||||
@ -247,7 +331,7 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
if (graphviewchange.elementsToRemove != null)
|
||||
{
|
||||
List<ImageProcessingGraphNodeVisual> nodesToRemove = graphviewchange.elementsToRemove.OfType<ImageProcessingGraphNodeVisual>().ToList();
|
||||
List<AssetGraphNodeEditor> nodesToRemove = graphviewchange.elementsToRemove.OfType<AssetGraphNodeEditor>().ToList();
|
||||
List<Edge> edges = graphviewchange.elementsToRemove.OfType<Edge>().ToList();
|
||||
|
||||
if (nodesToRemove.Count > 0)
|
||||
@ -294,8 +378,8 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
public void CreateEdge(Edge edge)
|
||||
{
|
||||
ImageProcessingGraphNodeVisual outputNode = (ImageProcessingGraphNodeVisual)edge.output.node;
|
||||
ImageProcessingGraphNodeVisual inputNode = (ImageProcessingGraphNodeVisual)edge.input.node;
|
||||
AssetGraphNodeEditor outputNode = (AssetGraphNodeEditor)edge.output.node;
|
||||
AssetGraphNodeEditor inputNode = (AssetGraphNodeEditor)edge.input.node;
|
||||
|
||||
|
||||
int outputIndex = outputNode.OutputPorts.IndexOf(edge.output);
|
||||
@ -309,8 +393,8 @@ namespace ImageProcessingGraph.Editor
|
||||
edge.output.Connect(edge);
|
||||
edge.input.Connect(edge);
|
||||
|
||||
IPTPort portIn = (IPTPort)edge.output;
|
||||
IPTPort portOut = (IPTPort)edge.output;
|
||||
AssetGraphPort portIn = (AssetGraphPort)edge.output;
|
||||
AssetGraphPort portOut = (AssetGraphPort)edge.output;
|
||||
|
||||
if (portIn.fieldInfo != null)
|
||||
inputNode.ToggleExposedVariable(edge.input, false);
|
||||
@ -329,9 +413,9 @@ namespace ImageProcessingGraph.Editor
|
||||
edge.output.Disconnect(edge);
|
||||
edge.input.Disconnect(edge);
|
||||
|
||||
ImageProcessingGraphNodeVisual inputNode = (ImageProcessingGraphNodeVisual)edge.input.node;
|
||||
AssetGraphNodeEditor inputNode = (AssetGraphNodeEditor)edge.input.node;
|
||||
|
||||
IPTPort portIn = (IPTPort)edge.input;
|
||||
AssetGraphPort portIn = (AssetGraphPort)edge.input;
|
||||
|
||||
if(portIn.fieldInfo != null)
|
||||
inputNode.ToggleExposedVariable(edge.input, true);
|
||||
@ -350,20 +434,20 @@ namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
foreach (GraphConnection conn in asset.Connections)
|
||||
{
|
||||
ImageProcessingGraphNodeVisual inputNode = GetNode(conn.inputPort.nodeID);
|
||||
ImageProcessingGraphNodeVisual outputNode = GetNode(conn.outputPort.nodeID);
|
||||
AssetGraphNodeEditor inputNode = GetNode(conn.inputPort.nodeID);
|
||||
AssetGraphNodeEditor outputNode = GetNode(conn.outputPort.nodeID);
|
||||
|
||||
if (inputNode != null && outputNode != null)
|
||||
{
|
||||
IPTPort inPort = inputNode.InputPorts[conn.inputPort.portID] as IPTPort;
|
||||
IPTPort outPort = outputNode.OutputPorts[conn.outputPort.portID] as IPTPort;
|
||||
AssetGraphPort inPort = inputNode.InputPorts[conn.inputPort.portID] as AssetGraphPort;
|
||||
AssetGraphPort outPort = outputNode.OutputPorts[conn.outputPort.portID] as AssetGraphPort;
|
||||
|
||||
Edge edge = inPort.ConnectTo(outPort);
|
||||
AddElement(edge);
|
||||
connectionDictionary.Add(edge, conn);
|
||||
conn.SetInternalEdge(edge);
|
||||
|
||||
((ImageProcessingGraphNodeVisual)inPort.node).ToggleExposedVariable(inPort, false);
|
||||
((AssetGraphNodeEditor)inPort.node).ToggleExposedVariable(inPort, false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -414,13 +498,13 @@ namespace ImageProcessingGraph.Editor
|
||||
#region Nodes
|
||||
private void DrawNodes()
|
||||
{
|
||||
foreach (ImageProcessingGraphNodeVisual node in graphNodes)
|
||||
foreach (AssetGraphNodeEditor node in graphNodes)
|
||||
{
|
||||
RemoveElement(node);
|
||||
}
|
||||
graphNodes.Clear();
|
||||
|
||||
foreach (KeyValuePair<string, ImageProcessingGraphNodeVisual> node in nodeDictionary)
|
||||
foreach (KeyValuePair<string, AssetGraphNodeEditor> node in nodeDictionary)
|
||||
{
|
||||
RemoveElement(node.Value);
|
||||
}
|
||||
@ -432,20 +516,20 @@ namespace ImageProcessingGraph.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNodeToGraph(BaseImageNode node)
|
||||
private void AddNodeToGraph(AssetGraphNode node)
|
||||
{
|
||||
node.typeName = node.GetType().AssemblyQualifiedName;
|
||||
|
||||
var infoAttr = node.GetType().GetCustomAttribute<NodeInfoAttribute>();
|
||||
|
||||
ImageProcessingGraphNodeVisual editorNode = null;
|
||||
if (typeof(ImageProcessingGraphNodeVisual).IsAssignableFrom(infoAttr.EditorType))
|
||||
AssetGraphNodeEditor editorNode = null;
|
||||
if (typeof(AssetGraphNodeEditor).IsAssignableFrom(infoAttr.EditorType))
|
||||
{
|
||||
editorNode = (ImageProcessingGraphNodeVisual)Activator.CreateInstance(infoAttr.EditorType, node, this);
|
||||
editorNode = (AssetGraphNodeEditor)Activator.CreateInstance(infoAttr.EditorType, node, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
editorNode = new ImageProcessingGraphNodeVisual(node, this);
|
||||
editorNode = new AssetGraphNodeEditor(node, this);
|
||||
}
|
||||
|
||||
editorNode.SetPosition(node.Position);
|
||||
@ -457,7 +541,7 @@ namespace ImageProcessingGraph.Editor
|
||||
AddElement(editorNode);
|
||||
}
|
||||
|
||||
public void Add(BaseImageNode node)
|
||||
public void Add(AssetGraphNode node)
|
||||
{
|
||||
Undo.RecordObject(serializedObject.targetObject, "Added Node");
|
||||
asset.Nodes.Add(node);
|
||||
@ -468,7 +552,7 @@ namespace ImageProcessingGraph.Editor
|
||||
|
||||
}
|
||||
|
||||
private void RemoveNode(ImageProcessingGraphNodeVisual variable)
|
||||
private void RemoveNode(AssetGraphNodeEditor variable)
|
||||
{
|
||||
List<GraphConnection> connectionsToRemove = new List<GraphConnection>();
|
||||
|
||||
@ -502,5 +586,30 @@ namespace ImageProcessingGraph.Editor
|
||||
#endregion
|
||||
|
||||
|
||||
#region Sticky Note
|
||||
|
||||
public void DrawStickyNotes()
|
||||
{
|
||||
foreach (var stick in asset.stickyNotes)
|
||||
{
|
||||
this.stickyNoteDictionary.Add(stick.GUID, DrawStickyNote(stick));
|
||||
}
|
||||
}
|
||||
|
||||
public AssetGraphStickyNote DrawStickyNote(AssetGraphStickyNoteData stickyNote)
|
||||
{
|
||||
AssetGraphStickyNote stickyNoteVisual = new AssetGraphStickyNote(stickyNote, this);
|
||||
|
||||
stickyNoteVisual.SetPosition(stickyNote.Position);
|
||||
stickyNoteVisual.style.width = stickyNote.Size.x;
|
||||
stickyNoteVisual.style.height = stickyNote.Size.y;
|
||||
|
||||
this.Add(stickyNoteVisual);
|
||||
return stickyNoteVisual;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
4
GenericNode.uss
Normal file
4
GenericNode.uss
Normal file
@ -0,0 +1,4 @@
|
||||
#Title
|
||||
{
|
||||
display: none;
|
||||
}
|
3
GenericNode.uss.meta
Normal file
3
GenericNode.uss.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79b350a401ed4074ab5fc42f451a8125
|
||||
timeCreated: 1746344909
|
@ -1,4 +1,4 @@
|
||||
ImageProcessingGraphViewWindow
|
||||
AssetGraphViewWindow
|
||||
{
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user