public void InitObject(GameObject gameObject, object data = null) { this.gameObject = gameObject; AutoReference(); GameObject childGameObject = new GameObject(GetType().FullName); childGameObject.transform.SetParent(gameObject.transform); childGameObject.transform.localPosition = Vector3.zero; childGameObject.transform.localRotation = Quaternion.identity; childGameObject.transform.localScale = Vector3.one; lccView = childGameObject.AddComponent <LccView>(); lccView.className = GetType().FullName; lccView.type = this; lccView.awake += Awake; lccView.onEnable += OnEnable; lccView.start += Start; lccView.fixedUpdate += FixedUpdate; lccView.update += Update; lccView.lateUpdate += LateUpdate; lccView.onDisable += OnDisable; lccView.onDestroy += Destroy; if (gameObject.activeSelf) { Awake(); } InitData(data); }
public void InitObject(GameObject gameObject, object data = null) { this.gameObject = gameObject; id = IdUtil.Generate(); AutoReference(); GameObject childGameObject = new GameObject(GetType().FullName); childGameObject.transform.SetParent(gameObject.transform); childGameObject.transform.localPosition = Vector3.zero; childGameObject.transform.localRotation = Quaternion.identity; childGameObject.transform.localScale = Vector3.one; lccView = childGameObject.AddComponent <LccView>(); lccView.className = GetType().Name; lccView.type = this; InitData(data); ObjectBaseEventSystem.Instance.Register(this); }
private void Destroy() { lccView = null; gameObject = null; OnDestroy(); }
public static T GetView <T>(GameObject gameObject) where T : AObjectBase { LccView lccView = gameObject.GetChildComponent <LccView>(typeof(T).FullName); return(lccView.GetType <T>()); }