Example #1
0
        public void LoadFromAnimator(MeshAnimator other)
        {
            meshes.Clear();
            models.Clear();
            modelMeshFilters.Clear();

            meshes.AddRange(other.meshes);
            models.AddRange(other.models);
            modelMeshFilters.AddRange(other.modelMeshFilters);

            meshFilterType  = other.meshFilterType;
            meshNameFilter  = other.meshNameFilter;
            modelFilterType = other.modelFilterType;
            modelNameFilter = other.modelNameFilter;
            autoSortModels  = other.autoSortModels;

            currentMeshIndex     = other.currentMeshIndex;
            framerate            = other.framerate;
            direction            = other.direction;
            playback             = other.playback;
            frameInterval        = other.frameInterval;
            frameIntervalCounter = other.frameIntervalCounter;
            paused = other.paused;
        }
Example #2
0
        void UpdateIndex()
        {
            while (frameIntervalCounter >= frameInterval)
            {
                switch (direction)
                {
                case MeshAnimatorPlaybackDirection.Forwards:

                    currentMeshIndex++;

                    switch (playback)
                    {
                    case MeshAnimatorPlaybackType.Loop:
                        if (currentMeshIndex >= meshes.Count)
                        {
                            currentMeshIndex = 0;
                            didLoop          = true;
                        }
                        break;

                    case MeshAnimatorPlaybackType.PingPong:
                        if (currentMeshIndex >= meshes.Count - 1)
                        {
                            if (meshes.Count == 1)
                            {
                                currentMeshIndex = 0;
                            }
                            else
                            {
                                currentMeshIndex = meshes.Count - 2;
                            }
                            direction = MeshAnimatorPlaybackDirection.Backwards;
                            didLoop   = true;
                        }
                        break;

                    case MeshAnimatorPlaybackType.PlayOnce:
                        if (currentMeshIndex >= meshes.Count)
                        {
                            paused = true;
                        }
                        break;
                    }
                    break;

                case MeshAnimatorPlaybackDirection.Backwards:

                    currentMeshIndex--;

                    switch (playback)
                    {
                    case MeshAnimatorPlaybackType.Loop:
                        if (currentMeshIndex < 0)
                        {
                            currentMeshIndex = meshes.Count - 1;
                            didLoop          = true;
                        }
                        break;

                    case MeshAnimatorPlaybackType.PingPong:
                        if (currentMeshIndex < 0)
                        {
                            if (meshes.Count == 1)
                            {
                                currentMeshIndex = 0;
                            }
                            else
                            {
                                currentMeshIndex = 1;
                            }
                            direction = MeshAnimatorPlaybackDirection.Forwards;
                            didLoop   = true;
                        }
                        break;

                    case MeshAnimatorPlaybackType.PlayOnce:
                        if (currentMeshIndex < 0)
                        {
                            paused = true;
                        }
                        break;
                    }

                    break;
                }


                frameIntervalCounter -= frameInterval;
            }
        }