private void HandleUnitySocialEntryPointStateUpdate(EntryPointState newState) //newState contains ImageURL for profile image && NotificationCount { m_NotificationCount = newState.notificationCount; if (!string.IsNullOrEmpty(newState.imageURL)) //If we get a valid path, we want to grab the image from the internet { StartCoroutine(ChangeProfileImage(newState.imageURL)); //Coroutine because WWW queries take time } else //If the path is not valid, let's use the original image { entryPointIconImage.sprite = m_EntryPointDefaultSprite; entryPointIconImage.color = m_EntryPointDefaultColor; m_CurrentProfileSprite = null; } //Notification count update if (newState.notificationCount != 0) //If the amount of notifications != 0, we want to show how many notifications the user has { notificationBadge.SetActive(true); //Set the badge active string newText = "9+"; if (newState.notificationCount < 10 && newState.notificationCount > 0) //If the count fits in one number, let's use that { newText = newState.notificationCount.ToString(); } else { newText = " "; //In case the system returns a negative number, there are pending notifications but the amount is massive } notificationBadgeCountText.text = newText; } else //If the notification count is 0, we want to hide the notification badge { notificationBadge.SetActive(false); } }
private void UnitySocialUpdateEntryPointState(string data) { if (data != null && data.Length > 0) { Dictionary <string, object> dict = Tools.DictionaryExtensions.JsonToDictionary(data); EntryPointState newState = new EntryPointState(); if (Tools.DictionaryExtensions.TryGetValue(dict, "imageURL", out newState.imageURL) && Tools.DictionaryExtensions.TryGetValue(dict, "notificationCount", out newState.notificationCount)) { SocialOverlay.onEntryPointStateUpdated.Invoke(newState); } } }