1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-09 08:38:44 +08:00

Started UI overhaul

This commit is contained in:
Thor Brigsted 2017-10-03 20:15:59 +02:00
parent 5f4da093f3
commit 965b086341
13 changed files with 321 additions and 36 deletions

View File

@ -19,8 +19,8 @@ public class NodeEditor {
}
protected void DrawDefaultHeaderGUI() {
GUILayout.Label(target.name, NodeEditorResources.styles.headerStyle, GUILayout.Height(30));
GUI.color = Color.white;
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>
@ -63,14 +63,14 @@ public class NodeEditor {
/// <summary> Draw node port GUI using automatic layouting. Returns port handle position. </summary>
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);
return DrawNodePortGUI(rect, port);
}
/// <summary> Draw node port GUI in rect. Returns port handle position. </summary>
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);
Vector2 handlePoint = rect.center;
@ -79,6 +79,14 @@ public class NodeEditor {
case NodePort.IO.Input: handlePoint.x = rect.xMin; 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;
}

View File

@ -15,7 +15,6 @@ public partial class NodeEditorWindow {
DrawNodes();
DrawConnections();
DrawDraggedConnection();
DrawPortHandles();
DrawToolbar();
GUI.matrix = m;
@ -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() {
Event e = Event.current;
if (e.type == EventType.Repaint) portConnectionPoints.Clear();
@ -172,11 +157,17 @@ public partial class NodeEditorWindow {
//Get node position
Vector2 nodePos = GridToWindowPositionNoClipped(node.rect.position);
GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
style = new GUIStyle(style);
style.padding.top = 0;
//GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
GUILayout.BeginArea(new Rect(nodePos,new Vector2(nodeEditor.GetWidth(), 4000)));
GUILayout.BeginVertical(style);
GUI.color = new Color(0.29f, 0.31f, 0.32f,0.8f);
GUIStyle style = NodeEditorResources.styles.nodeContent;
GUILayout.BeginVertical(new GUIStyle(style));
GUI.color = new Color(0.1f, 0.1f, 0.1f, 0.9f);
style = NodeEditorResources.styles.nodeFrame;
GUILayout.BeginVertical(new GUIStyle(style));
GUI.color = Color.white;
//Draw node contents
Dictionary<NodePort, Vector2> portHandlePoints;
@ -190,6 +181,7 @@ public partial class NodeEditorWindow {
}
}
GUILayout.EndVertical();
GUILayout.EndVertical();
//if (e.type == EventType.Repaint) node.rect.size = GUILayoutUtility.GetLastRect().size;

View File

@ -3,42 +3,57 @@ using UnityEditor;
using System;
public static class NodeEditorResources {
//Unec textures
public static Texture2D gridTexture { get { return _gridTexture != null ? _gridTexture : _gridTexture = GenerateGridTexture(); } }
private static Texture2D _gridTexture;
public static Texture2D crossTexture { get { return _crossTexture != null ? _crossTexture : _crossTexture = GenerateCrossTexture(); } }
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;
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;
public static Texture2D nodeFrame { get { return _nodeFrame != null ? _nodeFrame : _nodeFrame = Resources.Load<Texture2D>("unec_nodeframe"); } }
private static Texture2D _nodeFrame;
public static Texture2D nodeFrameOuter { get { return _nodeFrameOuter != null ? _nodeFrameOuter : _nodeFrameOuter = Resources.Load<Texture2D>("unec_nodeframe_outer"); } }
private static Texture2D _nodeFrameOuter;
//Grid colors
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 arteryColor = new Color(0.34f, 0.34f, 0.34f);
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 = null;
public class Styles {
public GUIStyle inputStyle, outputStyle, headerStyle;
public GUIStyle inputPort, outputPort, nodeHeader, nodeFrame, nodeContent;
public Styles() {
GUIStyle baseStyle = new GUIStyle("Label");
baseStyle.fixedHeight = 18;
inputStyle = new GUIStyle(baseStyle);
inputStyle.alignment = TextAnchor.UpperLeft;
inputStyle.padding.left = 10;
inputPort = new GUIStyle(baseStyle);
inputPort.alignment = TextAnchor.UpperLeft;
inputPort.padding.left = 10;
outputStyle = new GUIStyle(baseStyle);
outputStyle.alignment = TextAnchor.UpperRight;
outputStyle.padding.right = 10;
outputPort = new GUIStyle(baseStyle);
outputPort.alignment = TextAnchor.UpperRight;
outputPort.padding.right = 10;
headerStyle = new GUIStyle();
headerStyle.alignment = TextAnchor.MiddleCenter;
headerStyle.fontStyle = FontStyle.Bold;
nodeHeader = new GUIStyle();
nodeHeader.alignment = TextAnchor.MiddleCenter;
nodeHeader.fontStyle = FontStyle.Bold;
nodeHeader.normal.textColor = Color.white;
nodeFrame = new GUIStyle();
nodeFrame.normal.background = nodeFrameOuter;
nodeFrame.border = new RectOffset(32, 32, 32, 32);
nodeContent = new GUIStyle();
nodeContent.normal.background = NodeEditorResources.nodeFrame;
nodeContent.border = new RectOffset(32, 32, 32, 32);
}
}

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

View File

@ -0,0 +1,74 @@
fileFormatVersion: 2
guid: 526e7d4dc27d75e41b5d751e4d390d8b
timeCreated: 1506975350
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
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:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
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: 0
spriteTessellationDetail: -1
textureType: 0
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
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,98 @@
fileFormatVersion: 2
guid: dc27da104f7cfb24f8ad84db914f015a
timeCreated: 1506974712
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
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:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -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: 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: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,98 @@
fileFormatVersion: 2
guid: 1608df194c29ecd4d818b3b68dcdbc54
timeCreated: 1506974648
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
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:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -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: 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: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant: