private static Sprite GetSprite(string path) { path = MetaLoadUtil.GetPath(path); Sprite sprite = null; if (!spriteCache.TryGetValue(path, out sprite)) { if (File.Exists(path)) { var fileData = File.ReadAllBytes(path); var texture = new Texture2D(2, 2); texture.LoadImage(fileData); var squareSize = Mathf.Min(texture.width, texture.height); var rect = new Rect(0, 0, texture.width, texture.height); var pivot = new Vector2(0.5f, 0.5f); sprite = Sprite.Create(texture, rect, pivot, squareSize); spriteCache[path] = sprite; } else { Debug.LogError($"Sprite at {path} cannot be found!"); } } return(sprite); }
private static void ParseData() { // Debug.Log("KeyValueFormatParser::ParseData()"); var path = MetaLoadUtil.GetPath(DataPath); keyValuePairs = KeyValueFormatParser.Parse(path); if (keyValuePairs == null) { Debug.LogError($"Data file does not exist at {path}!"); } }
private void Win() { if (won) { return; } var videoPath = MetaLoadUtil.GetPath(videoLocation); var fileInfo = new FileInfo(videoPath); if (!fileInfo.Exists) { var message = $"Victory video not found in {videoPath}! (TODD SAYS TO GET IT FROM https://chaosed0.github.io/GGJ2020/Victory.video)"; OnGameCrashed?.Invoke(); #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN Util.OnNextFrame(this, () => tinyfd.tinyfd_beep()); Util.OnNextFrame(this, () => tinyfd.tinyfd_messageBox("Error!", "Consult crash.log for more details", "ok", "error", 1)); #endif using (var writer = new StreamWriter(crashDataLocation, false)) { writer.Write(message); } if (!Application.isEditor) { Debug.LogError(message); Utils.ForceCrash(ForcedCrashCategory.Abort); } else { Debug.Log(message); } } else { var videoPlayer = Camera.main.GetComponent <VideoPlayer>(); videoPlayer.Play(); won = true; OnVictory?.Invoke(); } }