文字檔案到 Unity 3D GUI Canvas 文字框

文字檔案到 Unity 3D GUI Canvas 文字框

因此,一位用戶給了我這段程式碼,他聲稱這可以實現我想要的功能...即顯示程式碼中註明的 txt 檔案並將其中的單行資訊發佈到 GUI 文字方塊...

然而,什麼也沒發生——你知道出了什麼問題嗎?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;

public class driverVersionText : MonoBehaviour
{

    public Text driverVerText = null;
    // Start is called before the first frame update
    void Start()
    {
        driverVerText.text = System.IO.File.ReadAllLines(@"C:\DriverVersion.txt");
    }
}

相關內容