您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

42 行
1.1 KiB

using GameplayIngredients;
using UnityEngine;
using Cinemachine;
public class DebugPOVManager : Manager
{
CinemachineVirtualCamera m_VirtualCamera;
public void SetCamera(Transform transform)
{
if (transform != null)
{
if (m_VirtualCamera == null)
{
CreateCamera();
}
m_VirtualCamera.gameObject.transform.position = transform.position;
m_VirtualCamera.gameObject.transform.rotation = transform.rotation;
m_VirtualCamera.gameObject.transform.localScale = Vector3.one;
}
else
DestroyCamera();
}
void CreateCamera()
{
var go = new GameObject("DebugPOV");
m_VirtualCamera = go.AddComponent<CinemachineVirtualCamera>();
m_VirtualCamera.Priority = int.MaxValue;
m_VirtualCamera.transform.parent = transform;
}
void DestroyCamera()
{
if(m_VirtualCamera != null)
{
Destroy(m_VirtualCamera.gameObject);
m_VirtualCamera = null;
}
}
}