Exemplo n.º 1
0
        /// <summary>
        /// Allows the caller to play an animation clip during edit mode. This form of animation playback is limited as
        /// you have no control over clip properties, and features like blending, cross fade or animation events are not
        /// supported.
        ///
        /// Caller will need to manually call <see cref="UpdateFloatProperties"/> in order to apply evaluated animation data
        /// to relevant float properties (if required).
        ///
        /// Caller will also need to manually call <see cref="RefreshClipMappings"/> whenever the curves internal to the
        /// animation clip change. This should be called before the call to <see cref="UpdateFloatProperties"/>.
        /// </summary>
        /// <param name="clip">Animation clip to play.</param>
        /// <param name="startTime">Time to start playing at, in seconds.</param>
        /// <param name="freeze">If true, only the frame at the specified time will be shown, without advancing the
        ///                      animation.</param>
        internal void EditorPlay(RRef <AnimationClip> clip, float startTime, bool freeze = false)
        {
            bool inPreviewMode = Internal__togglePreviewMode(mCachedPtr, true);

            if (!inPreviewMode)
            {
                return;
            }

            if (freeze)
            {
                Sample(clip, startTime);
            }
            else
            {
                AnimationClipState clipState = AnimationClipState.Default();
                clipState.time = startTime;

                SetState(clip, clipState);
            }

            Internal__refreshClipMappings(mCachedPtr);
        }