using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using UnityEditor; using DiamondArrow.Platform; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace DiamondArrow.Editor { // Drives the actual UI through raycasted pointer events. Uses a temporary save store. public static class PlayModeValidation { static DiamondArrowGame game; static PlayerSave original; static SaveStore originalStore; static Queue steps; static double next; static List results; static readonly BindingFlags Private=BindingFlags.Instance|BindingFlags.NonPublic; public static string Status="Not started"; static int nextArrow; static float pausedTime; public static void Begin() { if(!EditorApplication.isPlaying)throw new InvalidOperationException("Enter Play Mode first"); if(Status=="Running")throw new InvalidOperationException("Validation is already running"); AssetDatabase.DisallowAutoRefresh();AssemblyReloadEvents.beforeAssemblyReload+=BeforeReload; game=UnityEngine.Object.FindFirstObjectByType();original=game.Save;originalStore=(SaveStore)typeof(DiamondArrowGame).GetField("store",Private).GetValue(game); typeof(DiamondArrowGame).GetProperty("Save").SetValue(game,new PlayerSave());typeof(DiamondArrowGame).GetField("store",Private).SetValue(game,new SaveStore(Path.Combine(Application.temporaryCachePath,"DiamondArrowValidation"))); game.Save.InitializeGuest(new System.Random(7)); var services = game.GetComponentInChildren(); string request = null; services.EditorShowReward = id => request = id; Directory.CreateDirectory("Library/DiamondArrowValidation"); results=new List();steps=new Queue();Status="Running"; Add(()=>{game.ShowStart();Capture("start_750x1334");},"Start screen"); Add(()=>{Check(game.GetComponentsInChildren