public CharacterProperty(string propertyName, string propertyValue, DialogueGraphView dialogueGraphView) { graphView = dialogueGraphView; propertyType = BlackboardType.Character; PropertyName = propertyName; PropertyValue = propertyValue; propertyElement = new VisualElement(); var blackboardField = new BlackboardField { text = propertyName, typeText = "Character" }; blackboardField.Q <Label>("typeLabel").style.flexBasis = StyleKeyword.Auto; blackboardField.capabilities &= ~Capabilities.Deletable; blackboardField.RegisterCallback <ContextualMenuPopulateEvent>(PopulateDeleteOption); blackboardField.Add(new Button(() => { graphView.RemovePropertyFromBlackboard(this.PropertyName); }) { text = "X" }); propertyElement.Add(blackboardField); var propertyValueTextField = new TextField("Value:") { value = PropertyValue }; propertyValueTextField.Q <Label>().style.minWidth = StyleKeyword.Auto; propertyValueTextField.RegisterValueChangedCallback(evt => { var changingPropertyIndex = graphView.exposedProperties.FindIndex(x => x.PropertyName == this.PropertyName); if (changingPropertyIndex < 0) { return; } graphView.exposedProperties[changingPropertyIndex].PropertyValue = evt.newValue; propertyValueTextField.value = evt.newValue; }); var blackboardValueRow = new BlackboardRow(blackboardField, propertyValueTextField); propertyElement.Add(blackboardValueRow); }
private void InitVariables(BehaviourGraphModel model) { inspector.VariableContainer.Clear(); if (model.Settings.variableDefinition.Value != null) { foreach (var variable in model.Settings.variableDefinition.Value.Decompose()) { var blackboardField = new BlackboardField(ICON, $"{model.Settings.variableDefinition.Value.Name}.{variable.fullName}", $"{variable.type.Value.FullName}") { capabilities = Capabilities.Selectable | Capabilities.Deletable | Capabilities.Droppable }; blackboardField.userData = new VariableInfo { fieldOffsetInfo = variable, model = model }; blackboardField.AddToClassList(BEHAVIOUR_VARIABLE_CLASS); blackboardField.Q <Image>("icon").tintColor = variable.type.Value.GetColor(); inspector.VariableContainer.Add(blackboardField); } } }