void Start() { Button[] button = GameObject.Find("SaveContent").GetComponentsInChildren<Button>(); int i = 0; foreach(Button btn in button) { Text txt = btn.GetComponentInChildren<Text>(true); //SaveFileUtility.LoadSave(i); if(SaveFileUtility.IsSlotUsed(i)) { txt.fontSize = 13; txt.alignment = TextAnchor.UpperRight; DateTime timeSaved = SaveMaster.GetSaveCreationTime(i); txt.text = timeSaved.ToString("dd MMMM yyyy hh:mm:ss tt"); //txt.text = "Saved Slot"; } else if(!SaveFileUtility.IsSlotUsed(i)){ txt.fontSize = 16; txt.alignment = TextAnchor.MiddleCenter; txt.text = "New Slot"; } i++; } }
public static SaveGame LoadSave(int slot, bool createIfEmpty = false) { if (slot < 0) { Debug.LogWarning("Attempted to load negative slot"); return(null); } #if UNITY_WEBGL && !UNITY_EDITOR SyncFiles(); #endif string savePath = ""; if (SaveFileUtility.ObtainSavePaths().TryGetValue(slot, out savePath)) { SaveGame saveGame = LoadSaveFromPath(savePath); if (saveGame == null) { cachedSavePaths.Remove(slot); return(null); } Log(string.Format("Succesful load at slot (from cache): {0}", slot)); return(saveGame); } else { if (!createIfEmpty) { Log(string.Format("Could not load game at slot {0}", slot)); } else { Log(string.Format("Creating save at slot {0}", slot)); SaveGame saveGame = new SaveGame(); WriteSave(saveGame, slot); return(saveGame); } return(null); } }