Esempio n. 1
0
        public static void HierarchyFromStream(Stream stream, GameObject root)
        {
            var numSavedChildren = stream.ReadInt();
            var children         = root.GetComponentsInChildren <Transform>();
            var newHierarchy     = numSavedChildren != children.Length;

            var list = new List <ItemTuple <GameObject, int> >(numSavedChildren);

            if (newHierarchy)
            {
                GameObjectFromStream(stream, root);
                list.Add(ItemTuple.Create(root, 0));
                for (int i = 0; i < numSavedChildren - 1; i++)
                {
                    var depth = stream.ReadInt();
                    var go    = new GameObject();
                    GameObjectFromStream(stream, go);
                    list.Add(ItemTuple.Create(go, depth));
                }
            }
            else
            {
                GameObjectFromStream(stream, root);
                list.Add(ItemTuple.Create(root, 0));
                for (int i = 0; i < numSavedChildren - 1; i++)
                {
                    var depth = stream.ReadInt();
                    var go    = children[i + 1].gameObject;
                    GameObjectFromStream(stream, go);
                    list.Add(ItemTuple.Create(go, depth));
                }
            }

            // traverse forward
            for (int i = 0; i < list.Count; i++)
            {
                // foreach item going forward, we traverse backwards
                // to find the first parent item
                var forward = list[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    var backward = list[j];
                    if (forward.Item2 == backward.Item2 + 1)
                    {
                        //Debug.Log("parenting: " + forward.Item1 + " to: " + backward.Item1);
                        forward.Item1.transform.SetParent(backward.Item1.transform, true);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        public bool Member(MemberInfo member, object rawTarget, UnityObject unityTarget, int id, bool ignoreComposition, out EditorMember wrappedMember)
        {
            if (member.MemberType == MemberTypes.Method)
            {
                var method       = member as MethodInfo;
                var methodKey    = Cache.GetMethodKey(ItemTuple.Create(id, method));
                var methodDrawer = MemberDrawersHandler.GetMethodDrawer(methodKey);
                methodDrawer.Initialize(method, rawTarget, unityTarget, methodKey, this, prefs);
                wrappedMember = null;
                return(methodDrawer.OnGUI());
            }
            else
            {
                var cachedMember = Cache.GetMember(ItemTuple.Create(member, id));
                cachedMember.RawTarget   = rawTarget;
                cachedMember.UnityTarget = unityTarget;
                wrappedMember            = cachedMember;

                return(Member(cachedMember, ignoreComposition));
            }
        }
Esempio n. 3
0
 public static MemberInfo CachedGetMember(Type objType, string memberName)
 {
     return(_cachedGetMember(ItemTuple.Create(objType, memberName)));
 }