예제 #1
0
 protected override void OnDefineNode()
 {
     AddDataOutputPort(ComponentType.Name(Stencil), ComponentType);
 }
예제 #2
0
        protected override void UpdateInputPortModels()
        {
            Port.CreateInputPort(m_Store, Model.InstancePort, inputContainer, inputContainer);
            Port.CreateInputPort(m_Store, Model.EntityPort, titleContainer, inputContainer);
            //TODO deal with presence of same component type in both lists

            foreach (var componentOperation in Model.GetEditableComponents())
            {
                TypeHandle compType           = componentOperation.Type;
                var        componentContainer = new VisualElement {
                    name = "instantiateComponentNode"
                };
                var componentTitleContainer = new VisualElement {
                    name = "componentDataTitle"
                };
                componentContainer.Add(new VisualElement {
                    name = "componentSeparatorLine"
                });
                componentContainer.Add(componentTitleContainer);

                var deleteComponentButton = new Button {
                    name = "deleteComponentIcon"
                };
                deleteComponentButton.clickable.clicked += () => { DeleteComponentOperation(compType); };
                componentTitleContainer.Insert(0, deleteComponentButton);

                deleteComponentButton.EnableInClassList("deletable", !componentOperation.FromArchetype);
                componentTitleContainer.Add(deleteComponentButton);

                componentTitleContainer.Add(new Label(compType.Name(Model.GraphModel.Stencil))
                {
                    name = "componentTitle"
                });

                componentTitleContainer.Add(new VisualElement {
                    name = "filler"
                });

                var operationType = new EnumField(componentOperation.OperationType)
                {
                    name = "componentOperationType"
                };

                //Do I need to unregister it afterwards?
                //Also, allocation a closure for each component operations... meh?
                operationType.RegisterValueChangedCallback(eventValue => SetComponentOperation(compType, (ComponentOperation.ComponentOperationType)eventValue.newValue));
                componentTitleContainer.Add(operationType);
                inputContainer.Add(componentContainer);

                if (componentOperation.OperationType != ComponentOperation.ComponentOperationType.RemoveComponent)
                {
                    var componentPortsContainer = new VisualElement {
                        name = "componentDataPorts"
                    };
                    componentContainer.Add(componentPortsContainer);
                    foreach (var port in Model.GetPortsForComponent(componentOperation.Type))
                    {
                        Port.CreateInputPort(m_Store, port, componentPortsContainer, componentPortsContainer);
                    }
                }
            }
        }
예제 #3
0
 protected override string MakeTitle() => $"On {EventTypeHandle.Name(Stencil)}";