调整Bloom

This commit is contained in:
SoulliesOfficial
2026-06-30 04:36:54 -04:00
parent c5b6b4a089
commit 8e4690c964
34 changed files with 1883 additions and 1150 deletions

View File

@@ -57,16 +57,23 @@ namespace Ichni.RhythmGame
gameCamera.orthographicSize = orthographicSize;
gameCamera.cameraTransform = gameCamera.transform;
float ratioDifference = UIManager.GetScreenRatio() - UIManager.StandardRatio;
if (ratioDifference > 0)
float currentAspect = UIManager.GetScreenRatio();
float targetAspect = UIManager.StandardRatio;
if (currentAspect < targetAspect)
{
//gameCamera.perspectiveOffset = 12.5f * ratioDifference;
// 屏幕比较方 (如 4:3 平板),需要增加垂直 FOV 以保持 16:9 标准下的水平绝对视野
float hFovRad = 2.0f * Mathf.Atan(Mathf.Tan(perspectiveAngle * Mathf.Deg2Rad / 2.0f) * targetAspect);
float newVFovRad = 2.0f * Mathf.Atan(Mathf.Tan(hFovRad / 2.0f) / currentAspect);
// 设置 perspectiveOffset 以完美补足被裁切的空间
gameCamera.perspectiveOffset = (newVFovRad * Mathf.Rad2Deg) - perspectiveAngle;
}
else
{
gameCamera.perspectiveOffset = -25f * ratioDifference;
// 屏幕比较长 (如 20:9 手机),维持原有垂直 FOV左右延展屏幕用于渲染环境背景
gameCamera.perspectiveOffset = 0f;
}
gameCamera.RefreshFOV();
return gameCamera;
}

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public abstract partial class GameElement : SerializedMonoBehaviour, IBaseElement, IComparable<GameElement>
public abstract partial class GameElement : SerializedMonoBehaviour, IBaseElement, IComparable<GameElement>, IScheduledElement
{
#region [] Essential & Tracking Info
//物体名
@@ -145,6 +145,19 @@ namespace Ichni.RhythmGame
return HierarchyPriority.CompareTo(other.HierarchyPriority);
}
#endregion
#region [] IScheduledElement Implementation
/// <summary>
/// 由 ElementUpdateScheduler 在对应阶段调用。
/// 子类按需重写以实现特定阶段的更新逻辑。
/// </summary>
public virtual void ScheduledUpdate(UpdatePhase phase, float songTime) { }
/// <summary>
/// 元素是否处于活跃状态。调度器跳过非活跃元素以节省开销。
/// </summary>
public virtual bool IsScheduledActive => isActiveAndEnabled;
#endregion
}
#region [] Editor Interaction & Interfaces Overrides

View File

@@ -1,5 +1,137 @@
using System;
using System.Collections.Generic;
using Dreamteck.Splines;
using UnityEngine;
public class ObjectTracker : MonoBehaviour
namespace Ichni.RhythmGame
{
public partial class ObjectTracker : GameElement
{
#region [] Property Caches
public Track track;
public ObjectController objectController;
public GameObject objectPrefab;
private List<string> themeBundleList;
private List<string> objectNameList;
public string themeBundleName;
public string objectName;
public float playTime;
public float stopTime;
public int spawnCount;
public Vector2 positionOffsetMin = Vector2.zero;
public Vector2 positionOffsetMax = Vector2.zero;
public string customPositionRuleName;
public bool applyRotationOffset = false;
public Vector3 rotationOffsetMin = Vector3.zero;
public Vector3 rotationOffsetMax = Vector3.zero;
public string customRotationRuleName;
public bool applyScaleOffset = false;
public Vector3 scaleOffsetMin = Vector3.one;
public Vector3 scaleOffsetMax = Vector3.one;
public string customScaleRuleName;
#endregion
#region [] Generation & Initialization
public static ObjectTracker GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, Track track, string themeBundleName, string objectName, int spawnCount,
Vector2 positionOffsetMin, Vector2 positionOffsetMax, string customPositionRuleName,
bool applyRotationOffset, Vector3 rotationOffsetMin, Vector3 rotationOffsetMax, string customRotationRuleName,
bool applyScaleOffset, Vector3 scaleOffsetMin, Vector3 scaleOffsetMax, string customScaleRuleName)
{
ObjectTracker objectTracker = Instantiate(GameManager.Instance.basePrefabs.objectTracker, track.transform)
.GetComponent<ObjectTracker>();
objectTracker.objectPrefab = ThemeBundleManager.instance.GetObject<GameObject>(themeBundleName, objectName);
objectTracker.objectController.objects = new[] { objectTracker.objectPrefab };
objectTracker.Initialize(elementName, id, tags, isFirstGenerated, track);
objectTracker.track = track;
objectTracker.objectController.spline = track.trackPathSubmodule.path;
objectTracker.themeBundleList = ThemeBundleManager.instance.loadedThemeBundleList.ConvertAll(x => x.themeBundleName);
objectTracker.objectNameList = new List<string>();
objectTracker.themeBundleName = themeBundleName;
objectTracker.objectName = objectName;
objectTracker.SetSpawnSettings(spawnCount,
positionOffsetMin, positionOffsetMax, customPositionRuleName,
applyRotationOffset, rotationOffsetMin, rotationOffsetMax, customRotationRuleName,
applyScaleOffset, scaleOffsetMin, scaleOffsetMax, customScaleRuleName);
if (isFirstGenerated) objectTracker.AfterInitialize();
return objectTracker;
}
public override void AfterInitialize()
{
base.AfterInitialize();
// 向 ElementUpdateScheduler 注册 Phase.TrackFollower
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackFollower, this);
}
public void SetSpawnSettings(int spawnCount,
Vector2 positionOffsetMin, Vector2 positionOffsetMax, string customPositionRuleName,
bool applyRotationOffset, Vector3 rotationOffsetMin, Vector3 rotationOffsetMax, string customRotationRuleName,
bool applyScaleOffset, Vector3 scaleOffsetMin, Vector3 scaleOffsetMax, string customScaleRuleName)
{
this.spawnCount = spawnCount;
this.positionOffsetMin = positionOffsetMin;
this.positionOffsetMax = positionOffsetMax;
this.customPositionRuleName = customPositionRuleName;
this.applyRotationOffset = applyRotationOffset;
this.rotationOffsetMin = rotationOffsetMin;
this.rotationOffsetMax = rotationOffsetMax;
this.customRotationRuleName = customRotationRuleName;
this.applyScaleOffset = applyScaleOffset;
this.scaleOffsetMin = scaleOffsetMin;
this.scaleOffsetMax = scaleOffsetMax;
this.customScaleRuleName = customScaleRuleName;
objectController.spawnCount = spawnCount;
objectController.minOffset = positionOffsetMin;
objectController.maxOffset = positionOffsetMax;
objectController.applyRotation = applyRotationOffset;
objectController.minRotation = rotationOffsetMin;
objectController.maxRotation = rotationOffsetMax;
objectController.applyScale = applyScaleOffset;
objectController.minScaleMultiplier = scaleOffsetMin;
objectController.maxScaleMultiplier = scaleOffsetMax;
objectController.Spawn();
}
#endregion
#region [] Update
/// <summary>
/// IScheduledElement 实现:在 Phase.TrackFollower 阶段控制 objectController 的启用/禁用。
/// </summary>
public override void ScheduledUpdate(UpdatePhase phase, float songTime)
{
if (phase == UpdatePhase.TrackFollower)
{
if (playTime > songTime || stopTime < songTime)
{
if (objectController.enabled)
objectController.enabled = false;
}
else
{
if (!objectController.enabled)
{
objectController.enabled = true;
objectController.Spawn();
}
}
}
}
public override void OnDelete()
{
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
#endregion
}
}