public static int DecRef(GameObject go) { PoolTicket ticket = go.AssertGetComponent <PoolTicket>(); ticket.RefCnt--; if (ticket.RefCnt <= 0) { ticket.Despawn(); } return(ticket.RefCnt); }
public static void DespawnPrefab(GameObject go, bool requireTicket = false) { PoolTicket ticket = go.GetComponent <PoolTicket>(); if (ticket != null) { ticket.Despawn(); } else { if (requireTicket) { Dbg.LogWarn("PrefabPool.DespawnPrefab: cannot find PoolTicket when require it: '{0}'", go.name); } else { PrefabPool pool = ForceGetPoolByPrefab(go); pool.Despawn(go); } } }