Skip to content

Instantly share code, notes, and snippets.

@kou-yeung

kou-yeung/AddressableAssets.cs Secret

Last active Apr 17, 2020
Embed
What would you like to do?
Change Location in Runtime
public static class AddressableAssets
{
/// <summary>
/// replace "BASE_URL"
/// </summary>
static string BaseUrl = "";
public static void Init(string baseUrl)
{
BaseUrl = baseUrl;
}
static string CustomTransform(IResourceLocation location)
{
return location.InternalId.Replace("BASE_URL", BaseUrl);
}
[RuntimeInitializeOnLoadMethod]
static void SetInternalIdTransform()
{
Addressables.InternalIdTransformFunc = CustomTransform;
}
}
public class Sample : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
AddressableAssets.Init("http://localhost:8000");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.