public void LoadAllSessions() { SessionData sessionData = SessionManager.Instance.SessionData; int j = 0; for (int i = 0; i < tilesContainer.childCount; i++, j++) { if (i < sessionData.Length) { SessionData.Snipt session = SessionManager.Instance.SessionData.GetSession(i); bool havePositions = session.bowlsPositions.Length > 0; bool haveRecoding = session.recording != null; bool haveMP3 = false; Debug.Log("haveRecoding: " + haveRecoding); tilesContainer.GetChild(i).GetComponent <LibraryTileHandler>().SetTile ( session.name, new bool[3] { havePositions, haveRecoding, true } ); tilesContainer.GetChild(i).gameObject.SetActive(true); } else { if (!tilesContainer.GetChild(i).gameObject.activeInHierarchy) { break; } tilesContainer.GetChild(i).gameObject.SetActive(false); } } for (int i = j; i < sessionData.Length; i++) { SessionData.Snipt session = SessionManager.Instance.SessionData.GetSession(i); bool havePositions = session.bowlsPositions.Length > 0; bool haveRecoding = session.recording != null; bool haveMP3 = false; Debug.Log("haveRecoding: " + haveRecoding); Instantiate(sessionTile, tilesContainer).GetComponent <LibraryTileHandler>().SetTile ( session.name, new bool[3] { havePositions, haveRecoding, true } ).SetActive(true); } // Refresh content transform.GetChild(1).gameObject.SetActive(false); transform.GetChild(1).gameObject.SetActive(true); guidelineText.SetActive(sessionData.Length <= 0); }
public void SaveSession(string name, Recording recording = null) { int[] tempSession = Inventory.bowlsManager.activeBowlsIndexes; SessionData.Snipt newSession = new SessionData.Snipt { name = name }; if (recording != null) { newSession.recording = new Recording(); newSession.recording.DeepCopy(recording); } newSession.bowlsPositions = new int[tempSession.Length]; newSession.panings = new float[tempSession.Length]; newSession.volumes = new float[tempSession.Length]; for (int i = 0; i < tempSession.Length; i++) { // for creating a deep copy of session newSession.bowlsPositions[i] = tempSession[i]; if (newSession.bowlsPositions[i] != -1) { Debug.Log("Saving: " + Inventory.allBowls[newSession.bowlsPositions[i]].AudioSource.panStereo); newSession.panings[i] = Inventory.allBowls[newSession.bowlsPositions[i]].AudioSource.panStereo; newSession.volumes[i] = Inventory.allBowls[newSession.bowlsPositions[i]].AudioSource.volume; } } // SessionData.Snipt newSession = new SessionData.Snipt { // name = name, // volumes = volumes, // panings = panings, // bowlsPositions = session, // recording = recording // }; SessionData.AddSession(newSession); PersistantData.Save(SessionData); }
public void LoadSession(string name, bool playRecording = false) { currentSessionSnipt = SessionData.GetSession(name); Inventory.bowlsManager.activeBowlsIndexes = new int[currentSessionSnipt.bowlsPositions.Length]; for (int i = 0; i < Inventory.bowlsManager.activeBowlsIndexes.Length; i++) { // to create a deep copy Inventory.bowlsManager.activeBowlsIndexes[i] = currentSessionSnipt.bowlsPositions[i]; if (Inventory.bowlsManager.activeBowlsIndexes[i] != -1) { Inventory.allBowls[Inventory.bowlsManager.activeBowlsIndexes[i]].AudioSource.panStereo = currentSessionSnipt.panings[i]; Inventory.allBowls[Inventory.bowlsManager.activeBowlsIndexes[i]].AudioSource.volume = currentSessionSnipt.volumes[i]; } } Inventory.bowlsManager.SetUpBowls(true); PlayRecording(playRecording); }