标签:
动画播放步骤前面有...
然后在moveStart脚本里面添加
public DOTweenAnimation Hero_SelectPage;
public bool isCanShowSelectRole = false;//是否进入角色选择界面
public DOTweenAnimation WelcomPage;
public bool isWelcomFinished = false;
在inspector面板上进行拖拽赋值
“Welcom Page”是开始界面的logo
“Hero_SelectPage”则为整个角色选择面板
将DoTweenAnimation上的AutoPlay勾选掉
然后在代码的动画结束方法中添加
WelcomPage.DOPlay();
就实现了在动画结束之后播放logo弹跳的动画效果
还是在这个脚本中添加一个角色面板出现的标志位方法
public void OnWelcomPageFinished() { isCanShowSelectRole = true; }
将这个方法添加进WelcomPage的DoTweenAnimation里面的OnComplete方法中
由此实现在logo动画之后开启角色选择界面的“开关”
最后在Update中添加控制代码:
if (isCanShowSelectRole&&Input.GetMouseButtonDown(0)) { Hero_SelectPage.DOPlayForward(); }
就实现了跳出角色选择界面的方法。
整体代码:
1 using UnityEngine; 2 using System.Collections; 3 using DG.Tweening; 4 5 public class MoveStart : MonoBehaviour { 6 public MovieTexture movTexture; 7 public bool isDrawMov = true; 8 public bool isShowMessage = false; 9 10 public DOTweenAnimation Hero_SelectPage; 11 public bool isCanShowSelectRole = false;//是否进入角色选择界面 12 13 public DOTweenAnimation WelcomPage; 14 public bool isWelcomFinished = false; 15 16 17 18 19 20 void Start () 21 { 22 23 movTexture.loop = false; 24 movTexture.Play(); 25 26 } 27 28 // Update is called once per frame 29 void Update () { 30 if (isDrawMov) 31 { 32 if (Input .GetMouseButtonDown(0) && isShowMessage==false) 33 { 34 isShowMessage = true; 35 } 36 else if (Input.GetMouseButtonDown(0) && isShowMessage) 37 { 38 SpotMovie(); 39 40 41 42 43 44 }//人工干预后停止播放 45 } 46 if (isDrawMov!=movTexture.isPlaying) 47 { 48 SpotMovie(); 49 50 }//自动播放完毕停止播放 51 52 if (isCanShowSelectRole&&Input.GetMouseButtonDown(0)) 53 { 54 Hero_SelectPage.DOPlayForward(); 55 } 56 57 58 59 60 61 62 } 63 64 void OnGUI() 65 { 66 if (isDrawMov) 67 { 68 GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), movTexture); 69 if (isShowMessage) 70 { 71 GUI.Label(new Rect(Screen.width/2-60,Screen.height/2,200,40), "点击鼠标左键退出片头"); 72 } 73 } 74 75 76 } 77 78 private void SpotMovie() 79 { 80 movTexture.Stop(); 81 isDrawMov = false; 82 WelcomPage.DOPlay(); 83 } 84 85 public void OnWelcomPageFinished() 86 { 87 88 isCanShowSelectRole = true; 89 } 90 }
DoTween应用在炉石传说,从开始界面到角色选择界面动画切换
标签:
原文地址:http://www.cnblogs.com/fuperfun/p/5485760.html