您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
28 行
961 B
28 行
961 B
using Unity.Burst;
|
|
using Unity.Entities;
|
|
|
|
namespace Unity.NetCode.Extensions
|
|
{
|
|
[UpdateAfter(typeof(UpdateFPSData))]
|
|
[UpdateInGroup(typeof(NetCodePanelStats))]
|
|
public partial struct UpdateSystemsRunningData : ISystem
|
|
{
|
|
private uint m_PreviousFrameVersion;
|
|
private uint m_CurrentFrameVersion;
|
|
|
|
public void OnCreate(ref SystemState state)
|
|
{
|
|
state.RequireForUpdate<PlayerStats>();
|
|
}
|
|
|
|
[BurstCompile]
|
|
public void OnUpdate(ref SystemState state)
|
|
{
|
|
var playerStats = SystemAPI.GetSingletonRW<PlayerStats>().ValueRW;
|
|
m_CurrentFrameVersion = state.EntityManager.GlobalSystemVersion - m_PreviousFrameVersion;
|
|
m_PreviousFrameVersion = state.EntityManager.GlobalSystemVersion;
|
|
playerStats.NumberOfSystems = m_CurrentFrameVersion;
|
|
SystemAPI.SetSingleton(playerStats);
|
|
}
|
|
}
|
|
}
|