Beispiel #1
0
        protected override void OnUpdate()
        {
            var sprites = group.GetComponentDataArray <AnimationSpriteData>();
            var anims   = group.GetSharedComponentDataArray <AnimationData>();

            float delta = UnityEngine.Time.deltaTime;

            for (int i = 0; i < sprites.Length; i++)
            {
                AnimationSpriteData sprite = sprites[i];
                AnimationData       anim   = anims[i];

                Process(ref sprite, ref anim, delta);

                sprites[i] = sprite;
            }
        }
Beispiel #2
0
        protected virtual void OnRender(ref int[] sort)
        {
            var sprites = group.GetComponentDataArray <AnimationSpriteData>();
            var pos     = group.GetComponentDataArray <PositionData>();
            var meshes  = group.GetSharedComponentDataArray <SpriteMeshesData>();

            cmd.Clear();


            cmd.SetViewProjectionMatrices(camera.worldToCameraMatrix, UnityEngine.GL.GetGPUProjectionMatrix(camera.projectionMatrix, false));

            //for(int i=0; i<sprites.Length; i++)
            for (int indx = 0; indx < sort.Length; indx++)
            {
                int i = sort[indx];
                AnimationSpriteData sprite   = sprites[i];
                PositionData        position = pos[i];
                SpriteMeshesData    mesh     = meshes[i];

                cmd.DrawMesh(mesh.Meshes[sprite.spriteIndx], UnityEngine.Matrix4x4.Translate(position.Value), material);
            }
        }
Beispiel #3
0
        void Process(ref AnimationSpriteData sprite, [ReadOnly] ref AnimationData anim, float delta)
        {
            float time       = sprite.time;
            int   spriteImdx = sprite.spriteIndx;

            float interval = anim.interval;
            float count    = anim.count;

            time += delta;
            while (interval <= time)
            {
                time       -= interval;
                spriteImdx += 1;

                //if(count <= spriteImdx)
                if (5 <= spriteImdx)
                {
                    spriteImdx = 3;                    //0;
                }
            }

            sprite.time       = time;
            sprite.spriteIndx = spriteImdx;
        }