Files
ichni_Creator_Studio/Assets/Scripts/Manager/SceneCamera.cs
SoulliesOfficial d7ce55cd04 fix
2025-04-18 22:34:55 -04:00

59 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ichni.Editor
{
public class SceneCamera : MonoBehaviour, IBaseElement
{
[FormerlySerializedAs("camera")] public Camera sceneCamera;
public GameCamera.CameraViewType viewType;
public float perspectiveAngle;
public float orthographicSize;
public BaseElement_BM matchedBM { get; set; }
[HideInInspector]
public Vector3 cameraPosition; //注意这里的Position和EulerAngles是transform的中介变量仅能用于Inspector显示
[HideInInspector]
public Vector3 cameraEulerAngles;
public void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Scene Camera");
//摄像机参数设置
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);
//摄像机位置与旋转设置
var transformSettings = container.GenerateSubcontainer(1);
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);
}
private void Update()
{
cameraPosition = sceneCamera.transform.position;
cameraEulerAngles = sceneCamera.transform.eulerAngles;
}
}
}