Class AssetLoaders
Utilities for addressables
Assembly: SonsSdk.dll
Syntax
public static class AssetLoaders
Methods
InstantiatePrefab(string)
Load and instantiate a gameobject from addressables
Declaration
public static GameObject InstantiatePrefab(string name)
Parameters
Type |
Name |
Description |
string |
name |
|
Returns
Type |
Description |
GameObject |
|
LoadAsset<T>(string)
Declaration
public static T LoadAsset<T>(string name) where T : Object
Parameters
Type |
Name |
Description |
string |
name |
|
Returns
Type Parameters
LoadBundleFromAssembly(string)
Load an asset bundle from the calling assembly. The name will automatically be prefixed with the assembly name.
Declaration
public static AssetBundle LoadBundleFromAssembly(string name)
Parameters
Type |
Name |
Description |
string |
name |
The patch of the resource you wish to load
|
Returns
Type |
Description |
AssetBundle |
|
Examples
LoadFromAssembly("Resources.bundle")
Exceptions
LoadDataFromAssembly(string)
Load data from the calling assembly. The name will automatically be prefixed with the assembly name.
Declaration
public static byte[] LoadDataFromAssembly(string name)
Parameters
Type |
Name |
Description |
string |
name |
The patch of the resource you wish to load
|
Returns
Examples
LoadFromAssembly("Resources.bundle")
Exceptions
LoadPrefab(string)
Load a gameobject from addressables
Declaration
public static GameObject LoadPrefab(string name)
Parameters
Type |
Name |
Description |
string |
name |
|
Returns
Type |
Description |
GameObject |
|
LoadTexture(byte[])
Load a texture from a byte buffer
Declaration
public static Texture2D LoadTexture(byte[] data)
Parameters
Type |
Name |
Description |
byte[] |
data |
|
Returns
Type |
Description |
Texture2D |
|
LoadTexture(string)
Load a texture from a file
Declaration
public static Texture2D LoadTexture(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
Type |
Description |
Texture2D |
|
LoadTextureFromAssembly(string)
Load a texture from a file in the calling assembly. The name will automatically be prefixed with the assembly name.
Declaration
public static Texture2D LoadTextureFromAssembly(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
Type |
Description |
Texture2D |
|
Examples
LoadTextureFromAssembly("Resources.MyTexture.png")
MapBundleToFile(byte[], Type)
Maps the contents of an asset bundle to a static class. The name of the property must match the name of the asset in the bundle.
Declaration
public static void MapBundleToFile(byte[] bundleData, Type mapFileType)
Parameters
Type |
Name |
Description |
byte[] |
bundleData |
The loaded bundle
|
Type |
mapFileType |
The class to map the asset bundle contents to
|
MapBundleToFile<T>(byte[])
Maps the contents of an asset bundle to a static class. The name of the property must match the name of the asset in the bundle.
Declaration
public static void MapBundleToFile<T>(byte[] bundleData)
Parameters
Type |
Name |
Description |
byte[] |
bundleData |
The loaded bundle
|
Type Parameters
PrintAllAddressables()
Declaration
public static void PrintAllAddressables()