mirror of
https://github.com/hanzoai/ProjectTinySamples.git
synced 2026-09-24 00:01:34 +00:00
31 lines
980 B
C#
31 lines
980 B
C#
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.Spaceship.Authoring
|
|
{
|
|
public class HudComponent : MonoBehaviour, IConvertGameObjectToEntity
|
|
{
|
|
public GameStates ShowingState = GameStates.None;
|
|
public GameObject[] HudObjects = null;
|
|
|
|
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
|
|
{
|
|
if (HudObjects == null)
|
|
return;
|
|
|
|
dstManager.AddComponentData(entity, new HudShowState
|
|
{
|
|
Value = ShowingState,
|
|
});
|
|
|
|
var hudObjects = dstManager.AddBuffer<HudObject>(entity);
|
|
for(var i = 0; i < HudObjects.Length; i++)
|
|
{
|
|
hudObjects.Add(new HudObject()
|
|
{
|
|
Value = HudObjects[i] != null ? conversionSystem.GetPrimaryEntity(HudObjects[i]) : Entity.Null
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |