Пример #1
0
        public void ChangeDefinition(int index, ValueDefinition definition)
        {
            var variable = Variables[index];

            if (!definition.IsValid(variable))
            {
                Variables[index] = definition.Generate(null);
            }

            Definitions[index] = definition;
        }
Пример #2
0
        private static VariableValue ResolveValue(ValueDefinition definition, VariableValue value, Object errorContext, string invalidError, string variableName)
        {
            if (definition.Type == VariableType.Object && definition.Constraint is ObjectVariableConstraint constraint && value.TryGetObject(out var obj))
            {
                var resolved = ComponentHelper.GetAsObject(constraint.Type, obj);
                value = VariableValue.Create(resolved);
            }

            if (definition.Type != VariableType.Empty && !definition.IsValid(value))
            {
                Debug.LogWarningFormat(invalidError, variableName, errorContext, value);
            }

            return(value);
        }