예제 #1
0
        /// <summary>
        /// Generates a Blackboard for the Exposed Properties
        /// </summary>
        private void GenerateBlackBoard()
        {
            var blackboard = new Blackboard(_graphView)
            {
                subTitle = "Exposed Properties"
            };

            blackboard.Add(new BlackboardSection());
            blackboard.addItemRequested  = _blackboard => { _graphView.AddPropertyToBlackBoard(new ExposedProperty()); };
            blackboard.editTextRequested = (blackboard1, element, newValue) =>
            {
                var oldPropertyName = ((BlackboardField)element).text;
                if (_graphView.ExposedProperties.Any(x => x.PropertyName == newValue))
                {
                    EditorUtility.DisplayDialog("Error", "This property name already exists, please chose another one!", "OK");

                    return;
                }

                var propertyIndex = _graphView.ExposedProperties.FindIndex(x => x.PropertyName == oldPropertyName);
                _graphView.ExposedProperties[propertyIndex].PropertyName = newValue;

                ((BlackboardField)element).text = newValue;

                if (_autoSave)
                {
                    RequestDataOperation(true);
                }
            };

            _graphView._blackboard = blackboard;
            _graphView.Add(blackboard);
        }
        /// <summary>
        /// Links a port with an other
        /// </summary>

        private void LinkNodes(Port output, Port input)
        {
            var tempEdge = new Edge
            {
                output = output,
                input  = input
            };

            tempEdge?.input.Connect(tempEdge);
            tempEdge?.output.Connect(tempEdge);
            _targetGraphView.Add(tempEdge);
        }