zoukankan      html  css  js  c++  java
  • NGUI 3.5课程(五岁以下儿童)button-图片切换

    然后,我们去了一个样本,做一个button画面切换。

    特征,像球员“开始”和“暂停”。


    写TestButton.cs脚本:

    using UnityEngine;
    using System.Collections;
    
    public class TestButton : MonoBehaviour {
    	protected bool switchFlag = true;
    
    	// Use this for initialization
    	void Start () {
    	
    	}
    
    	void OnClick () {
    		if (this.switchFlag) {
    			this.GetComponent<UISprite> ().spriteName = "pause";
    			this.GetComponent<UIButton> ().normalSprite = "pause";
    			this.switchFlag = false;
    		}
    		else{
    			this.GetComponent<UISprite>().spriteName = "start";
    			this.GetComponent<UIButton>().normalSprite = "start";
    			this.switchFlag = true;
    		}
    	}
    }

    将脚本挂在simple button上


    然后。执行:执行效果例如以下:

    点击后,出现暂停button。





    版权声明:本文博客原创文章。博客,未经同意,不得转载。

  • 相关阅读:
    写在最前面
    Bzoj 2281 [Sdoi2011]黑白棋 题解
    bzoj3125: CITY 题解
    CDQZ 集训大总结
    CDQZ集训DAY10 日记
    CDQZ集训DAY9 日记
    CDQZ集训DAY7 日记
    CDQZ集训DAY6 日记
    CDQZ集训DAY5 日记
    CDQZ集训DAY4 日记
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4676153.html
Copyright © 2011-2022 走看看