Пример #1
0
        public virtual void Start()
        {
            if (root == null || (root != null && root.Context == null))
            {
                root = GetRoot();
            }

#if BUILD_TYPE_DEBUG
            if (root == null)
            {
                Debug.Log("Start Error:" + this.name + ":root not found!!");
            }
            if (root != null && root.Context == null)
            {
                Debug.Log("Start Error:" + this.name + ":root Context not found!!");
            }
#endif
            if (root != null && root.Context != null &&
                paths [0] != "" &&
                !(this is M4uEventBinding) && !(this is M4uEventBindings))
            {
                objs = new object[values.Length];
                pis  = new PropertyInfo[values.Length];
                fis  = new FieldInfo[values.Length];
                for (int i = 0; i < paths.Length; i++)
                {
                    string path = paths [i];
                    try
                    {
                        object   parent = root.Context;
                        string[] names  = path.Split('.');
                        for (int j = 0; j < names.Length; j++)
                        {
                            bool   isLast = (j == names.Length - 1);
                            string name   = names[j];
                            ParseMember(isLast, ref name, ref parent, ref values[i], ref objs[i], ref pis[i], ref fis[i]);
                            if (isLast)
                            {
                                var pname = name[0].ToString().ToLower() + name.Substring(1);
                                var pfi   = parent.GetType().GetField(pname, M4uConst.BindingAttr);
                                var p     = (M4uPropertyBase)pfi.GetValue(parent);
                                if (!p.Bindings.Contains(this))
                                {
                                    p.Bindings.Add(this);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(gameObject.name + ":" + path);
                        throw e;
                    }
                }
            }
        }
Пример #2
0
 public virtual void Awake()
 {
     root = GetRoot();
 }
Пример #3
0
 public virtual void Awake()
 {
     root = GetRoot(transform, true);
 }