Example #1
0
        /// <summary>
        /// Called by the replay system when the object should return to a previous state.
        /// </summary>
        /// <param name="state">The state object to deserialize the animator from</param>
        public override void OnReplayDeserialize(ReplayState state)
        {
            // Check for animator
            if (observedAnimator == null)
            {
                return;
            }

            // Read the number of layers
            int layerCount = state.Read32();

            // Check if we need to reallocate
            if (layerCount > animatorStates.Length)
            {
                animatorStates = new ReplayAnimatorState[layerCount];
            }

            // Read all layer information
            for (int i = 0; i < layerCount; i++)
            {
                // Update last values
                animatorStates[i].lastHash           = animatorStates[i].targetHash;
                animatorStates[i].lastNormalizedTime = animatorStates[i].targetNormalizedTime;

                // Deserialize animator values
                animatorStates[i].targetHash           = state.Read32();
                animatorStates[i].targetNormalizedTime = state.ReadFloat();
            }

            // Check for paused
            if (ReplayManager.IsPaused == true)
            {
                observedAnimator.speed = 0;
            }
        }
Example #2
0
        public override void OnReplayDeserialize(ReplayState state)
        {
            // Require particle system
            if (observedParticleSystem == null)
            {
                return;
            }

            // Save the last time
            lastTime = targetTime;

            // Read the target simulation time
            targetTime = state.ReadFloat();

            observedParticleSystem.Simulate(targetTime - lastTime, true, false);
        }