예제 #1
0
        IEnumerator PlaybackCoroutine(bool looping)
        {
START:
            float prevTime = 0;

            for (int i = 0; i < gameplayRecording.frames.Count; i++)
            {
                Frame currentFrame = gameplayRecording.frames[i];

                for (int j = 0; j < srPlayback.Length; j++)
                {
                    srPlayback[j].gameObject.SetActive(false);
                }

                for (int j = 0; j < currentFrame.spriteRenderers.Count; j++)
                {
                    SpriteRendererFrame srf = currentFrame.spriteRenderers[j];

                    srPlayback[j].gameObject.SetActive(true);

                    srPlayback[j].sprite                = SpriteDatabase.FindSpriteByName(srf.spriteName);
                    srPlayback[j].transform.position    = srf.pos;
                    srPlayback[j].transform.eulerAngles = new Vector3(0, srf.angleYZ.x, srf.angleYZ.y);
                    srPlayback[j].sortingOrder          = srf.layer;

                    Camera.main.transform.position = currentFrame.cameraPosition;
                }

                float timeToWait = prevTime == 0 ? 0.1f : currentFrame.time - prevTime;
                yield return(new WaitForSeconds(timeToWait));

                prevTime = currentFrame.time;
            }

            if (looping)
            {
                goto START; // ZOMGBBQ goto
            }
        }
예제 #2
0
        void CaptureFrame()
        {
            Frame frame = new Frame();

            gameplayRecording.frames.Add(frame);

            frame.cameraPosition = Camera.main.transform.position;
            frame.time           = Time.time;

            SpriteRenderer[] sr = GetComponentsInChildren <SpriteRenderer>();
            for (int i = 0; i < sr.Length; i++)
            {
                if (sr[i].sprite == null || !sr[i].isVisible)
                {
                    continue;
                }

                SpriteRendererFrame srFrame = new SpriteRendererFrame();

                frame.spriteRenderers.Add(srFrame);

                srFrame.spriteName = sr[i].sprite.name;

                srFrame.pos = sr[i].transform.position;

                srFrame.angleYZ.x = sr[i].transform.eulerAngles.y;
                srFrame.angleYZ.y = sr[i].transform.eulerAngles.z;

                srFrame.layer = sr[i].sortingOrder;

                //populating database
                if (SpriteDatabase.FindSpriteByName(srFrame.spriteName) == null)
                {
                    SpriteDatabase.AddSprite(sr[i].sprite, sr[i].sprite.name);
                }
            }
        }