Пример #1
0
        public void Play(int index, float crossFadeTime = 0.25f)
        {
            //first play
            if (oldAnimIndex < 0)
            {
                oldAnimIndex = index;
            }

            if (index >= manifest.animInfos.Count || oldAnimIndex >= manifest.animInfos.Count)
            {
                Debug.Log("Index : " + index.ToString() + " out");
                return;
            }

            AnimTextureClipInfo oldClipInfo  = manifest.animInfos[oldAnimIndex];
            AnimTextureClipInfo nextClipInfo = manifest.animInfos[index];

            block.SetVector(ID_START_END_FRAME, new Vector4(nextClipInfo.startFrame, nextClipInfo.endFrame, oldClipInfo.startFrame, oldClipInfo.endFrame));
            float curPlayTime = Shader.GetGlobalVector(ID_UNITY_TIME).y;

            block.SetVector(ID_ANIM_PARAM0, new Vector4(curPlayTime, nextClipInfo.isLoop == true ? 0 : 1, nextClipInfo.speed, 1.0f / nextClipInfo.frameRate));
            block.SetVector(ID_ANIM_PARAM1, new Vector4(lastPlayTime, oldClipInfo.isLoop == true ? 0 : 1, oldClipInfo.speed, (crossFadeTime == 0)? 9999999.0f : 1.0f / crossFadeTime));
            lastPlayTime = curPlayTime;

            render.SetPropertyBlock(block);
            oldAnimIndex = index;
            animName     = nextClipInfo.clipName;
        }
Пример #2
0
        void UpdateAnimTime(int index, int startNameHash, int endNameHash)
        {
            curClipInfo = manifest.animInfos[index];

            block.SetFloat(startNameHash, curClipInfo.startFrame);
            block.SetFloat(endNameHash, curClipInfo.endFrame);
            needUpdateBlock = true;
        }