Added Run order button and fixed a node connection issue
This commit is contained in:
parent
4985cf5748
commit
0c53ac8d18
@ -14,7 +14,7 @@ namespace ImageProcessingGraph.Editor
|
||||
public static IPTPort Create(IEdgeConnectorListener connectorListener, bool isInput, Type type)
|
||||
{
|
||||
var port = new IPTPort(Orientation.Horizontal, isInput ? Direction.Input : Direction.Output,
|
||||
Capacity.Multi, type)
|
||||
isInput ? Capacity.Single : Capacity.Multi, type)
|
||||
{
|
||||
m_EdgeConnector = new EdgeConnector<Edge>(connectorListener),
|
||||
};
|
||||
|
@ -3,16 +3,9 @@ using UnityEngine;
|
||||
|
||||
namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
#if true
|
||||
[CreateAssetMenu(menuName = "PreferenceCreate")]
|
||||
#endif
|
||||
public class IPT_Preferences : ScriptableObject
|
||||
{
|
||||
[Header("Grid Settings")]
|
||||
public float thickLines;
|
||||
public float spacing;
|
||||
public Color gridBackgroundColour;
|
||||
public Color lineColour;
|
||||
public bool debugMode = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace ImageProcessingGraph.Editor
|
||||
{
|
||||
[SerializeReference] private List<BaseImageNode> nodes;
|
||||
[SerializeField] private List<GraphConnection> connections;
|
||||
[SerializeField] public List<BaseImageNode> runOrder;
|
||||
[SerializeReference] public List<BaseImageNode> runOrder;
|
||||
[SerializeField] public List<StickyNote> stickyNotes;
|
||||
|
||||
public List<BaseImageNode> Nodes => nodes;
|
||||
|
@ -14,7 +14,6 @@ namespace ImageProcessingGraph.Editor
|
||||
internal ImageProcessingGraphAsset asset;
|
||||
private SerializedObject serializedObject;
|
||||
private ImageProcessingGraphEditorWindow window;
|
||||
|
||||
public ImageProcessingGraphEditorWindow Window => window;
|
||||
|
||||
public List<ImageProcessingGraphNodeVisual> graphNodes;
|
||||
@ -24,6 +23,11 @@ namespace ImageProcessingGraph.Editor
|
||||
internal ImageProcessingGraphSearchProvider searchProvider;
|
||||
internal ImageProcessingGraphEdgeConnectorListener edgeConnectorListener;
|
||||
|
||||
private bool isDropdownEnabled = false;
|
||||
|
||||
private Button debugModeButton;
|
||||
private Button outputRunOrder;
|
||||
|
||||
public ImageProcessingGraphViewWindow(SerializedObject obeject, ImageProcessingGraphEditorWindow window)
|
||||
{
|
||||
this.serializedObject = obeject;
|
||||
@ -50,34 +54,11 @@ namespace ImageProcessingGraph.Editor
|
||||
styleSheets.Add(styleSheet);
|
||||
|
||||
GridBackground background = new GridBackground();
|
||||
|
||||
background.name = "Grid";
|
||||
|
||||
Button runButton = new Button();
|
||||
runButton.text = "Run";
|
||||
|
||||
// Set the size of the button (width and height)
|
||||
runButton.style.width = 100; // Width in pixels
|
||||
runButton.style.height = 40; // Height in pixels
|
||||
|
||||
// Position the button at the top-left corner
|
||||
runButton.style.position = Position.Absolute; // Make sure it's positioned absolutely
|
||||
runButton.style.top = 10; // Top 10 pixels from the top
|
||||
runButton.style.left = 10; // Left 10 pixels from the left edge
|
||||
|
||||
// On click, execute the function
|
||||
runButton.clicked += () =>
|
||||
{
|
||||
asset.RunGraph();
|
||||
};
|
||||
|
||||
// Add the button to the UI
|
||||
Add(runButton);
|
||||
|
||||
Add(background);
|
||||
background.SendToBack();
|
||||
|
||||
|
||||
CreateButtons();
|
||||
|
||||
|
||||
this.AddManipulator(new ContentDragger());
|
||||
@ -93,6 +74,107 @@ namespace ImageProcessingGraph.Editor
|
||||
Undo.undoRedoEvent += UndoEvent;
|
||||
}
|
||||
|
||||
private void CreateButtons()
|
||||
{
|
||||
#region Run Button
|
||||
Button runButton = new Button
|
||||
{
|
||||
text = "Run",
|
||||
style =
|
||||
{
|
||||
width = 100,
|
||||
height = 40,
|
||||
position = Position.Absolute,
|
||||
top = 10,
|
||||
left = 10
|
||||
}
|
||||
};
|
||||
|
||||
runButton.clicked += () =>
|
||||
{
|
||||
asset.RunGraph();
|
||||
};
|
||||
|
||||
Add(runButton);
|
||||
#endregion
|
||||
|
||||
#if false
|
||||
debugModeButton = new Button
|
||||
{
|
||||
text = "Debug Mode",
|
||||
style =
|
||||
{
|
||||
width = 120,
|
||||
height = 40,
|
||||
position = Position.Absolute,
|
||||
top = 55,
|
||||
right = 10
|
||||
}
|
||||
};
|
||||
|
||||
debugModeButton.clicked += () =>
|
||||
{
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
outputRunOrder = new Button
|
||||
{
|
||||
text = "Recalculate Run Order",
|
||||
style =
|
||||
{
|
||||
width = 120,
|
||||
height = 40,
|
||||
position = Position.Absolute,
|
||||
top = 55,
|
||||
right = 10,
|
||||
fontSize = 9
|
||||
}
|
||||
};
|
||||
|
||||
outputRunOrder.clicked += () =>
|
||||
{
|
||||
asset.runOrder = asset.GetExecutionOrder(asset.Nodes, asset.Connections);
|
||||
};
|
||||
|
||||
|
||||
Button dropdownButton = new Button
|
||||
{
|
||||
text = "Options",
|
||||
style =
|
||||
{
|
||||
width = 120,
|
||||
height = 40,
|
||||
position = Position.Absolute,
|
||||
top = 10,
|
||||
right = 10
|
||||
}
|
||||
};
|
||||
|
||||
dropdownButton.clicked+= () =>
|
||||
{
|
||||
if (!isDropdownEnabled)
|
||||
{
|
||||
#if false
|
||||
Add(debugModeButton);
|
||||
#endif
|
||||
Add(outputRunOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if false
|
||||
Remove(debugModeButton);
|
||||
#endif
|
||||
Remove(outputRunOrder);
|
||||
}
|
||||
|
||||
isDropdownEnabled = !isDropdownEnabled;
|
||||
};
|
||||
|
||||
|
||||
Add(dropdownButton);
|
||||
}
|
||||
|
||||
private ImageProcessingGraphNodeVisual GetNode(string NodeID)
|
||||
{
|
||||
ImageProcessingGraphNodeVisual node = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user