-
-
Save kou-yeung/2a16190e8da66105a5bddcffa7cf4b10 to your computer and use it in GitHub Desktop.
Change Location in Runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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