纳金网

标题: GUI闪烁效果[C#] [打印本页]

作者: star-小虎    时间: 2013-10-15 16:11
标题: GUI闪烁效果[C#]
using UnityEngine;
using System.Collections;

public class MainBoardTop : MonoBehaviour
{
        public Texture2D Logo;
        public Texture2D SysInfo;
        public Texture2D FriInfo;
        public Texture2D IcoHelp;
        public GUIStyle style;
        public GUIStyle pathStyle;
        private bool displaySysLabel = false;
        private bool displayFriLabel = false;
        IEnumerator Start()
        {
                yield return StartCoroutine(flashSysLabel());
                yield return StartCoroutine(flashFriLabel());
        }
        IEnumerator flashSysLabel()
        {
                while(true)
                {
                        displaySysLabel = true;
                        yield return new WaitForSeconds(0.5f);
                        displaySysLabel = false;
                        yield return new WaitForSeconds(0.5f);
                }
        }
        IEnumerator flashFriLabel()
        {
                while(true)
                {
                        displayFriLabel = true;
                        yield return new WaitForSeconds(0.5f);
                        displayFriLabel = false;
                        yield return new WaitForSeconds(0.5f);
                }
        }
        void OnGUI()
        {
                GUI.BeginGroup(new Rect(0, 0, 300, 100));
                GUI.Button(new Rect(3,5,37,37),Logo,style);
                GUI.Button(new Rect(45,8,150,15),"test",pathStyle);
                if(displaySysLabel == true)
                {
                        GUI.Label(new Rect(45,25,16,16),SysInfo,style);
                }
                GUI.Label(new Rect(61,25,16,16),"0",style);
                if(displayFriLabel == true)
                {
                        GUI.Label(new Rect(77,25,16,16),FriInfo,style);
                }
                GUI.Label(new Rect(93,25,16,16),"0",style);
                GUI.Label(new Rect(108,25,16,16),IcoHelp,style);
                GUI.EndGroup();
        }
}


作者: HIDEOKOJIMA    时间: 2013-10-15 16:45
Thanks for this tutorial !
作者: nts    时间: 2013-10-16 09:53
C#的代码容易懂啊
作者: 幸福小猪    时间: 2013-10-28 09:55
感谢楼主分享~
作者: 梦魇    时间: 2013-11-19 14:57
我是准备弄人物闪烁 嘿嘿
作者: facebookupdate    时间: 2013-11-29 02:00

Thank for sharing




欢迎光临 纳金网 (http://www.narkii.com/club/) Powered by Discuz! X2.5