using System; using UnityEngine; namespace ZC { public class GameObjectBase : MonoBehaviour, IBehaviour { private long _id = 0; private bool _isDisposed; private bool _isPause; GameObjectBinding _binding; public GameObjectBinding binding => _binding; public long Id => this._id; public bool isDisposed => this._isDisposed; public bool isPause => this._isPause; private void Awake() { _binding = gameObject.GetComponent(); OnInit(); } public void SetID(long id) { if (_id != 0) throw new ArgumentException("id 不允许二次修改,一次固定的!"); _id = id; } 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; DestroyImmediate(this.gameObject); } } }