Ejemplo n.º 1
0
        public GraphCallerField(SerializedProperty property)
        {
            _rootProperty    = property;
            _graphProperty   = property.FindPropertyRelative(nameof(GraphCaller.Graph));
            _inputsProperty  = property.FindPropertyRelative(nameof(GraphCaller.Inputs));
            _outputsProperty = property.FindPropertyRelative(nameof(GraphCaller.Outputs));
            _graphCaller     = property.GetObject <GraphCaller>();

            var graphField = new ObjectPickerField(typeof(Graph)).ConfigureProperty(_graphProperty);

            graphField.SetFieldLabel(property.displayName);
            graphField.RegisterCallback <ChangeEvent <Object> >(evt => UpdateVariables(evt.newValue as Graph));

            _inputsList = new ListField
            {
                bindingPath  = _inputsProperty.propertyPath,
                AllowAdd     = false,
                AllowRemove  = false,
                AllowReorder = false,
                Tooltip      = "The input values to set for the Graph"
            };

            _outputsList = new ListField
            {
                bindingPath  = _outputsProperty.propertyPath,
                AllowAdd     = false,
                AllowRemove  = false,
                AllowReorder = false,
                Tooltip      = "The output values to resolve from this Graph"
            };

            Add(graphField);
            Add(_inputsList);
            Add(_outputsList);

            _outputsList.AddToClassList(OutputsUssClassName);
            _inputsList.AddToClassList(InputsUssClassName);

            AddToClassList(UssClassName);
            this.AddStyleSheet(Stylesheet);

            UpdateVariables(_graphProperty.objectReferenceValue as Graph);
        }