//点击实现渐隐渐现效果
//层级结构为:
//在bg_Sprite上添加TweenAlpha 控制渐隐效果:
//在title_sprite上添加脚本 点击实现fade in fade out:
1 using UnityEngine; 2 using System.Collections; 3 4 /// <summary> 5 /// Author:许清池 6 /// Date:2015-10-08 7 /// Version:4.3.4f 8 /// </summary> 9 public class ClickToShowRightMenu : MonoBehaviour 10 { 11 12 public UISprite _bg_sprite; 13 public TweenAlpha _bg_spriteAlpha; 14 15 void OnClick() 16 { 17 if (_bg_spriteAlpha != null) 18 { 19 if (_bg_sprite.alpha == 0) 20 { 21 _bg_spriteAlpha.enabled = true; 22 _bg_spriteAlpha.PlayForward(); 23 } 24 25 if (_bg_sprite.alpha == 1) 26 { 27 _bg_spriteAlpha.enabled = true; 28 _bg_spriteAlpha.PlayReverse(); 29 } 30 31 } 32 } 33 34 }
OK.