| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
- using UnityEditor;
- using UnityEngine;
- namespace HexaCrazy.Editor
- {
- public static class HexUIRevisionCapture
- {
- static string Folder=>Path.GetFullPath("output/qa/ui-v2");
- [MenuItem("Hexa Crazy/Capture UI Revision (Play Mode)")]
- public static void Capture()
- {
- if(!EditorApplication.isPlaying)throw new System.InvalidOperationException("Enter Play Mode first.");
- var app=Object.FindAnyObjectByType<HexGameApp>();app.StartCoroutine(Run(app));
- }
- static IEnumerator Shot(string name)
- {
- yield return new WaitForSecondsRealtime(.5f);yield return new WaitForEndOfFrame();
- ScreenCapture.CaptureScreenshot(Path.Combine(Folder,name+".png"));yield return new WaitForSecondsRealtime(.2f);
- }
- static IEnumerator Run(HexGameApp app)
- {
- Directory.CreateDirectory(Folder);Directory.CreateDirectory(Path.Combine(Folder,"frames"));
- HexProjectBuilder.SetGameView(750,1334);app.UseReviewProfile(Path.Combine(Folder,"review-profile.json"));app.Profile.Reset();
- app.Profile.Data.reduceMotion=true;app.Profile.Data.music=false;app.Profile.Data.sound=false;
- app.GetComponent<HexAudio>().Music=false;app.GetComponent<HexAudio>().Sound=false;
- app.SetMode(2);yield return Shot("lobby");app.PreviewApprovedGameplay();yield return Shot("game");
- app.OpenPanel("shop");yield return Shot("shop");app.ClosePanel();
- app.OpenPanel("draw");yield return Shot("draw");app.ClosePanel();
- app.StartLevel(2,20,true);yield return Shot("max-board");
- HexProjectBuilder.SetGameView(1125,2436);app.SetMode(2);yield return Shot("long-lobby");app.PreviewApprovedGameplay();yield return Shot("long-game");
- HexProjectBuilder.SetGameView(750,1334);app.SetMode(0);yield return new WaitForSecondsRealtime(.4f);app.Profile.Data.reduceMotion=false;
- var times=new List<string>();int frame=0;
- for(int step=0;step<3;step++)
- {
- app.SetMode((step+1)%3);float until=Time.realtimeSinceStartup+1;
- while(Time.realtimeSinceStartup<until)
- {
- yield return new WaitForEndOfFrame();var texture=ScreenCapture.CaptureScreenshotAsTexture();
- times.Add(Time.realtimeSinceStartup.ToString("F5",CultureInfo.InvariantCulture));
- File.WriteAllBytes(Path.Combine(Folder,"frames",frame.ToString("D4")+".jpg"),texture.EncodeToJPG(88));Object.Destroy(texture);frame++;
- yield return new WaitForSecondsRealtime(.025f);
- }
- }
- File.WriteAllLines(Path.Combine(Folder,"frame-times.txt"),times);File.WriteAllText(Path.Combine(Folder,"capture-complete.txt"),System.DateTimeOffset.UtcNow.ToString("O"));
- Debug.Log("HEXA_UI_REVISION_CAPTURE_COMPLETE");
- }
- }
- }
|