@XuPoH : Are you offering updated code?
If so, and you don’t mind contributing, just go ahead and post it!
I’m sure the community will appreciate it.
@XuPoH : Are you offering updated code?
If so, and you don’t mind contributing, just go ahead and post it!
I’m sure the community will appreciate it.
indeed… please do share!
I take the delay and lack of further posts as a no. meh, that’s fine, I’ve completely re-written it… I’m just thankful for the original contribution that took me on this journey.
Check out my profile. There you can find my post. It’s title starts with “[Bad Code, sry]”
But it seems that it does not works…
I’m not sure I understand what you meant?
I checked your project files… the nodes seem to be basically working.
I’ve made a bad structure, so that on compile you’ll got errors.
Hi!
I took the first posted script and expanded by a lot
Edit: Dropbox suspended my public links due to heavy traffick so here’s a new links
I’ve made it for my tutorial channel so here’s a video if somebody needs more explanation on the code:
Cheers!
You have no idea how happy I am to see these posts! Excellent resources for building a more advanced editor tool. Thank you everyone!
This is excellent - thank you a lot, now i understand a lot of the whole editor-window thing way better. Thanks!
Very nice thank you for that… Only one question: What about scrolling when the graph runs too big? This is my life time question at unity editor scripting. I’ve always had problem doing that.
Thanks anyway
Check the second script posted by unimechanic, you can do it using GUI.BeginGroup()
If you don’t want to use the buttons as in that example you can check the events for the middle mouse and start adding any changes on the mouse position to the PanY/PanX values. Haven’t done it but it should be fairly simply to do
Thanks I’ll do
Based on my experience so far, as long as you are only concerned with “content” that extends into positive space, you can easily use the GUI.BeginScrollView to deal with it; however, in the case of using nodes that can be moved into negative content space… it breaks, as none of the built in GUI nor GUILayout utilities that deal with horizontal, vertical, or scrollviews are capable of handling negative scrolling and offsets.
I would (and have for my projects) use a utility class to handle this by calculating a “virtual” frame containing the nodes, taking the offset values, and combining them into a simple “GUI.HorizontalScollBar” (or vertical) method, and deal with negative space scrolling and offsets myself. It works quite well.
I’ve added some more examples for this like enabling/disabling a gameobject , finding the distance between two GOs and a timer node.
Edit: see my first post for links
and of course a video if you need more explanation on the scripts
To make a scrollable area just do this:
(typing from memory, so treat as pseudocode)
EditorGUILayout.BeginScrollView();
GUILayout.LabelField(Height(4000),Width(4000));
//draw your nodes here
EditorGUILayout.EndScrollView();
Here’s an upgraded version of DrawCurve which allows you to specify which corner the line attaches to:
void DrawNodeCurve(Rect start, Rect end)
{
DrawNodeCurve(start, end, new Vector2(1.0f, 0.5f), new Vector2(1.0f, 0.5f));
}
void DrawNodeCurve(Rect start, Rect end, Vector2 vStartPercentage, Vector2 vEndPercentage )
{
Vector3 startPos = new Vector3(start.x + start.width * vStartPercentage.x, start.y + start.height * vStartPercentage.y, 0);
Vector3 endPos = new Vector3(end.x + end.width * vEndPercentage.x, end.y + end.height * vEndPercentage.y, 0);
Vector3 startTan = startPos + Vector3.right * (-50 + 100 * vStartPercentage.x) + Vector3.up * (-50 + 100 * vStartPercentage.y);
Vector3 endTan = endPos + Vector3.right * (-50 + 100 * vEndPercentage.x) + Vector3.up * (-50 + 100 * vEndPercentage.y);
Color shadowCol = new Color(0, 0, 0, 0.06f);
for (int i = 0; i < 3; i++) // Draw a shadow
Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 2);
}
And here’s a very simple Arrowhead drawing formula:
void DrawArrowhead(Rect start, Rect end, Vector2 vStartPercentage, Vector2 vEndPercentage, float fHandleDistance, float fLength, float fWidth)
{
float fHandleDistanceDouble = fHandleDistance * 2;
Vector3 startPos = new Vector3(start.x + start.width * vStartPercentage.x, start.y + start.height * vStartPercentage.y, 0);
Vector3 startTan = startPos + Vector3.right * (-fHandleDistance + fHandleDistanceDouble * vStartPercentage.x) + Vector3.up * (-fHandleDistance + fHandleDistanceDouble * vStartPercentage.y);
Vector3 endPos = new Vector3(end.x + end.width * vEndPercentage.x, end.y + end.height * vEndPercentage.y, 0);
Vector3 endTan = endPos + Vector3.right * (-fHandleDistance + fHandleDistanceDouble * vEndPercentage.x) + Vector3.up * (-fHandleDistance + fHandleDistanceDouble * vEndPercentage.y);
float dy = endTan.y - endPos.y;
float dx = endTan.x - endPos.x;
Vector3 vDelta = endTan - endPos;
Vector3 vNormal = new Vector3 ( -dy, dx, 0f ).normalized;
Vector3 vArrowHeadEnd1 = endPos + vDelta.normalized * fLength + vNormal.normalized * fWidth;
Vector3 vArrowHeadEnd2 = endPos + vDelta.normalized * fLength + vNormal.normalized * -fWidth;
Vector3 vHalfwayPoint = endPos + vDelta.normalized * fLength * 0.5f;
Color shadowCol = new Color(0, 0, 0, 0.06f);
for (int i = 0; i < 3; i++) // Draw a shadow
Handles.DrawBezier(endPos, vArrowHeadEnd1, endPos, vHalfwayPoint, shadowCol, null, (i + 1) * 5);
Handles.DrawBezier(endPos, vArrowHeadEnd1, endPos, vHalfwayPoint, Color.black, null, 2);
for (int i = 0; i < 3; i++) // Draw a shadow
Handles.DrawBezier(endPos, vArrowHeadEnd2, endPos, vHalfwayPoint, shadowCol, null, (i + 1) * 5);
Handles.DrawBezier(endPos, vArrowHeadEnd2, endPos, vHalfwayPoint, Color.black, null, 2);
}
Usage:
DrawArrowhead(rRawPrefabBox, rChildObjectBox, new Vector2(0.25f, 1.0f), new Vector2(0.0f, 0.5f), 50f, 30f, 10f);
Hey everyone,
Over two years of collaboration and constant development, the opensource Node Editor Framework has emerged out of this thread - thanks to lot’s of great feedback by the community:)
I started developing it end of May 2015, but I’m by far not the only contributor anymore…
Take a look:
Repository - WebGL Demo - Documentation
Major features:
More information can be found on the repository:)
Best regards,
Seneral
It shows this error:
Assets/Node_Editor/Node_Editor.cs(82,17): error CS0103: The name `CommonUtility' does not exist in the current context
Thank you!