Пример #1
0
 public static GraphSaveUtility GetInstance(ModuleGraphView targetGraphView)
 {
     return(new GraphSaveUtility
     {
         targetGraphView = targetGraphView
     });
 }
Пример #2
0
        protected override void DrawNode(ModuleGraphView graphView)
        {
            var inputPort = graphView.GeneratePort <float>(this, Direction.Input, Port.Capacity.Multi);

            inputPort.portName = "Input";
            inputContainer.Add(inputPort);

            //Set the Add Button
            titleContainer.Insert(1, new Button(() =>
            {
                OutputPortIDs.Add(AddMultiRow(this, graphView).name);
            })
            {
                text = "Add", style = { flexGrow = 0 }
            });

            //Add saved port, none otherwise
            foreach (var guid in OutputPortIDs)
            {
                Port port = AddMultiRow(this, graphView);
                port.name = guid;
            }

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Пример #3
0
        protected override void DrawNode(ModuleGraphView graphView)
        {
            Debug.Log(Script.SceneIndex);
            var inputPort = graphView.GeneratePort <float>(this, Direction.Input, Port.Capacity.Multi);

            inputPort.portName = "Input";
            inputContainer.Add(inputPort);
            AddToClassList("action");

            var outputPort = graphView.GeneratePort <float>(this, Direction.Output);

            outputPort.portName = "Output";
            outputContainer.Add(outputPort);

            IntegerField intField = new IntegerField("Scene Index", 2);

            intField.value = Script.SceneIndex;
            intField.RegisterValueChangedCallback(evt =>
            {
                var temp = evt.newValue < 0 ? 0 : evt.newValue > 99 ? 99 : evt.newValue;
                intField.SetValueWithoutNotify(temp);
                Script.SceneIndex = temp;
                graphView.SetDirty();
            });

            extensionContainer.Add(intField);

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Пример #4
0
        protected override void DrawNode(ModuleGraphView graphView)
        {
            AddToClassList("start");
            var generatedPort = graphView.GeneratePort <float>(this, Direction.Output, Port.Capacity.Multi);

            generatedPort.portName = "Next";
            outputContainer.Add(generatedPort);

            capabilities &= ~Capabilities.Deletable;
            capabilities &= ~Capabilities.Copiable;
            capabilities &= ~Capabilities.Renamable;

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Пример #5
0
        private Port AddMultiRow(RandomNode node, ModuleGraphView graphView)
        {
            var temp = graphView.GeneratePort <float>(node, Direction.Output);

            temp.portName = "Output";
            temp.name     = Guid.NewGuid().ToString();
            var deleteButton = new Button(() =>
            {
                node.OutputPortIDs.Remove(temp.name);
                graphView.RemovePort(node, temp);
                graphView.RefreshNode(node);
            })
            {
                text = "-", style = { width = 10 }
            };

            temp.contentContainer.Add(deleteButton);
            node.outputContainer.Add(temp);
            graphView.RefreshNode(node);
            return(temp);
        }
Пример #6
0
        protected override void DrawNode(ModuleGraphView graphView)
        {
            var inputPort = graphView.GeneratePort <float>(this, Direction.Input, Port.Capacity.Multi);

            inputPort.portName = "Input";
            inputContainer.Add(inputPort);

            var Success = graphView.GeneratePort <float>(this, Direction.Output);

            Success.portName = "Success";
            Success.name     = "Success";
            outputContainer.Add(Success);

            var Failure = graphView.GeneratePort <float>(this, Direction.Output);

            Failure.portName = "Failure";
            Failure.name     = "Failure";
            outputContainer.Add(Failure);

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Пример #7
0
        private Port AddMultiRow(ModuleGraphView graphView)
        {
            var temp = graphView.GeneratePort <float>(this, Direction.Output);

            temp.portName = "Output";
            temp.name     = Guid.NewGuid().ToString();
            var deleteButton = new Button(() =>
            {
                OutputPortIDs.Remove(temp.name);
                Debug.Log(OutputPortIDs.Count);
                graphView.RemovePort(this, temp);
                graphView.RefreshNode(this);
            })
            {
                text = "-", style = { width = 10 }
            };

            temp.contentContainer.Add(deleteButton);
            outputContainer.Add(temp);
            graphView.RefreshNode(this);
            return(temp);
        }
Пример #8
0
        protected override void DrawNode(ModuleGraphView graphView)
        {
            var inputPort = graphView.GeneratePort <float>(this, Direction.Input, Port.Capacity.Multi);

            inputPort.portName = "Input";
            inputContainer.Add(inputPort);
            AddToClassList("action");

            var outputPort = graphView.GeneratePort <float>(this, Direction.Output);

            outputPort.portName = "Output";
            outputContainer.Add(outputPort);

            ObjectField objectField = new ObjectField();

            objectField.objectType = typeof(GameObject);
            objectField.value      = Script.GameObject;
            objectField.RegisterCallback <ChangeEvent <Object> >(evt => Script.GameObject = evt.newValue);
            extensionContainer.Add(objectField);

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Пример #9
0
 protected virtual void DrawNode(ModuleGraphView graphView)
 {
     throw new NotImplementedException();
 }
Пример #10
0
 public void Draw(ModuleGraphView graphView)
 {
     DrawNode(graphView);
 }
Пример #11
0
 public void Init(EditorWindow window, ModuleGraphView graphView)
 {
     this.graphView = graphView;
     this.window    = window;
 }
Пример #12
0
 private void ConstructGraphView()
 {
     graphView = new ModuleGraphView(this);
     graphView.StretchToParentSize();
     rootVisualElement.Add(graphView);
 }
Пример #13
0
 public static IEnumerable <Port> GetOuputPorts(this ModuleGraphView graphView, BaseNode node)
 {
     return(graphView.ports.ToList().Where(x => x.direction == Direction.Output && x.node == node));
 }