Beispiel #1
0
        private VisualElement GenerateBlackboardField(ExposedProperty property)
        {
            var container       = new VisualElement();
            var blackboardField = new BlackboardField
            {
                text     = property.propertyName,
                typeText = "String",
            };

            container.Add(blackboardField);

            var propertyValueTextField = new TextField("Value:");

            propertyValueTextField.Q(className: "unity-label").style.minWidth = 50;
            propertyValueTextField.value = property.propertyValue;
            propertyValueTextField.RegisterValueChangedCallback(evt =>
            {
                int changingPropertyIndex = graphView.exposedProperties.FindIndex(
                    exposedProperty => exposedProperty.propertyName == property.propertyName);
                graphView.exposedProperties[changingPropertyIndex].propertyValue = evt.newValue;
            });

            var blackboardValueRow = new BlackboardRow(propertyValueTextField, propertyValueTextField);

            container.Add(blackboardValueRow);

            return(container);
        }
        private void GenerateBlackBoard()
        {
            var blackboard = new Blackboard(_graphView);

            blackboard.Add(new BlackboardSection {
                title = "Exposed Variables"
            });
            blackboard.addItemRequested = _blackboard =>
            {
                _graphView.AddPropertyToBlackBoard(ExposedProperty.CreateInstance(), false);
            };
            blackboard.editTextRequested = (_blackboard, 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 targetIndex = _graphView.ExposedProperties.FindIndex(x => x.PropertyName == oldPropertyName);
                _graphView.ExposedProperties[targetIndex].PropertyName = newValue;
                ((BlackboardField)element).text = newValue;
            };
            blackboard.SetPosition(new Rect(10, 30, 200, 300));
            _graphView.Add(blackboard);
            _graphView.Blackboard = blackboard;
        }
    internal void AddPropertyToBlackBoard(ExposedProperty exposedProperty)
    {
        var localPropertyName  = exposedProperty.PropertyName;
        var localPropertyValue = exposedProperty.PropertyValue;

        while (ExposedProperties.Any(x => x.PropertyName == localPropertyName))
        {
            localPropertyName = $"{localPropertyName}(1)"; // Username || Username(1)
        }
        var property = new ExposedProperty();

        property.PropertyName  = localPropertyName;
        property.PropertyValue = localPropertyValue;
        ExposedProperties.Add(property);

        var container       = new VisualElement();
        var blackboardField = new BlackboardField {
            text = property.PropertyName, typeText = "string property"
        };
        var propertyValueTextField = new TextField("Value: ")
        {
            value = localPropertyValue
        };

        propertyValueTextField.RegisterValueChangedCallback(evt =>
        {
            var changingPropertyIndex = ExposedProperties.FindIndex(x => x.PropertyName == property.PropertyName);
            ExposedProperties[changingPropertyIndex].PropertyValue = evt.newValue;
        });
        var blackBoardValueRow = new BlackboardRow(blackboardField, propertyValueTextField);

        container.Add(blackBoardValueRow);

        Blackboard.Add(container);
    }
Beispiel #4
0
        private void AddItemRequested(Blackboard blackboard)
        {
            var property = new ExposedProperty();

            property.propertyName = ValidateName(property.propertyName);
            graphView.exposedProperties.Add(property);

            blackboard.Add(GenerateBlackboardField(property));
        }
Beispiel #5
0
    public void AddPropertyToBlackBoard(ExposedProperty exposedProperty)
    {
        int    duplicateNameIndex = 1;
        string localPropertyName  = exposedProperty.PropertyName;
        string localPropertyValue = exposedProperty.PropertyValue;

        while (ExposedProperties.Any(x => x.PropertyName == localPropertyName))
        {
            localPropertyName = $"{localPropertyName}{duplicateNameIndex}"; // Name || Name1 || Name12
            duplicateNameIndex++;
        }

        ExposedProperty property = new ExposedProperty();

        property.PropertyName  = localPropertyName;
        property.PropertyValue = localPropertyValue;
        ExposedProperties.Add(property);

        VisualElement   container = new VisualElement();
        BlackboardField field     = new BlackboardField
        {
            text     = property.PropertyName,
            typeText = "string",
        };

        container.Add(field);

        TextField propertyValueTextField = new TextField("Value : ")
        {
            value = localPropertyValue,
            style = { width = new Length(80, LengthUnit.Percent) }
        };


        propertyValueTextField.RegisterValueChangedCallback(delegate(ChangeEvent <string> evt)
        {
            int changingPropertyIndex = ExposedProperties.FindIndex(x => x.PropertyName == property.PropertyName);
            ExposedProperties[changingPropertyIndex].PropertyValue = evt.newValue;
        });

        BlackboardRow blackboardRow = new BlackboardRow(field, propertyValueTextField);

        container.Add(blackboardRow);


        if (Blackboard != null)
        {
            Blackboard.Add(container);
        }
    }
Beispiel #6
0
    private void PlayContainerVFX(GameObject vfxToPlay, string colourName, float intensity)
    {
        GameObject      vfxObject      = Instantiate(vfxToPlay, displayContainerPosition.position, Quaternion.identity, displayContainerPosition);
        VisualEffect    vfx            = vfxObject.GetComponent <VisualEffect>();
        ExposedProperty colourProperty = "Colour";
        Vector4         colourToSet;
        float           hdrMultiplication = Mathf.Pow(2, intensity);

        colourToSet = (Color)typeof(Color).GetProperty(colourName.ToLowerInvariant()).GetValue(null, null);

        colourToSet = colourToSet * hdrMultiplication;

        vfx.SetVector4(colourProperty, colourToSet);
    }
        public void AddPropertyToBlackBoard(ExposedProperty property, bool loadMode = false)
        {
            var localPropertyName  = property.PropertyName;
            var localPropertyValue = property.PropertyValue;
            // var localPropertySprite = property.PropertySprite;
            var localPropertyNameCharacter = property.PropertyNameCharacter;

            if (!loadMode)
            {
                while (ExposedProperties.Any(x => x.PropertyName == localPropertyName))
                {
                    localPropertyName = $"{localPropertyName}(1)";
                }
            }

            var item = ExposedProperty.CreateInstance();

            item.PropertyName          = localPropertyName;
            item.PropertyValue         = localPropertyValue;
            item.PropertyNameCharacter = localPropertyNameCharacter;
            // item.PropertySprite = localPropertySprite;
            ExposedProperties.Add(item);

            var container = new VisualElement();
            //Serch Elements in BlackBoard
            var field = new BlackboardField {
                text = localPropertyName, typeText = "string"
            };

            container.Add(field);

            var propertyValueTextField = new TextField("Value:")
            {
                value = localPropertyValue
            };

            propertyValueTextField.RegisterValueChangedCallback(evt =>
            {
                var index = ExposedProperties.FindIndex(x => x.PropertyName == item.PropertyName);
                ExposedProperties[index].PropertyValue = evt.newValue;
            });
            var sa = new BlackboardRow(field, propertyValueTextField);

            container.Add(sa);
            Blackboard.Add(container);
        }
    internal void AddPropertyToBlackBoard(ExposedProperty exposedProperty)
    {
        //local var for the blackboard prop
        var localPropertyName  = exposedProperty.PropertyName;
        var localPropertyValue = exposedProperty.PropertyValue;

        //loop through and find the any duplicts and another +1 to name
        while (ExposedProperties.Any(x => x.PropertyName == localPropertyName))
        {
            localPropertyName = $"{localPropertyName}(1)"; //
        }
        var property = new ExposedProperty();

        property.PropertyName  = localPropertyName;
        property.PropertyValue = localPropertyValue;
        ExposedProperties.Add(property);

        var container       = new VisualElement();
        var blackboardField = new BlackboardField
        {
            text     = property.PropertyName,
            typeText = "string property"
        };

        container.Add(blackboardField);
        //add value fiels into black board
        var propertyValueTextField = new TextField("value")
        {
            value = localPropertyValue
        };

        propertyValueTextField.RegisterValueChangedCallback(evt =>
        {
            var changingPropertyIndex = ExposedProperties.FindIndex(x => x.PropertyName == property.PropertyName);
            ExposedProperties[changingPropertyIndex].PropertyValue = evt.newValue;
        });

        var blackBoardValueRow = new BlackboardRow(blackboardField, propertyValueTextField);

        container.Add(blackBoardValueRow);
        Blackboard.Add(container);
    }
Beispiel #9
0
        public void AddPropertyToBlackboard(ExposedProperty exposedProperty)
        {
            List <string> existingNamesList  = (from p in ExposedProperties select p.PropertyName).ToList();
            var           localPropertyName  = StringUtils.IncrementName(exposedProperty.PropertyName, existingNamesList);
            var           localPropertyValue = exposedProperty.PropertyValue;

            var property = new ExposedProperty
            {
                PropertyName  = localPropertyName,
                PropertyValue = localPropertyValue
            };

            ExposedProperties.Add(property);

            var container       = new VisualElement();
            var blackboardField = new BlackboardField {
                text = property.PropertyName, typeText = "string"
            };

            container.Add(blackboardField);

            var propertyValueTextField = new TextField("Value:")
            {
                value = property.PropertyValue
            };

            propertyValueTextField.RegisterValueChangedCallback(evt =>
            {
                var changingPropertyIndex = ExposedProperties.FindIndex(x => x.PropertyName == property.PropertyName);
                ExposedProperties[changingPropertyIndex].PropertyValue = evt.newValue;
            });

            var blackboardValueRow = new BlackboardRow(blackboardField, propertyValueTextField);

            container.Add(blackboardValueRow);

            Blackboard.Add(container);
        }
		static public void OnAdd(PEExposedPropertiesEditor editor, int parentId = 0)
		{
			var lr = GUILayoutUtility.GetLastRect();
			if (lr.min == Vector2.zero)
				lr.center = Event.current.mousePosition;
			lr.center = GUIUtility.GUIToScreenPoint(lr.center);
			var menu = new GenericMenu();
			menu.AddItem(new GUIContent("Property"), false, () =>
			{
				PEPropertyPickerWindow.OnPropertyPickerDelegate onChanged = property =>
				{
					var newProperty = new ExposedProperty();
					newProperty.Label = property.GetDisplayName();
					newProperty.PropertyPath = property.propertyPath;
					newProperty.Target = property.serializedObject.targetObject;
					newProperty.ParentId = parentId;
					editor.targets[0].Properties.Add(newProperty);
					newProperty.Order = editor.targets[0].Properties.OrderedItems.Any() ? editor.targets[0].Properties.OrderedItems.Max(i => i.Order + 10) : 0;
					editor.Build(true);

					Event.current.Use();

					Resources.FindObjectsOfTypeAll<Editor>()[0].Repaint();
					GUIUtility.ExitGUI();
				};
				EditorApplication.delayCall += () =>
					PEPropertyPickerWindow.Show(editor.targets[0].gameObject, onChanged, lr);
			});
			menu.AddItem(new GUIContent("Group"), false, () =>
					EditorApplication.delayCall += () =>
			{
				editor.targets[0].Properties.Add(new ExposedPropertyGroup {
					Label = "Property Group", ParentId = parentId,
					Order = editor.targets[0].Properties.OrderedItems.Any() ? editor.targets[0].Properties.OrderedItems.Max(i => i.Order + 10) : 0
				});
				editor.Build(true);
			});
			menu.ShowAsContext();
		}