예제 #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>
        /// Creates all the exposed properties with the saved graph data
        /// </summary>
        private void CreateExposedProperties()
        {
            //Clear existing properties and add correct ones
            _targetGraphView.ClearBlackBoardAndExposedProperties();

            foreach (var exposedProperty in _containerCache.ExposedProperties)
            {
                _targetGraphView.AddPropertyToBlackBoard(exposedProperty);
            }
        }