68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
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
|
|
{
|
|
get => sceneCamera.transform.position;
|
|
set
|
|
{
|
|
sceneCamera.transform.position = value;
|
|
}
|
|
}
|
|
[HideInInspector]
|
|
public Vector3 cameraEulerAngles
|
|
{
|
|
get => sceneCamera.transform.eulerAngles;
|
|
set
|
|
{
|
|
sceneCamera.transform.eulerAngles = value;
|
|
}
|
|
}
|
|
public bool CanBeFreeRotate => !EditorManager.instance.cameraManager.panelDrawer.isEditing;
|
|
|
|
|
|
public void SetUpInspector()
|
|
{
|
|
InspectorBuilder.For(this)
|
|
.Section("Scene Camera")
|
|
.Dropdown(nameof(viewType), typeof(GameCamera.CameraViewType), "View Type")
|
|
.OnChanged(() => sceneCamera.orthographic = viewType == GameCamera.CameraViewType.Orthographic)
|
|
.InputField(nameof(perspectiveAngle), "Perspective Angle")
|
|
.OnChanged(() => sceneCamera.fieldOfView = perspectiveAngle)
|
|
.InputField(nameof(orthographicSize), "Orthographic Size")
|
|
.OnChanged(() => sceneCamera.orthographicSize = orthographicSize)
|
|
.Vector3Field(nameof(cameraPosition), "Position")
|
|
.AutoUpdate()
|
|
.OnChanged(() => sceneCamera.transform.position = cameraPosition)
|
|
.Vector3Field(nameof(cameraEulerAngles), "Euler Angles")
|
|
.AutoUpdate()
|
|
.OnChanged(() => sceneCamera.transform.eulerAngles = cameraEulerAngles)
|
|
.Build();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
cameraPosition = sceneCamera.transform.position;
|
|
cameraEulerAngles = sceneCamera.transform.eulerAngles;
|
|
}
|
|
}
|
|
}
|