mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-12 10:08:46 +08:00
Merge branch 'development'
This commit is contained in:
commit
91ccab60db
@ -19,8 +19,8 @@ public class NodeEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void DrawDefaultHeaderGUI() {
|
protected void DrawDefaultHeaderGUI() {
|
||||||
|
GUI.color = Color.white;
|
||||||
GUILayout.Label(target.name, NodeEditorResources.styles.headerStyle, GUILayout.Height(30));
|
GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Draws standard editors for all fields marked with <see cref="Node.InputAttribute"/> or <see cref="Node.OutputAttribute"/> </summary>
|
/// <summary> Draws standard editors for all fields marked with <see cref="Node.InputAttribute"/> or <see cref="Node.OutputAttribute"/> </summary>
|
||||||
@ -63,14 +63,14 @@ public class NodeEditor {
|
|||||||
|
|
||||||
/// <summary> Draw node port GUI using automatic layouting. Returns port handle position. </summary>
|
/// <summary> Draw node port GUI using automatic layouting. Returns port handle position. </summary>
|
||||||
protected Vector2 DrawNodePortGUI(NodePort port) {
|
protected Vector2 DrawNodePortGUI(NodePort port) {
|
||||||
GUIStyle style = port.direction == NodePort.IO.Input ? NodeEditorResources.styles.inputStyle : NodeEditorResources.styles.outputStyle;
|
GUIStyle style = port.direction == NodePort.IO.Input ? NodeEditorResources.styles.inputPort : NodeEditorResources.styles.outputPort;
|
||||||
Rect rect = GUILayoutUtility.GetRect(new GUIContent(port.name.PrettifyCamelCase()), style);
|
Rect rect = GUILayoutUtility.GetRect(new GUIContent(port.name.PrettifyCamelCase()), style);
|
||||||
return DrawNodePortGUI(rect, port);
|
return DrawNodePortGUI(rect, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Draw node port GUI in rect. Returns port handle position. </summary>
|
/// <summary> Draw node port GUI in rect. Returns port handle position. </summary>
|
||||||
protected Vector2 DrawNodePortGUI(Rect rect, NodePort port) {
|
protected Vector2 DrawNodePortGUI(Rect rect, NodePort port) {
|
||||||
GUIStyle style = port.direction == NodePort.IO.Input ? NodeEditorResources.styles.inputStyle : NodeEditorResources.styles.outputStyle;
|
GUIStyle style = port.direction == NodePort.IO.Input ? NodeEditorResources.styles.inputPort : NodeEditorResources.styles.outputPort;
|
||||||
GUI.Label(rect, new GUIContent(port.name.PrettifyCamelCase()), style);
|
GUI.Label(rect, new GUIContent(port.name.PrettifyCamelCase()), style);
|
||||||
|
|
||||||
Vector2 handlePoint = rect.center;
|
Vector2 handlePoint = rect.center;
|
||||||
@ -79,6 +79,14 @@ public class NodeEditor {
|
|||||||
case NodePort.IO.Input: handlePoint.x = rect.xMin; break;
|
case NodePort.IO.Input: handlePoint.x = rect.xMin; break;
|
||||||
case NodePort.IO.Output: handlePoint.x = rect.xMax; break;
|
case NodePort.IO.Output: handlePoint.x = rect.xMax; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color col = GUI.color;
|
||||||
|
Rect handleRect = new Rect(handlePoint.x-8,handlePoint.y-8,16,16);
|
||||||
|
GUI.color = new Color(0.29f, 0.31f, 0.32f);
|
||||||
|
GUI.DrawTexture(handleRect, NodeEditorResources.dotOuter);
|
||||||
|
GUI.color = NodeEditorUtilities.GetTypeColor(port.type);
|
||||||
|
GUI.DrawTexture(handleRect, NodeEditorResources.dot);
|
||||||
|
GUI.color = col;
|
||||||
return handlePoint;
|
return handlePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +114,11 @@ public class NodeEditor {
|
|||||||
fieldValue = EditorGUILayout.Toggle(fieldPrettyName, (bool)fieldValue);
|
fieldValue = EditorGUILayout.Toggle(fieldPrettyName, (bool)fieldValue);
|
||||||
}
|
}
|
||||||
else if (fieldType.IsEnum) {
|
else if (fieldType.IsEnum) {
|
||||||
fieldValue = EditorGUILayout.EnumPopup(fieldPrettyName, (Enum)fieldValue);
|
Rect rect = EditorGUILayout.GetControlRect();
|
||||||
|
rect.width *= 0.5f;
|
||||||
|
EditorGUI.LabelField(rect, fieldPrettyName);
|
||||||
|
rect.x += rect.width;
|
||||||
|
fieldValue = EditorGUI.EnumPopup(rect, (Enum)fieldValue);
|
||||||
}
|
}
|
||||||
else if (fieldType == typeof(string)) {
|
else if (fieldType == typeof(string)) {
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,9 @@ public partial class NodeEditorWindow {
|
|||||||
Controls();
|
Controls();
|
||||||
|
|
||||||
DrawGrid(position, zoom, panOffset);
|
DrawGrid(position, zoom, panOffset);
|
||||||
DrawNodes();
|
|
||||||
DrawConnections();
|
DrawConnections();
|
||||||
DrawDraggedConnection();
|
DrawDraggedConnection();
|
||||||
DrawPortHandles();
|
DrawNodes();
|
||||||
DrawToolbar();
|
DrawToolbar();
|
||||||
|
|
||||||
GUI.matrix = m;
|
GUI.matrix = m;
|
||||||
@ -115,7 +114,7 @@ public partial class NodeEditorWindow {
|
|||||||
Color prevCol = GUI.color;
|
Color prevCol = GUI.color;
|
||||||
Color edgeCol = new Color(0.1f, 0.1f, 0.1f, col.a);
|
Color edgeCol = new Color(0.1f, 0.1f, 0.1f, col.a);
|
||||||
Handles.DrawBezier(startPoint, endPoint, startTangent, endTangent, edgeCol, null, 4);
|
Handles.DrawBezier(startPoint, endPoint, startTangent, endTangent, edgeCol, null, 4);
|
||||||
Handles.DrawBezier(startPoint, endPoint, startTangent, endTangent, col, null, 2);
|
Handles.DrawBezier(startPoint, endPoint, startTangent, endTangent, col, null, 4);
|
||||||
GUI.color = prevCol;
|
GUI.color = prevCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,20 +136,6 @@ public partial class NodeEditorWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Draws the draggable circle handles on the ports </summary>
|
|
||||||
public void DrawPortHandles() {
|
|
||||||
Color col = GUI.color;
|
|
||||||
foreach(var kvp in portConnectionPoints) {
|
|
||||||
Rect rect = GridToWindowRect(kvp.Value);
|
|
||||||
GUI.color = new Color(0.29f, 0.31f, 0.32f);
|
|
||||||
GUI.DrawTexture(rect, NodeEditorResources.dotOuter);
|
|
||||||
GUI.color = NodeEditorUtilities.GetTypeColor(kvp.Key.type);
|
|
||||||
GUI.DrawTexture(rect, NodeEditorResources.dot);
|
|
||||||
|
|
||||||
}
|
|
||||||
GUI.color = col;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawNodes() {
|
private void DrawNodes() {
|
||||||
Event e = Event.current;
|
Event e = Event.current;
|
||||||
if (e.type == EventType.Repaint) portConnectionPoints.Clear();
|
if (e.type == EventType.Repaint) portConnectionPoints.Clear();
|
||||||
@ -172,11 +157,12 @@ public partial class NodeEditorWindow {
|
|||||||
//Get node position
|
//Get node position
|
||||||
Vector2 nodePos = GridToWindowPositionNoClipped(node.rect.position);
|
Vector2 nodePos = GridToWindowPositionNoClipped(node.rect.position);
|
||||||
|
|
||||||
GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
|
//GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
|
||||||
style = new GUIStyle(style);
|
|
||||||
style.padding.top = 0;
|
|
||||||
GUILayout.BeginArea(new Rect(nodePos,new Vector2(nodeEditor.GetWidth(), 4000)));
|
GUILayout.BeginArea(new Rect(nodePos,new Vector2(nodeEditor.GetWidth(), 4000)));
|
||||||
GUILayout.BeginVertical(style);
|
|
||||||
|
GUIStyle style = NodeEditorResources.styles.nodeBody;
|
||||||
|
GUILayout.BeginVertical(new GUIStyle(style));
|
||||||
|
|
||||||
//Draw node contents
|
//Draw node contents
|
||||||
Dictionary<NodePort, Vector2> portHandlePoints;
|
Dictionary<NodePort, Vector2> portHandlePoints;
|
||||||
|
|||||||
@ -3,42 +3,52 @@ using UnityEditor;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
public static class NodeEditorResources {
|
public static class NodeEditorResources {
|
||||||
|
//Unec textures
|
||||||
public static Texture2D gridTexture { get { return _gridTexture != null ? _gridTexture : _gridTexture = GenerateGridTexture(); } }
|
public static Texture2D gridTexture { get { return _gridTexture != null ? _gridTexture : _gridTexture = GenerateGridTexture(); } }
|
||||||
private static Texture2D _gridTexture;
|
private static Texture2D _gridTexture;
|
||||||
public static Texture2D crossTexture { get { return _crossTexture != null ? _crossTexture : _crossTexture = GenerateCrossTexture(); } }
|
public static Texture2D crossTexture { get { return _crossTexture != null ? _crossTexture : _crossTexture = GenerateCrossTexture(); } }
|
||||||
private static Texture2D _crossTexture;
|
private static Texture2D _crossTexture;
|
||||||
public static Texture2D dot { get { return _dot != null ? _dot : _dot = Resources.Load<Texture2D>("dot"); } }
|
public static Texture2D dot { get { return _dot != null ? _dot : _dot = Resources.Load<Texture2D>("unec_dot"); } }
|
||||||
private static Texture2D _dot;
|
private static Texture2D _dot;
|
||||||
public static Texture2D dotOuter { get { return _dotOuter != null ? _dotOuter : _dotOuter = Resources.Load<Texture2D>("dot_outer"); } }
|
public static Texture2D dotOuter { get { return _dotOuter != null ? _dotOuter : _dotOuter = Resources.Load<Texture2D>("unec_dot_outer"); } }
|
||||||
private static Texture2D _dotOuter;
|
private static Texture2D _dotOuter;
|
||||||
|
public static Texture2D nodeBody { get { return _nodeBody != null ? _nodeBody : _nodeBody = Resources.Load<Texture2D>("unec_node"); } }
|
||||||
|
private static Texture2D _nodeBody;
|
||||||
|
|
||||||
|
//Grid colors
|
||||||
private static Color backgroundColor = new Color(0.18f, 0.18f, 0.18f);
|
private static Color backgroundColor = new Color(0.18f, 0.18f, 0.18f);
|
||||||
private static Color veinColor = new Color(0.25f, 0.25f, 0.25f);
|
private static Color veinColor = new Color(0.25f, 0.25f, 0.25f);
|
||||||
private static Color arteryColor = new Color(0.34f, 0.34f, 0.34f);
|
private static Color arteryColor = new Color(0.34f, 0.34f, 0.34f);
|
||||||
private static Color crossColor = new Color(0.45f, 0.45f, 0.45f);
|
private static Color crossColor = new Color(0.45f, 0.45f, 0.45f);
|
||||||
|
|
||||||
|
//Unec styles
|
||||||
public static Styles styles { get { return _styles != null ? _styles : _styles = new Styles(); } }
|
public static Styles styles { get { return _styles != null ? _styles : _styles = new Styles(); } }
|
||||||
public static Styles _styles = null;
|
public static Styles _styles = null;
|
||||||
|
|
||||||
public class Styles {
|
public class Styles {
|
||||||
public GUIStyle inputStyle, outputStyle, headerStyle;
|
public GUIStyle inputPort, outputPort, nodeHeader, nodeBody;
|
||||||
|
|
||||||
public Styles() {
|
public Styles() {
|
||||||
GUIStyle baseStyle = new GUIStyle("Label");
|
GUIStyle baseStyle = new GUIStyle("Label");
|
||||||
baseStyle.fixedHeight = 18;
|
baseStyle.fixedHeight = 18;
|
||||||
|
|
||||||
inputStyle = new GUIStyle(baseStyle);
|
inputPort = new GUIStyle(baseStyle);
|
||||||
inputStyle.alignment = TextAnchor.UpperLeft;
|
inputPort.alignment = TextAnchor.UpperLeft;
|
||||||
inputStyle.padding.left = 10;
|
inputPort.padding.left = 10;
|
||||||
|
|
||||||
outputStyle = new GUIStyle(baseStyle);
|
outputPort = new GUIStyle(baseStyle);
|
||||||
outputStyle.alignment = TextAnchor.UpperRight;
|
outputPort.alignment = TextAnchor.UpperRight;
|
||||||
outputStyle.padding.right = 10;
|
outputPort.padding.right = 10;
|
||||||
|
|
||||||
headerStyle = new GUIStyle();
|
nodeHeader = new GUIStyle();
|
||||||
headerStyle.alignment = TextAnchor.MiddleCenter;
|
nodeHeader.alignment = TextAnchor.MiddleCenter;
|
||||||
headerStyle.fontStyle = FontStyle.Bold;
|
nodeHeader.fontStyle = FontStyle.Bold;
|
||||||
|
nodeHeader.normal.textColor = Color.white;
|
||||||
|
|
||||||
|
nodeBody = new GUIStyle();
|
||||||
|
nodeBody.normal.background = NodeEditorResources.nodeBody;
|
||||||
|
nodeBody.border = new RectOffset(32, 32, 32, 32);
|
||||||
|
nodeBody.padding = new RectOffset(10, 10, 2, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
BIN
Scripts/Editor/Resources/unec_node.psd
Normal file
BIN
Scripts/Editor/Resources/unec_node.psd
Normal file
Binary file not shown.
100
Scripts/Editor/Resources/unec_node.psd.meta
Normal file
100
Scripts/Editor/Resources/unec_node.psd.meta
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 526e7d4dc27d75e41b5d751e4d390d8b
|
||||||
|
timeCreated: 1506975350
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 0
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 2
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: iPhone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user