2025-02-18 10:30:11 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Ichni.RhythmGame;
|
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
|
using UnityEngine;
|
2025-03-01 22:58:20 -05:00
|
|
|
|
using UnityEngine.Serialization;
|
2025-02-18 10:30:11 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Ichni.Editor
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SceneCamera : MonoBehaviour, IBaseElement
|
|
|
|
|
|
{
|
2025-03-01 22:58:20 -05:00
|
|
|
|
[FormerlySerializedAs("camera")] public Camera sceneCamera;
|
2025-02-21 19:36:03 +08:00
|
|
|
|
|
2025-02-18 10:30:11 -05:00
|
|
|
|
public GameCamera.CameraViewType viewType;
|
|
|
|
|
|
public float perspectiveAngle;
|
|
|
|
|
|
public float orthographicSize;
|
2025-02-21 19:36:03 +08:00
|
|
|
|
|
2025-02-18 10:30:11 -05:00
|
|
|
|
public BaseElement_BM matchedBM { get; set; }
|
|
|
|
|
|
|
2025-02-26 00:52:08 -05:00
|
|
|
|
[HideInInspector]
|
|
|
|
|
|
public Vector3 cameraPosition; //注意,这里的Position和EulerAngles,是transform的中介变量,仅能用于Inspector显示!
|
|
|
|
|
|
[HideInInspector]
|
|
|
|
|
|
public Vector3 cameraEulerAngles;
|
|
|
|
|
|
|
2025-02-18 10:30:11 -05:00
|
|
|
|
public void SetUpInspector()
|
|
|
|
|
|
{
|
2025-02-21 01:03:01 -05:00
|
|
|
|
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
2025-02-18 10:30:11 -05:00
|
|
|
|
var container = inspector.GenerateContainer("Scene Camera");
|
2025-04-14 17:49:47 -04:00
|
|
|
|
|
|
|
|
|
|
//摄像机参数设置
|
|
|
|
|
|
var cameraSettings = container.GenerateSubcontainer(3);
|
|
|
|
|
|
var viewTypeDropdown =
|
|
|
|
|
|
inspector.GenerateDropdown(this, cameraSettings, "View Type", typeof(GameCamera.CameraViewType), nameof(viewType))
|
|
|
|
|
|
.AddListenerFunction(() => sceneCamera.orthographic = viewType == GameCamera.CameraViewType.Orthographic);
|
|
|
|
|
|
var perspectiveAngleField =
|
|
|
|
|
|
inspector.GenerateInputField(this, cameraSettings, "Perspective Angle", nameof(perspectiveAngle))
|
|
|
|
|
|
.AddListenerFunction(() => sceneCamera.fieldOfView = perspectiveAngle);
|
|
|
|
|
|
var orthographicSizeField =
|
|
|
|
|
|
inspector.GenerateInputField(this, cameraSettings, "Orthographic Size", nameof(orthographicSize))
|
|
|
|
|
|
.AddListenerFunction(() => sceneCamera.orthographicSize = orthographicSize);
|
|
|
|
|
|
|
|
|
|
|
|
//摄像机位置与旋转设置
|
2025-04-18 22:34:55 -04:00
|
|
|
|
var transformSettings = container.GenerateSubcontainer(1);
|
2025-04-14 17:49:47 -04:00
|
|
|
|
var positionInputFields =
|
|
|
|
|
|
inspector.GenerateVector3InputField(this, transformSettings, "Position", nameof(cameraPosition), true)
|
|
|
|
|
|
.AddListenerFunction(() => sceneCamera.transform.position = cameraPosition);
|
|
|
|
|
|
var eulerAnglesInputFields =
|
|
|
|
|
|
inspector.GenerateVector3InputField(this, transformSettings, "Euler Angles", nameof(cameraEulerAngles), true)
|
|
|
|
|
|
.AddListenerFunction(() => sceneCamera.transform.eulerAngles = cameraEulerAngles);
|
2025-02-18 10:30:11 -05:00
|
|
|
|
}
|
2025-02-21 19:36:03 +08:00
|
|
|
|
|
2025-02-26 00:52:08 -05:00
|
|
|
|
private void Update()
|
2025-02-18 10:30:11 -05:00
|
|
|
|
{
|
2025-03-01 22:58:20 -05:00
|
|
|
|
cameraPosition = sceneCamera.transform.position;
|
|
|
|
|
|
cameraEulerAngles = sceneCamera.transform.eulerAngles;
|
2025-02-18 10:30:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|