浏览代码

Make Node and NodePresenter members private

They still accessible through public (and in the case of Node, virtual)
interfaces.

Signed-off-by: joce <joce@unity3d.com>
/main
joce 8 年前
当前提交
98e645eb
共有 6 个文件被更改,包括 48 次插入47 次删除
  1. 10
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/NodeDrawData.cs
  2. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs
  3. 6
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Elements/Presenters/VerticalNodePresenter.cs
  4. 66
      MaterialGraphProject/Assets/NewUI/Editor/Elements/Node.cs
  5. 9
      MaterialGraphProject/Assets/NewUI/Editor/Elements/Presenters/NodePresenter.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs

10
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/NodeDrawData.cs


{
var slots = node.GetSlots<ISlot>().ToList();
m_InputAnchors.RemoveAll(data => !slots.Contains(((AnchorDrawData)data).slot));
m_OutputAnchors.RemoveAll(data => !slots.Contains(((AnchorDrawData)data).slot));
inputAnchors.RemoveAll(data => !slots.Contains(((AnchorDrawData)data).slot));
outputAnchors.RemoveAll(data => !slots.Contains(((AnchorDrawData)data).slot));
AddSlots(slots.Except(m_InputAnchors.Concat(m_OutputAnchors).Select(data => ((AnchorDrawData)data).slot)));
AddSlots(slots.Except(inputAnchors.Concat(outputAnchors).Select(data => ((AnchorDrawData)data).slot)));
m_InputAnchors.Sort((x, y) => slots.IndexOf(((AnchorDrawData)x).slot) - slots.IndexOf(((AnchorDrawData)y).slot));
m_OutputAnchors.Sort((x, y) => slots.IndexOf(((AnchorDrawData)x).slot) - slots.IndexOf(((AnchorDrawData)y).slot));
inputAnchors.Sort((x, y) => slots.IndexOf(((AnchorDrawData)x).slot) - slots.IndexOf(((AnchorDrawData)y).slot));
outputAnchors.Sort((x, y) => slots.IndexOf(((AnchorDrawData)x).slot) - slots.IndexOf(((AnchorDrawData)y).slot));
}
}

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs


pickingMode = PickingMode.Ignore,
};
m_LeftContainer.AddChild(m_ControlsContainer);
leftContainer.AddChild(m_ControlsContainer);
m_CurrentControlDrawData = new List<ControlDrawData>();
}

6
MaterialGraphProject/Assets/NewUI/Editor/Demo/Elements/Presenters/VerticalNodePresenter.cs


[Serializable]
class VerticalNodePresenter : NodePresenter
{
public override Orientation orientation
{
get { return Orientation.Vertical; }
}
m_Orientation = Orientation.Vertical;
}
}
}

66
MaterialGraphProject/Assets/NewUI/Editor/Elements/Node.cs


{
public class Node : GraphElement
{
protected readonly VisualContainer m_MainContainer;
protected readonly VisualContainer m_LeftContainer;
protected readonly VisualContainer m_RightContainer;
protected readonly VisualContainer m_TitleContainer;
protected readonly VisualContainer m_InputContainer;
protected readonly VisualContainer m_OutputContainer;
protected virtual VisualContainer mainContainer { get; private set; }
protected virtual VisualContainer leftContainer { get; private set; }
protected virtual VisualContainer rightContainer { get; private set; }
protected virtual VisualContainer titleContainer { get; private set; }
protected virtual VisualContainer inputContainer { get; private set; }
protected virtual VisualContainer outputContainer { get; private set; }
protected readonly Label m_TitleLabel;
protected readonly Button m_CollapseButton;
private readonly Label m_TitleLabel;
private readonly Button m_CollapseButton;
public override void SetPosition(Rect newPos)
{

if (nodePresenter.orientation == Orientation.Vertical)
{
if (m_LeftContainer.children.Contains(m_TitleContainer))
if (leftContainer.children.Contains(titleContainer))
m_LeftContainer.RemoveChild(m_TitleContainer);
leftContainer.RemoveChild(titleContainer);
if (!m_LeftContainer.children.Contains(m_TitleContainer))
if (!leftContainer.children.Contains(titleContainer))
m_LeftContainer.InsertChild(0, m_TitleContainer);
leftContainer.InsertChild(0, titleContainer);
}
}

{
base.OnDataChanged();
m_OutputContainer.ClearChildren();
m_InputContainer.ClearChildren();
outputContainer.ClearChildren();
inputContainer.ClearChildren();
m_InputContainer.AddChild(NodeAnchor.Create<EdgePresenter>(anchorPresenter));
inputContainer.AddChild(NodeAnchor.Create<EdgePresenter>(anchorPresenter));
m_OutputContainer.AddChild(NodeAnchor.Create<EdgePresenter>(anchorPresenter));
outputContainer.AddChild(NodeAnchor.Create<EdgePresenter>(anchorPresenter));
hasOutput = true;
}

if (!m_MainContainer.children.Contains(m_RightContainer))
if (!mainContainer.children.Contains(rightContainer))
m_MainContainer.InsertChild(0, m_RightContainer);
mainContainer.InsertChild(0, rightContainer);
if (m_MainContainer.children.Contains(m_RightContainer))
if (mainContainer.children.Contains(rightContainer))
m_MainContainer.RemoveChild(m_RightContainer);
mainContainer.RemoveChild(rightContainer);
}
}

public Node()
{
m_MainContainer = new VisualContainer()
mainContainer = new VisualContainer()
m_LeftContainer = new VisualContainer
leftContainer = new VisualContainer
m_RightContainer = new VisualContainer
rightContainer = new VisualContainer
m_TitleContainer = new VisualContainer
titleContainer = new VisualContainer
m_InputContainer = new VisualContainer
inputContainer = new VisualContainer
m_OutputContainer = new VisualContainer
outputContainer = new VisualContainer
{
name = "output",
pickingMode = PickingMode.Ignore,

elementTypeColor = new Color(0.9f, 0.9f, 0.9f, 0.5f);
AddChild(m_MainContainer);
m_MainContainer.AddChild(m_LeftContainer);
m_MainContainer.AddChild(m_RightContainer);
AddChild(mainContainer);
mainContainer.AddChild(leftContainer);
mainContainer.AddChild(rightContainer);
m_TitleContainer.AddChild(m_TitleLabel);
m_TitleContainer.AddChild(m_CollapseButton);
titleContainer.AddChild(m_TitleLabel);
titleContainer.AddChild(m_CollapseButton);
m_LeftContainer.AddChild(m_InputContainer);
m_RightContainer.AddChild(m_OutputContainer);
leftContainer.AddChild(inputContainer);
rightContainer.AddChild(outputContainer);
classList = new ClassList("node");
}

9
MaterialGraphProject/Assets/NewUI/Editor/Elements/Presenters/NodePresenter.cs


public class NodePresenter : SimpleElementPresenter
{
[SerializeField]
protected List<NodeAnchorPresenter> m_InputAnchors;
private List<NodeAnchorPresenter> m_InputAnchors;
public List<NodeAnchorPresenter> inputAnchors
{
get { return m_InputAnchors ?? (m_InputAnchors = new List<NodeAnchorPresenter>()); }

protected List<NodeAnchorPresenter> m_OutputAnchors;
private List<NodeAnchorPresenter> m_OutputAnchors;
[SerializeField]
protected Orientation m_Orientation;
get { return m_Orientation; }
get { return Orientation.Horizontal; }
}
// TODO make a simple creation function

protected NodePresenter()
{
m_Orientation = Orientation.Horizontal;
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs


name = "preview", // for USS&Flexbox
pickingMode = PickingMode.Ignore,
};
m_LeftContainer.AddChild(m_PreviewContainer);
leftContainer.AddChild(m_PreviewContainer);
m_currentPreviewData = new List<NodePreviewDrawData>();
}

正在加载...
取消
保存