public static void SaveInitialSnapshot(PolyGraph graph) { string path = string.Format( "{0}/{1}/{2}/{3}", Application.dataPath, Paths.AssetArtworksNoPrefix, graph.name, Paths.SnapshotFile); string saveName = graph.name + '_' + Paths.Snapshot; var go = new GameObject(saveName); var holder = go.AddComponent <PuzzleSnapshotHolder>(); PuzzleSnapshotOneOff.Take(graph, null, path); holder.texture = AssetDatabase.LoadAssetAtPath <Texture2D>(Paths.ToAssetPath(path)); string prefabPath = string.Format( "{0}/{1}/{2}.prefab", Paths.AssetResArtworks, graph.name, saveName); UnityEngine.Object prefab = PrefabUtility.CreatePrefab(prefabPath, go); PrefabUtility.ReplacePrefab(go, prefab, ReplacePrefabOptions.ConnectToPrefab); GameObject.DestroyImmediate(go); }
public void OnDestroy() { FUI.Instance.ClosePanel <PuzzlePanel>(); var puzzle = Puzzle.Current; if (null != puzzle) { puzzle.SaveProgress(); PuzzleSnapshotOneOff.Take(puzzle.puzzleName, puzzle.finished); GameEvent.Instance.Fire(GameEvent.ReloadItem, puzzle.puzzleName); } }
public static void RetakeExpiredSnapshot() { string puzzleName = "unknown"; try { if (File.Exists(Paths.SnapshotMark)) { puzzleName = File.ReadAllText(Paths.SnapshotMark, Encoding.UTF8); string path = ProgressFolder(puzzleName) + Filename; string json = File.ReadAllText(path, Encoding.UTF8); Progress p = JsonUtility.FromJson <Progress>(json); PuzzleSnapshotOneOff.Take(puzzleName, p.finishedFlags); File.Delete(Paths.SnapshotMark); GameLog.LogFormat("[{0}] Retake snapshot", puzzleName); } } catch (Exception e) { GameLog.LogErrorFormat("[{0}] Failed to retake expired snapshot", puzzleName); GameLog.LogException(e); } }