用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>();//获取组件的方式
    UIButton exe2=button2.GetComponent<UIButton>();
        
    }
    
    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<UIGrid>().repositionNow=true;
   
      }
      else
      {
        Destroy(GameObject.Find("Sprite"));//删除这个图片

      }

    }

    }


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