BITKit/Src/Unity/Scripts/Entity/Core/UnityIdComponent.cs

27 lines
514 B
C#
Raw Normal View History

2023-11-15 23:55:06 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.Entities
{
public interface IdComponent
{
2024-05-31 01:23:15 +08:00
int Id { get; }
2023-11-15 23:55:06 +08:00
string Name { get; }
}
public class UnityIdComponent : EntityBehavior,IdComponent
{
2024-05-31 01:23:15 +08:00
[SerializeField] private int id;
2023-11-15 23:55:06 +08:00
[SerializeField] private string unityName;
2024-05-31 01:23:15 +08:00
public int Id => id;
2023-11-15 23:55:06 +08:00
public string Name => unityName;
public override void Initialize(IEntity _entity)
{
base.Initialize(_entity);
id = _entity.Id;
}
}
}