IXGU2SOXBCQYBV3S5EHZFEFJKSCVUQPVZ3NY7KPG2UHWTEVGRZCAC
JAZ27QX53QXAN4JVMMX2KYKN4GCULWFMXYSPFZ5HWW4T7FUB5EHAC
3UN6NREN32ZBQW4EWI7ED4WVQILCU2EIE7DQGFWZR3OUDCO3ZSPQC
FXM5KEZSKC2Z4LH4SEM6SSXN7WXH7B35MO4PQ4HMW5CFYFTCSNPQC
IFN4UDLTN7TD26CPONDCRHW4G3DJEXEYV62ZHZC4QD7DKJ76JAEQC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
D4K77RTIZUI46DIDLVOR42DW3EP6IOMEAASAPZQ5XA2J7GEYFQIAC
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c4299eb7af6691f4a82ce6a25fd96981, type: 3}
m_Name: Test Rune
m_EditorClassIdentifier:
RuneSprite: {fileID: 0}
Rune:
DisplayName:
Speed: 0
ManaCost: 0
Effects: []
RuneEffects:
- {fileID: 8640598257864221512}
references:
version: 2
RefIds: []
--- !u!114 &8640598257864221512
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4585b32f67d50794cad3c057a0f091a1, type: 3}
m_Name: e8e2d732-2b9d-4977-a7a4-3054375ad036
m_EditorClassIdentifier:
Guid: e8e2d732-2b9d-4977-a7a4-3054375ad036
_nodes: []
fileFormatVersion: 2
guid: 1d6944c39ca44dd4e98bb684f6d9b79c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8227769925427620265
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4585b32f67d50794cad3c057a0f091a1, type: 3}
m_Name: e27d0db8-224c-4166-bb89-5253c668df10
m_EditorClassIdentifier:
Guid: e27d0db8-224c-4166-bb89-5253c668df10
_nodes: []
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c4299eb7af6691f4a82ce6a25fd96981, type: 3}
m_Name: TestRune
m_EditorClassIdentifier:
RuneSprite: {fileID: 0}
Rune:
DisplayName:
Speed: 0
ManaCost: 0
Effects: []
RuneEffects:
- {fileID: -8227769925427620265}
references:
version: 2
RefIds: []
[Serializable]
public class EffectStepNodeGraph
{
public List<EffectStepNode> Nodes;
public Vector2 Center;
public EffectStepNodeGraph() {
Nodes = new();
Center = Vector2.zero;
}
public EffectStepNodeGraph(IEnumerable<EffectStepNodeView> nodes) {
Nodes = nodes.Select(nodeView => nodeView.Node).ToList();
Center = new Vector2(nodes.Select(node => node.layout.center.x).Average(), nodes.Select(node => node.layout.center.y).Average());
}
var mousePositionOnGraph = CalculatePositionOnGraph(_lastMousePosition);
foreach (var node in graph.Nodes) {
var newNode = ScriptableObject.Instantiate(node);
newNode.name = node.name;
newNode.Guid = Guid.NewGuid().ToString();
newNode.Position = node.Position - graph.Center + mousePositionOnGraph;
clonedGraph.Nodes.Add(newNode);
clonedSteps.TryAdd(node.Guid, newNode);
}
foreach (var input in clonedGraph.Nodes.SelectMany(node => node.Inputs)) {
var newNodeConnections = input.Connections().Select(c => clonedSteps.GetValueOrDefault(c.Guid)).Where(step => step != null).ToList();
input.DisconnectAll();
foreach (var newNodeConnection in newNodeConnections) {
input.TryConnect(newNodeConnection);
}
}
RegisterNodesEnum(clonedGraph.Nodes);
CreateNodeViews(clonedGraph.Nodes);
CreateEdges(clonedGraph.Nodes);
RefreshSelection(clonedGraph.Nodes);
}
string CutCopyOperation(IEnumerable<GraphElement> elements) {
EffectStepNodeGraph graph = new(elements.Select(e => e as EffectStepNodeView).Where(e => e != null));
var data = EditorJsonUtility.ToJson(graph);
return data;
}
UnityEngine.Vector2 CalculatePositionOnGraph(UnityEngine.Vector2 position) {
return viewTransform.matrix.inverse.MultiplyPoint(this.WorldToLocal(position));
UnityEngine.Vector2 CalculatePositionOnGraph(UnityEngine.Vector2 localPosition) {
return viewTransform.matrix.inverse.MultiplyPoint(localPosition);
Undo.RecordObject(_runeEffect, "Rune Effect (Create Node)");
_runeEffect.AddNode(node);
AssetDatabase.AddObjectToAsset(node, _runeEffect);
Undo.RegisterCreatedObjectUndo(node, "Rune Effect (Create Node)");
RegisterNodes(node);
void RegisterNodesEnum(IEnumerable<EffectStepNode> nodes) {
foreach (var node in nodes) {
Undo.RecordObject(_runeEffect, "Rune Effect (Create Node)");
_runeEffect.AddNode(node);
AssetDatabase.AddObjectToAsset(node, _runeEffect);
Undo.RegisterCreatedObjectUndo(node, "Rune Effect (Create Node)");
}
}