mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Changed group resizing, no longer snaps to cursor position.
Changed rename textfield styling to account for custom styling on NodeEditor.cs classes.
This commit is contained in:
parent
ef83d77a72
commit
ebb36fbd28
@ -151,6 +151,11 @@ namespace XNodeEditor
|
|||||||
return NodeEditorResources.styles.nodeBody;
|
return NodeEditorResources.styles.nodeBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual GUIStyle GetHeaderStyle()
|
||||||
|
{
|
||||||
|
return NodeEditorResources.styles.nodeHeader;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual GUIStyle GetBodyHighlightStyle()
|
public virtual GUIStyle GetBodyHighlightStyle()
|
||||||
{
|
{
|
||||||
return NodeEditorResources.styles.nodeHighlight;
|
return NodeEditorResources.styles.nodeHighlight;
|
||||||
@ -216,6 +221,9 @@ namespace XNodeEditor
|
|||||||
/// <summary> Called after this node's name has changed. </summary>
|
/// <summary> Called after this node's name has changed. </summary>
|
||||||
public virtual void OnRename() {}
|
public virtual void OnRename() {}
|
||||||
|
|
||||||
|
/// <summary> Called when exiting rename mode for this node. </summary>
|
||||||
|
public virtual void OnRenameDeactive() {}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class CustomNodeEditorAttribute : Attribute,
|
public class CustomNodeEditorAttribute : Attribute,
|
||||||
INodeEditorAttrib
|
INodeEditorAttrib
|
||||||
|
|||||||
@ -429,7 +429,7 @@ namespace XNodeEditor
|
|||||||
!(e.control || e.shift))
|
!(e.control || e.shift))
|
||||||
{
|
{
|
||||||
selectedReroutes.Clear();
|
selectedReroutes.Clear();
|
||||||
SelectNode(hoveredNode, false);
|
// SelectNode(hoveredNode, false);
|
||||||
|
|
||||||
// Double click to rename node
|
// Double click to rename node
|
||||||
if (isDoubleClick)
|
if (isDoubleClick)
|
||||||
@ -718,7 +718,7 @@ namespace XNodeEditor
|
|||||||
|
|
||||||
public void RenameSelectedNodeTextField()
|
public void RenameSelectedNodeTextField()
|
||||||
{
|
{
|
||||||
if (Selection.objects.Length == 1 && Selection.activeObject is Node)
|
if (Selection.activeObject is Node)
|
||||||
{
|
{
|
||||||
currentActivity = NodeActivity.Renaming;
|
currentActivity = NodeActivity.Renaming;
|
||||||
RenameTextField.Show(Selection.activeObject);
|
RenameTextField.Show(Selection.activeObject);
|
||||||
|
|||||||
@ -11,18 +11,29 @@ namespace XNodeEditor.NodeGroups
|
|||||||
{
|
{
|
||||||
private NodeGroup group => _group != null ? _group : _group = target as NodeGroup;
|
private NodeGroup group => _group != null ? _group : _group = target as NodeGroup;
|
||||||
private NodeGroup _group;
|
private NodeGroup _group;
|
||||||
|
public static Texture2D corner =>
|
||||||
|
_corner != null ? _corner : _corner = Resources.Load<Texture2D>("xnode_corner");
|
||||||
|
private static Texture2D _corner;
|
||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
private Vector2 _size;
|
private Vector2 _size;
|
||||||
private float _currentHeight;
|
private float _currentHeight;
|
||||||
|
private Vector2 _draggingOffset;
|
||||||
|
|
||||||
|
private const int mouseRectPadding = 4;
|
||||||
|
private const int mouseRectMargin = 30;
|
||||||
|
|
||||||
|
private GUIStyle headerStyle;
|
||||||
|
|
||||||
public override void OnCreate()
|
public override void OnCreate()
|
||||||
{
|
{
|
||||||
_currentHeight = group.height;
|
_currentHeight = group.height;
|
||||||
|
headerStyle = new GUIStyle(NodeEditorResources.styles.nodeHeader);
|
||||||
|
headerStyle.fontSize = 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnHeaderGUI()
|
public override void OnHeaderGUI()
|
||||||
{
|
{
|
||||||
GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
|
GUILayout.Label(target.name, headerStyle, GUILayout.Height(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnBodyGUI()
|
public override void OnBodyGUI()
|
||||||
@ -33,8 +44,8 @@ namespace XNodeEditor.NodeGroups
|
|||||||
case EventType.MouseDrag:
|
case EventType.MouseDrag:
|
||||||
if (_isDragging)
|
if (_isDragging)
|
||||||
{
|
{
|
||||||
group.width = Mathf.Max(200, (int)e.mousePosition.x + 16);
|
group.width = Mathf.Max(200, (int)e.mousePosition.x + (int)_draggingOffset.x + 16);
|
||||||
group.height = Mathf.Max(100, (int)e.mousePosition.y - 34);
|
group.height = Mathf.Max(100, (int)e.mousePosition.y + (int)_draggingOffset.y - 34);
|
||||||
_currentHeight = group.height;
|
_currentHeight = group.height;
|
||||||
NodeEditorWindow.current.Repaint();
|
NodeEditorWindow.current.Repaint();
|
||||||
}
|
}
|
||||||
@ -50,10 +61,13 @@ namespace XNodeEditor.NodeGroups
|
|||||||
if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
|
if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
|
||||||
{
|
{
|
||||||
// Mouse position checking is in node local space
|
// Mouse position checking is in node local space
|
||||||
Rect lowerRight = new Rect(_size.x - 34, _size.y - 34, 30, 30);
|
Rect lowerRight = new Rect(_size.x - (mouseRectMargin + mouseRectPadding),
|
||||||
|
_size.y - (mouseRectMargin + mouseRectPadding), mouseRectMargin, mouseRectMargin);
|
||||||
if (lowerRight.Contains(e.mousePosition))
|
if (lowerRight.Contains(e.mousePosition))
|
||||||
{
|
{
|
||||||
_isDragging = true;
|
_isDragging = true;
|
||||||
|
_draggingOffset = _size - e.mousePosition - new Vector2(GetBodyStyle().padding.right,
|
||||||
|
GetBodyStyle().padding.bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,17 +143,18 @@ namespace XNodeEditor.NodeGroups
|
|||||||
// Add scale cursors
|
// Add scale cursors
|
||||||
if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
|
if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
|
||||||
{
|
{
|
||||||
Rect lowerRight = new Rect(target.position, new Vector2(30, 30));
|
Rect lowerRight = new Rect(target.position, new Vector2(mouseRectMargin, mouseRectMargin));
|
||||||
lowerRight.y += _size.y - 34;
|
lowerRight.y += _size.y - (mouseRectMargin + mouseRectPadding);
|
||||||
lowerRight.x += _size.x - 34;
|
lowerRight.x += _size.x - (mouseRectMargin + mouseRectPadding);
|
||||||
lowerRight = NodeEditorWindow.current.GridToWindowRect(lowerRight);
|
lowerRight = NodeEditorWindow.current.GridToWindowRect(lowerRight);
|
||||||
NodeEditorWindow.current.onLateGUI += () => AddMouseRect(lowerRight);
|
NodeEditorWindow.current.onLateGUI += () => AddMouseRect(lowerRight, MouseCursor.ResizeUpLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.Space(_currentHeight);
|
GUILayout.Space(_currentHeight);
|
||||||
|
GUI.DrawTexture(new Rect(group.width - 34, group.height + 16, 24, 24), corner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRenameActive()
|
public override void OnRenameActive()
|
||||||
@ -150,7 +165,7 @@ namespace XNodeEditor.NodeGroups
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void OnRename()
|
public override void OnRenameDeactive()
|
||||||
{
|
{
|
||||||
_currentHeight = group.height;
|
_currentHeight = group.height;
|
||||||
}
|
}
|
||||||
@ -165,9 +180,14 @@ namespace XNodeEditor.NodeGroups
|
|||||||
return group.color;
|
return group.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddMouseRect(Rect rect)
|
public override GUIStyle GetHeaderStyle()
|
||||||
{
|
{
|
||||||
EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeUpLeft);
|
return headerStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddMouseRect(Rect rect, MouseCursor mouseCursor)
|
||||||
|
{
|
||||||
|
EditorGUIUtility.AddCursorRect(rect, mouseCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddContextMenuItems(GenericMenu menu)
|
public override void AddContextMenuItems(GenericMenu menu)
|
||||||
|
|||||||
@ -35,7 +35,10 @@ namespace XNodeEditor
|
|||||||
public void DrawRenameTextField()
|
public void DrawRenameTextField()
|
||||||
{
|
{
|
||||||
GUI.SetNextControlName(inputControlName);
|
GUI.SetNextControlName(inputControlName);
|
||||||
input = GUILayout.TextField(input, NodeEditorResources.styles.nodeHeaderRename);
|
GUIStyle stylesNodeHeaderRename = NodeEditorResources.styles.nodeHeaderRename;
|
||||||
|
stylesNodeHeaderRename.fontSize =
|
||||||
|
NodeEditor.GetEditor((Node)target, NodeEditorWindow.current).GetHeaderStyle().fontSize;
|
||||||
|
input = GUILayout.TextField(input, stylesNodeHeaderRename);
|
||||||
EditorGUI.FocusTextInControl(inputControlName);
|
EditorGUI.FocusTextInControl(inputControlName);
|
||||||
|
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
@ -80,7 +83,6 @@ namespace XNodeEditor
|
|||||||
Undo.RecordObject(target, $"Renamed Node: [{target.name}] -> [{input}]");
|
Undo.RecordObject(target, $"Renamed Node: [{target.name}] -> [{input}]");
|
||||||
|
|
||||||
target.name = input;
|
target.name = input;
|
||||||
NodeEditor.GetEditor((Node)target, NodeEditorWindow.current).OnRename();
|
|
||||||
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target)))
|
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target)))
|
||||||
{
|
{
|
||||||
AssetDatabase.SetMainObject((target as Node).graph, AssetDatabase.GetAssetPath(target));
|
AssetDatabase.SetMainObject((target as Node).graph, AssetDatabase.GetAssetPath(target));
|
||||||
@ -97,6 +99,7 @@ namespace XNodeEditor
|
|||||||
current = null;
|
current = null;
|
||||||
|
|
||||||
EditorGUIUtility.editingTextField = false;
|
EditorGUIUtility.editingTextField = false;
|
||||||
|
NodeEditor.GetEditor((Node)target, NodeEditorWindow.current).OnRenameDeactive();
|
||||||
NodeEditorWindow.current.Repaint();
|
NodeEditorWindow.current.Repaint();
|
||||||
|
|
||||||
// If another action has not taken precedence, then just return to an idle state.
|
// If another action has not taken precedence, then just return to an idle state.
|
||||||
|
|||||||
BIN
Scripts/Editor/Resources/xnode_corner.png
Normal file
BIN
Scripts/Editor/Resources/xnode_corner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
140
Scripts/Editor/Resources/xnode_corner.png.meta
Normal file
140
Scripts/Editor/Resources/xnode_corner.png.meta
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0babe8a4377248fcacd576e5da1a27e5
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 12
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
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
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 2
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 1
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 2
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Server
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user