您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
62 行
1.6 KiB
62 行
1.6 KiB
using System.Collections.Generic;
|
|
using RMGUI.GraphView;
|
|
using UnityEngine;
|
|
using UnityEngine.Graphing;
|
|
|
|
namespace UnityEditor.Graphing.Drawing
|
|
{
|
|
public class NodeDrawData : GraphElementData
|
|
{
|
|
protected NodeDrawData()
|
|
{}
|
|
|
|
public INode node { get; private set; }
|
|
|
|
protected List<GraphElementData> m_Children = new List<GraphElementData>();
|
|
|
|
public override IEnumerable<GraphElementData> elements
|
|
{
|
|
get { return m_Children; }
|
|
}
|
|
|
|
public virtual void OnModified(ModificationScope scope)
|
|
{}
|
|
|
|
public override void CommitChanges()
|
|
{
|
|
base.CommitChanges();
|
|
var drawData = node.drawState;
|
|
drawData.position = position;
|
|
node.drawState = drawData;
|
|
}
|
|
|
|
protected virtual IEnumerable<GraphElementData> GetControlData()
|
|
{
|
|
return new ControlDrawData[0];
|
|
}
|
|
|
|
public virtual void Initialize(INode inNode)
|
|
{
|
|
node = inNode;
|
|
capabilities |= Capabilities.Movable;
|
|
|
|
if (node == null)
|
|
return;
|
|
|
|
name = inNode.name;
|
|
|
|
foreach (var input in node.GetSlots<ISlot>())
|
|
{
|
|
var data = CreateInstance<AnchorDrawData>();
|
|
data.Initialize(input);
|
|
m_Children.Add(data);
|
|
}
|
|
|
|
var controlData = GetControlData();
|
|
m_Children.AddRange(controlData);
|
|
|
|
position = new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0);
|
|
//position
|
|
}
|
|
}
|
|
}
|