首页 > 其他 > 详细

UGUI怎么获取Image,怎么动态的更换Image

时间:2015-01-11 09:46:59      阅读:285      评论:0      收藏:0      [点我收藏+]

    怎么动态来修改UGUI中的image呢,怎么来获取这个组件呢 ,首先我们需要在头文件里面定义一下 

我圈中的那***哪里,不能没办法获取到image组件

     using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Sprites;
public class OnButton : MonoBehaviour {

   private Button button;
   private Image image;
    
    void Start () {

    button=this.GetComponent<Button>();
    image=this.GetComponent<Image>();

    }

 
    private void ButtonDown()
    {

    button.interactable=false;           image.overrideSprite=Resources.Load("Textures/TechBlue/background",typeof(Sprite))as Sprite;//这里就是修改他的图片,
    image.color=Color.red;

    }
}


最后记住,在图片哪里我们需要换一下类型,不然没办法修改他的图片


本文出自 “计算机” 博客,请务必保留此出处http://5152481.blog.51cto.com/5142481/1601758

UGUI怎么获取Image,怎么动态的更换Image

原文:http://5152481.blog.51cto.com/5142481/1601758

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!