示例#1
0
        public AnyStateFilterVisualItem()
        {
            style.flexDirection = FlexDirection.Row;
            AddToClassList("any-state__filters__item");

            _stateFinder = new NamedItemFinder <StateNodeUI>(StateMachineEditor.Editor.States);
            _stateFinder.OnItemSelected += (previousState, state, index) =>
            {
                _filter.State = state;
            };

            _filterModeField = new EnumField(AnyStateFilterMode.CurrentAndNextState);
            _filterModeField.RegisterValueChangedCallback(e => _filter.Mode = (AnyStateFilterMode)e.newValue);

            Add(_stateFinder);
            Add(_filterModeField);
        }
示例#2
0
        public TransitionConditionUI()
        {
            AddToClassList("transition-condition");

            style.flexDirection = FlexDirection.Row;

            _parameterStateSwitch = new Button(() =>
            {
                if (_condition.ProviderSourceType == ValueProviderSourceType.Parameter)
                {
                    _condition.ProviderSourceType = ValueProviderSourceType.State;
                }
                else
                {
                    _condition.ProviderSourceType = ValueProviderSourceType.Parameter;
                }

                SetProviderSourceType(_condition.ProviderSourceType);
            })
            {
                text = "P"
            };
            Add(_parameterStateSwitch);

            _parameterFinder = new NamedItemFinder <ParameterNodeUI>(StateMachineEditor.Editor.Parameters);
            _parameterFinder.OnItemSelected += (previousParameter, parameter, index) =>
            {
                _condition.Parameter = parameter;

                if (previousParameter != null)
                {
                    previousParameter.OnTypeChanged -= ParameterTypeChanged;
                }

                if (parameter != null)
                {
                    SetProviderType(parameter.ParameterType);
                    parameter.OnTypeChanged += ParameterTypeChanged;
                }
                else
                {
                    ComparisonElementsEnabling(_providerType, false);
                }
            };
            Add(_parameterFinder);

            _stateFinder = new NamedItemFinder <StateNodeUI>(StateMachineEditor.Editor.States);
            _stateFinder.OnItemSelected += (previousState, state, index) =>
            {
                _condition.State = state;

                if (state != null)
                {
                    _stateValueProvider.style.display = DisplayStyle.Flex;
                    SetProviderType(ValueProviderType.Float);
                }
                else
                {
                    _stateValueProvider.style.display = DisplayStyle.None;
                    ComparisonElementsEnabling(_providerType, false);
                }
            };
            _stateFinder.style.display = DisplayStyle.None;
            Add(_stateFinder);

            _stateValueProvider = new EnumField(StateValueProviders.Time);
            _stateValueProvider.style.display = DisplayStyle.None;
            _stateValueProvider.RegisterValueChangedCallback(e => _condition.StateValueProvider = (StateValueProviders)e.newValue);
            Add(_stateValueProvider);

            _boolComparisonValueField = new EnumField(Bool.True);
            _boolComparisonValueField.style.display = DisplayStyle.None;
            _boolComparisonValueField.RegisterValueChangedCallback(e => _condition.BoolComparisonValue = (Bool)e.newValue == Bool.True);
            Add(_boolComparisonValueField);

            _intComparisonField = new EnumField(IntComparison.Equal);
            _intComparisonField.style.display = DisplayStyle.None;
            _intComparisonField.RegisterValueChangedCallback(e => _condition.IntComparison = (IntComparison)e.newValue);
            Add(_intComparisonField);

            _intComparisonValueField = new IntegerField();
            _intComparisonValueField.style.display = DisplayStyle.None;
            _intComparisonValueField.RegisterValueChangedCallback(e => _condition.IntComparisonValue = e.newValue);
            Add(_intComparisonValueField);

            _floatComparisonField = new EnumField(FloatComparison.BiggerOrEqual);
            _floatComparisonField.style.display = DisplayStyle.None;
            _floatComparisonField.RegisterValueChangedCallback(e => _condition.FloatComparison = (FloatComparison)e.newValue);
            Add(_floatComparisonField);

            _floatComparisonValueField = new FloatField();
            _floatComparisonValueField.style.display = DisplayStyle.None;
            _floatComparisonValueField.RegisterValueChangedCallback(e => _condition.FloatComparisonValue = e.newValue);
            Add(_floatComparisonValueField);

            RegisterCallback <DetachFromPanelEvent>(e =>
            {
                if (_parameterFinder.Item != null)
                {
                    _parameterFinder.Item.OnTypeChanged -= ParameterTypeChanged;
                }
            });
        }