public bool IsAnimatable(PropertyModification[] modifications)
        {
            // search playable assets
            for (int i = 0; i < modifications.Length; i++)
            {
                var iAsset = modifications[i].target as IPlayableAsset;
                if (iAsset != null)
                {
                    var curvesOwner = AnimatedParameterUtility.ToCurvesOwner(iAsset, state.editSequence.asset);
                    if (curvesOwner != null && curvesOwner.HasAnyAnimatableParameters() && curvesOwner.IsParameterAnimatable(modifications[i].propertyPath))
                    {
                        return(true);
                    }
                }
            }

            // search recordable game objects
            foreach (var gameObject in TimelineRecording.GetRecordableGameObjects(state))
            {
                for (int i = 0; i < modifications.Length; ++i)
                {
                    var modification = modifications[i];
                    if (AnimationWindowUtility.PropertyIsAnimatable(modification.target, modification.propertyPath, gameObject))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #2
0
        // Helper that finds the animation clip we are recording and the relative time to that clip
        static bool GetClipAndRelativeTime(UnityEngine.Object target, WindowState state,
                                           out AnimationClip outClip, out double keyTime, out bool keyInRange)
        {
            const float floatToDoubleError = 0.00001f;

            outClip    = null;
            keyTime    = 0;
            keyInRange = false;

            double        startTime = 0;
            double        timeScale = 1;
            AnimationClip clip      = null;

            IPlayableAsset playableAsset = target as IPlayableAsset;
            Component      component     = target as Component;

            // Handle recordable playable assets
            if (playableAsset != null)
            {
                var curvesOwner = AnimatedParameterUtility.ToCurvesOwner(playableAsset, state.editSequence.asset);
                if (curvesOwner != null)
                {
                    if (curvesOwner.curves == null)
                    {
                        curvesOwner.CreateCurves(curvesOwner.GetUniqueRecordedClipName());
                    }

                    clip = curvesOwner.curves;

                    var timelineClip = curvesOwner as TimelineClip;
                    if (timelineClip != null)
                    {
                        startTime = timelineClip.start;
                        timeScale = timelineClip.timeScale;
                    }
                }
            }
            // Handle recording components, including infinite clip
            else if (component != null)
            {
                var asset = GetTrackForGameObject(component.gameObject, state);
                if (asset != null)
                {
                    clip = GetRecordingClip(asset, state, out startTime, out timeScale);
                }
            }

            if (clip == null)
            {
                return(false);
            }

            keyTime    = (state.editSequence.time - startTime) * timeScale;
            outClip    = clip;
            keyInRange = keyTime >= 0 && keyTime <= (clip.length * timeScale + floatToDoubleError);

            return(true);
        }
コード例 #3
0
        static bool ProcessPlayableAssetModification(UndoPropertyModification mod, WindowState state)
        {
            var target = GetTarget(mod) as IPlayableAsset;
            if (target == null)
                return false;

            var curvesOwner = AnimatedParameterUtility.ToCurvesOwner(target, state.editSequence.asset);
            if (curvesOwner == null || !curvesOwner.HasAnyAnimatableParameters())
                return false;

            return ProcessPlayableAssetRecording(mod, state, curvesOwner);
        }
コード例 #4
0
        static bool ProcessPlayableAssetModification(UndoPropertyModification mod, WindowState state)
        {
            var target = GetTarget(mod) as IPlayableAsset;

            if (target == null)
            {
                return(false);
            }

            var curvesOwner = AnimatedParameterUtility.ToCurvesOwner(target, state.editSequence.asset);

            if (curvesOwner == null || !state.IsTrackRecordable(curvesOwner.targetTrack))
            {
                return(false);
            }

            return(ProcessPlayableAssetRecording(mod, state, curvesOwner));
        }