mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Removed #if UNITY_EDITOR from NodeGraph.cs #23
This commit is contained in:
parent
19e244212c
commit
1885d453a4
@ -302,7 +302,7 @@ namespace XNodeEditor {
|
|||||||
foreach (UnityEngine.Object item in Selection.objects) {
|
foreach (UnityEngine.Object item in Selection.objects) {
|
||||||
if (item is XNode.Node) {
|
if (item is XNode.Node) {
|
||||||
XNode.Node node = item as XNode.Node;
|
XNode.Node node = item as XNode.Node;
|
||||||
graph.RemoveNode(node);
|
graphEditor.RemoveNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ namespace XNodeEditor {
|
|||||||
if (Selection.objects[i] is XNode.Node) {
|
if (Selection.objects[i] is XNode.Node) {
|
||||||
XNode.Node srcNode = Selection.objects[i] as XNode.Node;
|
XNode.Node srcNode = Selection.objects[i] as XNode.Node;
|
||||||
if (srcNode.graph != graph) continue; // ignore nodes selected in another graph
|
if (srcNode.graph != graph) continue; // ignore nodes selected in another graph
|
||||||
XNode.Node newNode = graph.CopyNode(srcNode);
|
XNode.Node newNode = graphEditor.CopyNode(srcNode);
|
||||||
substitutes.Add(srcNode, newNode);
|
substitutes.Add(srcNode, newNode);
|
||||||
newNode.position = srcNode.position + new Vector2(30, 30);
|
newNode.position = srcNode.position + new Vector2(30, 30);
|
||||||
newNodes[i] = newNode;
|
newNodes[i] = newNode;
|
||||||
|
|||||||
@ -39,6 +39,22 @@ namespace XNodeEditor {
|
|||||||
return NodeEditorPreferences.GetTypeColor(type);
|
return NodeEditorPreferences.GetTypeColor(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Creates a copy of the original node in the graph </summary>
|
||||||
|
public XNode.Node CopyNode(XNode.Node original) {
|
||||||
|
XNode.Node node = target.CopyNode(original);
|
||||||
|
node.name = original.name;
|
||||||
|
AssetDatabase.AddObjectToAsset(node, target);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Safely remove a node and all its connections. </summary>
|
||||||
|
public void RemoveNode(XNode.Node node) {
|
||||||
|
UnityEngine.Object.DestroyImmediate(node, true);
|
||||||
|
target.RemoveNode(node);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class CustomNodeGraphEditorAttribute : Attribute,
|
public class CustomNodeGraphEditorAttribute : Attribute,
|
||||||
XNodeEditor.Internal.NodeEditorBase<NodeGraphEditor, NodeGraphEditor.CustomNodeGraphEditorAttribute, XNode.NodeGraph>.INodeEditorAttrib {
|
XNodeEditor.Internal.NodeEditorBase<NodeGraphEditor, NodeGraphEditor.CustomNodeGraphEditorAttribute, XNode.NodeGraph>.INodeEditorAttrib {
|
||||||
|
|||||||
@ -28,13 +28,6 @@ namespace XNode {
|
|||||||
public virtual Node CopyNode(Node original) {
|
public virtual Node CopyNode(Node original) {
|
||||||
Node node = ScriptableObject.Instantiate(original);
|
Node node = ScriptableObject.Instantiate(original);
|
||||||
node.ClearConnections();
|
node.ClearConnections();
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (!Application.isPlaying) {
|
|
||||||
UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
|
|
||||||
UnityEditor.AssetDatabase.SaveAssets();
|
|
||||||
node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
nodes.Add(node);
|
nodes.Add(node);
|
||||||
node.graph = this;
|
node.graph = this;
|
||||||
return node;
|
return node;
|
||||||
@ -44,12 +37,6 @@ namespace XNode {
|
|||||||
/// <param name="node"></param>
|
/// <param name="node"></param>
|
||||||
public void RemoveNode(Node node) {
|
public void RemoveNode(Node node) {
|
||||||
node.ClearConnections();
|
node.ClearConnections();
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (!Application.isPlaying) {
|
|
||||||
DestroyImmediate(node, true);
|
|
||||||
UnityEditor.AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
nodes.Remove(node);
|
nodes.Remove(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user