2using System.Collections;
17 private int _loadingCount;
27 if (!Application.isPlaying)
31 if (_instance ==
null)
33 _instance =
new GameObject(
"TriLibGCHelper").AddComponent<
GCHelper>();
43 StartCoroutine(CollectGC());
50 private IEnumerator CollectGC()
52 if (!Application.isPlaying)
54 Destroy(_instance.gameObject);
59 if (_loadingCount > 0)
61 yield
return new WaitForSeconds(
Interval);
73 private IEnumerator RemoveInstanceInternal(
float interval)
75 yield
return new WaitForSeconds(interval);
76 _loadingCount = Mathf.Max(0, _loadingCount-1);
93 StartCoroutine(RemoveInstanceInternal(interval));
Represents a class that forces GC collection using a fixed interval.
float Interval
The interval to do the GC Collection.
void UnRegisterLoading(float interval)
Indicates a model has finished loading or an error occurred.
static GCHelper GetInstance()
Gets the GCHelper instance and setup the given internal.
void RegisterLoading()
Indicates a new model is loading.