HAARFTE/Assets/DemoGame/GameScript/Hotfix/FloorBase/GameObjectBase.cs

64 lines
1.5 KiB
C#
Raw Normal View History

2024-10-24 16:16:57 +08:00
using UnityEngine;
namespace ZC
{
public class GameObjectBase<T> : IBehaviour, ICreateBindingGo
{
private GameObject _go;
private long _id;
private bool _isDisposed;
private bool _isPause;
public GameObject go => this._go;
public long Id => this._id;
public bool isDisposed => this._isDisposed;
public bool isPause => this._isPause;
protected GameObjectBase(GameObject go = null)
{
this._id = IDGenerator.Generate();
Debug.Log($"name is {typeof(T)}, id is {this._id}");
if (go == null)
{
var name = typeof(T).FullName;
this._go = new GameObject(name);
_go.transform.SetParent(ZCGame.ObjectPool);
this._go.name = name;
}
else
this._go = go;
}
public void SetGo(GameObject go)
{
this._go = go;
}
public virtual void OnInit()
{
this._isDisposed = false;
this._isPause = false;
}
public virtual void OnUpdate(float dateTime)
{
}
public virtual void OnPause()
{
this._isPause = true;
}
public virtual void OnResume()
{
this._isPause = false;
}
public virtual void OnDispose()
{
this._isDisposed = true;
}
}
}