feat(init): 搭建初始的项目框架
This commit is contained in:
32
Assets/Script/Core/UI/UICamera.cs
Normal file
32
Assets/Script/Core/UI/UICamera.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class UICamera : MonoBehaviour
|
||||
{
|
||||
public static UICamera Instance { get; private set; }
|
||||
private Camera uiCamera;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
|
||||
uiCamera = GetComponent<Camera>();
|
||||
uiCamera.clearFlags = CameraClearFlags.Depth;
|
||||
uiCamera.cullingMask = LayerMask.GetMask("UI");
|
||||
uiCamera.orthographic = true;
|
||||
uiCamera.depth = 100; // 确保在主相机之后渲染
|
||||
}
|
||||
|
||||
public Camera GetCamera()
|
||||
{
|
||||
return uiCamera;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user