private void UpdatePortrait(int i_Index) { if (m_Portrait == null) { return; } tnCreditsData creditsData = tnGameData.GetCreditsDataMain(i_Index); if (creditsData == null) { return; } m_Portrait.SetCharacterSprite(creditsData.characterSprite); string name = ""; name += creditsData.firstName; name += " "; name += creditsData.lastName; m_Portrait.SetName(name); m_Portrait.SetRole(creditsData.role); }
// LOGIC public void Initialize(string i_DatabasePath) { tnCreditsDatabase database = Resources.Load <tnCreditsDatabase>(i_DatabasePath); if (database != null) { for (int index = 0; index < database.entriesCount; ++index) { tnCreditsDataDescriptor descriptor = database.GetEntry(index); if (descriptor != null) { tnCreditsData data = new tnCreditsData(descriptor); m_Data.Add(data); } } for (int index = 0; index < database.specialThanksEntriesCount; ++index) { tnCreditsTextEntryDescriptor descriptor = database.GetTextEntry(index); if (descriptor != null) { tnCreditsTextEntry data = new tnCreditsTextEntry(descriptor); m_Texts.Add(data); } } } else { LogManager.LogWarning(this, "Database not loaded."); } }
// INTERNALS private void SetupPage() { if (m_Prefab == null) { return; } for (int anchorIndex = 0; anchorIndex < m_Anchors.Length; ++anchorIndex) { RectTransform anchor = m_Anchors[anchorIndex]; if (anchor == null) { continue; } // Try to get a credits data entry. tnCreditsData creditsData = tnGameData.GetCreditsDataMain(anchorIndex); if (creditsData == null) { continue; } // Create credits entry. tnUICreditsEntry creditsEntry = Instantiate <tnUICreditsEntry>(m_Prefab); creditsEntry.transform.SetParent(anchor, false); // Configure entry. creditsEntry.SetIndex(anchorIndex); creditsEntry.SetBaseImage(creditsData.baseSprite); creditsEntry.SetCharacterAnimator(creditsData.animatorController); creditsEntry.SetCharacterName(creditsData.nickname); creditsEntry.SetRole(creditsData.role); creditsEntry.SetHighlighted(false); m_Entries.Add(creditsEntry); } }