void CheckMultipleCreate(Type behaviourType) { if (_pools.ContainsKey(behaviourType)) { AltoLog.FW_Warn($"[AltoObjectPoolRegistry] Multiple creation detected : {behaviourType}"); } }
void CheckMultipleReturn(T obj) { if (_pool.Contains(obj)) { AltoLog.FW_Warn($"[AltoObjectPool] Multiple return detected : {typeof(T)}"); } }
public virtual void OnUnload(string assetAddress) { AltoLog.FW( $"[{GetType().Name}] *** OnUnload : <b>{assetAddress}</b>", null, "4463c9" ); Remove(assetAddress); }
//---------------------------------------------------------------------- // called by framework //---------------------------------------------------------------------- public virtual void OnLoad(string assetAddress, T resource) { AltoLog.FW( $"[{GetType().Name}] OnLoad : <b>{assetAddress}</b> - {resource.GetType()}", null, "3bc29a" ); Add(assetAddress, resource); }
//---------------------------------------------------------------------- // private //---------------------------------------------------------------------- bool ValidateKey(string assetAddress) { if (!_entries.ContainsKey(assetAddress)) { AltoLog.FW_Warn($"[ResourceRegistry] Key not found : {assetAddress}"); return(false); } return(true); }
public T Get(string assetAddress) { if (!_resources.ContainsKey(assetAddress)) { AltoLog.FW_Error($"[{GetType().Name}] Resource not found : <b>{assetAddress}</b>"); return(null); } return(_resources[assetAddress]); }
protected void ReturnToPool() { if (_pool == null) { AltoLog.FW_Warn("[PoolableBehaviour] Pool is not set."); Destroy(gameObject); return; } _pool.Return(this); }
//---------------------------------------------------------------------- // 状態取得 //---------------------------------------------------------------------- public ResourceEntry GetEntry(string assetAddress) { ResourceEntry entry; if (!_entries.TryGetValue(assetAddress, out entry)) { AltoLog.FW_Error($"[ResourceRegistry] Entry not found : {assetAddress}"); return(null); } return(entry); }
public Sprite GetSprite(string spriteName) { Sprite sprite; if (!_sprites.TryGetValue(spriteName, out sprite)) { AltoLog.FW_Error($"[SpriteAtlasStore] Sprite <b>{spriteName}</b> not found."); return(null); } return(sprite); }
/// <summary> /// プールから取得。プールが枯渇していた場合はインスタンスを生成する /// </summary> public T Get() { T obj; if (_pool.Count > 0) { obj = _pool.Pop(); } else { obj = Create(); AltoLog.Info($"[AltoObjectPool] Pool ({typeof(T)}) is empty" + $" (now total is <color=#{AltoLog.COLOR_WARN}>{ this.reservedNum }</color>)"); } obj.gameObject.SetActive(true); obj.OnGetFromPool(); return(obj); }