189 8069 5689

用NGUI动态添加和删除Sprite-创新互联

using UnityEngine;
using System.Collections;

public class NGUI_button : MonoBehaviour {

   public UIButton button1;
   public UIButton button2;

    void Start () {

    UIButton exe1=button1.GetComponent();//获取组件的方式
    UIButton exe2=button2.GetComponent();

    }

    void Update () {

    }

    void opnedButton1(GameObject obj)
    {

      if(obj.name=="Button01")
      {
      UIAtlas atlas=Resources.Load("Textrue/Atlas/Text Atlas",typeof(UIAtlas))as UIAtlas;  //必须建一个Resources 文件夹 ,在他下面放制作好的图集
      GameObject parent=GameObject.Find("point"); //在U3D里面建一个空物体  在这个空物体身上加UIGrid这个脚本 .他时NGUI的脚本。
      UISprite sprite=NGUITools.AddSprite(parent,atlas,"xiaofeiji");//要更换的图片名字
      sprite.MakePixelPerfect();
      parent.GetComponent().repositionNow=true;

      }
      else
      {
        Destroy(GameObject.Find("Sprite"));//删除这个图片

      }

    }

    }

站在用户的角度思考问题,与客户深入沟通,找到白塔网站设计与白塔网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、成都网站建设、企业官网、英文网站、手机端网站、网站推广、域名与空间、网络空间、企业邮箱。业务覆盖白塔地区。

//使用说明  先建一个UIroot  在他下面建2个Button  ,

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:用NGUI动态添加和删除Sprite-创新互联
文章起源:http://cdxtjz.cn/article/dpppdi.html

其他资讯