public GameObject Instantiate() { if (!_asset.isLoaded) { UnityEngine.Debug.LogErrorFormat("GameObjectPool({0}) 加载未完成", _asset.assetPath); return(null); } var count = _gameObjects != null ? _gameObjects.Count : 0; if (count > 0) { var old = _gameObjects[count - 1]; _gameObjects.RemoveAt(count - 1); _count++; return(old); } var prefab = _asset.GetObject() as GameObject; if (prefab != null) { var gameObject = UnityEngine.Object.Instantiate(prefab); _count++; return(gameObject); } return(null); }
private void onAssetLoaded(UAsset asset) { var prefab = asset.GetObject() as GameObject; if (prefab != null) { _localRotation = prefab.transform.localRotation; _localScale = prefab.transform.localScale; } if (_callbacks == null) { return; } var shadows = _callbacks; var count = shadows.Count; if (count > 0) { _callbacks = null; for (var i = 0; i < count; i++) { var cb = shadows[i]; try { cb(); } catch (Exception exception) { UnityEngine.Debug.LogErrorFormat("GameObjectPool({0}) Exception: {1}", _asset.assetPath, exception); } } } }
private void OnCompleted(UAsset asset) { Object.Instantiate(asset.GetObject(), transform); if (!_loaded) { // Debug.Log($"asset loaded {_assetPath}"); _loaded = true; OnLoaded(); } }
private void OnCompleted(UAsset asset) { _target = Object.Instantiate(asset.GetObject() as GameObject, transform); _target.transform.localPosition = Vector3.zero; _target.transform.localRotation = Quaternion.identity; _target.transform.localScale = Vector3.one; if (!_loaded) { // Debug.Log($"asset loaded {_assetPath}"); _loaded = true; OnLoaded(); } }
public static AssetHandle CreateInstance(UAsset asset, float ttl) { var gameObject = Object.Instantiate(asset.GetObject()) as GameObject; return(UnityFS.Utils.AssetHandle.Attach(gameObject, asset, ttl)); }