在canvas初始化的时候设置渲染模式为ScreenSpaceCamera,并指定摄像机
程序员文章站
2022-07-14 10:33:45
...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CanvasInit : MonoBehaviour
{
private void Awake()
{
Canvas thiscanvas = GetComponent<Canvas>();
thiscanvas.renderMode=RenderMode.ScreenSpaceCamera;
GameObject gameObject = GameObject.Find("Main Camera");
thiscanvas.worldCamera = gameObject.GetComponent<Camera>();
}
}
下一篇: matplotlib的使用