Example #1
0
        private void LoadState(byte[][] state)
        {
            ISerializer serializer = IOC.Resolve <ISerializer>();
            Type        animType   = GetSurrogateType(typeof(RuntimeAnimation));
            Type        clipType   = GetSurrogateType(typeof(RuntimeAnimationClip));

            if (serializer == null || animType == null || clipType == null)
            {
                return;
            }

            IPersistentSurrogate animationSurrogate = (IPersistentSurrogate)serializer.Deserialize(state[0], animType);

            animationSurrogate.WriteTo(Target);

            IList <RuntimeAnimationClip> clips = Target.Clips;

            for (int i = 0; i < clips.Count; ++i)
            {
                RuntimeAnimationClip clip = clips[i];
                if (clip == null)
                {
                    clips[i] = clip = ScriptableObject.CreateInstance <RuntimeAnimationClip>();
                }

                IPersistentSurrogate clipSurrogate = (IPersistentSurrogate)serializer.Deserialize(state[1 + i], clipType);
                clipSurrogate.WriteTo(clip);
            }
        }
        protected void WriteSurrogateTo(IPersistentSurrogate from, object to)
        {
            if (from == null)
            {
                return;
            }

            from.WriteTo(to);
        }