29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class MonoBehaviourSingletonTemplate<T> : MyCoroutine where T : MyCoroutine
|
||
|
|
{
|
||
|
|
public static T Ins;
|
||
|
|
public GameObject go_child;
|
||
|
|
|
||
|
|
protected virtual void Awake() { Ins = this as T; if (go_child) go_child.SetActive(false); }
|
||
|
|
protected void DontDestroy() { if (transform.parent == null) DontDestroyOnLoad(gameObject); }
|
||
|
|
public bool IsActive() { return go_child && go_child.activeSelf; }
|
||
|
|
public void On() { if (go_child) go_child.SetActive(true); else gameObject.SetActive(true); }
|
||
|
|
public virtual void Off() { if (go_child) go_child.SetActive(false); else gameObject.SetActive(false); }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class MonoBehaviourSingletonuScrollViewMgr<T> : uScrollViewMgr where T : MonoBehaviour
|
||
|
|
{
|
||
|
|
public static T Ins;
|
||
|
|
|
||
|
|
protected override void Awake() { Ins = this as T; }
|
||
|
|
protected void DontDestroy() { DontDestroyOnLoad(gameObject); }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class MonoBehaviourSingletonTemplateBackKeyAdd<T> : BackKeyAdd where T : MonoBehaviour
|
||
|
|
{
|
||
|
|
public static T Ins;
|
||
|
|
|
||
|
|
protected override void Awake() { Ins = this as T; }
|
||
|
|
protected void DontDestroy() { DontDestroyOnLoad(gameObject); }
|
||
|
|
}
|