Getting no results in textmeshpro while trying to write text in it with c#

So im trying to make a story line for the unity game which is already complete. everything was going swimmingly but this script. here it is:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using System.Text;
using System.Threading.Tasks;
using TMPro;
public class storyLineController : MonoBehaviour
{
public FPSController fpc;
public vechileSwitch vs;
private readonly string folderpath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}too-bad-to-be-true";
byte[] bytes = null;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
public List<string> messages = new List<string>();
public TextMeshProUGUI messagesPlaceholder;
public TextMeshProUGUI newMessageAlert;
public int newMessageCount;
// Start is called before the first frame update
void Start()
{
new Task(Program).Start();
sw.Start();
using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Create, FileAccess.Write))
{
messages.Add($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] program booted up n");
foreach ( var message in messages )
{
bytes = Encoding.ASCII.GetBytes($"{message}n");
fs.Write(bytes);
}
UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes));
}
}
void Program()
{
newMessageCount++;
sendMessage("james: Hey bro, james here. get in the car i left you, its right next to you.");
while (!vs.isInVechile) { };
newMessageCount++;
sendMessage("james: if you are in a car already, come by me. i have something to chat about");
}
public void sendMessage(string message)
{
newMessageAlert.text = $"+{newMessageCount} new message(s)";
messages.Add(message);
using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Open, FileAccess.Write))
{
foreach (var message1 in messages)
{
bytes = Encoding.ASCII.GetBytes($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] {message1}n");
fs.Write(bytes);
}
UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes));
}
messagesPlaceholder.text = $"{messages[messages.Count]} n {messages[messages.Count - 1]}";
UnityEngine.Debug.Log($"messagePlaceholder text is: {messagesPlaceholder.text}");
}
}
</code>
<code>using System.Collections.Generic; using UnityEngine; using System.IO; using System; using System.Text; using System.Threading.Tasks; using TMPro; public class storyLineController : MonoBehaviour { public FPSController fpc; public vechileSwitch vs; private readonly string folderpath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}too-bad-to-be-true"; byte[] bytes = null; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); public List<string> messages = new List<string>(); public TextMeshProUGUI messagesPlaceholder; public TextMeshProUGUI newMessageAlert; public int newMessageCount; // Start is called before the first frame update void Start() { new Task(Program).Start(); sw.Start(); using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Create, FileAccess.Write)) { messages.Add($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] program booted up n"); foreach ( var message in messages ) { bytes = Encoding.ASCII.GetBytes($"{message}n"); fs.Write(bytes); } UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes)); } } void Program() { newMessageCount++; sendMessage("james: Hey bro, james here. get in the car i left you, its right next to you."); while (!vs.isInVechile) { }; newMessageCount++; sendMessage("james: if you are in a car already, come by me. i have something to chat about"); } public void sendMessage(string message) { newMessageAlert.text = $"+{newMessageCount} new message(s)"; messages.Add(message); using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Open, FileAccess.Write)) { foreach (var message1 in messages) { bytes = Encoding.ASCII.GetBytes($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] {message1}n"); fs.Write(bytes); } UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes)); } messagesPlaceholder.text = $"{messages[messages.Count]} n {messages[messages.Count - 1]}"; UnityEngine.Debug.Log($"messagePlaceholder text is: {messagesPlaceholder.text}"); } } </code>
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using System.Text;
using System.Threading.Tasks;
using TMPro;

public class storyLineController : MonoBehaviour
{
    public FPSController fpc;
    public vechileSwitch vs;
    private readonly string folderpath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}too-bad-to-be-true";
    byte[] bytes = null;
    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
    public List<string> messages = new List<string>();
    public TextMeshProUGUI messagesPlaceholder;
    public TextMeshProUGUI newMessageAlert;
    public int newMessageCount;
    // Start is called before the first frame update
    void Start()
    {
        new Task(Program).Start();
        sw.Start();
        using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Create, FileAccess.Write))
        {
            messages.Add($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] program booted up n");
            foreach ( var message in messages )
            {
                bytes = Encoding.ASCII.GetBytes($"{message}n");
                fs.Write(bytes);
            }
            UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes));
        }
    }
    void Program()
    {
        newMessageCount++;
        sendMessage("james: Hey bro, james here. get in the car i left you, its right next to you.");
        while (!vs.isInVechile) { };
        newMessageCount++;
        sendMessage("james: if you are in a car already, come by me. i have something to chat about");
    }
    public void sendMessage(string message)
    {
        newMessageAlert.text = $"+{newMessageCount} new message(s)";
        messages.Add(message);
        using (FileStream fs = new FileStream(@$"{folderpath}ESSgr.txt", FileMode.Open, FileAccess.Write))
        {
            foreach (var message1 in messages)
            {
                bytes = Encoding.ASCII.GetBytes($"[{sw.Elapsed.Minutes}:{sw.Elapsed.Seconds}] {message1}n");
                fs.Write(bytes);
            }
            UnityEngine.Debug.Log(Encoding.ASCII.GetString(bytes));
        }
        messagesPlaceholder.text = $"{messages[messages.Count]} n {messages[messages.Count - 1]}";
        UnityEngine.Debug.Log($"messagePlaceholder text is: {messagesPlaceholder.text}");
    }
}


as you can see, im not using unity’s default start and update methodes. that would cause too much lag because i would have had to write if code in update and that would cause a ton of lag. instead, i tried so call program methode asynchronously.

thing is, the first code line in the sendMessage methode, newMessageAlert.text = $"+{newMessageCount} new message(s)";, works, but others dont. besides, im not getting any logs.

i would be so happy if someone found the solution.

p.s. is there a better way to make the script wait other than while loop?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật