基础内容-5
主题包; 测试NoteVisual与NoteEffect; LookAt旋转动画与FlexibleBool 动画杂项 控制台初步
This commit is contained in:
90
Assets/Scripts/GameElements/GameCamera/GameCamera.cs
Normal file
90
Assets/Scripts/GameElements/GameCamera/GameCamera.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class GameCamera : BaseElement
|
||||
{
|
||||
public Camera camera;
|
||||
public Transform rotationPoint;
|
||||
public Transform positionPoint;
|
||||
public Transform cameraTransform;
|
||||
|
||||
public CameraViewType cameraViewType;
|
||||
public float perspectiveAngle;
|
||||
public float orthographicSize;
|
||||
|
||||
public static GameCamera GenerateElement(string elementName, BaseElement parentElement,
|
||||
CameraViewType cameraViewType, float perspectiveAngle, float orthographicSize,
|
||||
Vector3 initialPosition, Vector3 initialEulerAngles)
|
||||
{
|
||||
GameCamera gameCamera = LeanPool.Spawn(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
|
||||
|
||||
gameCamera.NewInitialize(elementName);
|
||||
gameCamera.parentElement = parentElement;
|
||||
gameCamera.cameraViewType = cameraViewType;
|
||||
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
|
||||
gameCamera.perspectiveAngle = perspectiveAngle;
|
||||
gameCamera.orthographicSize = orthographicSize;
|
||||
gameCamera.transformSubmodule = new TransformSubmodule(initialPosition, initialEulerAngles, Vector3.one);
|
||||
gameCamera.cameraTransform = gameCamera.transform;
|
||||
|
||||
gameCamera.SetParent(parentElement);
|
||||
|
||||
return gameCamera;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
public enum CameraViewType
|
||||
{
|
||||
None = -1,
|
||||
Perspective = 0,
|
||||
Orthographic = 1
|
||||
}
|
||||
}
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
public override void SetTransformObserver()
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (transformSubmodule.eulerAnglesOffsetLock)
|
||||
{
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
}
|
||||
else if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 eulerOffset in transformSubmodule.eulerAnglesOffset)
|
||||
{
|
||||
offset += eulerOffset;
|
||||
}
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
}
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 posOffset in transformSubmodule.positionOffset)
|
||||
{
|
||||
offset += posOffset;
|
||||
}
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
positionPoint.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
}
|
||||
}).AddTo(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameElements/GameCamera/GameCamera.cs.meta
Normal file
11
Assets/Scripts/GameElements/GameCamera/GameCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79d811a12f27f43629797719fcbfc6ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user