Compare commits

...

19 Commits

Author SHA1 Message Date
Chromium
a17b04566e Added Maz Nodes 2025-05-17 12:53:28 +01:00
Chromium
7fcd596a16 FIXED! 2025-05-17 12:34:37 +01:00
Chromium
687c52df62 CumBuckets 2025-05-17 11:04:41 +01:00
Chromium
1b941d6531 Fixed null reference with stickynotes 2025-05-11 13:15:57 +01:00
Chromium
679f93c04d Added Documentation Links 2025-05-11 13:06:33 +01:00
Chromium
0b7696fc79 Added tooltips 2025-05-07 10:05:22 +01:00
Chromium
2e32a83484 Fixed Connector 2025-05-06 10:10:15 +01:00
Chromium
fa5cba5ded BEGONE stupid fuckin warnings 2025-05-04 10:14:54 +01:00
Chromium
020d29a6fe sticky notes kinda work! 2025-05-04 10:12:39 +01:00
Chromium
e3e851e9db fixed spooky warning 2025-05-04 08:54:56 +01:00
Chromium
9e512b8e8e oomfies 2025-05-04 08:51:30 +01:00
Chromium
fb800946ab i forgor whsat i did 2025-05-04 08:44:03 +01:00
Chromium
c1d99aa06e Tooltip addded to View Node 2025-05-04 08:25:30 +01:00
Chromium
ceac1eeba5 RAH 2025-05-03 07:33:41 +01:00
Chromium
b1e0767d91 4 magladore! 2025-05-03 07:23:00 +01:00
Chromium
8d629e5cd3 FIX 2025-05-03 06:15:32 +01:00
Chromium
c08c554aa4 Fixed 2025-05-03 06:14:49 +01:00
Chromium
f1824f8b5e SCARY STUFF VERY EARLY 2025-05-03 06:10:58 +01:00
Chromium
f5c9b2833c From path nodes and Variable nodes 2025-05-03 04:02:14 +01:00
87 changed files with 1293 additions and 511 deletions

View File

@ -1,52 +1,56 @@
using ImageProcessingGraph.Editor.Windows;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEditor.Callbacks; using UnityEditor.Callbacks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using AssetGraph.Core.GraphElements;
using AssetGraph.Nodes;
using ImageProcessingGraph.Editor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using Debug = UnityEngine.Debug; using Debug = UnityEngine.Debug;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace ImageProcessingGraph.Editor namespace AssetGraph.Core
{ {
[CreateAssetMenu(menuName = "Image Processing Graph/New Graph")] [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; [SerializeField] private List<GraphConnection> connections;
[SerializeReference] public List<BaseImageNode> runOrder; [SerializeReference] public List<AssetGraphNode> runOrder;
[SerializeField] public List<StickyNote> stickyNotes; [SerializeField] public List<AssetGraphStickyNoteData> stickyNotes;
public List<BaseImageNode> Nodes => nodes; public List<AssetGraphNode> Nodes => nodes;
public List<GraphConnection> Connections => connections; public List<GraphConnection> Connections => connections;
public delegate void OnRunEvent(); public delegate void OnRunEvent();
public event OnRunEvent OnRun; public event OnRunEvent OnRun;
public OnRunEvent OnRunEnd; public OnRunEvent OnRunEnd;
public ImageProcessingGraphAsset() public AssetGraphData()
{ {
nodes = new List<BaseImageNode>(); nodes = new List<AssetGraphNode>();
connections = new List<GraphConnection>(); connections = new List<GraphConnection>();
stickyNotes = new List<AssetGraphStickyNoteData>();
} }
[OnOpenAsset(1)] [OnOpenAsset(1)]
public static bool OpenGraphAsset(int instanceID, int line) 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) if (asset != null)
{ {
ImageProcessingGraphEditorWindow.Open(asset); AssetGraphEditorWindow.Open(asset);
return true; return false;
} }
return false; return true;
} }
public void RunGraph() public void RunGraph()
{ {
var bleh = GetAllVariableNodesWithTypes();
OnRun?.Invoke(); OnRun?.Invoke();
// Create and start the stopwatch to measure time // Create and start the stopwatch to measure time
@ -54,25 +58,20 @@ namespace ImageProcessingGraph.Editor
stopwatch.Start(); stopwatch.Start();
runOrder = GetExecutionOrder(this.nodes, this.connections); runOrder = GetExecutionOrder(this.nodes, this.connections);
bool failed = false;
foreach (var VARIABLE in runOrder) foreach (var VARIABLE in runOrder)
{ {
if (!VARIABLE.RunNode()) if (!VARIABLE.RunNode())
{ {
failed = true;
break; break;
} }
} }
foreach (var VARIABLE in runOrder) foreach (var VARIABLE in runOrder)
{ {
if(!VARIABLE.RunCleanUp()) VARIABLE.RunCleanUp();
failed = true;
} }
// Stop the stopwatch after running the nodes
stopwatch.Stop(); stopwatch.Stop();
// Log the elapsed time // Log the elapsed time
@ -81,15 +80,32 @@ namespace ImageProcessingGraph.Editor
AssetDatabase.Refresh(); AssetDatabase.Refresh();
} }
public List<(AssetGraphNode node, System.Type type)> GetAllVariableNodesWithTypes()
{
var result = new List<(AssetGraphNode node, System.Type type)>();
/// <summary> foreach (var node in nodes)
/// 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. var nodeType = node.GetType();
/// </summary> var baseType = nodeType.BaseType;
public List<BaseImageNode> GetExecutionOrder(List<BaseImageNode> nodes, List<GraphConnection> connections, bool debug = false)
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 === // === 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 adjList = new Dictionary<string, List<string>>(nodes.Count);
var inDegree = new Dictionary<string, int>(nodes.Count); var inDegree = new Dictionary<string, int>(nodes.Count);
@ -126,7 +142,7 @@ namespace ImageProcessingGraph.Editor
} }
// === Topological Sort (Kahn's Algorithm) === // === 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); var queue = new Queue<string>(nodes.Count);
foreach (var kvp in inDegree) foreach (var kvp in inDegree)

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 43834c706e924da6b7f11712b89420bc
timeCreated: 1747472390

View File

@ -1,7 +1,6 @@
using System; using System;
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows;
namespace ImageProcessingGraph.Editor.Nodes.NodeAttributes namespace AssetGraph.Core.Attributes
{ {
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class NodeInfoAttribute : Attribute public class NodeInfoAttribute : Attribute
@ -10,18 +9,21 @@ namespace ImageProcessingGraph.Editor.Nodes.NodeAttributes
private string menuItem; private string menuItem;
private string ussPath; private string ussPath;
private Type editorType; private Type editorType;
private string docuementationURL;
public string Title => name; public string Title => name;
public string MenuItem => menuItem; public string MenuItem => menuItem;
public string UssPath => ussPath; public string UssPath => ussPath;
public Type EditorType => editorType; 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.name = name;
this.menuItem = menuItem; this.menuItem = menuItem;
this.ussPath = ussPath; this.ussPath = ussPath;
this.editorType = editorType; this.editorType = editorType;
this.docuementationURL = docuementationURL;
} }
} }

View File

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

View File

@ -1,11 +0,0 @@
using UnityEngine;
namespace ImageProcessingGraph.Editor
{
public class IPT_Preferences : ScriptableObject
{
public bool debugMode = false;
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 80dcc02594d68e3439df7dc743c9d4b2

View File

@ -3,77 +3,51 @@ using System.IO;
using Unity.Collections; using Unity.Collections;
using UnityEngine; using UnityEngine;
/// <summary>
/// A structure that holds image pixel data and its dimensions. namespace AssetGraph.Core.DataTypes
/// </summary>
[Serializable]
public struct ImageData
{ {
/// <summary> [Serializable]
/// The pixel data of the image in Color32 format.
/// </summary>
public NativeArray<Color32> PixelData;
/// <summary> public struct ImageData
/// 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; public NativeArray<Color32> PixelData;
Dimensions = widthHeight; public (int width, int height) Dimensions;
isRGBA = isRgba; public bool isRGBA;
}
/// <summary> public ImageData(NativeArray<Color32> imageData, (int width, int height) widthHeight, bool isRgba)
/// 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);
Dimensions = (sourceTexture.width, sourceTexture.height);
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);
texture.LoadRawTextureData(PixelData);
texture.Apply();
return texture;
}
public void ExportPNG(string path)
{
Texture2D texture = this.ToTexture2D();
byte[] data = texture.EncodeToPNG();
if (data != null)
{ {
System.IO.File.WriteAllBytes(path, data); PixelData = imageData;
Dimensions = widthHeight;
isRGBA = isRgba;
}
public ImageData(Texture2D sourceTexture)
{
PixelData = new NativeArray<Color32>(sourceTexture.GetPixelData<Color32>(0), Allocator.Persistent);
Dimensions = (sourceTexture.width, sourceTexture.height);
isRGBA = sourceTexture.format == TextureFormat.RGBA32;
}
public int Width => Dimensions.width;
public int Height => Dimensions.height;
public Texture2D ToTexture2D()
{
var texture = new Texture2D(Width, Height, TextureFormat.RGBA32, false);
texture.LoadRawTextureData(PixelData);
texture.Apply();
return texture;
}
public void ExportPNG(string path)
{
Texture2D texture = this.ToTexture2D();
byte[] data = texture.EncodeToPNG();
if (data != null)
{
File.WriteAllBytes(path, data);
}
} }
} }
} }

View File

@ -2,46 +2,22 @@
using UnityEngine; using UnityEngine;
/// <summary> namespace AssetGraph.Core.DataTypes
/// Represents a single image channel (e.g., Red, Green, Blue, Alpha) as a 1D byte array,
/// along with the original image dimensions.
/// </summary>
public struct SplitChannelData
{ {
/// <summary> public struct SplitChannelData
/// 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; public byte[] ChannelData;
Dimensions = widthHeight; public (int width, int height) Dimensions;
public SplitChannelData(byte[] channelData, (int width, int height) widthHeight)
{
ChannelData = channelData;
Dimensions = widthHeight;
}
public int Width => Dimensions.width;
public int Height => Dimensions.height;
public bool IsValid => ChannelData != null && ChannelData.Length == Width * Height;
} }
/// <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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 458de9252a6744148203b96771e2ad90
timeCreated: 1747472377

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

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 119eef6b9f4b410da217f8a12be9973d
timeCreated: 1746345401

View File

@ -6,7 +6,7 @@ using UnityEditor.UIElements;
#endif #endif
namespace ImageProcessingGraph.Editor namespace AssetGraph.Core.GraphElements
{ {
[Serializable] [Serializable]
public class GreyscaleValue public class GreyscaleValue

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1403355e956148e3a298f151e782e76c
timeCreated: 1747472333

View File

@ -0,0 +1,10 @@
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
namespace AssetGraph.Core
{
public class AssetGraphEdge : Edge
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 76cd012b608644caa127970fd3caf115
timeCreated: 1746343590

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

View File

@ -2,16 +2,18 @@ using System;
using System.Configuration; using System.Configuration;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEngine; using UnityEngine;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes;
using System.Collections.Generic; using System.Collections.Generic;
using Input = ImageProcessingGraph.Editor.Nodes.NodeAttributes.Input;
using System.Linq; using System.Linq;
using System.Reflection; 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] [System.Serializable]
public abstract class BaseImageNode public abstract class AssetGraphNode
{ {
[SerializeField] private string guid; [SerializeField] private string guid;
@ -24,17 +26,14 @@ namespace ImageProcessingGraph.Editor
public string ID => guid; public string ID => guid;
public Rect Position => position; public Rect Position => position;
public ImageProcessingGraphAsset asset; public AssetGraphData asset;
public delegate void OnFailed(); public delegate void OnFailed();
public event OnFailed onFailed; public event OnFailed onFailed;
public BaseImageNode() public AssetGraphNode()
{ {
guid = Guid.NewGuid().ToString(); guid = Guid.NewGuid().ToString();
/*Type t = this.GetType();
Debug.Log(t.Name);*/
} }
public void SetNodeInputs() public void SetNodeInputs()
@ -51,7 +50,7 @@ namespace ImageProcessingGraph.Editor
// Find the connection that leads to this input property // Find the connection that leads to this input property
GraphConnection connection = default; GraphConnection connection = default;
foreach (var conn in asset.Connections) foreach (GraphConnection conn in asset.Connections)
{ {
if (conn.inputPort.nodeID == this.ID) if (conn.inputPort.nodeID == this.ID)
{ {

View File

@ -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)
{
}
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 31313dec455d4407bb6fffc7b167dabb
timeCreated: 1743744035

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: dbd7cd37cae147f3a54f12c52ef54217
timeCreated: 1742158168

View File

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

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 78c0de359ceae406cb2985637a2e6c97

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 587f3b2d6fad453fbf6664066f807f21
timeCreated: 1745299284

View File

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

View File

@ -1,18 +1,19 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfoAttribute("Invert Channel", "Adjustments/InvertChannel", true)] [NodeInfo("Invert Channel", "Adjustments/InvertChannel", true, docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FInvertChannel")]
public class ChannelInvertNode : BaseImageNode public class ChannelInvertNode : AssetGraphNode
{ {
[NodeAttributes.Input("Input Channel")] [Core.Attributes.Input("Input Channel")]
public SplitChannelData inputChannel; public SplitChannelData inputChannel;
[NodeAttributes.Output("Output Channel")] [Core.Attributes.Output("Output Channel")]
public SplitChannelData outputChannel; public SplitChannelData outputChannel;
public override void Process() public override void Process()

View File

@ -1,4 +1,5 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
@ -6,16 +7,16 @@ using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfoAttribute("Desaturate", "Adjustments/Desaturate", true)] [NodeInfo("Desaturate", "Adjustments/Desaturate", true, docuementationURL: "https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FDesaturate")]
public class Texture2DDesaturate : BaseImageNode public class Texture2DDesaturate : AssetGraphNode
{ {
[NodeAttributes.Input("")] [Core.Attributes.Input("")]
public ImageData inputTexture; // Changed to ImageData public ImageData inputTexture;
[NodeAttributes.Output("")] [Core.Attributes.Output("")]
public ImageData outputTexture; // Changed to ImageData public ImageData outputTexture;
public override void Process() public override void Process()
{ {

View File

@ -1,26 +1,25 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfoAttribute("Invert", "Adjustments/Invert", true)] [NodeInfo("Invert", "Adjustments/Invert", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FInvert")]
public class Texture2DInvert : BaseImageNode public class Texture2DInvert : AssetGraphNode
{ {
[NodeAttributes.Input("")] [Core.Attributes.Input("")]
public ImageData inputTexture; // Changed to ImageData public ImageData inputTexture;
[NodeAttributes.Output("")] [Core.Attributes.Output("")]
public ImageData outputTexture; // Changed to ImageData public ImageData outputTexture;
public override void Process() public override void Process()
{ {
// Create an empty NativeArray for the output
NativeArray<Color32> output = new NativeArray<Color32>(inputTexture.PixelData.Length, Allocator.Persistent); NativeArray<Color32> output = new NativeArray<Color32>(inputTexture.PixelData.Length, Allocator.Persistent);
// Create and run the InvertJob
InvertJob job = new InvertJob InvertJob job = new InvertJob
{ {
pixels = inputTexture.PixelData, pixels = inputTexture.PixelData,
@ -29,7 +28,6 @@ namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
job.Run(); job.Run();
// Store the result in the outputImage as an ImageData instance
outputTexture = new ImageData(output, (inputTexture.Width, inputTexture.Height), inputTexture.isRGBA); outputTexture = new ImageData(output, (inputTexture.Width, inputTexture.Height), inputTexture.isRGBA);
} }
} }
@ -37,14 +35,13 @@ namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture
[BurstCompile] [BurstCompile]
public struct InvertJob : IJob public struct InvertJob : IJob
{ {
[ReadOnly] public NativeArray<Color32> pixels; // Input pixels [ReadOnly] public NativeArray<Color32> pixels;
[WriteOnly] public NativeArray<Color32> outputPixels; // Output pixels [WriteOnly] public NativeArray<Color32> outputPixels;
public void Execute() public void Execute()
{ {
int length = pixels.Length; int length = pixels.Length;
// Invert each pixel color
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
Color32 pixel = pixels[i]; Color32 pixel = pixels[i];

View File

@ -1,27 +1,28 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfo("RGBA Combine", "Channels/RGBA Combine", true)] [NodeInfo("RGBA Combine", "Channels/RGBA Combine", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FRGBACombine")]
public class RGBASCombine : BaseImageNode public class RGBASCombine : AssetGraphNode
{ {
[NodeAttributes.Input("R")] [Core.Attributes.Input("R")]
public SplitChannelData r; public SplitChannelData r;
[NodeAttributes.Input("G")] [Core.Attributes.Input("G")]
public SplitChannelData g; public SplitChannelData g;
[NodeAttributes.Input("B")] [Core.Attributes.Input("B")]
public SplitChannelData b; public SplitChannelData b;
[NodeAttributes.Input("A")] [Core.Attributes.Input("A")]
public SplitChannelData a; public SplitChannelData a;
[NodeAttributes.Output("")] [Core.Attributes.Output("")]
public ImageData inputTexture; public ImageData inputTexture;
// Job struct for combining RGBA channels // Job struct for combining RGBA channels

View File

@ -1,24 +1,25 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfoAttribute("RGBA Split", "Channels/RGBA Split", true)] [NodeInfo("RGBA Split", "Channels/RGBA Split", true, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FRGBASplit")]
public class RGBASplit : BaseImageNode public class RGBASplit : AssetGraphNode
{ {
[NodeAttributes.Input("")] [Core.Attributes.Input("")]
public ImageData inputTexture; public ImageData inputTexture;
[NodeAttributes.Output("R")] [Core.Attributes.Output("R")]
public SplitChannelData r; public SplitChannelData r;
[NodeAttributes.Output("G")] [Core.Attributes.Output("G")]
public SplitChannelData g; public SplitChannelData g;
[NodeAttributes.Output("B")] [Core.Attributes.Output("B")]
public SplitChannelData b; public SplitChannelData b;
[NodeAttributes.Output("A")] [Core.Attributes.Output("A")]
public SplitChannelData a; public SplitChannelData a;
public override void Process() public override void Process()

View File

@ -1,21 +1,22 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Burst; using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Fun_Nodes.Texture namespace AssetGraph.Nodes
{ {
[NodeInfoAttribute("Get Dimensions", "Dimensions/Get Dimensions", false)] [NodeInfo("Get Dimensions", "Dimensions/Get Dimensions", false, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FGetDimensions")]
public class TextureGetDimensions : BaseImageNode public class TextureGetDimensions : AssetGraphNode
{ {
[NodeAttributes.Input("")] [Core.Attributes.Input("")]
public ImageData inputTexture; public ImageData inputTexture;
[NodeAttributes.Output("Width")] [Core.Attributes.Output("Width")]
public int width; public int width;
[NodeAttributes.Output("Height")] [Core.Attributes.Output("Height")]
public int height; public int height;
public override void Process() public override void Process()

View File

@ -1,17 +1,18 @@
using System.ComponentModel.Composition.Primitives; using System.ComponentModel.Composition.Primitives;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Collections; using Unity.Collections;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Output namespace AssetGraph.Nodes
{ {
[NodeInfo("Texture Export", "Export/Texture Export", true)] [NodeInfo("Texture Export", "Export/Texture Export", true,docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FTexture2DOutput")]
public class Texture2DOutput : BaseImageNode public class Texture2DOutput : AssetGraphNode
{ {
[NodeAttributes.Input("")] public ImageData inputPixels; [Core.Attributes.Input("")] public ImageData inputPixels;
[NodeAttributes.Input("File Name")] public string fileName; [Core.Attributes.Input("File Name")] public string fileName;
[NodeAttributes.Input("File Directory")] public string fileDirectory; [Core.Attributes.Input("File Directory")] public string fileDirectory;
public enum ExportType public enum ExportType
{ {
@ -19,10 +20,10 @@ namespace ImageProcessingGraph.Editor.Nodes.Output
PNG PNG
} }
[NodeAttributes.Input("Export Type")] public ExportType exportType; [Core.Attributes.Input("Export Type")] public ExportType exportType;
[NodeAttributes.Input("Texture Type")] public TextureImporterType textureType; [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() public override void Process()
{ {

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 077795206494544448685fbd8458fa0c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fd58cf45d01e429abcb9b8f4e3894b7a
timeCreated: 1746240608

View File

@ -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> { }
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dbdf66c38fa94127a4665bf6fd1ac011
timeCreated: 1746240631

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c2fcf5cdfdc07ba479efe9544501e5e6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,22 +1,23 @@
using System.IO; using System.IO;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using Unity.Collections; using Unity.Collections;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Import_Nodes namespace AssetGraph.Nodes
{ {
[NodeInfo("Texture Import", "Imports/Import Texture")] [NodeInfo("Texture Import", "Imports/Import Texture", docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImage%2FTexture2DImport")]
public class Texture2DImport : BaseImageNode public class Texture2DImport : AssetGraphNode
{ {
[NodeAttributes.Input("")] [Core.Attributes.Input("")]
public Texture2D textureImport; public Texture2D textureImport;
[NodeAttributes.Output("")] [Core.Attributes.Output("")]
public ImageData textureOutput; public ImageData textureOutput;
[NodeAttributes.Output("File Name")] [Core.Attributes.Output("File Name")]
public string fileName; public string fileName;
[NodeAttributes.Output("File Directory")] [Core.Attributes.Output("File Directory")]
public string filePath; public string filePath;
public override void Process() public override void Process()

View File

@ -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.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities namespace AssetGraph.Nodes
{ {
public class SingleChannelColor public class SingleChannelColor
{ {
[NodeInfoAttribute("Channel Color", "Utility/Channel Color", false)] [NodeInfo("Channel Color", "Utility/Channel Color", false, docuementationURL:"https://git.sam-green.dev/Chromum/UnityImageProcessing_Package/wiki/Nodes%2FImages%2FSingleChannelColor")]
public class SingleColorChannel : BaseImageNode 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() public override void Process()
{ {

View File

@ -1,16 +1,17 @@
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.DataTypes;
using UnityEngine; using UnityEngine;
using Unity.Collections; using Unity.Collections;
using Unity.Jobs; using Unity.Jobs;
using Unity.Burst; 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))] [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 : BaseImageNode public partial class ViewTextureNode : AssetGraphNode
{ {
[NodeAttributes.Input("Texture")] public Texture2D texture; [Core.Attributes.Input("Texture")] public Texture2D texture;
[NodeAttributes.Input("Image Data")] public ImageData imageData; [Core.Attributes.Input("Image Data")] public ImageData imageData;
public delegate void OnImageUpdated(); public delegate void OnImageUpdated();
public OnImageUpdated onImageUpdated; public OnImageUpdated onImageUpdated;

View File

@ -1,22 +1,23 @@
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows; using AssetGraph.Core;
using UnityEditor.UIElements;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; 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 UnityEngine.UIElements.Image viewableImage;
private Foldout foldout; private Foldout foldout;
private VisualElement buttonRow; 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 0 is Texture2D
//Port 1 is ImageData //Port 1 is ImageData
IPTPort tex2DPort = InputPorts[0] as IPTPort; AssetGraphPort tex2DPort = InputPorts[0] as AssetGraphPort;
IPTPort imageDataPort = InputPorts[1] as IPTPort; AssetGraphPort imageDataPort = InputPorts[1] as AssetGraphPort;
tex2DPort.OnPortConnected += () => { imageDataPort.style.display = DisplayStyle.None; }; 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; }; viewImageNode.onImageUpdated += () => { viewableImage.image = viewImageNode.texture; };
Toolbar tb = new Toolbar();
tb.style.height = 32;
buttonRow = new VisualElement buttonRow = new VisualElement
{ {
style = style =
@ -70,10 +74,11 @@ namespace ImageProcessingGraph.Editor.Nodes.Types.Image.Utilities.ViewNode
text = channel text = channel
}; };
btn.style.flexGrow = 1; 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) private void OnChannelClicked(ViewTextureNode viewNode, string channel)

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 899a77acab6b46d9af23756a397e7eea
timeCreated: 1746228396

View File

@ -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> { }
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b10ad5cecfc74b548431deb876d3cb9a
timeCreated: 1746228592

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 35175651a2c0f6947b7cc63fde04829f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee2323729ea6fa84788137af3807d8b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 455f8a7df4c9c2e4691f68b537e29573
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e4a21d5960ac4b858705aec0bdaddab4
timeCreated: 1746343737

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b77f4983d61d4a2ab1916ea59a0ec6fa
timeCreated: 1746343741

View File

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

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c3fb7dc03aa647a8a99146ef19bb663e
timeCreated: 1746343749

View File

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a32e947621c08940b8f9c68c3bc0bdc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 851727f1cfe10de4b8073aa6a334518c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 612cfa8fb6e00e14d9f78091cb61cdde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 79f6818ae71efcd48a44d3fb422891bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,30 +1,36 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace ImageProcessingGraph.Editor.Windows namespace AssetGraph.Core
{ {
[CustomEditor(typeof(ImageProcessingGraphAsset))] [CustomEditor(typeof(AssetGraphData))]
public class ImageProcessingGraphAssetEditorWindow : UnityEditor.Editor public class AssetGraphDataEditor : UnityEditor.Editor
{ {
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
if (GUILayout.Button("Open")) if (GUILayout.Button("Open"))
{ {
ImageProcessingGraphEditorWindow.Open((ImageProcessingGraphAsset)target); AssetGraphEditorWindow.Open((AssetGraphData)target);
} }
if(GUILayout.Button("Calculate Dependancy Graph")) if(GUILayout.Button("Calculate Dependancy Graph"))
{ {
var bleh = (ImageProcessingGraphAsset)target; var bleh = (AssetGraphData)target;
bleh.runOrder = bleh.GetExecutionOrder(bleh.Nodes, bleh.Connections, true); bleh.runOrder = bleh.GetExecutionOrder(bleh.Nodes, bleh.Connections, true);
} }
if(GUILayout.Button("Run Graph")) if(GUILayout.Button("Run Graph"))
{ {
var bleh = (ImageProcessingGraphAsset)target; var bleh = (AssetGraphData)target;
bleh.RunGraph(); bleh.RunGraph();
} }
} }
[MenuItem("Test/TEser", false, 1)]
public static void OpenBatchingWindow()
{
}
} }
} }

View File

@ -1,21 +1,22 @@
using System.Collections.Generic; using System.Collections.Generic;
using ImageProcessingGraph.Editor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEditor.MemoryProfiler; using UnityEditor.MemoryProfiler;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; 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 GraphViewChange m_GraphViewChange;
private List<Edge> m_EdgesToCreate; private List<Edge> m_EdgesToCreate;
private List<GraphElement> m_EdgesToDelete; 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_EdgesToCreate = new List<Edge>();
this.m_EdgesToDelete = new List<GraphElement>(); this.m_EdgesToDelete = new List<GraphElement>();
@ -26,9 +27,18 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
public void OnDropOutsidePort(Edge edge, Vector2 position) public void OnDropOutsidePort(Edge edge, Vector2 position)
{ {
window.searchProvider.target = (VisualElement)window.focusController.focusedElement; window.searchProvider.target = (VisualElement)window.focusController.focusedElement;
var mousePos =
window.ChangeCoordinatesTo(window, window.cachedMousePos - window.Window.position.position);
var graphMousePosition = window.contentViewContainer.WorldToLocal(mousePos);
// ⚡ Override the search window open with a customized search tree var searchProviderInstance = ScriptableObject.CreateInstance<AssetGraphSearchProvider.CustomSearchProviderForEdge>();
SearchWindow.Open(new SearchWindowContext(position), new ImageProcessingGraphSearchProvider.CustomSearchProviderForEdge(window.searchProvider, edge, (IPTPort)edge.input, (IPTPort)edge.output)); 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 // Remove connections as you did
List<GraphConnection> connections = new List<GraphConnection>(); 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 != null)
if (edge.input.node != 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); 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(); this.m_EdgesToCreate.Clear();

View File

@ -3,18 +3,18 @@ using UnityEditor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEngine; 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 SerializedObject serializedObject;
[SerializeField] private ImageProcessingGraphViewWindow currentView; [SerializeField] private AssetGraphViewWindow currentView;
public ImageProcessingGraphAsset CurrentGraph => currentGraph; 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) foreach (var w in existingWindows)
{ {
if (w.CurrentGraph == asset) 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}", window.titleContent = new GUIContent($"{asset.name}",
EditorGUIUtility.ObjectContent(null, typeof(ImageProcessingGraphAsset)).image); EditorGUIUtility.ObjectContent(null, typeof(AssetGraphData)).image);
window.Load(asset); window.Load(asset);
window.Focus(); window.Focus();
} }
@ -50,7 +50,7 @@ namespace ImageProcessingGraph.Editor.Windows
} }
} }
public void Load(ImageProcessingGraphAsset asset) public void Load(AssetGraphData asset)
{ {
currentGraph = asset; currentGraph = asset;
DrawGraph(); DrawGraph();
@ -59,8 +59,9 @@ namespace ImageProcessingGraph.Editor.Windows
public void DrawGraph() public void DrawGraph()
{ {
serializedObject = new SerializedObject(currentGraph); serializedObject = new SerializedObject(currentGraph);
currentView = new ImageProcessingGraphViewWindow(serializedObject, this); currentView = new AssetGraphViewWindow(serializedObject, this);
currentView.graphViewChanged += OnChange; currentView.graphViewChanged += OnChange;
rootVisualElement.style.flexGrow = 1;
rootVisualElement.Add(currentView); rootVisualElement.Add(currentView);
} }

View File

@ -2,30 +2,33 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using AssetGraph.Core.GraphElements;
using AssetGraph.Nodes;
using UnityEditor; using UnityEditor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEditor.UIElements; using UnityEditor.UIElements;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; 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; private AssetGraphNode graphNode;
public BaseImageNode GraphNode => graphNode; public AssetGraphNode GraphNode => graphNode;
public List<Port> AllPorts = new List<Port>();
public List<Port> InputPorts { get; } public List<Port> InputPorts { get; }
public List<Port> OutputPorts { get; } public List<Port> OutputPorts { get; }
private ImageProcessingGraphViewWindow window; public AssetGraphViewWindow window;
private StyleSheet defaaStyleSheet; private StyleSheet defaaStyleSheet;
private StyleSheet errorStyleSheet; private StyleSheet errorStyleSheet;
private NodeInfoAttribute info;
public ImageProcessingGraphNodeVisual(BaseImageNode node, ImageProcessingGraphViewWindow window)
public AssetGraphNodeEditor(AssetGraphNode node, AssetGraphViewWindow window)
{ {
this.AddToClassList("image-node-visual"); this.AddToClassList("image-node-visual");
this.window = window; this.window = window;
@ -33,9 +36,10 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
Type typeInfo = node.GetType(); Type typeInfo = node.GetType();
NodeInfoAttribute info = typeInfo.GetCustomAttribute<NodeInfoAttribute>(); info = typeInfo.GetCustomAttribute<NodeInfoAttribute>();
title = info.Title; title = info.Title;
this.name = typeInfo.Name; this.name = typeInfo.Name;
string[] depths = info.MenuItem.Split('/'); string[] depths = info.MenuItem.Split('/');
foreach (var depth in depths) foreach (var depth in depths)
@ -46,16 +50,16 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
this.InputPorts = new List<Port>(); this.InputPorts = new List<Port>();
this.OutputPorts = 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> inputFieldInfo = new List<FieldInfo>();
List<FieldInfo> outputFieldInfo = new List<FieldInfo>(); List<FieldInfo> outputFieldInfo = new List<FieldInfo>();
FieldInfo[] fields = typeInfo.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); FieldInfo[] fields = typeInfo.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
foreach (var field in fields) 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); inputs.Add(input);
inputFieldInfo.Add(field); inputFieldInfo.Add(field);
} }
@ -101,12 +105,13 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
for (var index = 0; index < fields.Count; index++) for (var index = 0; index < fields.Count; index++)
{ {
var field = fields[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 != "") if (label != "")
port.portName = label; port.portName = label;
InputPorts.Add(port); InputPorts.Add(port);
AllPorts.Add(port);
inputContainer.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++) for (var index = 0; index < fields.Count; index++)
{ {
var field = fields[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; string label = field.GetCustomAttribute<Output>().Label;
if (label != "") if (label != "")
port.portName = label; port.portName = label;
OutputPorts.Add(port); OutputPorts.Add(port);
AllPorts.Add(port);
outputContainer.Add(port); outputContainer.Add(port);
port.fieldInfo = field; port.fieldInfo = field;
@ -137,7 +143,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
public void ExposeVariableToPort(Port port, FieldInfo field) public void ExposeVariableToPort(Port port, FieldInfo field)
{ {
VisualElement NewElement = new VisualElement(); VisualElement NewElement = new VisualElement();
var ExposedPropertyContainer = ((IPTPort)port).ExposedPropertyContainer; var ExposedPropertyContainer = ((AssetGraphPort)port).ExposedPropertyContainer;
Type containerType = null; Type containerType = null;
if (ExposedPropertyContainer == null) if (ExposedPropertyContainer == null)
@ -149,8 +155,8 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
containerType = the.GetType(); containerType = the.GetType();
NewElement.Add(the); NewElement.Add(the);
((IPTPort)port).ExposedPropertyContainer = the; ((AssetGraphPort)port).ExposedPropertyContainer = the;
ExposedPropertyContainer = ((IPTPort)port).ExposedPropertyContainer; ExposedPropertyContainer = ((AssetGraphPort)port).ExposedPropertyContainer;
} }
else else
{ {
@ -244,9 +250,9 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
public void ToggleExposedVariable(Port port, bool value) public void ToggleExposedVariable(Port port, bool value)
{ {
IPTPort iptPort = port as IPTPort; AssetGraphPort assetGraphPort = port as AssetGraphPort;
if(iptPort.ExposedPropertyContainer != null) if(assetGraphPort.ExposedPropertyContainer != null)
iptPort.ExposedPropertyContainer.style.display = value ? DisplayStyle.Flex : DisplayStyle.None; assetGraphPort.ExposedPropertyContainer.style.display = value ? DisplayStyle.Flex : DisplayStyle.None;
} }
private VisualElement CreatePropertyFieldForType(Type type, object value) 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) }; var objectField = new ObjectField { value = (UnityEngine.Object)value, objectType = typeof(UnityEngine.Object) };
return objectField; return objectField;
} }
// Add more types as needed
return null; return null;
} }
@ -322,7 +326,14 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
private void OpenDocumentation(DropdownMenuAction obj) 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()); public void SavePosition() => graphNode.SetPosition(GetPosition());

View File

@ -2,15 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Codice.Client.Common; using AssetGraph.Core.Attributes;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Nodes;
using UnityEditor; using UnityEditor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; 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 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 VisualElement target;
public static List<SearchContextElement> elements; public static List<SearchContextElement> elements;
@ -60,7 +59,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
foreach (var field in Fields) foreach (var field in Fields)
{ {
if (field.GetCustomAttribute<Input>() != null) if (field.GetCustomAttribute<Core.Attributes.Input>() != null)
ImportPortTypes.Add(ImportPortTypes.Count, field.FieldType); ImportPortTypes.Add(ImportPortTypes.Count, field.FieldType);
if (field.GetCustomAttribute<Output>() != null) if (field.GetCustomAttribute<Output>() != null)
OutputPortTypes.Add(OutputPortTypes.Count, field.FieldType); OutputPortTypes.Add(OutputPortTypes.Count, field.FieldType);
@ -128,7 +127,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
SearchContextElement element = (SearchContextElement)SearchTreeEntry.userData; SearchContextElement element = (SearchContextElement)SearchTreeEntry.userData;
BaseImageNode node = (BaseImageNode)element.target; AssetGraphNode node = (AssetGraphNode)element.target;
node.SetPosition(new Rect(graphMousePosition, new Vector2())); node.SetPosition(new Rect(graphMousePosition, new Vector2()));
graph.Add(node); graph.Add(node);
node.asset = graph.asset; node.asset = graph.asset;
@ -146,7 +145,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
var sourcePort = edge.output ?? edge.input; var sourcePort = edge.output ?? edge.input;
bool isSourceOutput = edge.output != null; bool isSourceOutput = edge.output != null;
Type targetType = (sourcePort as IPTPort)?.portType; Type targetType = (sourcePort as AssetGraphPort)?.portType;
if (targetType == null) if (targetType == null)
{ {
@ -163,7 +162,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
var fields = type.GetFields(); var fields = type.GetFields();
// Get all ports // 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(); var outputPorts = fields.Where(f => f.GetCustomAttribute<Output>() != null).ToList();
// REVERSED LOGIC: // REVERSED LOGIC:
@ -206,7 +205,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
// Add compatible port entries // Add compatible port entries
foreach (var portField in compatiblePorts) 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); int portIndex = portList.IndexOf(portField);
var portTitle = $"{attr.Title}: {portField.Name}"; var portTitle = $"{attr.Title}: {portField.Name}";
@ -228,12 +227,21 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
public class CustomSearchProviderForEdge : ScriptableObject, ISearchWindowProvider public class CustomSearchProviderForEdge : ScriptableObject, ISearchWindowProvider
{ {
private readonly ImageProcessingGraphSearchProvider original; private AssetGraphSearchProvider original;
private readonly Edge edge; private Edge edge;
private readonly IPTPort inputPort; private AssetGraphPort inputPort;
private readonly IPTPort outputPort; 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.original = original;
this.edge = edge; this.edge = edge;
@ -254,7 +262,7 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind
SearchContextElement element = (SearchContextElement)selectedEntry.userData; SearchContextElement element = (SearchContextElement)selectedEntry.userData;
BaseImageNode node = (BaseImageNode)element.target; AssetGraphNode node = (AssetGraphNode)element.target;
node.SetPosition(new Rect(graphMousePosition, new Vector2())); node.SetPosition(new Rect(graphMousePosition, new Vector2()));
original.graph.Add(node); original.graph.Add(node);
node.asset = original.graph.asset; node.asset = original.graph.asset;

View File

@ -2,53 +2,61 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using ImageProcessingGraph.Editor.Nodes.NodeAttributes; using AssetGraph.Core.Attributes;
using ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Windows; using AssetGraph.Core.GraphElements;
using ImageProcessingGraph.Editor.Windows; using AssetGraph.Nodes;
using ImageProcessingGraph.Editor;
using UnityEditor; using UnityEditor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; 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 SerializedObject serializedObject;
private ImageProcessingGraphEditorWindow window; private AssetGraphEditorWindow window;
public ImageProcessingGraphEditorWindow Window => window; public AssetGraphEditorWindow Window => window;
public List<ImageProcessingGraphNodeVisual> graphNodes; public List<AssetGraphNodeEditor> graphNodes;
public Dictionary<string, ImageProcessingGraphNodeVisual> nodeDictionary; public Dictionary<string, AssetGraphNodeEditor> nodeDictionary;
public Dictionary<Edge, GraphConnection> connectionDictionary; public Dictionary<Edge, GraphConnection> connectionDictionary;
public Dictionary<string, AssetGraphStickyNote> stickyNoteDictionary;
internal ImageProcessingGraphSearchProvider searchProvider; internal AssetGraphSearchProvider searchProvider;
internal ImageProcessingGraphEdgeConnectorListener edgeConnectorListener; public AssetGraphEdgeConnector edgeConnectorListener;
private bool isDropdownEnabled = false; private bool isDropdownEnabled = false;
public Vector2 cachedMousePos;
private Button debugModeButton; private Button debugModeButton;
private Button outputRunOrder; private Button outputRunOrder;
private Button makeStickyNode;
public ImageProcessingGraphViewWindow(SerializedObject obeject, ImageProcessingGraphEditorWindow window) public AssetGraphViewWindow(SerializedObject obeject, AssetGraphEditorWindow window)
{ {
this.serializedObject = obeject; this.serializedObject = obeject;
this.asset = obeject.targetObject as ImageProcessingGraphAsset; this.asset = obeject.targetObject as AssetGraphData;
this.graphNodes = new List<ImageProcessingGraphNodeVisual>(); this.graphNodes = new List<AssetGraphNodeEditor>();
nodeDictionary = new Dictionary<string, ImageProcessingGraphNodeVisual>(); nodeDictionary = new Dictionary<string, AssetGraphNodeEditor>();
stickyNoteDictionary = new Dictionary<string, AssetGraphStickyNote>();
connectionDictionary = new Dictionary<Edge, GraphConnection>(); connectionDictionary = new Dictionary<Edge, GraphConnection>();
searchProvider = ScriptableObject.CreateInstance<ImageProcessingGraphSearchProvider>(); searchProvider = ScriptableObject.CreateInstance<AssetGraphSearchProvider>();
searchProvider.graph = this; searchProvider.graph = this;
edgeConnectorListener = new ImageProcessingGraphEdgeConnectorListener(this); edgeConnectorListener = new AssetGraphEdgeConnector(this);
this.nodeCreationRequest = ShowSearchWindow; this.nodeCreationRequest = ShowSearchWindow;
this.window = window; this.window = window;
StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Unity Image Processing/GraphView.uss"); StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Unity Image Processing/GraphView.uss");
if (styleSheet == null) if (styleSheet == null)
{ {
@ -58,12 +66,12 @@ namespace ImageProcessingGraph.Editor
GridBackground background = new GridBackground(); GridBackground background = new GridBackground();
background.name = "Grid"; background.name = "Grid";
Add(background); this.Add(background);
background.SendToBack(); background.SendToBack();
CreateButtons(); CreateButtons();
this.AddManipulator(new ContentDragger()); this.AddManipulator(new ContentDragger());
this.AddManipulator(new SelectionDragger()); this.AddManipulator(new SelectionDragger());
this.AddManipulator(new RectangleSelector()); this.AddManipulator(new RectangleSelector());
@ -72,16 +80,25 @@ namespace ImageProcessingGraph.Editor
DrawNodes(); DrawNodes();
DrawConnections(); DrawConnections();
DrawStickyNotes();
graphViewChanged += OnGraphViewChanged; graphViewChanged += OnGraphViewChanged;
Undo.undoRedoPerformed += UndoRedoPerformed; Undo.undoRedoPerformed += UndoRedoPerformed;
RegisterCallback<MouseMoveEvent>(OnMouseMove);
} }
private void OnMouseMove(MouseMoveEvent evt)
{
cachedMousePos = evt.localMousePosition;
}
private void UndoRedoPerformed() private void UndoRedoPerformed()
{ {
DrawNodes(); DrawNodes();
DrawConnections(); DrawConnections();
DrawStickyNotes();
} }
private void CreateButtons() private void CreateButtons()
@ -146,6 +163,27 @@ namespace ImageProcessingGraph.Editor
{ {
asset.runOrder = asset.GetExecutionOrder(asset.Nodes, asset.Connections); 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 Button dropdownButton = new Button
@ -169,6 +207,7 @@ namespace ImageProcessingGraph.Editor
Add(debugModeButton); Add(debugModeButton);
#endif #endif
Add(outputRunOrder); Add(outputRunOrder);
Add(makeStickyNode);
} }
else else
{ {
@ -176,6 +215,7 @@ namespace ImageProcessingGraph.Editor
Remove(debugModeButton); Remove(debugModeButton);
#endif #endif
Remove(outputRunOrder); Remove(outputRunOrder);
Remove(makeStickyNode);
} }
isDropdownEnabled = !isDropdownEnabled; isDropdownEnabled = !isDropdownEnabled;
@ -185,9 +225,9 @@ namespace ImageProcessingGraph.Editor
Add(dropdownButton); Add(dropdownButton);
} }
private ImageProcessingGraphNodeVisual GetNode(string NodeID) private AssetGraphNodeEditor GetNode(string NodeID)
{ {
ImageProcessingGraphNodeVisual node = null; AssetGraphNodeEditor node = null;
nodeDictionary.TryGetValue(NodeID, out node); nodeDictionary.TryGetValue(NodeID, out node);
return node; return node;
} }
@ -196,50 +236,94 @@ namespace ImageProcessingGraph.Editor
{ {
List<Port> compatiblePorts = new List<Port>(); List<Port> compatiblePorts = new List<Port>();
foreach (var node in graphNodes) foreach (var node in graphNodes)
{ {
// Prevent connections to self
if (node == startPort.node) if (node == startPort.node)
continue; 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 (startPort.direction == port.direction)
if (port.direction == startPort.direction)
continue; continue;
if (port.portType != startPort.portType) Type typeA = GetPortEffectiveType(startPort);
{ Type typeB = GetPortEffectiveType(port);
if (DoesConversionNodeExist())
{
}
else // if (typeA == typeof(object))
continue; // {
} // 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;
// }
// }
// Prevent connection if it creates a cycle if (!typeA.IsAssignableFrom(typeB) && !typeB.IsAssignableFrom(typeA))
continue;
if (startPort.direction == Direction.Output && CreatesCycle(startPort, port)) if (startPort.direction == Direction.Output && CreatesCycle(startPort, port))
continue; continue;
if (startPort.direction == Direction.Input && CreatesCycle(port, startPort)) if (startPort.direction == Direction.Input && CreatesCycle(port, startPort))
continue; continue;
compatiblePorts.Add(port); compatiblePorts.Add(port);
} }
} }
return compatiblePorts; 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) private GraphViewChange OnGraphViewChanged(GraphViewChange graphviewchange)
{ {
if (graphviewchange.movedElements != null) if (graphviewchange.movedElements != null)
{ {
Undo.RecordObject(serializedObject.targetObject, "Moved Graph Elements"); 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(); VARIABLE.SavePosition();
} }
@ -247,7 +331,7 @@ namespace ImageProcessingGraph.Editor
if (graphviewchange.elementsToRemove != null) 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(); List<Edge> edges = graphviewchange.elementsToRemove.OfType<Edge>().ToList();
if (nodesToRemove.Count > 0) if (nodesToRemove.Count > 0)
@ -294,8 +378,8 @@ namespace ImageProcessingGraph.Editor
public void CreateEdge(Edge edge) public void CreateEdge(Edge edge)
{ {
ImageProcessingGraphNodeVisual outputNode = (ImageProcessingGraphNodeVisual)edge.output.node; AssetGraphNodeEditor outputNode = (AssetGraphNodeEditor)edge.output.node;
ImageProcessingGraphNodeVisual inputNode = (ImageProcessingGraphNodeVisual)edge.input.node; AssetGraphNodeEditor inputNode = (AssetGraphNodeEditor)edge.input.node;
int outputIndex = outputNode.OutputPorts.IndexOf(edge.output); int outputIndex = outputNode.OutputPorts.IndexOf(edge.output);
@ -309,8 +393,8 @@ namespace ImageProcessingGraph.Editor
edge.output.Connect(edge); edge.output.Connect(edge);
edge.input.Connect(edge); edge.input.Connect(edge);
IPTPort portIn = (IPTPort)edge.output; AssetGraphPort portIn = (AssetGraphPort)edge.output;
IPTPort portOut = (IPTPort)edge.output; AssetGraphPort portOut = (AssetGraphPort)edge.output;
if (portIn.fieldInfo != null) if (portIn.fieldInfo != null)
inputNode.ToggleExposedVariable(edge.input, false); inputNode.ToggleExposedVariable(edge.input, false);
@ -329,9 +413,9 @@ namespace ImageProcessingGraph.Editor
edge.output.Disconnect(edge); edge.output.Disconnect(edge);
edge.input.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) if(portIn.fieldInfo != null)
inputNode.ToggleExposedVariable(edge.input, true); inputNode.ToggleExposedVariable(edge.input, true);
@ -350,20 +434,20 @@ namespace ImageProcessingGraph.Editor
{ {
foreach (GraphConnection conn in asset.Connections) foreach (GraphConnection conn in asset.Connections)
{ {
ImageProcessingGraphNodeVisual inputNode = GetNode(conn.inputPort.nodeID); AssetGraphNodeEditor inputNode = GetNode(conn.inputPort.nodeID);
ImageProcessingGraphNodeVisual outputNode = GetNode(conn.outputPort.nodeID); AssetGraphNodeEditor outputNode = GetNode(conn.outputPort.nodeID);
if (inputNode != null && outputNode != null) if (inputNode != null && outputNode != null)
{ {
IPTPort inPort = inputNode.InputPorts[conn.inputPort.portID] as IPTPort; AssetGraphPort inPort = inputNode.InputPorts[conn.inputPort.portID] as AssetGraphPort;
IPTPort outPort = outputNode.OutputPorts[conn.outputPort.portID] as IPTPort; AssetGraphPort outPort = outputNode.OutputPorts[conn.outputPort.portID] as AssetGraphPort;
Edge edge = inPort.ConnectTo(outPort); Edge edge = inPort.ConnectTo(outPort);
AddElement(edge); AddElement(edge);
connectionDictionary.Add(edge, conn); connectionDictionary.Add(edge, conn);
conn.SetInternalEdge(edge); conn.SetInternalEdge(edge);
((ImageProcessingGraphNodeVisual)inPort.node).ToggleExposedVariable(inPort, false); ((AssetGraphNodeEditor)inPort.node).ToggleExposedVariable(inPort, false);
} }
} }
@ -414,13 +498,13 @@ namespace ImageProcessingGraph.Editor
#region Nodes #region Nodes
private void DrawNodes() private void DrawNodes()
{ {
foreach (ImageProcessingGraphNodeVisual node in graphNodes) foreach (AssetGraphNodeEditor node in graphNodes)
{ {
RemoveElement(node); RemoveElement(node);
} }
graphNodes.Clear(); graphNodes.Clear();
foreach (KeyValuePair<string, ImageProcessingGraphNodeVisual> node in nodeDictionary) foreach (KeyValuePair<string, AssetGraphNodeEditor> node in nodeDictionary)
{ {
RemoveElement(node.Value); 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; node.typeName = node.GetType().AssemblyQualifiedName;
var infoAttr = node.GetType().GetCustomAttribute<NodeInfoAttribute>(); var infoAttr = node.GetType().GetCustomAttribute<NodeInfoAttribute>();
ImageProcessingGraphNodeVisual editorNode = null; AssetGraphNodeEditor editorNode = null;
if (typeof(ImageProcessingGraphNodeVisual).IsAssignableFrom(infoAttr.EditorType)) if (typeof(AssetGraphNodeEditor).IsAssignableFrom(infoAttr.EditorType))
{ {
editorNode = (ImageProcessingGraphNodeVisual)Activator.CreateInstance(infoAttr.EditorType, node, this); editorNode = (AssetGraphNodeEditor)Activator.CreateInstance(infoAttr.EditorType, node, this);
} }
else else
{ {
editorNode = new ImageProcessingGraphNodeVisual(node, this); editorNode = new AssetGraphNodeEditor(node, this);
} }
editorNode.SetPosition(node.Position); editorNode.SetPosition(node.Position);
@ -457,7 +541,7 @@ namespace ImageProcessingGraph.Editor
AddElement(editorNode); AddElement(editorNode);
} }
public void Add(BaseImageNode node) public void Add(AssetGraphNode node)
{ {
Undo.RecordObject(serializedObject.targetObject, "Added Node"); Undo.RecordObject(serializedObject.targetObject, "Added Node");
asset.Nodes.Add(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>(); List<GraphConnection> connectionsToRemove = new List<GraphConnection>();
@ -502,5 +586,30 @@ namespace ImageProcessingGraph.Editor
#endregion #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
View File

@ -0,0 +1,4 @@
#Title
{
display: none;
}

3
GenericNode.uss.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 79b350a401ed4074ab5fc42f451a8125
timeCreated: 1746344909

View File

@ -1,4 +1,4 @@
ImageProcessingGraphViewWindow AssetGraphViewWindow
{ {
flex-grow: 1; flex-grow: 1;
} }