Unity uses Ugui package atlas to dynamically load Sprite resources

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.