Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.EventSystems;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class EndingSystem : MonoBehaviour
  7. {
  8. public GameObject LockImg;
  9.  
  10. public EventSystem eventsystem; //イベントシステム(いろんなことに使う)の定義
  11. public GameObject Intro;
  12. public GameObject IntroClose;
  13. public GameObject EndingOpen;
  14. public GameObject Letter;
  15. public GameObject ClearNext;
  16.  
  17. // Use this for initialization
  18. void Start()
  19. {
  20. FadeOut();
  21. eventsystem = GameObject.Find("EventSystem").GetComponent<EventSystem>();
  22. EndingOpen.SetActive(false);
  23. Letter.SetActive(false);
  24. ClearNext.SetActive(false);
  25. }
  26.  
  27. // Update is called once per frame
  28. void Update ()
  29. {
  30.  
  31. if (eventsystem.currentSelectedGameObject == null)
  32. {// UI以外(3D)をさわった
  33. }
  34. else
  35. {
  36. if (Input.GetMouseButtonUp(0))
  37. { //左クリック
  38. switch (eventsystem.currentSelectedGameObject.name)
  39. {
  40. case "Logo":
  41. iTween.MoveTo(GameObject.Find("Intro"),
  42. iTween.Hash("y", 0, "time", 0.8, "islocal", true, "easeType", iTween.EaseType.easeInOutQuad));
  43. break;
  44. case "IntroClose":
  45. iTween.MoveTo(GameObject.Find("Intro"),
  46. iTween.Hash("y", 830, "time", 0.8, "islocal", true, "easeType", iTween.EaseType.easeInOutQuad));
  47. break;
  48. case "Btn_Skip_Img":
  49. FadeIn();
  50. Invoke("EndingImg", 0.5f);
  51. break;
  52. case "EndingClose":
  53. FadeIn();
  54. Invoke("NextLetter", 0.5f);
  55. break;
  56. case "LetterClose":
  57. FadeIn();
  58. Invoke("NextClear", 0.5f);
  59. break;
  60. }
  61. }
  62. }
  63. }
  64.  
  65. void EndingImg()
  66. {
  67. FadeOut();
  68. EndingOpen.SetActive(true);
  69. }
  70. void NextLetter()
  71. {
  72. FadeOut();
  73. Letter.SetActive(true);
  74. EndingOpen.SetActive(false);
  75. LockOut();
  76. Invoke("LockOpen", 0.5f);
  77. Debug.Log("LockIn();");
  78. }
  79. void LockOpen()
  80. {
  81. LockIn();
  82. Debug.Log("LockOpen()");
  83. }
  84.  
  85. void NextClear()
  86. {
  87. FadeOut();
  88. ClearNext.SetActive(true);
  89. Invoke("NextTop", 1.5f);
  90. }
  91. void NextTop()
  92. {
  93. FadeIn();
  94. SceneManager.LoadScene("top");
  95. }
  96. void FadeIn()
  97. {
  98. // SetValue()を毎フレーム呼び出して、1秒間に0から1までの値の中間値を渡す
  99. iTween.ValueTo(gameObject, iTween.Hash("from", 0f, "to", 1f, "time", 0.5f, "onupdate", "SetValue"));
  100. }
  101. void FadeOut()
  102. {
  103. // SetValue()を毎フレーム呼び出して、1秒間に1から0までの値の中間値を渡す
  104. iTween.ValueTo(gameObject, iTween.Hash("from", 1f, "to", 0f, "time", 0.5f, "onupdate", "SetValue"));
  105. }
  106. void SetValue(float alpha)
  107. {
  108. // iTweenで呼ばれたら、受け取った値をImageのアルファ値にセット
  109. gameObject.GetComponent<UnityEngine.UI.Image>().color = new Color(1, 1, 1, alpha);
  110. }
  111.  
  112. void LockIn()
  113. {
  114. // SetValue()を毎フレーム呼び出して、1秒間に0から1までの値の中間値を渡す
  115. iTween.ValueTo( this.LockImg, iTween.Hash("from", 0f, "to", 2f, "time", 10.0f, "onupdate", "LockSetValue"));
  116. }
  117. void LockOut()
  118. {
  119. // SetValue()を毎フレーム呼び出して、1秒間に1から0までの値の中間値を渡す
  120. iTween.ValueTo(this.LockImg, iTween.Hash("from", 2f, "to", 0f, "time", 10.0f, "onupdate", "LockSetValue"));
  121. }
  122. void LockSetValue(float alpha)
  123. {
  124. // iTweenで呼ばれたら、受け取った値をImageのアルファ値にセット
  125. this.LockImg.GetComponent<UnityEngine.UI.Image>().color = new Color(1, 1, 1, alpha);
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement