initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
|
@ -0,0 +1,33 @@
|
|||
#region CONTENT_BUILT_CHECK
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor.AddressableAssets;
|
||||
using UnityEditor.AddressableAssets.Build;
|
||||
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class ContentBuiltCheck : IPreprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder => 1;
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
// we don't want to throw the exception in our continuous integration environment
|
||||
if (Application.isBatchMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var settingsPath = Addressables.BuildPath + "/settings.json";
|
||||
if (!File.Exists(settingsPath))
|
||||
{
|
||||
throw new System.Exception("Player content has not been built. Aborting build until content is built. This can be done from the Addressables window in the Build->Build Player Content menu command.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc282c9c64eccda4392e29f59439a37e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.AddressableAssets.ResourceLocators;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
|
||||
internal class UsingAddResourceLocator
|
||||
{
|
||||
#region DECLARATION
|
||||
public static void AddResourceLocator(IResourceLocator locator, string localCatalogHash = null, IResourceLocation remoteCatalogLocation = null)
|
||||
#endregion
|
||||
{ }
|
||||
|
||||
#region SAMPLE_ADDLOCATOR
|
||||
private string m_SourceFolder = "dataFiles";
|
||||
|
||||
public void AddFileLocatorToAddressables()
|
||||
{
|
||||
if (!Directory.Exists(m_SourceFolder))
|
||||
return;
|
||||
|
||||
ResourceLocationMap locator = new ResourceLocationMap(m_SourceFolder + "_FilesLocator", 12);
|
||||
string providerId = typeof(TextDataProvider).ToString();
|
||||
|
||||
string[] files = Directory.GetFiles(m_SourceFolder);
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
if (!filePath.EndsWith(".json"))
|
||||
continue;
|
||||
string keyForLoading = Path.GetFileNameWithoutExtension(filePath);
|
||||
locator.Add(keyForLoading, new ResourceLocationBase(keyForLoading, filePath, providerId, typeof(string)));
|
||||
}
|
||||
Addressables.AddResourceLocator(locator);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_LOADING
|
||||
private string m_DataFileName = "settings";
|
||||
|
||||
public IEnumerator LoadDataUsingAddedLocator()
|
||||
{
|
||||
var loadingHandle = Addressables.LoadAssetAsync<string>(m_DataFileName);
|
||||
yield return loadingHandle;
|
||||
Debug.Log("Load completed " + loadingHandle.Status + (loadingHandle.Status == AsyncOperationStatus.Succeeded ? ", with result " + loadingHandle.Result : ""));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 08d6d38651abd624b9c945a1ed5d80bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.AddressableAssets.Initialization;
|
||||
|
||||
internal class UsingBuildPath
|
||||
{
|
||||
#region GET_SETTINGS_FROM_BUILDPATH
|
||||
public string GetBuiltContentAddressablesVersion()
|
||||
{
|
||||
string settingsPath = Addressables.BuildPath + "/settings.json";
|
||||
if (System.IO.File.Exists(settingsPath))
|
||||
{
|
||||
string json = System.IO.File.ReadAllText(settingsPath);
|
||||
ResourceManagerRuntimeData activeRuntimeSettings =
|
||||
JsonUtility.FromJson<ResourceManagerRuntimeData>(json);
|
||||
return activeRuntimeSettings.AddressablesVersion;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ba9fc75a0048b0469b01c6cf75f65e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingCheckForCatalogUpdates
|
||||
{
|
||||
#region DECLARATION
|
||||
public static AsyncOperationHandle<List<string>> CheckForCatalogUpdates(bool autoReleaseHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
public void UsingCheckForCatalogUpdatesSample()
|
||||
{
|
||||
#region SAMPLE
|
||||
Addressables.CheckForCatalogUpdates().Completed += op =>
|
||||
{
|
||||
if (op.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
foreach (string catalogWithUpdate in op.Result)
|
||||
Debug.Log($"Catalog {catalogWithUpdate} has an available update.");
|
||||
}
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fae9482157db504bbc96bab93cc2e52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingCleanBundleCache
|
||||
{
|
||||
#region DECLARATION
|
||||
public static AsyncOperationHandle<bool> CleanBundleCache(IEnumerable<string> catalogsIds = null)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region SAMPLE_ALL
|
||||
public void UsingCleanBundleCacheForAllCatalogs()
|
||||
{
|
||||
// clear for all currently loaded catalogs
|
||||
// if catalogIds are provided, only those catalogs are used from the currently loaded
|
||||
AsyncOperationHandle<bool> cleanBundleCacheHandle = Addressables.CleanBundleCache();
|
||||
cleanBundleCacheHandle.Completed += op =>
|
||||
{
|
||||
// during caching a reference is added to the catalogs.
|
||||
// release is needed to reduce the reference and allow catalog to be uncached for updating
|
||||
Addressables.Release(op);
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_SPECIFY
|
||||
public void UsingCleanBundleCacheWithcatalogIds()
|
||||
{
|
||||
HashSet<string> catalogsIds = new HashSet<string>();
|
||||
foreach (var locator in Addressables.ResourceLocators)
|
||||
{
|
||||
if (locator.LocatorId == "AddressablesMainContentCatalog")
|
||||
{
|
||||
catalogsIds.Add(locator.LocatorId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (catalogsIds.Count == 0)
|
||||
return;
|
||||
|
||||
var cleanBundleCacheHandle = Addressables.CleanBundleCache(catalogsIds);
|
||||
cleanBundleCacheHandle.Completed += op =>
|
||||
{
|
||||
// during caching a reference is added to the catalogs.
|
||||
// release is needed to reduce the reference and allow catalog to be uncached for updating
|
||||
Addressables.Release(op);
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 255df104f26ec08439fcee2d0df9ae0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingClearDependencyCacheAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingClearDependencyCacheAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e94e1c7d8bd4b842a1d59b7eefc8a34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingClearResourceLocators
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingClearResourceLocatorsSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1a93de9886d3e5046be743fac772d5c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingCreateCatalogLocationWithHashDependencies
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingCreateCatalogLocationWithHashDependenciesSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5127a10aa9aa1f147b436d8241d02ce0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingDownloadDependencies
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingDownloadDependenciesSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d165a767fad23a54d963742efdf90740
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingDownloadDependenciesAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingDownloadDependenciesAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 07dd3f1d43b528f4ea00ed7dcb84972d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingGetDownloadSize
|
||||
{
|
||||
#region DECLARATION
|
||||
public static AsyncOperationHandle<long> GetDownloadSize(object key)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ca20cc03036f2e428964397259f253a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingGetDownloadSizeAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingGetDownloadSizeAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 48d6c3468cb636c449f15b9361793735
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.AddressableAssets.ResourceLocators;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingGetLocatorInfo
|
||||
{
|
||||
#region DECLARATION_1
|
||||
public static ResourceLocatorInfo GetLocatorInfo(string locatorId)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_2
|
||||
public static ResourceLocatorInfo GetLocatorInfo(IResourceLocator locator)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region SAMPLE_1
|
||||
IEnumerator UsingGetLocatorInfoSampleId()
|
||||
{
|
||||
yield return Addressables.InitializeAsync();
|
||||
IEnumerable<IResourceLocator> resourceLocators = Addressables.ResourceLocators;
|
||||
foreach (IResourceLocator locator in resourceLocators)
|
||||
{
|
||||
// Call GetLocatorInfo using the locator id
|
||||
ResourceLocatorInfo locatorInfo = Addressables.GetLocatorInfo(locator.LocatorId);
|
||||
if (locatorInfo != null && locatorInfo.CatalogLocation != null)
|
||||
{
|
||||
if (locatorInfo.CanUpdateContent)
|
||||
Debug.Log($"Locator {locator.LocatorId} was loaded from an UPDATABLE catalog with internal id : {locatorInfo.CatalogLocation.InternalId}");
|
||||
else
|
||||
Debug.Log($"Locator {locator.LocatorId} was loaded from an NON-UPDATABLE catalog with internal id : {locatorInfo.CatalogLocation.InternalId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Locator {locator.LocatorId} is not associated with a catalog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_2
|
||||
IEnumerator UsingGetLocatorInfoSampleLocator()
|
||||
{
|
||||
yield return Addressables.InitializeAsync();
|
||||
IEnumerable<IResourceLocator> resourceLocators = Addressables.ResourceLocators;
|
||||
foreach (IResourceLocator locator in resourceLocators)
|
||||
{
|
||||
// Call GetLocatorInfo using the locator object
|
||||
ResourceLocatorInfo locatorInfo = Addressables.GetLocatorInfo(locator);
|
||||
if (locatorInfo != null && locatorInfo.CatalogLocation != null)
|
||||
{
|
||||
if (locatorInfo.CanUpdateContent)
|
||||
Debug.Log($"Locator {locator.LocatorId} was loaded from an UPDATABLE catalog with internal id : {locatorInfo.CatalogLocation.InternalId}");
|
||||
else
|
||||
Debug.Log($"Locator {locator.LocatorId} was loaded from an NON-UPDATABLE catalog with internal id : {locatorInfo.CatalogLocation.InternalId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Locator {locator.LocatorId} is not associated with a catalog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3e43e1a65262edd4f99dd21ce8ee50ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets.ResourceLocators;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingInitializationOperation
|
||||
{
|
||||
#region DECLARATION
|
||||
public static AsyncOperationHandle<IResourceLocator> InitializationOperation { get; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4061552d898b3a04696a1cefac59e068
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets.ResourceLocators;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingInitialize
|
||||
{
|
||||
#region DECLARATION
|
||||
public static AsyncOperationHandle<IResourceLocator> Initialize()
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7aebf13e806bda4db01138506100f36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.AddressableAssets.ResourceLocators;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
|
||||
internal class UsingInitializeAsync
|
||||
{
|
||||
#region DECLARATION_1
|
||||
public static AsyncOperationHandle<IResourceLocator> InitializeAsync()
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_2
|
||||
public static AsyncOperationHandle<IResourceLocator> InitializeAsync(bool autoReleaseHandle)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region SAMPLE_LOADALL
|
||||
void UsingInitializeAsyncSampleCallback()
|
||||
{
|
||||
Addressables.InitializeAsync().Completed += OnInitializeComplete;
|
||||
}
|
||||
|
||||
void OnInitializeComplete(AsyncOperationHandle<IResourceLocator> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log("Addressables initialization succeeded");
|
||||
IResourceLocator locator = handle.Result;
|
||||
|
||||
// locator.Keys includes bundle names and other identifiers from the local catalog.
|
||||
foreach (object locatorKey in locator.Keys)
|
||||
{
|
||||
locator.Locate(locatorKey, typeof(UnityEngine.Object), out IList<IResourceLocation> locations);
|
||||
if (locations == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (IResourceLocation location in locations)
|
||||
{
|
||||
// The key representing the location of an Addressable asset.
|
||||
string locationKey = location.InternalId;
|
||||
Addressables.LoadAssetAsync<UnityEngine.Object>(locationKey).Completed += OnLoadAssetComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnLoadAssetComplete(AsyncOperationHandle<UnityEngine.Object> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully loaded {handle.Result.name} ({handle.Result.GetType()})");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_TASK
|
||||
async Task UsingInitializeAsyncSampleTask()
|
||||
{
|
||||
AsyncOperationHandle<IResourceLocator> handle = Addressables.InitializeAsync(false);
|
||||
await handle.Task;
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log("Addressables initialization succeeded");
|
||||
IResourceLocator locator = handle.Result;
|
||||
Debug.Log($"The resource locator returned has an id of {locator.LocatorId}");
|
||||
}
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a0e76a5271d67041be5c790b6c724fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
|
||||
internal class UsingInstanceProvider
|
||||
{
|
||||
#region DECLARATION
|
||||
public static IInstanceProvider InstanceProvider { get; }
|
||||
#endregion
|
||||
|
||||
#region SAMPLE
|
||||
public AssetReferenceGameObject asset; // Identify the asset
|
||||
AsyncOperationHandle<GameObject> instHandle;
|
||||
AsyncOperationHandle<IList<IResourceLocation>> locHandle;
|
||||
|
||||
void UsingInstanceProviderSample()
|
||||
{
|
||||
locHandle = Addressables.LoadResourceLocationsAsync(asset, typeof(GameObject));
|
||||
locHandle.Completed += OnLoadComplete;
|
||||
}
|
||||
|
||||
void OnLoadComplete(AsyncOperationHandle<IList<IResourceLocation>> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully loaded resource locations");
|
||||
foreach (IResourceLocation location in handle.Result)
|
||||
{
|
||||
ResourceManager rm = Addressables.ResourceManager;
|
||||
IInstanceProvider provider = Addressables.InstanceProvider;
|
||||
instHandle = rm.ProvideInstance(provider, location, default(InstantiationParameters));
|
||||
instHandle.Completed += OnProvideInstanceComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnProvideInstanceComplete(AsyncOperationHandle<GameObject> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully instantiated GameObject named '{handle.Result.name}'");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseResources()
|
||||
{
|
||||
Addressables.Release(locHandle);
|
||||
Addressables.Release(instHandle);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseResources().
|
||||
// For example during OnDestroy().
|
||||
// void OnDestroy()
|
||||
// {
|
||||
// ReleaseResources();
|
||||
// }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cef69ad46d3a2a54aa5198dad625fe82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingInstantiate
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingInstantiateSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d8f1f0a84c60dd84e8aea13155080a5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
|
||||
internal class UsingInstantiateAsync
|
||||
{
|
||||
#region DECLARATION_1
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, Transform parent = null, bool instantiateInWorldSpace = false, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_2
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, Vector3 position, Quaternion rotation, Transform parent = null, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return Addressables.InstantiateAsync(location, position, rotation, parent, trackHandle);
|
||||
}
|
||||
|
||||
#region DECLARATION_3
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, InstantiationParameters instantiateParameters, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_4
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, Transform parent = null, bool instantiateInWorldSpace = false, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_5
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, Vector3 position, Quaternion rotation, Transform parent = null, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_6
|
||||
public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, InstantiationParameters instantiateParameters, bool trackHandle = true)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region SAMPLE_LOCATION
|
||||
public AssetReferenceGameObject assetRefLocation; // Identify the asset
|
||||
public Transform parentTransformLocation; // Identify the transform of the parent GameObject
|
||||
AsyncOperationHandle<IList<IResourceLocation>> locHandle;
|
||||
GameObject instanceLocation;
|
||||
|
||||
void UsingInstantiateAsyncSampleLocation()
|
||||
{
|
||||
locHandle = Addressables.LoadResourceLocationsAsync(assetRefLocation, typeof(GameObject));
|
||||
locHandle.Completed += OnLoadComplete;
|
||||
}
|
||||
|
||||
void OnLoadComplete(AsyncOperationHandle<IList<IResourceLocation>> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully loaded resource locations");
|
||||
foreach (IResourceLocation location in handle.Result)
|
||||
{
|
||||
string locationKey = location.InternalId;
|
||||
var instParams = new InstantiationParameters(parentTransformLocation, false);
|
||||
Addressables.InstantiateAsync(location, instParams).Completed += OnInstantiateCompleteLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnInstantiateCompleteLocation(AsyncOperationHandle<GameObject> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
instanceLocation = handle.Result;
|
||||
Debug.Log($"Successfully instantiated GameObject with name '{instanceLocation.name}'.");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseResourcesLocation()
|
||||
{
|
||||
Addressables.Release(locHandle);
|
||||
Addressables.ReleaseInstance(instanceLocation);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseTrackedResources().
|
||||
// For example during OnDestroy().
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// ReleaseResourcesLocation();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_OBJECT_TRACKED
|
||||
public AssetReferenceGameObject assetRefTracked; // Identify the asset
|
||||
public Transform parentTransformTracked; // Identify the transform of the parent GameObject
|
||||
GameObject instanceTracked;
|
||||
|
||||
void UsingInstantiateAsyncSampleKeyTracked()
|
||||
{
|
||||
var instParams = new InstantiationParameters(parentTransformTracked, false);
|
||||
Addressables.InstantiateAsync(assetRefTracked, instParams).Completed += OnInstantiateCompleteObjectTracked;
|
||||
}
|
||||
|
||||
void OnInstantiateCompleteObjectTracked(AsyncOperationHandle<GameObject> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
instanceTracked = handle.Result;
|
||||
Debug.Log($"Successfully instantiated GameObject with name '{instanceTracked.name}'.");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseTrackedResources()
|
||||
{
|
||||
Addressables.ReleaseInstance(instanceTracked);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseTrackedResources().
|
||||
// For example during OnDestroy().
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// ReleaseTrackedResources();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_OBJECT_UNTRACKED
|
||||
public AssetReferenceGameObject assetRefUntracked; // Identify the asset
|
||||
public Transform parentTransformUntracked; // Identify the transform component of the parent GameObject
|
||||
AsyncOperationHandle<GameObject> handleUntracked;
|
||||
|
||||
void UsingInstantiateAsyncSampleKeyUntracked()
|
||||
{
|
||||
var instParams = new InstantiationParameters(parentTransformUntracked, false);
|
||||
handleUntracked = Addressables.InstantiateAsync(assetRefUntracked, instParams, false);
|
||||
handleUntracked.Completed += OnInstantiateCompleteObjectUntracked;
|
||||
}
|
||||
|
||||
void OnInstantiateCompleteObjectUntracked(AsyncOperationHandle<GameObject> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully instantiated GameObject with name '{handle.Result.name}'.");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseUntrackedResources()
|
||||
{
|
||||
Addressables.Release(handleUntracked);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseUntrackedResources().
|
||||
// For example during OnDestroy().
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// ReleaseUntrackedResources();
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e779c13e241463d4ebc307772337cb19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingInternalIdTransformFunc
|
||||
{
|
||||
#region DECLARATION
|
||||
static public Func<IResourceLocation, string> InternalIdTransformFunc { get; set; }
|
||||
#endregion
|
||||
|
||||
#region SAMPLE
|
||||
public AssetReferenceGameObject asset; // Identify the asset
|
||||
AsyncOperationHandle<GameObject> opHandle;
|
||||
|
||||
void UsingInternalIdTransformFuncSample()
|
||||
{
|
||||
Addressables.InternalIdTransformFunc = MyCustomTransform;
|
||||
opHandle = Addressables.InstantiateAsync(asset);
|
||||
opHandle.Completed += OnInstantiateComplete;
|
||||
}
|
||||
|
||||
//Implement a method to transform the internal ids of locations
|
||||
static string MyCustomTransform(IResourceLocation location)
|
||||
{
|
||||
if (location.ResourceType == typeof(IAssetBundleResource)
|
||||
&& !location.InternalId.StartsWith("http"))
|
||||
{
|
||||
Debug.Log($"Replace local identifier with remote URL : {location.InternalId}");
|
||||
return "file:///" + location.InternalId;
|
||||
}
|
||||
|
||||
return location.InternalId;
|
||||
}
|
||||
|
||||
void OnInstantiateComplete(AsyncOperationHandle<GameObject> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully instantiated GameObject named '{handle.Result.name}'");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseResources()
|
||||
{
|
||||
Addressables.Release(opHandle);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseResources().
|
||||
// For example during OnDestroy().
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// ReleaseResources();
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5bdf414fcef4cf49b67c56a99fea355
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadAsset
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadAssetSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c3607deff504fbc4eb56e16a80415a85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
|
||||
internal class UsingLoadAssetAsync
|
||||
{
|
||||
#region DECLARATION_1
|
||||
public static AsyncOperationHandle<TObject> LoadAssetAsync<TObject>(IResourceLocation location)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region DECLARATION_2
|
||||
public static AsyncOperationHandle<TObject> LoadAssetAsync<TObject>(object key)
|
||||
#endregion
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
#region SAMPLE_LOCATION
|
||||
public AssetReference materialLocation; // Identify the material
|
||||
public GameObject goLocation; // Identify the GameObject
|
||||
AsyncOperationHandle<Material> instHandleLocation;
|
||||
AsyncOperationHandle<IList<IResourceLocation>> locHandle;
|
||||
|
||||
public void UsingLoadAssetAsyncSampleLocation()
|
||||
{
|
||||
locHandle = Addressables.LoadResourceLocationsAsync(materialLocation, typeof(Material));
|
||||
locHandle.Completed += OnLoadComplete;
|
||||
}
|
||||
|
||||
void OnLoadComplete(AsyncOperationHandle<IList<IResourceLocation>> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
Debug.Log($"Successfully loaded resource locations");
|
||||
foreach (IResourceLocation location in handle.Result)
|
||||
{
|
||||
instHandleLocation = Addressables.LoadAssetAsync<Material>(location);
|
||||
instHandleLocation.Completed += OnLoadCompleteLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnLoadCompleteLocation(AsyncOperationHandle<Material> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
var loadedMaterial = handle.Result;
|
||||
Debug.Log($"Successfully loaded material '{loadedMaterial.name}'");
|
||||
|
||||
var renderer = goLocation.GetComponent<MeshRenderer>();
|
||||
if (renderer == null)
|
||||
renderer = goLocation.AddComponent<MeshRenderer>();
|
||||
renderer.material = loadedMaterial;
|
||||
Debug.Log($"Assigned loaded material to GameObject named '{goLocation.name}'");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseResourcesLocation()
|
||||
{
|
||||
Addressables.Release(locHandle);
|
||||
Addressables.Release(instHandleLocation);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseResourcesLocation().
|
||||
// For example during OnDestroy().
|
||||
// void OnDestroy()
|
||||
// {
|
||||
// ReleaseResourcesLocation();
|
||||
// }
|
||||
#endregion
|
||||
|
||||
#region SAMPLE_KEY
|
||||
public AssetReference materialKey; // Identify the material
|
||||
public GameObject goKey; // Identify the GameObject
|
||||
AsyncOperationHandle<Material> handleKey;
|
||||
|
||||
public void UsingLoadAssetAsyncSampleKey()
|
||||
{
|
||||
handleKey = Addressables.LoadAssetAsync<Material>(materialKey);
|
||||
handleKey.Completed += OnLoadCompleteKey;
|
||||
}
|
||||
|
||||
void OnLoadCompleteKey(AsyncOperationHandle<Material> handle)
|
||||
{
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
var loadedMaterial = handle.Result;
|
||||
Debug.Log($"Successfully loaded material '{loadedMaterial.name}'");
|
||||
|
||||
var renderer = goKey.GetComponent<MeshRenderer>();
|
||||
if (renderer == null)
|
||||
renderer = goKey.AddComponent<MeshRenderer>();
|
||||
renderer.material = loadedMaterial;
|
||||
Debug.Log($"Assigned loaded material to GameObject named '{goKey.name}'");
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseResourcesKey()
|
||||
{
|
||||
Addressables.Release(handleKey);
|
||||
}
|
||||
|
||||
// When ready to release the asset, call ReleaseResourcesKey().
|
||||
// For example during OnDestroy().
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// ReleaseResourcesKey();
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9dec9370340da43409dd436c2cc60a62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadAssets
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadAssetsSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de23aaeee6fa41346a6886273da4f875
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadAssetsAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadAssetsAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c6842422df3f52c49bd039fb475426ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadContentCatalog
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadContentCatalogSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4f1ede4836c84544798220e17204830f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadContentCatalogAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadContentCatalogAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cda5ad9bd8be5214c853a418eeb6d268
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadResourceLocations
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadResourceLocationsSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7305448792709444a2866d80750c130
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadResourceLocationsAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadResourceLocationsAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d4fc965925d484439a7a0bebb3518d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadScene
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadSceneSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c82c3b37db403f947beff6c5abacab7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingLoadSceneAsync
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLoadSceneAsyncSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4afdd37c029df5643ad1e16511ae0987
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLog
|
||||
{
|
||||
|
||||
public void UsingLogSample()
|
||||
{
|
||||
#region SAMPLE
|
||||
Addressables.Log("Unloading bundle");
|
||||
|
||||
Addressables.Log("<color=red>Unloading bundle</color> ");
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4d398e97edad129428605a181ebba953
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLogError
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLogErrorSample()
|
||||
{
|
||||
Addressables.LogError("Unable to load asset bundle");
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 875335d887d78ba45af8467d0c5f9922
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLogErrorFormat
|
||||
{
|
||||
|
||||
#region SAMPLE
|
||||
public void UsingLogErrorFormatSample()
|
||||
{
|
||||
Addressables.LogErrorFormat("{0:o}[{1}]Unloading bundle", DateTime.Now, this.GetType().Name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0952ae1d131b4a4dbcdd7010c2d69aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
internal class UsingLogException
|
||||
{
|
||||
|
||||
#region SAMPLE
|
||||
public void LogExceptionDebugLogging(bool isErrored)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isErrored)
|
||||
{
|
||||
throw new Exception("Unable to complete task");
|
||||
}
|
||||
|
||||
} catch(Exception e)
|
||||
{
|
||||
Addressables.LogException(e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private Material k_PlaceholderMaterial;
|
||||
#region SAMPLE_ASYNC_OP
|
||||
public async Task<Material> LogExceptionSuccessfulTask(bool isErrored)
|
||||
{
|
||||
var loadHandle = Addressables.LoadAssetAsync<Material>("green.material");
|
||||
var material = await loadHandle.Task;
|
||||
if (loadHandle.Status == AsyncOperationStatus.Failed)
|
||||
{
|
||||
// something went wrong, log it and return the placeholder material
|
||||
Addressables.LogException(loadHandle, loadHandle.OperationException);
|
||||
return k_PlaceholderMaterial;
|
||||
}
|
||||
return material;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38964569356fc0f408d65786ea2c747f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLogFormat
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingLogFormatSample()
|
||||
{
|
||||
|
||||
Addressables.LogFormat("{0:o}[{1}]Downloaded bundle", DateTime.Now, this.GetType().Name);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65b4415e251f7254db22c87ae045dd4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLogWarning
|
||||
{
|
||||
public void UsingLogWarningSample()
|
||||
{
|
||||
#region SAMPLE
|
||||
Addressables.LogWarning("Operation took longer than 1 minute");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c051a7c17509c9c4db8019ce2f8df3b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingLogWarningFormat
|
||||
{
|
||||
public void UsingLogWarningFormatSample()
|
||||
{
|
||||
#region SAMPLE
|
||||
Addressables.LogWarningFormat("{0:o}[{1}]Operation took longer than 1 minute", DateTime.Now, this.GetType().Name);
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 99221d63cc20cba41a19c8095144b82e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
#region SAMPLE
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.AddressableAssets.Build;
|
||||
using UnityEditor.AddressableAssets.Build.DataBuilders;
|
||||
using UnityEditor.AddressableAssets.Settings;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
|
||||
[CreateAssetMenu(fileName = "CustomLocationBuildScript.asset", menuName = "Addressables/Custom Build/Custom Location Build Script")]
|
||||
public class CustomLocationBuildScript : BuildScriptPackedMode
|
||||
{
|
||||
|
||||
// BuildPath is set to [CustomLocationBuildScript.CustomLocationBuildRoot]/SpecialGroup/[BuildTarget]
|
||||
// LoadPath is set to {UnityEngine.AddressableAssets.Addressables.PlayerBuildDataPath}/SpecialGroup/[BuildTarget]
|
||||
public static string CustomLocationBuildRoot
|
||||
{
|
||||
get { return "CustomBuildPath"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Custom Location Build Script"; }
|
||||
}
|
||||
|
||||
protected override TResult BuildDataImplementation<TResult>(AddressablesDataBuilderInput context)
|
||||
{
|
||||
var result = base.BuildDataImplementation<TResult>(context);
|
||||
|
||||
AddressableAssetSettings settings = context.AddressableSettings;
|
||||
CopyBundles(settings);
|
||||
return result;
|
||||
}
|
||||
|
||||
void CopyBundles(AddressableAssetSettings settings)
|
||||
{
|
||||
|
||||
// if the PlayerBuildDataPath does not exist, create it
|
||||
var streamingAssetsPath = Addressables.PlayerBuildDataPath;
|
||||
if (!Directory.Exists(streamingAssetsPath))
|
||||
{
|
||||
Directory.CreateDirectory(streamingAssetsPath);
|
||||
}
|
||||
|
||||
// Copy all directories from the CustomLocationBuildRoot to the PlayerBuildDataPath
|
||||
var directories = Directory.GetDirectories(CustomLocationBuildRoot);
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
var fileName = Path.GetFileName(directory);
|
||||
FileUtil.ReplaceFile($"{CustomLocationBuildRoot}/{fileName}", $"{streamingAssetsPath}/{fileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8da8f70d2b1f92d4dbb383119d26f656
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingRelease
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingReleaseSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c43adc6464e9d348b56ac4906fb5df0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingReleaseInstance
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingReleaseInstanceSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 17f3afdeeb438464081ed4088648c676
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingRemoveResourceLocator
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingRemoveResourceLocatorSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66938b26cbbd898498a9ad998e49dbbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingResolveInternalId
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingResolveInternalIdSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c8e9fe359bd1fe94c8529447c3342a2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingResourceLocators
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingResourceLocatorsSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa4c633b074b9764294948e525c07a1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingResourceManager
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingResourceManagerSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 09b3b931802726b4bb0194bac55fa739
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
internal class UsingRuntimePath
|
||||
{
|
||||
#region SAMPLE
|
||||
public void UsingRuntimePathSample()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 027c478450e773e47b8cc1fbe7455f72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System.IO;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
internal class UsingStreamingAssetsSubFolder
|
||||
{
|
||||
#region SAMPLE
|
||||
class StreamingAssetBuilds
|
||||
{
|
||||
public static string[] GetBuiltPlatforms()
|
||||
{
|
||||
// list all platform folders in the addressable asset build directory:
|
||||
var addressableBuildPath = Addressables.LibraryPath + Addressables.StreamingAssetsSubFolder;
|
||||
return Directory.GetDirectories(addressableBuildPath);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d3cbfb08ad9ea4b4b93c2c2f3cc73e70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.IO.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
internal class UsingUnloadScene
|
||||
{
|
||||
#region SAMPLE
|
||||
// The idea with this sample is to show a simple streaming world. This has 3 events
|
||||
// that work to load and unload scenes as required. Load would be triggered when
|
||||
// the player gets close to the entrypoint. Activate would be called by doing
|
||||
// something like "opening a door". And then unload could be called when the player
|
||||
// crosses the entrypoint again in the other direction.
|
||||
public class SceneGatewayManager {
|
||||
|
||||
// the Addressables key for the scene to load
|
||||
[SerializeField]
|
||||
public string sceneKey;
|
||||
|
||||
private AsyncOperationHandle<SceneInstance> sceneHandle;
|
||||
|
||||
public void EnterBoundary()
|
||||
{
|
||||
if (sceneHandle.IsValid() && sceneHandle.IsDone)
|
||||
{
|
||||
// do not reload if they have already passed the load boundary
|
||||
return;
|
||||
}
|
||||
|
||||
// load, but do not activate
|
||||
var activateOnLoad = false;
|
||||
|
||||
// the scene is additive to keep our base scene and simply add a new area to it
|
||||
sceneHandle = Addressables.LoadSceneAsync(sceneKey, LoadSceneMode.Additive, activateOnLoad);
|
||||
}
|
||||
|
||||
public IEnumerator<AsyncOperationHandle<SceneInstance>> EnterScene()
|
||||
{
|
||||
// at this point we have to finish waiting for the scene to load if it
|
||||
// hasn't already
|
||||
yield return sceneHandle;
|
||||
|
||||
// this will activate the scene
|
||||
sceneHandle.Result.ActivateAsync();
|
||||
}
|
||||
|
||||
// exist boundary takes an optional cleanup callback that could be
|
||||
// used to cleanup Assets after scene unload
|
||||
public void ExitBoundary(Action cleanupCallback = null)
|
||||
{
|
||||
|
||||
if (!sceneHandle.Result.Scene.isLoaded)
|
||||
{
|
||||
// scene has not been activated and cannot be unloaded
|
||||
return;
|
||||
}
|
||||
var unloadHandle = Addressables.UnloadSceneAsync(sceneHandle, UnloadSceneOptions.None);
|
||||
unloadHandle.Completed += (s) =>
|
||||
{
|
||||
if (cleanupCallback != null)
|
||||
{
|
||||
cleanupCallback();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bcc4daca72f2dd41bca1527a1bfe3d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
namespace AddressableAssets.DocExampleCode
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#region SAMPLE
|
||||
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using System.Text;
|
||||
|
||||
internal class PrivateWebRequestOverride : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private String bucketAccessToken;
|
||||
|
||||
//Register to override WebRequests Addressables creates to download
|
||||
private void Start()
|
||||
{
|
||||
Addressables.WebRequestOverride = AddPrivateToken;
|
||||
}
|
||||
|
||||
// Demonstrate adding an Authorization header to access a Cloud Content Delivery private bucket
|
||||
private void AddPrivateToken(UnityWebRequest request)
|
||||
{
|
||||
var encodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($":{bucketAccessToken}"));
|
||||
request.SetRequestHeader("Authorization", $"Bearer: {encodedToken}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b58235bf371a87a429cb8db2eec7fad6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue