Today I made a UI interface, which is a friend interface with several friends item on the interface. You need to dynamically display the corresponding avatar for each TEM's Avatar object (image). Try to use the Ugui atlas to load, the implementation is as follows:
1. First, you need to know the Spriteatlas function, you can save some of the sprite to be packaged in the settings. (The significance of the detailed parameter setting needs to be further studied), where the objects for packing can be associated to a sprite that needs to be packaged into this created atlas, or a folder, or texture. The current practice here is to associate to the folder.
2. At this point, unity has given a hint: Sprite Atlas packing is disabled. Change the mode of the Sprite Packer as prompted:
Here, the unity operation is complete, and the code is implemented below.
3. The mode of loading uses the Resources.load method, which is no different from other (generics are used here so that they can be extracted separately to load other types):
4. The 3rd step is to load the sprite Atlas, which will then be loaded with a sprite in this atlas:
Note: 41 Lines load the gallery, and 37 rows and 42 rows load the sprite. To load a picture just call the Loadsprite method. For example:
Summary: After you create the atlas in Unity and specify the atlas, you only need to load the atlas first, and then load one of the sprites in the set. Of course, the dynamic loading method is many, this is just one of the attempts.
Unity uses Ugui package atlas to dynamically load Sprite resources