void OnPortAdded(BasePort port) { BasePortView portView = NewPortView(port); portView.SetUp(port, Owner); portViews[port.name] = portView; if (portView.orientation == Orientation.Horizontal) { if (portView.direction == Direction.Input) { inputContainer.Add(portView); } else { outputContainer.Add(portView); } } else { if (portView.direction == Direction.Input) { topPortContainer.Add(portView); } else { bottomPortContainer.Add(portView); } } RefreshPorts(); }
private void InitPorts() { void AddPortView(BasePort port) { if (port == null) { return; } BasePortView portView = NewPortView(port); portView.SetUp(port, Owner); portViews[port.name] = portView; if (portView.orientation == Orientation.Horizontal) { if (portView.direction == Direction.Input) { inputContainer.Add(portView); } else { outputContainer.Add(portView); } } else { if (portView.direction == Direction.Input) { topPortContainer.Add(portView); } else { bottomPortContainer.Add(portView); } } } //自定义端口 foreach (var port in Model.Ports.Values) { AddPortView(port); } }