• UGUI替换图片的三种方式


    //方法一: Image/pic 在 Assets/Resources/目录下 
    Image _myImage; 
    void Start()
    {
        _myImage.sprite = Resources.Load("Image/pic", typeof(Sprite)) as Sprite;
    }
    
    //方法二:mySprite 为外部指定的图片资源
    Image _myImage; 
    Sprite _ISprite; void Start()
    {
      _myImage.sprite = ISprite
    }
    //方法三 
    Image myImage; void Start () { StartCoroutine(GetImage()); }
    IEnumerator GetImage()
    {

    string url = "http://www.5dbb.com/images/logo.gif";
    WWW www
    = new WWW(url);
    yield return www;

    if (string.IsNullOrEmpty(www.error))
    {
    Texture2D tex
    = www.texture;
    Sprite temp
    = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0)); myImage.sprite = temp;
    }
    }
  • 相关阅读:
    新式类、经典类与多继承
    实现抽象类之方式二
    实现抽象类之方式一
    re模块
    28个高频Linux命令
    Git使用教程
    编程语言介绍
    编码
    进制
    操作系统简史
  • 原文地址:https://www.cnblogs.com/Cocomo/p/6477588.html
Copyright © 2020-2023  润新知