/// <summary> /// Initialization method. Gets news from PlayFab, and shows a random one. /// </summary> void OnEnable() { gameNews = PlayFabManager.instance.gameNews; if (gameNews != null) { TitleNewsItem randomNews = gameNews[Random.Range(0, gameNews.Count)]; newsHeadline.text = randomNews.Title; newsBody.text = randomNews.Body; } }
private void NotifyClients(TitleNewsItem newsItem) { foreach (var uconn in UnityNetworkingData.Connections) { Logger.Dispatch(LoggerTypes.Info, string.Format("Sending Title News to client {0}", uconn.ConnectionId)); uconn.Connection.Send(1010, new TitleNewsItemMessage { NewsId = newsItem.NewsId, Title = newsItem.Title, Timestamp = newsItem.Timestamp, Body = newsItem.Body }); } }
/// <summary> /// 初期化する。 /// </summary> /// <param name="news"></param> public void Initialize(TitleNewsItem news) { _timestampText.text = (news.Timestamp + TimeSpan.FromHours(9)).ToString("g"); _titleText.text = news.Title; _button.OnClickAsObservable().ThrottleFirst(TimeSpan.FromMilliseconds(500)).Subscribe(_ => MessageDialog.ShowAsync(news.Body).Forget()); }