void IPersistantUnityObject.OnDeserialize(SerializationInfo info, StreamingContext context, IAssetBundle assetBundle)
        {
            this.transform.position   = (Vector3)info.GetValue("pos", typeof(Vector3));
            this.transform.rotation   = (Quaternion)info.GetValue("rot", typeof(Quaternion));
            this.transform.localScale = (Vector3)info.GetValue("scale", typeof(Vector3));

            int cnt = info.GetInt32("count");

            if (cnt > 0)
            {
                using (var lst = TempCollection.GetList <IPersistantUnityObject>())
                {
                    this.GetComponentsInChildren <IPersistantUnityObject>(true, lst);
                    for (int i = 0; i < cnt; i++)
                    {
                        ChildObjectData data = (ChildObjectData)info.GetValue(i.ToString(), typeof(ChildObjectData));
                        if (data != null && data.ComponentType != null)
                        {
                            IPersistantUnityObject pobj = (from o in lst where o.Uid == data.Uid select o).FirstOrDefault();
                            if (pobj != null)
                            {
                                pobj.OnDeserialize(data.DeserializeInfo, data.DeserializeContext, assetBundle);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void IPersistantUnityObject.OnDeserialize(SerializationInfo info, StreamingContext context, IAssetBundle assetBundle)
        {
            this.transform.position   = (Vector3)info.GetValue("pos", typeof(Vector3));
            this.transform.rotation   = (Quaternion)info.GetValue("rot", typeof(Quaternion));
            this.transform.localScale = (Vector3)info.GetValue("scale", typeof(Vector3));

            int cnt = info.GetInt32("count");

            for (int i = 0; i < cnt; i++)
            {
                ChildObjectData data = (ChildObjectData)info.GetValue(i.ToString(), typeof(ChildObjectData));
                if (data != null && data.ComponentType != null)
                {
                    IPersistantUnityObject pobj = ComponentUtil.GetComponentFromSource(data.ComponentType, (data.Path != null) ? this.transform.Find(data.Path) : this.transform) as IPersistantUnityObject;
                    if (pobj != null)
                    {
                        pobj.OnDeserialize(data.DeserializeInfo, data.DeserializeContext, assetBundle);
                    }
                }
            }
        }