NGUI Atlas ( change atlas )

Unity3D 2019. 1. 25. 18:36
반응형
1
NGUI 3 Support / Re: Latest Version: 3.12.1 (June 28, 2018)
« Last post by ArenMook on December 13, 2018, 11:52:00 AM »
2018.3.0
- NEW: As the name suggests, support for Unity 2018.3 and its new prefab workflow. Still supports previous versions, including Unity 5.6.
- NEW: NGUI's atlases and fonts are now saved as ScriptableObjects instead of prefabs. To upgrade, select any old prefab-based atlas or font, and the Upgrade button will show up. BACK UP FIRST just in case! After the new asset gets created, the old atlas or font will be changed to Reference type, pointing to it. You can use the new asset directly, of course -- and if you are Unity savvy enough, you can swap their GUIDs from the meta files, effectively removing the need for the reference asset altogether.
- NEW: Added a new widget type: Sprite Collection. It can be used to efficiently add thousands of sprites without the overhead of creating game objects. This is meant to be used from code by programmers, but can speed up the creation and modification of sprites by several orders of magnitude. In Sightseer it allowed the world map creation to go from 3348 ms down to 22 ms, for example.
- NEW: Added UITweener.Finish() to immediately finish the tween, skipping to the end.
- FIX: Some fixes for key binding text form serialization.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class TestNewNGUI : MonoBehaviour
{
    public NGUIAtlas newAtlas;
    public UIAtlas oldAtlas;
    public UISprite sp;
    public UIButton btn;
 
    // Start is called before the first frame update
    void Start()
    {
        var spAtlas = sp.GetAtlasSprite();
        Debug.LogFormat("{0}, {1}, {2}", spAtlas.GetType(), newAtlas.GetType(), oldAtlas.GetType());
 
        btn.onClick.Subscribe(() =>
        {
            this.sp.atlas = this.newAtlas;
            System.Random r = new System.Random();
            this.sp.spriteName = newAtlas.spriteList[r.Next(newAtlas.spriteList.Count)].name;
            this.sp.MakePixelPerfect();
        });
        
    }
 
    // Update is called once per frame
    void Update()
    {
        
    }
}
 
cs




c# list random select : https://stackoverflow.com/questions/2019417/how-to-access-random-item-in-list

반응형
: