场景相机初步,日志输出LogWindow

This commit is contained in:
SoulliesOfficial
2025-02-18 10:30:11 -05:00
parent 8d4772532f
commit b36f0469d0
31 changed files with 1497 additions and 721 deletions

View File

@@ -33,11 +33,12 @@ public class BasePrefabsCollection : SerializedScriptableObject
[Title("DynamicUI相关-Simple")] public GameObject dynamicUIContainer;
public GameObject inputField;
public GameObject Vector3inputField;
public GameObject text;
[FormerlySerializedAs("Vector3inputField")] public GameObject vector3InputField;
[FormerlySerializedAs("text")] public GameObject parameterText;
public GameObject hintText;
public GameObject button;
public GameObject toggle;
[FormerlySerializedAs("dropdown")] public GameObject enumDropdown;
public GameObject enumDropdown;
public GameObject stringListDropdown;
public GameObject baseColorPicker;
public GameObject emissionColorPicker;

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.Editor
{
public class CameraManager : MonoBehaviour, IBaseElement
{
public bool isSceneCameraActive;
public SceneCamera sceneCamera;
public float cameraMoveSpeed;
public GameCamera gameCamera;
private bool haveGameCamera => gameCamera != null;
public BaseElement_BM matchedBM { get; set; }
public void SwitchCamera()
{
if (!haveGameCamera)
{
throw new System.Exception("GameCamera is not assigned");
}
isSceneCameraActive = !isSceneCameraActive;
sceneCamera.camera.enabled = isSceneCameraActive;
gameCamera.camera.enabled = !isSceneCameraActive;
}
public void SetUpInspector()
{
string ShowCameraType() => isSceneCameraActive ? "Scene Camera" : "Game Camera";
var container = EditorManager.instance.uiManager.inspector.GenerateContainer("Camera Manager");
var cameraTypeText = EditorManager.instance.uiManager.inspector.GenerateHintText(this, container, ShowCameraType);
var switchCameraButton = EditorManager.instance.uiManager.inspector.GenerateButton(this, container, "Switch Camera", SwitchCamera);
var cameraMoveSpeedField = EditorManager.instance.uiManager.inspector.GenerateInputField(this, container, "Camera Move Speed", nameof(cameraMoveSpeed));
sceneCamera.SetUpInspector();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 604e2c80e1fb64c2ba9608c11fb2f040
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,6 +7,7 @@ using Ichni.RhythmGame.Beatmap;
using Ichni.RhythmGame.ThemeBundles.Basic;
using Sirenix.OdinInspector;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Ichni
{
@@ -18,6 +19,7 @@ namespace Ichni
public EditorUIManager uiManager;
public EditorSettings editorSettings;
public BackgroundController backgroundController;
public CameraManager cameraManager;
public ProjectInformation projectInformation;
public SongInformation songInformation;
@@ -75,6 +77,7 @@ namespace Ichni
"basic", "Skybox", "Background"));
projectInformation.SetUpInspector();
songInformation.SetUpInspector();
cameraManager.SetUpInspector();
}
private void CreateNew()

View File

@@ -10,6 +10,37 @@ namespace Ichni.Editor
{
private void Update()
{
if (EditorManager.instance.cameraManager.isSceneCameraActive)
{
float cameraSpeed = EditorManager.instance.cameraManager.cameraMoveSpeed * Time.deltaTime;
Transform sceneCameraTransform = EditorManager.instance.cameraManager.sceneCamera.transform;
if (Keyboard.current.wKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.forward * cameraSpeed;
}
if (Keyboard.current.sKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.forward * cameraSpeed;
}
if (Keyboard.current.dKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.right * cameraSpeed;
}
if (Keyboard.current.aKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.right * cameraSpeed;
}
if (Keyboard.current.spaceKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.up * cameraSpeed;
}
if (Keyboard.current.leftShiftKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.up * cameraSpeed;
}
}
if (Keyboard.current.leftCtrlKey.isPressed)
{
if (Keyboard.current.sKey.wasPressedThisFrame)
@@ -20,7 +51,9 @@ namespace Ichni.Editor
{
EditorManager.instance.projectManager.exportManager.Export();
}
else if (Keyboard.current.digit1Key.wasPressedThisFrame)
if (Keyboard.current.digit1Key.wasPressedThisFrame)
{
EditorManager.instance.uiManager.mainPage.resolutionHints.SetPhoneFrame();
}

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 63e7ac45befe54908ba6c691211fcbfa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: