A sample project has been uploaded.
Unity 2021.3.4f1 version
Just open the sample project, change to the Android platform, and run Login.unity in the Scenes folder. Then the image called TestSample is normally displayed on the screen.
Uncomment the RequestAtlas() function of the Awake() function and make an explicit call.
In the Request Atlas callback function var result = Resources.Load(“Sprite Atlas/UI Login/” + _Key); —> var result = Resources.Load(_Key);
change to
When debugging, the Awake function calls RequestAtlas forcibly.
Then, RequestAtlas is called once more to find the rs_ui_title image in the object registered in Hierarchy. In conclusion, it is called twice, but in the first forced call, Atlas is considered to be registered, but the image output fails.
From the attached project, it is still unclear what exactly is the issue. I see this code :
…
if (test != null)
{ GetComponent().sprite = test;
}
The above line in SpriteAtlasManager.cs will obviously fail as it does not contain an UI Image component. Could you please provide more info or explain the issue ?
Also regarding When is the packed texture data in Spriteatlas saved to a file and where is the path? - This is not accessible as its managed internally by SpriteAtlas.
Thanks.
I understand that the atlas texture is accessed through the registered callback function when the texture is needed. However, the final conclusion is that I want the path of the atlas texture to be a subfolder of Resources/SpriteAtlas in the Resources folder.
Looking at the second source code, RequestAtlas is forcibly called in the Awake() function. Then, the atlas is registered in memory in advance, and the necessary textures can be retrieved from the registered atlas. In the second source, RequestAtlas is called once more. And the result is that the texture is not output normally. I may not understand it, but the conclusion is that I want to create a random subfolder of Resource to collect and refer to atlas textures.