浏览代码

Handle nodes without any output

The right container simply isn't shown in this case.

Signed-off-by: joce <joce@unity3d.com>
/main
Peter Bay Bastian 8 年前
当前提交
d683bd58
共有 3 个文件被更改,包括 40 次插入10 次删除
  1. 20
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/Presenters/NodesContentViewPresenter.cs
  2. 26
      MaterialGraphProject/Assets/NewUI/Editor/Elements/Node.cs
  3. 4
      MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.uss

20
MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/Presenters/NodesContentViewPresenter.cs


inputNodeAnchorPresenter.anchorType = typeof(Color);
nodePresenter.inputAnchors.Add(inputNodeAnchorPresenter);
var outputNodeAnchorPresenter = CreateInstance<OutputNodeAnchorPresenter>();
outputNodeAnchorPresenter.anchorType = outputType;
nodePresenter.outputAnchors.Add(outputNodeAnchorPresenter);
if (outputType != null)
{
var outputNodeAnchorPresenter = CreateInstance<OutputNodeAnchorPresenter>();
outputNodeAnchorPresenter.anchorType = outputType;
nodePresenter.outputAnchors.Add(outputNodeAnchorPresenter);
}
return nodePresenter;
}

// This is a demo, so our data (and thus our presenters) is fixed.
var containerPresenter = CreateInstance<InvisibleBorderContainerPresenter>();
containerPresenter.position = new Rect(630.0f, 0.0f, 200.0f, 200.0f);
containerPresenter.position = new Rect(850, 320, 200, 200);
containerPresenter.position = new Rect(630.0f, 210.0f, 200.0f, 200.0f);
containerPresenter.position = new Rect(1070, 320, 200, 200);
circlePresenter.position = new Rect(630, 420, 0, 0);
circlePresenter.position = new Rect(630, 320, 0, 0);
circlePresenter.radius = 200;
AddElement(circlePresenter);

nodePresenter = InitNodePresenter(typeof(float));
nodePresenter.position = new Rect(0, 186, 200, 176);
nodePresenter.title = "Another Operator";
AddElement(nodePresenter);
nodePresenter = InitNodePresenter(null);
nodePresenter.position = new Rect(600, 0, 200, 176);
nodePresenter.title = "No Output";
AddElement(nodePresenter);
var verticalNodePresenter = InitVerticalNodePresenter();

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


m_InputContainer.AddChild(NodeAnchor.Create<EdgePresenter>(anchorPresenter));
}
bool hasOutput = false;
hasOutput = true;
}
// Show output container only if we have one or more child
if (hasOutput)
{
if (!m_MainContainer.children.Contains(m_RightContainer))
{
m_MainContainer.InsertChild(0, m_RightContainer);
}
}
else
{
if (m_MainContainer.children.Contains(m_RightContainer))
{
m_MainContainer.RemoveChild(m_RightContainer);
}
}
m_TitleLabel.content.text = nodePresenter.title;

public Node()
{
m_MainContainer = new VisualContainer()
{
name = "pane",
pickingMode = PickingMode.Ignore,
};
{
name = "pane",
pickingMode = PickingMode.Ignore,
};
m_LeftContainer = new VisualContainer
{
name = "left",

4
MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.uss


.node #left > #title > Button {
text-color: rgb(153, 153, 153);
flex: 1;
margin-right: 6;
padding-right: 0;
padding-left: 0;
text-alignment: middle-center;
}
.node.horizontal #left > #input {

正在加载...
取消
保存