diff --git a/Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs b/Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs index 8cdccfe56..41a91fb59 100644 --- a/Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs +++ b/Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using System.Xml; using UnityEngine; using UnityEngine.AddressableAssets; namespace Basis.Scripts.Avatar @@ -15,35 +14,32 @@ namespace Basis.Scripts.Avatar public static class BasisAvatarFactory { public static BasisLoadableBundle LoadingAvatar = new BasisLoadableBundle() - { - BasisBundleInformation = new BasisBundleInformation() - { - BasisBundleDescription = new BasisBundleDescription() - { - AssetBundleDescription = "LoadingAvatar", - AssetBundleName = "LoadingAvatar" - }, - HasError = false, - BasisBundleGenerated = new BasisBundleGenerated() - { - AssetBundleCRC = 0, - AssetBundleHash = "N/A", - AssetMode = "Gameobject" - }, - }, - UnlockPassword = "N/A", - BasisRemoteBundleEncrypted = new BasisRemoteEncyptedBundle() - { - BundleURL = "LoadingAvatar", - IsLocal = true, - MetaURL = "LoadingAvatar", - }, - BasisLocalEncryptedBundle = new BasisStoredEncyptedBundle() - { - LocalBundleFile = "LoadingAvatar", - LocalMetaFile = "LoadingAvatar", - }, - }; + { + BasisBundleConnector = new BasisBundleConnector() + { + BasisBundleDescription = new BasisBundleDescription() + { + AssetBundleDescription = "LoadingAvatar", + AssetBundleName = "LoadingAvatar" + }, + BasisBundleGenerated = new BasisBundleGenerated[] + { + new BasisBundleGenerated("N/A","Gameobject",string.Empty,0,true,string.Empty,string.Empty,true,string.Empty) + }, + }, + UnlockPassword = "N/A", + BasisRemoteBundleEncrypted = new BasisRemoteEncyptedBundle() + { + BundleURL = "LoadingAvatar", + IsLocal = true, + MetaURL = "LoadingAvatar", + }, + BasisLocalEncryptedBundle = new BasisStoredEncyptedBundle() + { + LocalBundleFile = "LoadingAvatar", + LocalMetaFile = "LoadingAvatar", + }, + }; public static async Task LoadAvatarLocal(BasisLocalPlayer Player,byte Mode, BasisLoadableBundle BasisLoadableBundle) { if (string.IsNullOrEmpty(BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL)) diff --git a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleConversionNetwork.cs b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleConversionNetwork.cs index 79c114632..2e0f46349 100644 --- a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleConversionNetwork.cs +++ b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleConversionNetwork.cs @@ -11,7 +11,7 @@ public static BasisLoadableBundle ConvertFromNetwork(AvatarNetworkLoadInformatio MetaURL = AvatarNetworkLoadInformation.AvatarMetaUrl, BundleURL = AvatarNetworkLoadInformation.AvatarBundleUrl }, - BasisBundleInformation = new BasisBundleInformation(), + BasisBundleConnector = new BasisBundleConnector(), BasisLocalEncryptedBundle = new BasisStoredEncyptedBundle(), UnlockPassword = AvatarNetworkLoadInformation.UnlockPassword }; diff --git a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleLoadAsset.cs b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleLoadAsset.cs index 7c6a82bc2..2e9c46467 100644 --- a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleLoadAsset.cs +++ b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleLoadAsset.cs @@ -12,33 +12,36 @@ public static async Task LoadFromWrapper(BasisTrackedBundleWrapper B if (BasisLoadableBundle.AssetBundle != null) { BasisLoadableBundle output = BasisLoadableBundle.LoadableBundle; - switch (output.BasisBundleInformation.BasisBundleGenerated.AssetMode) + if (output.BasisBundleConnector.GetPlatform(out BasisBundleGenerated Generated)) { - case "GameObject": - { - AssetBundleRequest Request = BasisLoadableBundle.AssetBundle.LoadAssetAsync(output.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName); - await Request; - GameObject loadedObject = Request.asset as GameObject; - if (loadedObject == null) - { - BasisDebug.LogError("Unable to proceed, null Gameobject"); - BasisLoadableBundle.DidErrorOccur = true; - await BasisLoadableBundle.AssetBundle.UnloadAsync(true); - return null; - } - ChecksRequired ChecksRequired = new ChecksRequired(); - if (loadedObject.TryGetComponent(out BasisAvatar BasisAvatar)) + switch (Generated.AssetMode) + { + case "GameObject": { - ChecksRequired.DisableAnimatorEvents = true; + AssetBundleRequest Request = BasisLoadableBundle.AssetBundle.LoadAssetAsync(Generated.AssetToLoadName); + await Request; + GameObject loadedObject = Request.asset as GameObject; + if (loadedObject == null) + { + BasisDebug.LogError("Unable to proceed, null Gameobject"); + BasisLoadableBundle.DidErrorOccur = true; + await BasisLoadableBundle.AssetBundle.UnloadAsync(true); + return null; + } + ChecksRequired ChecksRequired = new ChecksRequired(); + if (loadedObject.TryGetComponent(out BasisAvatar BasisAvatar)) + { + ChecksRequired.DisableAnimatorEvents = true; + } + ChecksRequired.UseContentRemoval = UseContentRemoval; + GameObject CreatedCopy = ContentPoliceControl.ContentControl(loadedObject, ChecksRequired, Position, Rotation, ModifyScale, Scale, Parent); + Incremented = BasisLoadableBundle.Increment(); + return CreatedCopy; } - ChecksRequired.UseContentRemoval = UseContentRemoval; - GameObject CreatedCopy = ContentPoliceControl.ContentControl(loadedObject, ChecksRequired, Position, Rotation, ModifyScale, Scale, Parent); - Incremented = BasisLoadableBundle.Increment(); - return CreatedCopy; - } - default: - BasisDebug.LogError("Requested type " + output.BasisBundleInformation.BasisBundleGenerated.AssetMode + " has no handler"); - return null; + default: + BasisDebug.LogError("Requested type " + Generated.AssetMode + " has no handler"); + return null; + } } } else diff --git a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleManagement.cs b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleManagement.cs index bc9a9e6c7..ce19ec2e2 100644 --- a/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleManagement.cs +++ b/Basis/Packages/com.basis.framework/Bundle Management/BasisBundleManagement.cs @@ -12,18 +12,18 @@ public static class BasisBundleManagement // Dictionary to track ongoing downloads keyed by MetaURL public static BasisProgressReport FindAllBundlesReport = new BasisProgressReport(); - public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper BasisTrackedBundleWrapper, BasisProgressReport progressCallback, CancellationToken cancellationToken) + public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper BasisTrackedBundleWrapper, BasisProgressReport progressCallback, CancellationToken cancellationToken) { if (BasisTrackedBundleWrapper == null) { BasisDebug.LogError("Basis Tracked Bundle Wrapper is null."); - return; + return false; } if (BasisTrackedBundleWrapper.LoadableBundle == null || BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted == null) { BasisDebug.LogError("Loadable Bundle or Basis Remote Bundle Encrypted is null."); - return; + return false; } string metaUrl = BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL; @@ -31,7 +31,7 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (string.IsNullOrEmpty(metaUrl)) { BasisDebug.LogError("MetaURL is null or empty."); - return; + return false; } BasisDebug.Log($"Starting download process for {metaUrl}"); @@ -44,14 +44,14 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (string.IsNullOrEmpty(UniqueDownload)) { BasisDebug.LogError("Failed to generate a unique ID."); - return; + return false; } string UniqueFilePath = BasisIOManagement.GenerateFilePath($"Temp_{UniqueDownload}{EncryptedMetaBasisSuffix}", LockedBundlesFolder); if (string.IsNullOrEmpty(UniqueFilePath)) { BasisDebug.LogError("Failed to generate file path for the unique file."); - return; + return false; } if (File.Exists(UniqueFilePath)) @@ -64,7 +64,7 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (!File.Exists(BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL)) { BasisDebug.LogError($"Local meta file not found: {metaUrl}"); - return; + return false; } File.Copy(BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL, UniqueFilePath); // The goal here is just to get the data out @@ -81,7 +81,7 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (BasisTrackedBundleWrapper.LoadableBundle == null) { BasisDebug.LogError("Failed to decrypt meta file, Loadable Bundle is null."); - return; + return false; } // Step 4: Download the bundle file @@ -90,27 +90,27 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (string.IsNullOrEmpty(bundleUrl)) { BasisDebug.LogError("BundleURL is null or empty."); - return; + return false; } BasisDebug.Log($"Downloading bundle file from {bundleUrl}"); - if (BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation == null) + if (BasisTrackedBundleWrapper.LoadableBundle.BasisBundleConnector == null) { BasisDebug.LogError("Missing Basis Bundle Information for Loaded Bundle ", BasisDebug.LogTag.System); - return; + return false; } - if (BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated == null) + if (BasisTrackedBundleWrapper.LoadableBundle.BasisBundleConnector.BasisBundleGenerated == null) { BasisDebug.LogError("Missing Basis Bundle Generated for Loaded Bundle ", BasisDebug.LogTag.System); - return; + return false; } - string FilePathMeta = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName}{EncryptedMetaBasisSuffix}", AssetBundlesFolder); - string FilePathBundle = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName}{EncryptedBundleBasisSuffix}", AssetBundlesFolder); + string FilePathMeta = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleConnector.BasisBundleGenerated[0].AssetToLoadName}{EncryptedMetaBasisSuffix}", AssetBundlesFolder); + string FilePathBundle = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleConnector.BasisBundleGenerated[0].AssetToLoadName}{EncryptedBundleBasisSuffix}", AssetBundlesFolder); if (string.IsNullOrEmpty(FilePathMeta) || string.IsNullOrEmpty(FilePathBundle)) { BasisDebug.LogError("Failed to generate file paths for meta or bundle."); - return; + return false; } if (File.Exists(FilePathMeta)) @@ -125,7 +125,7 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba if (!File.Exists(bundleUrl)) { BasisDebug.LogError($"Local bundle file not found: {bundleUrl}"); - return; + return false; } if (File.Exists(FilePathBundle)) @@ -143,25 +143,26 @@ public static async Task DownloadStoreMetaAndBundle(BasisTrackedBundleWrapper Ba BasisDebug.Log($"Successfully downloaded bundle file for {bundleUrl}"); BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalBundleFile = FilePathBundle; BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalMetaFile = FilePathMeta; + return true; } catch (Exception ex) { BasisDebug.LogError($"Error during download and processing of meta: {ex.Message} {ex.StackTrace}"); - BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.HasError = true; + return false; } } - public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper BasisTrackedBundleWrapper, BasisProgressReport progressCallback, CancellationToken cancellationToken) + public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper BasisTrackedBundleWrapper, BasisProgressReport progressCallback, CancellationToken cancellationToken) { if (BasisTrackedBundleWrapper == null) { BasisDebug.LogError("BasisTrackedBundleWrapper is null."); - return; + return false; } if (BasisTrackedBundleWrapper.LoadableBundle == null || BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted == null) { BasisDebug.LogError("LoadableBundle or BasisRemoteBundleEncrypted is null."); - return; + return false; } string metaUrl = BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL; @@ -169,7 +170,7 @@ public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper Basis if (string.IsNullOrEmpty(metaUrl)) { BasisDebug.LogError("MetaURL is null or empty."); - return; + return false; } BasisDebug.Log($"Starting download process for {metaUrl}"); @@ -182,14 +183,14 @@ public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper Basis if (string.IsNullOrEmpty(UniqueDownload)) { BasisDebug.LogError("Failed to generate a unique ID."); - return; + return false; } string UniqueFilePath = BasisIOManagement.GenerateFilePath($"{UniqueDownload}{EncryptedMetaBasisSuffix}", LockedBundlesFolder); if (string.IsNullOrEmpty(UniqueFilePath)) { BasisDebug.LogError("Failed to generate file path for the unique file."); - return; + return false; } if (File.Exists(UniqueFilePath)) @@ -202,7 +203,7 @@ public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper Basis if (!File.Exists(BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL)) { BasisDebug.LogError($"Local meta file not found: {metaUrl}"); - return; + return false; } File.Copy(BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.MetaURL, UniqueFilePath); // The goal here is just to get the data out @@ -219,16 +220,16 @@ public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper Basis if (BasisTrackedBundleWrapper.LoadableBundle == null) { BasisDebug.LogError("Failed to decrypt meta file, LoadableBundle is null."); - return; + return false; } // Move the meta file to its final destination - string FilePathMeta = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName}{EncryptedMetaBasisSuffix}", AssetBundlesFolder); + string FilePathMeta = BasisIOManagement.GenerateFilePath($"{BasisTrackedBundleWrapper.LoadableBundle.BasisBundleConnector.BasisBundleGenerated[0].AssetToLoadName}{EncryptedMetaBasisSuffix}", AssetBundlesFolder); if (string.IsNullOrEmpty(FilePathMeta)) { BasisDebug.LogError("Failed to generate file path for the meta file."); - return; + return false; } if (File.Exists(FilePathMeta)) @@ -241,11 +242,12 @@ public static async Task DownloadAndSaveMetaFile(BasisTrackedBundleWrapper Basis BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalMetaFile = FilePathMeta; BasisDebug.Log($"Meta file saved successfully at {FilePathMeta}"); + return true; } catch (Exception ex) { BasisDebug.LogError($"Error during download and processing of meta: {ex.Message}"); - BasisTrackedBundleWrapper.LoadableBundle.BasisBundleInformation.HasError = true; + return false; } } public static async Task ProcessOnDiscMetaDataAsync(BasisTrackedBundleWrapper basisTrackedBundleWrapper, BasisStoredEncyptedBundle BasisStoredEncyptedBundle, BasisProgressReport progressCallback, CancellationToken cancellationToken) diff --git a/Basis/Packages/com.basis.framework/Bundle Management/BasisLoadhandler.cs b/Basis/Packages/com.basis.framework/Bundle Management/BasisLoadhandler.cs index 22d7abd67..f949dd5f2 100644 --- a/Basis/Packages/com.basis.framework/Bundle Management/BasisLoadhandler.cs +++ b/Basis/Packages/com.basis.framework/Bundle Management/BasisLoadhandler.cs @@ -185,46 +185,54 @@ public static async Task HandleBundleAndMetaLoading(BasisTrackedBundleWrapper wr { BasisDebug.Log("Bundle was already on disc proceeding", BasisDebug.LogTag.Event); } - IEnumerable AssetBundles = AssetBundle.GetAllLoadedAssetBundles(); - foreach (AssetBundle assetBundle in AssetBundles) + if (wrapper.LoadableBundle.BasisBundleConnector.GetPlatform(out BasisBundleGenerated Generated)) { - if (assetBundle != null && assetBundle.Contains(wrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName)) + IEnumerable AssetBundles = AssetBundle.GetAllLoadedAssetBundles(); + foreach (AssetBundle assetBundle in AssetBundles) { - wrapper.AssetBundle = assetBundle; - BasisDebug.Log("we already have this AssetToLoadName in our loaded bundles using that instead!"); - if (IsMetaOnDisc == false || IsBundleOnDisc == false) + if (assetBundle != null && assetBundle.Contains(Generated.AssetToLoadName)) { - OnDiscInformation newDiscInfo = new OnDiscInformation + wrapper.AssetBundle = assetBundle; + BasisDebug.Log("we already have this AssetToLoadName in our loaded bundles using that instead!"); + if (IsMetaOnDisc == false || IsBundleOnDisc == false) { - StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, - StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, - AssetIDToLoad = wrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName, - }; - - await AddDiscInfo(newDiscInfo); + OnDiscInformation newDiscInfo = new OnDiscInformation + { + StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, + StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, + AssetIDToLoad = Generated.AssetToLoadName, + }; + + await AddDiscInfo(newDiscInfo); + } + return; } - return; } - } - AssetBundleCreateRequest bundleRequest = await BasisEncryptionToData.GenerateBundleFromFile( - wrapper.LoadableBundle.UnlockPassword, - wrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalBundleFile, - wrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetBundleCRC, - report - ); - wrapper.AssetBundle = bundleRequest.assetBundle; + AssetBundleCreateRequest bundleRequest = await BasisEncryptionToData.GenerateBundleFromFile( + wrapper.LoadableBundle.UnlockPassword, + wrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalBundleFile, + Generated.AssetBundleCRC, + report + ); - if (IsMetaOnDisc == false || IsBundleOnDisc == false) - { - OnDiscInformation newDiscInfo = new OnDiscInformation + wrapper.AssetBundle = bundleRequest.assetBundle; + + if (IsMetaOnDisc == false || IsBundleOnDisc == false) { - StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, - StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, - AssetIDToLoad = wrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName, - }; + OnDiscInformation newDiscInfo = new OnDiscInformation + { + StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, + StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, + AssetIDToLoad = Generated.AssetToLoadName, + }; - await AddDiscInfo(newDiscInfo); + await AddDiscInfo(newDiscInfo); + } + } + else + { + BasisDebug.LogError("Missing Bundle Request Platform for " + Application.platform); } } public static async Task HandleMetaLoading(BasisTrackedBundleWrapper wrapper, BasisProgressReport report, CancellationToken cancellationToken) @@ -242,14 +250,20 @@ public static async Task HandleMetaLoading(BasisTrackedBundleWrapper wrapper, Ba if (!isOnDisc) { - OnDiscInformation newDiscInfo = new OnDiscInformation + if (wrapper.LoadableBundle.BasisBundleConnector.GetPlatform(out BasisBundleGenerated Generated)) { - StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, - StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, - AssetIDToLoad = wrapper.LoadableBundle.BasisBundleInformation.BasisBundleGenerated.AssetToLoadName, - }; - - await AddDiscInfo(newDiscInfo); + OnDiscInformation newDiscInfo = new OnDiscInformation + { + StoredRemote = wrapper.LoadableBundle.BasisRemoteBundleEncrypted, + StoredLocal = wrapper.LoadableBundle.BasisLocalEncryptedBundle, + AssetIDToLoad = Generated.AssetToLoadName, + }; + await AddDiscInfo(newDiscInfo); + } + else + { + BasisDebug.LogError("Missing Bundle Request Platform for " + Application.platform); + } } } public static bool IsMetaDataOnDisc(string MetaURL, out OnDiscInformation info) diff --git a/Basis/Packages/com.basis.framework/Bundle Management/EncryptionToData/BasisEncryptionToData.cs b/Basis/Packages/com.basis.framework/Bundle Management/EncryptionToData/BasisEncryptionToData.cs index 82474ff56..336527d90 100644 --- a/Basis/Packages/com.basis.framework/Bundle Management/EncryptionToData/BasisEncryptionToData.cs +++ b/Basis/Packages/com.basis.framework/Bundle Management/EncryptionToData/BasisEncryptionToData.cs @@ -58,20 +58,27 @@ public static async Task GenerateMetaFromFile(BasisLoadable // BasisDebug.Log("BasisLoadableBundle.UnlockPassword" + BasisLoadableBundle.UnlockPassword); byte[] LoadedMetaData = await BasisEncryptionWrapper.DecryptFileAsync(UniqueID, BasisPassword, FilePath, progressCallback, 81920); BasisDebug.Log("Converting decrypted meta file to BasisBundleInformation...", BasisDebug.LogTag.Event); - BasisLoadableBundle.BasisBundleInformation = ConvertBytesToJson(LoadedMetaData); - return BasisLoadableBundle; + if (ConvertBytesToJson(LoadedMetaData, out BasisLoadableBundle.BasisBundleConnector)) + { + return BasisLoadableBundle; + } + else + { + return null; + } } - public static BasisBundleConnector ConvertBytesToJson(byte[] loadedlocalmeta) + public static bool ConvertBytesToJson(byte[] loadedlocalmeta,out BasisBundleConnector BasisBundleConnector) { if (loadedlocalmeta == null || loadedlocalmeta.Length == 0) { BasisDebug.LogError($"Data for {nameof(BasisBundleConnector)} is empty or null.", BasisDebug.LogTag.Event); - return new BasisBundleInformation() { HasError = true }; + BasisBundleConnector = null; + return false; } // Convert the byte array to a JSON string (assuming UTF-8 encoding) BasisDebug.Log($"Converting byte array to JSON string...", BasisDebug.LogTag.Event); - BasisBundleConnector Information = SerializationUtility.DeserializeValue(loadedlocalmeta, DataFormat.JSON); - return Information; + BasisBundleConnector = SerializationUtility.DeserializeValue(loadedlocalmeta, DataFormat.JSON); + return true; } } diff --git a/Basis/Packages/com.basis.framework/Players/BasisLocalPlayer.cs b/Basis/Packages/com.basis.framework/Players/BasisLocalPlayer.cs index ef4ed9d33..c786e2865 100644 --- a/Basis/Packages/com.basis.framework/Players/BasisLocalPlayer.cs +++ b/Basis/Packages/com.basis.framework/Players/BasisLocalPlayer.cs @@ -117,11 +117,7 @@ public async Task LoadInitalAvatar(BasisDataStore.BasisSavedAvatar LastUsedAvata BasisLoadableBundle bundle = new BasisLoadableBundle { BasisRemoteBundleEncrypted = info.StoredRemote, - BasisBundleInformation = new BasisBundleInformation - { - BasisBundleDescription = new BasisBundleDescription(), - BasisBundleGenerated = new BasisBundleGenerated() - }, + BasisBundleConnector = new BasisBundleConnector("1", new BasisBundleDescription("Loading Avatar", "Loading Avatar"),new BasisBundleGenerated[] { new BasisBundleGenerated()}), BasisLocalEncryptedBundle = info.StoredLocal, UnlockPassword = Key.Pass }; diff --git a/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundleBuilder.cs b/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundleBuilder.cs index 6e0709d6b..c5a93aa3d 100644 --- a/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundleBuilder.cs +++ b/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundleBuilder.cs @@ -6,14 +6,14 @@ using static BasisEncryptionWrapper; public static class AssetBundleBuilder { - public static async Task BuildAssetBundle(string targetDirectory,BasisAssetBundleObject settings,string assetBundleName,BasisBundleConnector basisBundleConnector,string mode,string password,BuildTarget buildTarget,bool isEncrypted = true) + public static async Task BuildAssetBundle(string targetDirectory,BasisAssetBundleObject settings,string assetBundleName,string mode,string password,BuildTarget buildTarget,bool isEncrypted = true) { EnsureDirectoryExists(targetDirectory); EditorUtility.DisplayProgressBar("Building Asset Bundles", "Initializing...", 0f); AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(targetDirectory, settings.BuildAssetBundleOptions, buildTarget); if (manifest != null) { - await ProcessAssetBundles(targetDirectory, settings, manifest, password, isEncrypted,password); + InformationHash Hash = await ProcessAssetBundles(targetDirectory, settings, manifest, password, isEncrypted,password); DeleteManifestFiles(targetDirectory); } else @@ -21,7 +21,6 @@ public static async Task BuildAssetBundle(string targetDir BasisDebug.LogError("AssetBundle build failed."); } EditorUtility.ClearProgressBar(); - return basisBundleConnector; } private static async Task ProcessAssetBundles(string targetDirectory,BasisAssetBundleObject settings,AssetBundleManifest manifest,string password,bool isEncrypted,string PasswordTextFileFolderPath) { diff --git a/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundlePipeline.cs b/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundlePipeline.cs index b6cda5c47..0e575b2eb 100644 --- a/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundlePipeline.cs +++ b/Basis/Packages/com.basis.sdk/Scripts/Editor/AssetBundleBuilder/BasisAssetBundlePipeline.cs @@ -51,16 +51,16 @@ public static void ClearOutExistingSets() Debug.Log("All AssetBundle names cleared from Importer settings."); } - public static async Task BuildAssetBundle(GameObject originalPrefab, BasisAssetBundleObject settings, BasisBundleConnector BasisBundleConnector, string Password, BuildTarget Target) + public static async Task<(bool, BasisBundleGenerated)> BuildAssetBundle(GameObject originalPrefab, BasisAssetBundleObject settings, string Password, BuildTarget Target) { - return await BuildAssetBundle(false, originalPrefab, new Scene(), settings, BasisBundleConnector, Password, Target); + return await BuildAssetBundle(false, originalPrefab, new Scene(), settings, Password, Target); } - public static async Task BuildAssetBundle(Scene scene, BasisAssetBundleObject settings, BasisBundleConnector BasisBundleConnector, string Password, BuildTarget Target) + public static async Task<(bool, BasisBundleGenerated)> BuildAssetBundle(Scene scene, BasisAssetBundleObject settings, string Password, BuildTarget Target) { - return await BuildAssetBundle(true, null, scene, settings, BasisBundleConnector, Password, Target); + return await BuildAssetBundle(true, null, scene, settings, Password, Target); } - public static async Task BuildAssetBundle(bool isScene, GameObject asset, Scene scene, BasisAssetBundleObject settings, BasisBundleConnector BasisBundleConnector, string Password, BuildTarget Target) + public static async Task<(bool,BasisBundleGenerated)> BuildAssetBundle(bool isScene, GameObject asset, Scene scene, BasisAssetBundleObject settings, string Password, BuildTarget Target) { if (EditorUserBuildSettings.activeBuildTarget != Target) { @@ -84,7 +84,7 @@ public static async Task BuildAssetBundle(bool isScene, GameObject asset, if (!BasisValidationHandler.IsSceneValid(scene)) { Debug.LogError("Invalid scene. AssetBundle build aborted."); - return false; + return new (false, null); } OnBeforeBuildScene?.Invoke(scene, settings); @@ -98,7 +98,7 @@ public static async Task BuildAssetBundle(bool isScene, GameObject asset, } string assetBundleName = AssetBundleBuilder.SetAssetBundleName(assetPath, uniqueID, settings); - await AssetBundleBuilder.BuildAssetBundle(targetDirectory, settings, assetBundleName, BasisBundleConnector, isScene ? "Scene" : "GameObject", Password, Target); + await AssetBundleBuilder.BuildAssetBundle(targetDirectory, settings, assetBundleName, isScene ? "Scene" : "GameObject", Password, Target); AssetBundleBuilder.ResetAssetBundleName(assetPath); TemporaryStorageHandler.ClearTemporaryStorage(settings.TemporaryStorage); @@ -113,7 +113,7 @@ public static async Task BuildAssetBundle(bool isScene, GameObject asset, OnAfterBuildPrefab?.Invoke(assetBundleName); } - return true; + return new(true,); } catch (Exception ex) { @@ -129,7 +129,7 @@ public static async Task BuildAssetBundle(bool isScene, GameObject asset, EditorUtility.DisplayDialog("Failed To Build", "Please check the console for the full issue: " + ex, "Will do"); } - return false; + return new(false, null); } finally { diff --git a/Basis/Packages/com.basis.sdk/Scripts/Editor/SDKInspector/BasisBundleBuild.cs b/Basis/Packages/com.basis.sdk/Scripts/Editor/SDKInspector/BasisBundleBuild.cs index 4960fc68b..7e224199a 100644 --- a/Basis/Packages/com.basis.sdk/Scripts/Editor/SDKInspector/BasisBundleBuild.cs +++ b/Basis/Packages/com.basis.sdk/Scripts/Editor/SDKInspector/BasisBundleBuild.cs @@ -39,20 +39,24 @@ public static class BasisBundleBuild Targets.Remove(activeTarget); Targets.Insert(0, activeTarget); } + BasisAssetBundleObject Objects = AssetDatabase.LoadAssetAtPath(BasisAssetBundleObject.AssetBundleObject); + Debug.Log("Generating random bytes for hex string..."); + byte[] randomBytes = GenerateRandomBytes(32); + string hexString = ByteArrayToHexString(randomBytes); + Debug.Log($"Generated hex string: {hexString}"); Debug.Log("IL2CPP is installed. Proceeding to build asset bundle..."); foreach (BuildTarget Target in Targets) { - bool Success = await BasisAssetBundlePipeline.BuildAssetBundle(BasisContentBase.gameObject, Objects, Information, hexString, Target); + bool Success = await BasisAssetBundlePipeline.BuildAssetBundle(BasisContentBase.gameObject, Objects, hexString, Target); if (Success == false) { return new(false, "Failure While Building for " + Target); } } Debug.Log("Passed error checking for GameObjectBundleBuild..."); - BasisBundleGenerated[] Generated = new BasisBundleGenerated[] { }; - BasisBundleInformation(BasisContentBase, Generated, out BasisAssetBundleObject Objects, out BasisBundleConnector Information, out string hexString); - Debug.Log($"Generated bundle information. Hex string: {hexString}"); + + BasisBundleConnector BasisBundleConnector = new BasisBundleConnector(BasisGenerateUniqueID.GenerateUniqueID(), BasisContentBase.BasisBundleDescription,); Debug.Log("Successfully built GameObject asset bundle."); @@ -83,10 +87,6 @@ public static class BasisBundleBuild } Debug.Log("Passed error checking for SceneBundleBuild..."); - - BasisBundleInformation(BasisContentBase, out BasisAssetBundleObject Objects, out BasisBundleConnector Information, out string hexString); - Debug.Log($"Generated bundle information. Hex string: {hexString}"); - // Ensure active build target is first in the list BuildTarget activeTarget = EditorUserBuildSettings.activeBuildTarget; if (!Targets.Contains(activeTarget)) @@ -99,19 +99,26 @@ public static class BasisBundleBuild Targets.Remove(activeTarget); Targets.Insert(0, activeTarget); } + BasisAssetBundleObject Objects = AssetDatabase.LoadAssetAtPath(BasisAssetBundleObject.AssetBundleObject); + Debug.Log("Generating random bytes for hex string..."); + byte[] randomBytes = GenerateRandomBytes(32); + string hexString = ByteArrayToHexString(randomBytes); + Debug.Log($"Generated hex string: {hexString}"); - Debug.Log("IL2CPP is installed. Proceeding to build scene asset bundle..."); - Scene activeScene = BasisContentBase.gameObject.scene; + Debug.Log("IL2CPP is installed. Proceeding to build asset bundle..."); foreach (BuildTarget Target in Targets) { - bool Success = await BasisAssetBundlePipeline.BuildAssetBundle(activeScene, Objects, Information, hexString, Target); + bool Success = await BasisAssetBundlePipeline.BuildAssetBundle(BasisContentBase.gameObject, Objects, hexString, Target); if (Success == false) { return new(false, "Failure While Building for " + Target); } } + Debug.Log("Passed error checking for GameObjectBundleBuild..."); + BasisBundleGenerated[] Generated = new BasisBundleGenerated[] { }; + BasisBundleConnector BasisBundleConnector = new BasisBundleConnector(BasisGenerateUniqueID.GenerateUniqueID(), BasisContentBase.BasisBundleDescription, Generated); - Debug.Log("Successfully built Scene asset bundle."); + Debug.Log("Successfully built GameObject asset bundle."); // If the original active target was not the current one, switch back if (EditorUserBuildSettings.activeBuildTarget != originalActiveTarget) @@ -157,19 +164,6 @@ public static void OpenFolderInExplorer(string folderPath) Debug.LogError("Path does not exist: " + windowsPath); } } - public static void BasisBundleInformation(BasisContentBase BasisContentBase, BasisBundleGenerated[] BasisBundleGenerateds, out BasisAssetBundleObject BasisAssetBundleObject, out BasisBundleConnector basisBundleInformation, out string hexString) - { - Debug.Log("Fetching BasisBundleInformation..."); - - BasisAssetBundleObject = AssetDatabase.LoadAssetAtPath(BasisAssetBundleObject.AssetBundleObject); - basisBundleInformation = new BasisBundleConnector(BasisGenerateUniqueID.GenerateUniqueID(), BasisContentBase.BasisBundleDescription, BasisBundleGenerateds); - - Debug.Log("Generating random bytes for hex string..."); - byte[] randomBytes = GenerateRandomBytes(32); - hexString = ByteArrayToHexString(randomBytes); - Debug.Log($"Generated hex string: {hexString}"); - } - public static bool ErrorChecking(BasisContentBase BasisContentBase, out string Error) { Error = string.Empty; // Initialize the error variable