mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Code FixFormat
None of the code was changed, just moved around.
This commit is contained in:
parent
9abdf2995e
commit
64282028aa
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. </summary>
|
||||
public class NodeEditor {
|
||||
@ -75,8 +75,12 @@ public class NodeEditor {
|
||||
Vector2 handlePoint = rect.center;
|
||||
|
||||
switch (port.direction) {
|
||||
case NodePort.IO.Input: handlePoint.x = rect.xMin; break;
|
||||
case NodePort.IO.Output: handlePoint.x = rect.xMax; break;
|
||||
case NodePort.IO.Input:
|
||||
handlePoint.x = rect.xMin;
|
||||
break;
|
||||
case NodePort.IO.Output:
|
||||
handlePoint.x = rect.xMax;
|
||||
break;
|
||||
}
|
||||
|
||||
Color col = GUI.color;
|
||||
@ -112,55 +116,44 @@ public class NodeEditor {
|
||||
EditorGUI.LabelField(rect, fieldPrettyName);
|
||||
rect.x += rect.width;
|
||||
fieldValue = EditorGUI.IntField(rect, (int) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(bool)) {
|
||||
} else if (fieldType == typeof(bool)) {
|
||||
fieldValue = EditorGUILayout.Toggle(fieldPrettyName, (bool) fieldValue);
|
||||
}
|
||||
else if (fieldType.IsEnum) {
|
||||
} else if (fieldType.IsEnum) {
|
||||
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)) {
|
||||
|
||||
if (fieldName == "name") return; //Ignore 'name'
|
||||
TextAreaAttribute textAreaAttrib;
|
||||
if (NodeEditorUtilities.GetAttrib(fieldAttribs, out textAreaAttrib)) {
|
||||
fieldValue = EditorGUILayout.TextArea(fieldValue != null ? (string) fieldValue : "");
|
||||
}
|
||||
else
|
||||
} else
|
||||
fieldValue = EditorGUILayout.TextField(fieldPrettyName, fieldValue != null ? (string) fieldValue : "");
|
||||
}
|
||||
else if (fieldType == typeof(Rect)) {
|
||||
} else if (fieldType == typeof(Rect)) {
|
||||
if (fieldName == "rect") return; //Ignore 'rect'
|
||||
fieldValue = EditorGUILayout.RectField(fieldPrettyName, (Rect) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(float)) {
|
||||
} else if (fieldType == typeof(float)) {
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
rect.width *= 0.5f;
|
||||
EditorGUI.LabelField(rect, fieldPrettyName);
|
||||
rect.x += rect.width;
|
||||
fieldValue = EditorGUI.FloatField(rect, (float) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(Vector2)) {
|
||||
} else if (fieldType == typeof(Vector2)) {
|
||||
fieldValue = EditorGUILayout.Vector2Field(fieldPrettyName, (Vector2) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(Vector3)) {
|
||||
} else if (fieldType == typeof(Vector3)) {
|
||||
fieldValue = EditorGUILayout.Vector3Field(new GUIContent(fieldPrettyName), (Vector3) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(Vector4)) {
|
||||
} else if (fieldType == typeof(Vector4)) {
|
||||
fieldValue = EditorGUILayout.Vector4Field(fieldPrettyName, (Vector4) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(Color)) {
|
||||
} else if (fieldType == typeof(Color)) {
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
rect.width *= 0.5f;
|
||||
EditorGUI.LabelField(rect, fieldPrettyName);
|
||||
rect.x += rect.width;
|
||||
fieldValue = EditorGUI.ColorField(rect, (Color) fieldValue);
|
||||
}
|
||||
else if (fieldType == typeof(AnimationCurve)) {
|
||||
} else if (fieldType == typeof(AnimationCurve)) {
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
rect.width *= 0.5f;
|
||||
EditorGUI.LabelField(rect, fieldPrettyName);
|
||||
@ -169,8 +162,7 @@ public class NodeEditor {
|
||||
AnimationCurve curve = fieldValue != null ? (AnimationCurve) fieldValue : new AnimationCurve();
|
||||
curve = EditorGUI.CurveField(rect, curve);
|
||||
if (fieldValue != curve) fieldInfo.SetValue(target, curve);
|
||||
}
|
||||
else if (fieldType.IsSubclassOf(typeof(UnityEngine.Object)) || fieldType == typeof(UnityEngine.Object)) {
|
||||
} else if (fieldType.IsSubclassOf(typeof(UnityEngine.Object)) || fieldType == typeof(UnityEngine.Object)) {
|
||||
if (fieldName == "graph") return; //Ignore 'graph'
|
||||
fieldValue = EditorGUILayout.ObjectField(fieldPrettyName, (UnityEngine.Object) fieldValue, fieldType, true);
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public partial class NodeEditorWindow {
|
||||
|
||||
@ -45,18 +45,15 @@ public partial class NodeEditorWindow {
|
||||
if (!draggedOutput.IsConnectedTo(hoveredPort)) {
|
||||
draggedOutputTarget = hoveredPort;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
draggedOutputTarget = null;
|
||||
}
|
||||
Repaint();
|
||||
}
|
||||
else if (IsDraggingNode) {
|
||||
} else if (IsDraggingNode) {
|
||||
draggedNode.rect.position = WindowToGridPosition(e.mousePosition) + dragOffset;
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
else if (e.button == 1) {
|
||||
} else if (e.button == 1) {
|
||||
panOffset += e.delta * zoom;
|
||||
isPanning = true;
|
||||
}
|
||||
@ -71,8 +68,7 @@ public partial class NodeEditorWindow {
|
||||
if (IsHoveringPort) {
|
||||
if (hoveredPort.IsOutput) {
|
||||
draggedOutput = hoveredPort;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (hoveredPort.IsConnected) {
|
||||
NodePort output = hoveredPort.Connection;
|
||||
hoveredPort.Disconnect(output);
|
||||
@ -80,8 +76,7 @@ public partial class NodeEditorWindow {
|
||||
draggedOutputTarget = hoveredPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
|
||||
} else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
|
||||
draggedNode = hoveredNode;
|
||||
dragOffset = hoveredNode.rect.position - WindowToGridPosition(e.mousePosition);
|
||||
}
|
||||
@ -100,12 +95,10 @@ public partial class NodeEditorWindow {
|
||||
draggedOutputTarget = null;
|
||||
EditorUtility.SetDirty(graph);
|
||||
Repaint();
|
||||
}
|
||||
else if (IsDraggingNode) {
|
||||
} else if (IsDraggingNode) {
|
||||
draggedNode = null;
|
||||
}
|
||||
}
|
||||
else if (e.button == 1) {
|
||||
} else if (e.button == 1) {
|
||||
if (!isPanning) ShowContextMenu();
|
||||
isPanning = false;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> Contains GUI methods </summary>
|
||||
public partial class NodeEditorWindow {
|
||||
@ -25,9 +25,7 @@ public partial class NodeEditorWindow {
|
||||
GUIUtility.ScaleAroundPivot(Vector2.one / zoom, rect.size * 0.5f);
|
||||
Vector4 padding = new Vector4(0, 22, 0, 0);
|
||||
padding *= zoom;
|
||||
GUI.BeginClip(new Rect(
|
||||
-((rect.width * zoom) - rect.width) * 0.5f,
|
||||
-(((rect.height * zoom) - rect.height) * 0.5f) + (22 * zoom),
|
||||
GUI.BeginClip(new Rect(-((rect.width * zoom) - rect.width) * 0.5f, -(((rect.height * zoom) - rect.height) * 0.5f) + (22 * zoom),
|
||||
rect.width * zoom,
|
||||
rect.height * zoom));
|
||||
}
|
||||
@ -78,8 +76,7 @@ public partial class NodeEditorWindow {
|
||||
if (hoveredNode != null) {
|
||||
Node node = hoveredNode;
|
||||
contextMenu.AddItem(new GUIContent("Remove"), false, () => graph.RemoveNode(node));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (int i = 0; i < nodeTypes.Length; i++) {
|
||||
Type type = nodeTypes[i];
|
||||
Type editorType = GetNodeEditor(type).GetType();
|
||||
|
||||
@ -20,7 +20,6 @@ public static class NodeEditorPreferences {
|
||||
string[] typeKeys = new string[typeColors.Count];
|
||||
typeColors.Keys.CopyTo(typeKeys, 0);
|
||||
|
||||
|
||||
foreach (var key in typeKeys) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
Color col = typeColors[key];
|
||||
@ -36,7 +35,6 @@ public static class NodeEditorPreferences {
|
||||
SavePrefs();
|
||||
}
|
||||
|
||||
|
||||
string[] generatedTypeKeys = new string[generatedTypeColors.Count];
|
||||
generatedTypeColors.Keys.CopyTo(generatedTypeKeys, 0);
|
||||
foreach (var key in generatedTypeKeys) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> Contains reflection-related info </summary>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public static class NodeEditorResources {
|
||||
//Unec textures
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> A set of editor-only utilities and extensions for UnityNodeEditorBase </summary>
|
||||
public static class NodeEditorUtilities {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public partial class NodeEditorWindow : EditorWindow {
|
||||
@ -36,8 +36,7 @@ public partial class NodeEditorWindow : EditorWindow {
|
||||
if (AssetDatabase.Contains(graph)) {
|
||||
EditorUtility.SetDirty(graph);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
else SaveAs();
|
||||
} else SaveAs();
|
||||
}
|
||||
|
||||
public void SaveAs() {
|
||||
@ -81,7 +80,6 @@ public partial class NodeEditorWindow : EditorWindow {
|
||||
selectedNode = node;
|
||||
}
|
||||
|
||||
|
||||
[OnOpenAsset(0)]
|
||||
public static bool OnOpen(int instanceID, int line) {
|
||||
NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as NodeGraph;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> Base class for all nodes </summary>
|
||||
[Serializable]
|
||||
@ -99,14 +99,12 @@ public abstract class Node : ScriptableObject {
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class InputAttribute : Attribute {
|
||||
public InputAttribute() {
|
||||
}
|
||||
public InputAttribute() { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class OutputAttribute : Attribute {
|
||||
public OutputAttribute() {
|
||||
}
|
||||
public OutputAttribute() { }
|
||||
}
|
||||
|
||||
private void GetPorts() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> Precaches reflection data in editor so we won't have to do it runtime </summary>
|
||||
public static class NodeDataCache {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
/// <summary> Base class for all node graphs </summary>
|
||||
[Serializable]
|
||||
@ -45,8 +45,7 @@ public abstract class NodeGraph : ScriptableObject, ISerializationCallbackReceiv
|
||||
nodes.Clear();
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize() {
|
||||
}
|
||||
public void OnBeforeSerialize() { }
|
||||
|
||||
public void OnAfterDeserialize() {
|
||||
/*for (int i = 0; i < nodes.Count; i++) {
|
||||
@ -62,4 +61,3 @@ public abstract class NodeGraph : ScriptableObject, ISerializationCallbackReceiv
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class NodePort {
|
||||
@ -20,7 +20,6 @@ public class NodePort {
|
||||
|
||||
public string fieldName { get { return _fieldName; } }
|
||||
|
||||
|
||||
[SerializeField] public Node node;
|
||||
[SerializeField] private string _fieldName;
|
||||
[SerializeField] public Type type;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user