Beispiel #1
0
    public bool NextLex()
    {
        SkipSpace();
        string s;

        switch (_cChar)
        {
        case '\0':
            return(false);

        case ']':
        case ')':
            throw new Exception("Unexpected symbol" + _cChar);

        case '(':
            s = ReadString();
            _pathParts.Add(new KeyValuePair <PathPartType, string>(PathPartType.Find, s));
            _actions.Add((o) => UnityReflectionAccessor.Find(o, s));
            break;

        case '[':
            s = ReadClass();
            _pathParts.Add(new KeyValuePair <PathPartType, string>(PathPartType.Component, s));
            _actions.Add((o) => UnityReflectionAccessor.FindComponent(o, s));
            break;

        default:
            s = ReadName();
            _pathParts.Add(new KeyValuePair <PathPartType, string>(PathPartType.Acceessor, s));
            _actions.Add((o) => UnityReflectionAccessor.Access(o, s));
            break;
        }
        return(true);
    }
Beispiel #2
0
    public static object ResolvePart(object o, KeyValuePair <UnityPathResolver.PathPartType, string>[] pathParts, int cutParts = 0)
    {
        var cObj = o;

        for (int i = 0; i < pathParts.Length - cutParts; i++)
        {
            KeyValuePair <PathPartType, string> part = pathParts[i];
            switch (part.Key)
            {
            case PathPartType.Find:
                cObj = UnityReflectionAccessor.Find(cObj, part.Value);
                break;

            case PathPartType.Component:
                cObj = UnityReflectionAccessor.FindComponent(cObj, part.Value);
                break;

            case PathPartType.Acceessor:
                cObj = UnityReflectionAccessor.Access(cObj, part.Value);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        return(cObj);
    }
Beispiel #3
0
 private void Log(string a)
 {
     Debug.LogFormat("{0} value is  '{1}'", a, UnityReflectionAccessor.Access(this, a));
 }