您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
33 行
1.2 KiB
33 行
1.2 KiB
using Unity.Burst;
|
|
using Unity.Entities;
|
|
using Unity.Transforms;
|
|
using static Unity.Entities.SystemAPI;
|
|
|
|
namespace Unity.MegaCity.CameraManagement
|
|
{
|
|
/// <summary>
|
|
/// Updates player camera target position and rotation
|
|
/// </summary>
|
|
[BurstCompile]
|
|
[UpdateAfter(typeof(TransformSystemGroup))]
|
|
[WorldSystemFilter(WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation)]
|
|
public partial struct PlayerCameraTargetUpdater : ISystem
|
|
{
|
|
public void OnCreate(ref SystemState state)
|
|
{
|
|
state.RequireForUpdate<PlayerCameraTarget>();
|
|
}
|
|
|
|
public void OnUpdate(ref SystemState state)
|
|
{
|
|
var player = GetSingletonEntity<PlayerCameraTarget>();
|
|
var deltaTime = state.WorldUnmanaged.Time.DeltaTime;
|
|
var localToWorld = state.EntityManager.GetComponentData<LocalToWorld>(player);
|
|
if (HybridCameraManager.Instance == null)
|
|
return;
|
|
|
|
HybridCameraManager.Instance.SetPlayerCameraPosition(localToWorld.Position, deltaTime);
|
|
HybridCameraManager.Instance.SetPlayerCameraRotation(localToWorld.Rotation, deltaTime);
|
|
}
|
|
}
|
|
}
|