Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public bool ResolveObject <ObjectType>(IVariableStore variables, VariableReference reference, out ObjectType result) where ObjectType : Object
        {
            var value = reference.GetValue(variables);

            if (value.HasObject)
            {
                result = ComponentHelper.GetAsObject <ObjectType>(value.Object);

                if (result != null)
                {
                    return(true);
                }
            }

            result = null;
            LogResolveWarning(value, reference, VariableType.Object, typeof(ObjectType));
            return(false);
        }