public int LoadAssetSync <T>(string path, Action <T> onSuccess = null, Action <int> onFailed = null) where T : class { path = AssetPathUtil.NormalizePath(path); AssetLoadHandler handler = LoadAssetHandler <T>(path, (AssetLoadResult result) => { if (result.isDone && result.asset != null) { onSuccess?.Invoke(result.GetAsset <T>()); } else { onFailed?.Invoke(AssetLoadStatus.LOAD_ERROR); } }); return(handler.id); }
public int LoadAssetAsync <T>(string path, Action <T> onSuccess = null, Action <int> onFailed = null) where T : class { path = AssetPathUtil.NormalizePath(path); var handler = LoadAssetHandler <T>(path); handler.OnCompleted((AssetLoadResult result) => { if (handler.status == AssetLoadStatus.LOAD_FINISHED) { onSuccess?.Invoke(result.GetAsset <T>()); } else { onFailed?.Invoke(handler.status); } }); return(handler.id); }