// Update is called once per frame void Update() { //Shortcuts if (Input.GetKeyDown(RecordKey)) { Player.Record(); } if (Input.GetKeyDown(ReplayKey)) { Player.Replay(); } if (Input.GetKeyDown(PauseKey)) { Player.Pause(); } }
public virtual void OnGUI() { ShowOptions = GUI.Toggle(new Rect(0, 0, StandardWidth, StandardHeight), ShowOptions, (ShowOptions ? "Hide" : "Show") + KeyToText(HideKey)); if (ShowOptions) { UseXml = GUI.Toggle(new Rect(0, StandardHeight, StandardWidth, StandardHeight), UseXml, "Use XML"); GUI.skin.label.fontSize = GUI.skin.button.fontSize = GUI.skin.textField.fontSize = GUI.skin.toggle.fontSize = _fontSize; if (!Player.Recording) { if (GUI.Button(new Rect(StandardWidth * 2, 0, StandardWidth, StandardHeight), (Player.Replaying ? "Stop" : "Replay") + (KeyInput != null ? KeyToText(KeyInput.ReplayKey) : ""))) { Player.Replay(); } //Compression options Player.UseZip = GUI.Toggle(new Rect(0, StandardHeight * 3, StandardWidth, StandardHeight), Player.UseZip, "Zip"); if (Player.UseZip) { Player.UseCompoundArchive = GUI.Toggle(new Rect(0, StandardHeight * 4, StandardWidth, StandardHeight), Player.UseCompoundArchive, "Archive"); if (Player.UseCompoundArchive) { Player.CompoundZipName = GUI.TextField( new Rect(0, StandardHeight * 5, StandardWidth, StandardHeight), Player.CompoundZipName, 25); } } if (Player.Replaying) { { //Pause/Unpause button if (GUI.Button(new Rect(StandardWidth * 2, StandardHeight, StandardWidth, StandardHeight), (Player.Playing ? "Pause" : "Unpause") + (KeyInput != null ? KeyToText(KeyInput.PauseKey) : ""))) { Player.Pause(); } //Index float index = GUI.HorizontalSlider(new Rect(StandardWidth * 2, StandardHeight * 2, StandardWidth, StandardHeight), Player.Index, 0, Player.FrameCount); if (index != Player.Index) { Player.SetIndex(index, false); } //Speed Player.Speed = GUI.HorizontalSlider(new Rect(StandardWidth * 2, StandardHeight * 3, StandardWidth, StandardHeight), Player.Speed, 0.1f, 2); Player.Speed = Mathf.Clamp(Single.Parse(GUI.TextField(new Rect(StandardWidth * 2, StandardHeight * 4, StandardWidth, StandardHeight), Player.Speed.ToString(), 25)), 0.1f, 2); } } //Multi-replay handling if (XmlData != null && XmlData.Files.Length > 1) { // Progress bar GUI.DrawTexture(new Rect(Screen.width - StandardWidth, Screen.height - StandardHeight, StandardWidth, StandardHeight), _noProgressBar); GUI.DrawTexture(new Rect(Screen.width - StandardWidth, Screen.height - StandardHeight, StandardWidth * ((XmlDataIndex + 1.0f) / XmlData.Files.Length), StandardHeight), _progressBar); //Previous replay if (XmlDataIndex > 0) { if (GUI.Button(new Rect(0, Screen.height / 2f, Screen.width / 10f, Screen.height / 5f), "Previous")) { XmlDataIndex--; FileInfo data = XmlData.Files[XmlDataIndex]; Player.Load(data.Zip, data.FileName, data.EntryName); Player.SetIndex(0, false); Player.Speed = 1; Player.Replay(); Player.Replay(); } } //Next replay if (XmlDataIndex < XmlData.Files.Length - 1) { if (GUI.Button( new Rect(Screen.width * 0.9f, Screen.height / 2f, Screen.width / 10f, Screen.height / 5f), "Next")) { XmlDataIndex++; FileInfo data = XmlData.Files[XmlDataIndex]; Player.Load(data.Zip, data.FileName, data.EntryName); Player.SetIndex(0, false); Player.Speed = 1; Player.Replay(); Player.Replay(); } } } } } }