コード例 #1
0
 private void UpdateText()
 {
     if (scrollArea)
     {
         var nameText = scrollArea.transform.Find("NameText");
         if (nameText)
         {
             nameText.gameObject.GetComponent <TextMesh>().text = globalVars.PlayerName;
         }
         var postsText = scrollArea.transform.Find("PostsText");
         if (postsText)
         {
             var postCount = dgSerializer.GetPosts().Count;
             postsText.gameObject.GetComponent <TextMesh>().text = postCount.ToString();
         }
         var followersText = scrollArea.transform.Find("FollowersText");
         if (followersText)
         {
             var followers = dgSerializer.Followers;
             followersText.gameObject.GetComponent <TextMesh>().text = followers.ToString();
         }
         var moneyText = scrollArea.transform.Find("MoneyText");
         if (moneyText)
         {
             var cash = globalVars.TotalCash;
             if (cash > 0.0f)
             {
                 var formattedCash = cash.ToString("C2");
                 moneyText.gameObject.GetComponent <TextMesh>().text = formattedCash;
             }
             else
             {
                 moneyText.gameObject.GetComponent <TextMesh>().text = "$0.00";
             }
         }
     }
 }
コード例 #2
0
    private void GeneratePostObjects()
    {
        foreach (GameObject post in postObjects)
        {
            Destroy(post);
        }

        var pastPosts = serializer.GetPosts();

        pastPosts.Sort((a, b) => b.dateTime.CompareTo(a.dateTime));

        var currentY = scrollArea.transform.position.y + 1.5f;

        foreach (DelayGramPost post in pastPosts)
        {
            var newPost = SetupPostPrefab(post, currentY);

            currentY -= lengthBetweenPosts;
            postObjects.Add(newPost);
        }

        scrollController = scrollArea.AddComponent <ScrollController>();
        scrollController.UpdateScrollArea(scrollArea, scrollArea.transform.localPosition.y, -currentY);
    }