场景相机初步,日志输出LogWindow
This commit is contained in:
54
Assets/Scripts/Manager/SceneCamera.cs
Normal file
54
Assets/Scripts/Manager/SceneCamera.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class SceneCamera : MonoBehaviour, IBaseElement
|
||||
{
|
||||
public Camera camera;
|
||||
|
||||
public GameCamera.CameraViewType viewType;
|
||||
public float perspectiveAngle;
|
||||
public float orthographicSize;
|
||||
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
public void SetUpInspector()
|
||||
{
|
||||
Inspector inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Scene Camera");
|
||||
var viewTypeDropdown = inspector.GenerateDropdown(this, container, "View Type", typeof(GameCamera.CameraViewType), nameof(viewType));
|
||||
var perspectiveAngleField = inspector.GenerateInputField(this, container, "Perspective Angle", nameof(perspectiveAngle));
|
||||
var orthographicSizeField = inspector.GenerateInputField(this, container, "Orthographic Size", nameof(orthographicSize));
|
||||
|
||||
viewTypeDropdown.AddListenerFunction(_ =>
|
||||
{
|
||||
camera.orthographic = viewType == GameCamera.CameraViewType.Orthographic;
|
||||
});
|
||||
|
||||
perspectiveAngleField.AddListenerFunction(_ =>
|
||||
{
|
||||
camera.fieldOfView = perspectiveAngle;
|
||||
});
|
||||
|
||||
orthographicSizeField.AddListenerFunction(_ =>
|
||||
{
|
||||
camera.orthographicSize = orthographicSize;
|
||||
});
|
||||
|
||||
string GetPosition() => $"Position: {camera.transform.position}";
|
||||
var positionText = inspector.GenerateHintText(this, container, GetPosition);
|
||||
string GetEulerAngles() => $"Euler Angles: {camera.transform.eulerAngles}";
|
||||
var eulerAnglesText = inspector.GenerateHintText(this, container, GetEulerAngles);
|
||||
}
|
||||
|
||||
public void MoveCamera(Vector3 delta)
|
||||
{
|
||||
camera.transform.position += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user