コード例 #1
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn (context);
        if (string.IsNullOrEmpty (theName)) {
            throw new UTFailBuildException ("The name of the property must not be empty.",this);
        }

        object theRealValue = propertyValue.Value;
        if (propertyValue.UseExpression) {
            theRealValue = context.Evaluate (propertyValue.Expression);
        }

        var doSetOnlyIfUnset = onlyIfUnset.EvaluateIn(context);

        if (!doSetOnlyIfUnset || !context.ContainsProperty(theName)) {
            if (UTPreferences.DebugMode) {
                Type valueType = theRealValue != null ? theRealValue.GetType() : null;
                Debug.Log ("Setting property '" + theName + "' to " +
                    (valueType != null ? "[" + valueType.Name + "] " : "") + theRealValue, this);
            }
            context [theName] = theRealValue;
        }
        else {
            if (doSetOnlyIfUnset) {
                if (UTPreferences.DebugMode) {
                    Debug.Log("Not setting property '" + theName + "' because it is already set.");
                }
            }
        }
        yield return "";
    }
コード例 #2
0
    /// <summary>
    /// Applies the project properties to the given context.
    /// </summary>
    public void ApplyTo(UTContext context)
    {
        for (int i = 0; i < propertyNames.Length; i++) {
            var propName = propertyNames [i];
            var propValue = propertyValues [i];
            var propIsPrivate = isPrivate [i];
            object theRealValue = null;
            if (propValue.UseExpression) {
                theRealValue = context.Evaluate (propValue.Expression);
            } else {
                theRealValue = propValue.Value;
            }

            if (UTPreferences.DebugMode) {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propValue.UseExpression && valueOutput != null) {
                    valueOutput = new string ('*', valueOutput.ToString ().Length);
                }
                Type valueType = theRealValue != null ? theRealValue.GetType () : null;
                Debug.Log ("Setting property '" + propName + "' to " +
                (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput, this);
            }

            context [propName] = theRealValue;
        }
    }
コード例 #3
0
    /// <summary>
    /// Applies the project properties to the given context.
    /// </summary>
    public void ApplyTo(UTContext context)
    {
        for (int i = 0; i < propertyNames.Length; i++)
        {
            var    propName      = propertyNames [i];
            var    propValue     = propertyValues [i];
            var    propIsPrivate = isPrivate [i];
            object theRealValue  = null;
            if (propValue.UseExpression)
            {
                theRealValue = context.Evaluate(propValue.Expression);
            }
            else
            {
                theRealValue = propValue.Value;
            }

            if (UTPreferences.DebugMode)
            {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propValue.UseExpression && valueOutput != null)
                {
                    valueOutput = new string ('*', valueOutput.ToString().Length);
                }
                Type valueType = theRealValue != null?theRealValue.GetType() : null;

                Debug.Log("Setting property '" + propName + "' to " +
                          (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput, this);
            }

            context [propName] = theRealValue;
        }
    }
コード例 #4
0
    /// <summary>
    /// Applies the editor properties to the given context.
    /// </summary>
    public static void ApplyTo(UTContext context)
    {
        if (isDirty) {
            RebuildCaches ();
        }

        foreach (var prop in properties) {
            bool propIsExpression = prop.UseExpression;
            bool propIsPrivate = prop.IsPrivate;

            object theRealValue = null;
            if (propIsExpression) {
                theRealValue = context.Evaluate (prop.Expression);
            } else {
                theRealValue = prop.Value;
            }

            if (UTPreferences.DebugMode) {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propIsExpression && valueOutput != null) {
                    valueOutput = new string ('*', valueOutput.ToString ().Length);
                }

                Type valueType = theRealValue != null ? theRealValue.GetType () : null;
                Debug.Log ("Setting property '" + prop.Name + "' to " +
                (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput);
            }

            context [prop.Name] = theRealValue;
        }
    }
コード例 #5
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theName))
        {
            throw new UTFailBuildException("The name of the property must not be empty.", this);
        }

        object theRealValue = propertyValue.Value;

        if (propertyValue.UseExpression)
        {
            theRealValue = context.Evaluate(propertyValue.Expression);
        }

        var doSetOnlyIfUnset = onlyIfUnset.EvaluateIn(context);

        if (!doSetOnlyIfUnset || !context.ContainsProperty(theName))
        {
            if (UTPreferences.DebugMode)
            {
                Type valueType = theRealValue != null?theRealValue.GetType() : null;

                Debug.Log("Setting property '" + theName + "' to " +
                          (valueType != null ? "[" + valueType.Name + "] " : "") + theRealValue, this);
            }
            context [theName] = theRealValue;
        }
        else
        {
            if (doSetOnlyIfUnset)
            {
                if (UTPreferences.DebugMode)
                {
                    Debug.Log("Not setting property '" + theName + "' because it is already set.");
                }
            }
        }
        yield return("");
    }
コード例 #6
0
    /// <summary>
    /// Applies the editor properties to the given context.
    /// </summary>
    public static void ApplyTo(UTContext context)
    {
        if (isDirty)
        {
            RebuildCaches();
        }

        foreach (var prop in properties)
        {
            bool propIsExpression = prop.UseExpression;
            bool propIsPrivate    = prop.IsPrivate;

            object theRealValue = null;
            if (propIsExpression)
            {
                theRealValue = context.Evaluate(prop.Expression);
            }
            else
            {
                theRealValue = prop.Value;
            }

            if (UTPreferences.DebugMode)
            {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propIsExpression && valueOutput != null)
                {
                    valueOutput = new string ('*', valueOutput.ToString().Length);
                }

                Type valueType = theRealValue != null?theRealValue.GetType() : null;

                Debug.Log("Setting property '" + prop.Name + "' to " +
                          (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput);
            }

            context [prop.Name] = theRealValue;
        }
    }
コード例 #7
0
    public bool Accept(object o)
    {
        GameObject go = o as GameObject;

        if (go == null)
        {
            return(false);
        }

        if (expressions == null || expressions.Length == 0)
        {
            return(false);
        }

        context[gameObjectProperty] = go;

        var result = false;

        foreach (var expression in expressions)
        {
            var evalResult = context.Evaluate(expression);

            if (UTPreferences.DebugMode)
            {
                Debug.Log("Expression " + expression + " returned with value " + evalResult + " for game object " + go);
            }

            if (evalResult is bool && ((bool)evalResult))
            {
                result = true;
                break;
            }
        }

        context.Unset(gameObjectProperty);
        return(result);
    }
コード例 #8
0
ファイル: UTProperty.cs プロジェクト: kimch2/PackageClient
 /// <summary>
 /// Evaluates this property in the given context.
 /// </summary>
 /// <returns>
 /// The value of the evaluated property.
 /// </returns>
 /// <param name='context'>
 /// The context to evaluate the property in.
 /// </param>
 public T EvaluateIn(UTContext context)
 {
     if (UseExpression)
     {
         var result = context.Evaluate(Expression);
         if (!(result is T) || AlwaysCast)
         {
             result = CustomCast(result);
         }
         if (result == null)
         {
             throw new UTFailBuildException("Internal Error: An evaluated expression yielded null.", null);
         }
         return((T)result);
     }
     else
     {
         if (AlwaysCast)
         {
             return(CustomCast(Value));
         }
         return(Value);
     }
 }