44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Gameplay;
|
|
using PhxhSDK;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 记录一个相机的机位
|
|
/// </summary>
|
|
public class CameraStand : MonoBehaviour
|
|
{
|
|
[LabelText("是否正交")]
|
|
[SerializeField]
|
|
private bool _isOrthographic;
|
|
|
|
[ShowIf("isOrthographic")]
|
|
[LabelText("正交size")]
|
|
[SerializeField]
|
|
private float _size;
|
|
|
|
[HideIf("isOrthographic")]
|
|
[LabelText("FOV")]
|
|
[SerializeField]
|
|
private float _fov;
|
|
|
|
private Camera DefaultCamera => CommonUtils.GetSceneRootComponent<Camera>(gameObject.scene) ?? Camera.main;
|
|
|
|
[Button("测试机位")]
|
|
private void TestStand()
|
|
{
|
|
Apply();
|
|
}
|
|
|
|
public void Apply(Camera targetCamera = null)
|
|
{
|
|
targetCamera = targetCamera ? targetCamera : DefaultCamera;
|
|
var trans = transform;
|
|
targetCamera.transform.SetPositionAndRotation(trans.position, trans.rotation);
|
|
targetCamera.orthographic = _isOrthographic;
|
|
targetCamera.orthographicSize = _size > 0 ? _size : targetCamera.orthographicSize;
|
|
targetCamera.fieldOfView = _fov > 0 ? _fov : targetCamera.fieldOfView;
|
|
}
|
|
} |