Unity學習-程式碼中動態生成預製體

小張每天都要很努力發表於2020-10-23

程式碼

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

public class test001 : MonoBehaviour
{
    
  
    void Start()
    {

        GameObject GameController = (GameObject)Resources.Load("MyContext");
        GameObject UICanvas = GameObject.Find("Canvas");
        GameController = Instantiate(GameController);
        GameController.transform.parent = UICanvas.transform;
       


    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

相關文章