private static void PopAchievement(PermanentAchievementManager.Achievement achievement) { var assetReference = PermanentAchievementManager.ReturnSpriteAssetReference(achievement); _activeAchievements++; AssetReferenceLoader.LoadAssetReferenceAsynchronously <Sprite>(assetReference, (returnVariable) => { var popUp = PopUps.Dequeue(); popUp.transform.SetSiblingIndex(_maximumNumberOfActiveAchievements - 1); popUp.Show(returnVariable, StringUtilities.AddSpacesBeforeCapitals(achievement.ToString()), PermanentAchievementManager.ReturnDescription(achievement), PermanentAchievementManager.ReturnReward(achievement), () => { _activeAchievements--; PopUps.Enqueue(popUp); popUp.gameObject.SetActive(false); }); AssetReferenceLoader.UnloadAssetReference(assetReference); Instance.StartCoroutine(Instance.HandleDelayedAdditions()); }); }
private void CreateListItemAsynchronously(PermanentAchievementManager.Achievement itemName, string description, int reward, AssetReference sprite, bool unlocked) { var achievementItemGameObject = Instantiate(DisplayItemAddressableAsGameObject, Display).GetComponentInChildren <AchievementListItem>(); var achievementItemGameObjectTransform = achievementItemGameObject.transform; achievementItemGameObjectTransform.SetParent(Display); achievementItemGameObjectTransform.localScale = Vector3.one; _achievementListItems.Add(itemName, new AchievementItemStruct(achievementItemGameObject.Background, achievementItemGameObject.ReturnNameDisplay, achievementItemGameObject.ReturnDescriptionDisplay, achievementItemGameObject.ReturnRewardDisplay, achievementItemGameObject.ReturnGraphic, unlocked)); _achievementListItems[itemName].NameDisplay.text = StringUtilities.AddSpacesBeforeCapitals(itemName.ToString()); _achievementListItems[itemName].DescriptionDisplay.text = description; _achievementListItems[itemName].RewardDisplay.text = reward.ToString(); if (unlocked) { SetUnlockedState(itemName); } AssetReferenceLoader.LoadAssetReferenceAsynchronously <Sprite>(sprite, (returnSprite) => { _achievementListItems[itemName].Graphic.sprite = returnSprite; achievementItemGameObject.RemoveClassFromObject(); if (sprite.Asset) { AssetReferenceLoader.UnloadAssetReference(sprite); //TODO: cant unload sprites in use } }); }