public void SetUp() { m_Window = EditorWindow.GetWindowWithRect <VseWindow>(new Rect(Vector2.zero, new Vector2(800, 600))); m_Stencil = new ClassStencil(); var AssetModel = ScriptableObject.CreateInstance <VSGraphAssetModel>(); var graphModel = AssetModel.CreateGraph <VSGraphModel>("test", typeof(ClassStencil), false); var portModelMock = new Mock <IPortModel>(); portModelMock.Setup(x => x.GraphModel).Returns(graphModel); portModelMock.Setup(x => x.PortType).Returns(PortType.Event); portModelMock.Setup(x => x.Direction).Returns(Direction.Input); portModelMock.Setup(x => x.Name).Returns("port"); portModelMock.Setup(x => x.DataType).Returns(typeof(float).GenerateTypeHandle(m_Stencil)); m_Port = Port.Create(portModelMock.Object, m_Window.Store, Orientation.Horizontal); VariableDeclarationModel intVariableModel = graphModel.CreateGraphVariableDeclaration( "int", typeof(int).GenerateTypeHandle(m_Stencil), false ); VariableDeclarationModel stringVariableModel = graphModel.CreateGraphVariableDeclaration( "string", typeof(string).GenerateTypeHandle(m_Stencil), false ); m_IntField = new BlackboardVariableField(m_Window.Store, intVariableModel, m_Window.GraphView); m_StringField = new BlackboardVariableField(m_Window.Store, stringVariableModel, m_Window.GraphView); m_IntTokenModel = Activator.CreateInstance <VariableNodeModel>(); m_IntTokenModel.DeclarationModel = intVariableModel; m_IntTokenModel.GraphModel = graphModel; m_StringTokenModel = Activator.CreateInstance <VariableNodeModel>(); m_StringTokenModel.DeclarationModel = stringVariableModel; m_StringTokenModel.GraphModel = graphModel; }
protected override void UpdateInputPortModels() { Port.CreateInputPort(m_Store, Model.InstancePort, inputContainer, inputContainer); //TODO deal with presence of same component type in both lists foreach (var compType in Model.GetEditableComponents()) { 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", true); componentTitleContainer.Add(deleteComponentButton); componentTitleContainer.Add(new Label(compType.Name(Model.GraphModel.Stencil)) { name = "componentTitle" }); componentTitleContainer.Add(new VisualElement { name = "filler" }); inputContainer.Add(componentContainer); { var componentPortsContainer = new VisualElement { name = "componentDataPorts" }; componentContainer.Add(componentPortsContainer); foreach (var port in Model.GetPortsForComponent(compType)) { Port.CreateInputPort(m_Store, port, componentPortsContainer, componentPortsContainer); } } } }
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); } } } }
public DotsVariableToken(INodeModel model, Store store, Port input, Port output, GraphView graphView, Texture2D icon = null) : base(model, store, input, output, graphView, icon) { styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UIHelper.TemplatePath + "SetVariableNode.uss")); AddToClassList("dots-variable-token"); }