public static void Instantiate(string key, Action <string, GameObject> onSucceeded, Action <string> onFailed = null, Transform parent = null, bool inWorldSpace = false, bool trackHandle = true) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); return; } try { var operation = Addressables.InstantiateAsync(key, parent, inWorldSpace, trackHandle); operation.Completed += handle => OnInstantiateCompleted(handle, key, false, onSucceeded, onFailed); } catch (Exception ex) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw ex; } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(ex); } } }
public static void Instantiate(string key, Transform parent = null, bool inWorldSpace = false, bool trackHandle = true) { if (!GuardKey(key, out key)) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw new InvalidKeyException(key); } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(new InvalidKeyException(key)); } return; } try { var operation = Addressables.InstantiateAsync(key, parent, inWorldSpace, trackHandle); operation.Completed += handle => OnInstantiateCompleted(handle, key, false); } catch (Exception ex) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw ex; } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(ex); } } }
public static void Instantiate(string key, Transform parent = null, bool inWorldSpace = false, bool trackHandle = true) { if (!GuardKey(key, out key)) { return; } var operation = Addressables.InstantiateAsync(key, parent, inWorldSpace, trackHandle); operation.Completed += handle => OnInstantiateCompleted(handle, key); }
public static void Instantiate(string key, Action <string, GameObject> onSucceeded, Action <string> onFailed = null, Transform parent = null, bool inWorldSpace = false, bool trackHandle = true) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); return; } var operation = Addressables.InstantiateAsync(key, parent, inWorldSpace, trackHandle); operation.Completed += handle => OnInstantiateCompleted(handle, key, onSucceeded, onFailed); }
public static IEnumerator InstantiateCoroutine(string key, Transform parent = null, bool inWorldSpace = false, bool trackHandle = true, Action <string, GameObject> onSucceeded = null, Action <string> onFailed = null) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); } else { var operation = Addressables.InstantiateAsync(key, parent, inWorldSpace, trackHandle); yield return(operation); OnInstantiateCompleted(operation, key, false, onSucceeded, onFailed); } }
/// <summary> /// InstantiateAsync the referenced asset as type TObject. /// </summary> /// <param name="parent">The parent of the instantiated object.</param> /// <param name="instantiateInWorldSpace">Option to retain world space when instantiated with a parent.</param> /// <returns></returns> public virtual AsyncOperationHandle <GameObject> InstantiateAsync(Transform parent = null, bool instantiateInWorldSpace = false) { return(Addressables.InstantiateAsync(RuntimeKey, parent, instantiateInWorldSpace, true)); }
/// <summary> /// InstantiateAsync the referenced asset as type TObject. /// </summary> /// <param name="position">Position of the instantiated object.</param> /// <param name="rotation">Rotation of the instantiated object.</param> /// <param name="parent">The parent of the instantiated object.</param> /// <returns></returns> public virtual AsyncOperationHandle <GameObject> InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null) { return(Addressables.InstantiateAsync(RuntimeKey, position, rotation, parent, true)); }