using Unity.Entities;
using UnityEngine;
namespace GarmentButton.CameraGeneral
{
public class CameraEntity : MonoBehaviour
{
private Entity _entity;
void Awake()
{
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
_entity = entityManager.CreateEntity(typeof(CameraReferenceProperty), typeof(CameraRotationProperties),
typeof(CameraPositionProperties),typeof(CameraDirectionToPlayer),typeof(CameraOffestFromPlayer),
typeof(WantedRotationCamera),typeof(BaseRotation),typeof(ScreenPositionPlayer));
entityManager.SetComponentData(_entity, new CameraReferenceProperty()
{
Transform = transform,
Value = Camera.main,
});
entityManager.SetComponentData(_entity, new BaseRotation()
{
Value = transform.rotation,
});
}
private void OnDestroy()
{
#if UNITY_EDITOR
if (World.DefaultGameObjectInjectionWorld == null)
return;
#endif
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.DestroyEntity(_entity);
}
}
}