Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Canvas : MonoBehaviour {
  5.  
  6. public GameObject header;
  7. public GameObject botHeader;
  8. public GameObject continueOption;
  9.  
  10. private RectTransform headerRect;
  11. private RectTransform botHeaderRect;
  12.  
  13. private Vector2 headerStartPos;
  14. private Vector2 botHeaderStartPos;
  15.  
  16. private float slideStep;
  17.  
  18. private bool slide = true;
  19.  
  20.  
  21. // Use this for initialization
  22. void Start () {
  23. headerRect = header.GetComponent<RectTransform>();
  24. botHeaderRect = botHeader.GetComponent<RectTransform>();
  25. headerRect.sizeDelta = new Vector2(Screen.width, headerRect.sizeDelta.y);
  26. botHeaderRect.sizeDelta = new Vector2(Screen.width, botHeaderRect.sizeDelta.y);
  27. headerRect.anchoredPosition = new Vector2(Screen.width, headerRect.anchoredPosition.y);
  28. botHeaderRect.anchoredPosition = new Vector2(-Screen.width, botHeaderRect.anchoredPosition.y);
  29. headerStartPos = headerRect.anchoredPosition;
  30. botHeaderStartPos = botHeaderRect.anchoredPosition;
  31. }
  32.  
  33. // Update is called once per frame
  34. void Update () {
  35. if (slide) {
  36. headerRect.anchoredPosition = new Vector2(Mathf.Lerp(headerStartPos.x, 0, slideStep), headerRect.anchoredPosition.y);
  37. botHeaderRect.anchoredPosition = new Vector2(Mathf.Lerp(botHeaderStartPos.x, 0, slideStep), botHeaderRect.anchoredPosition.y);
  38. slideStep += Time.deltaTime * 0.75f;
  39. if(slideStep > 1)
  40. {
  41. headerRect.anchoredPosition = new Vector2(0, headerRect.anchoredPosition.y);
  42. botHeaderRect.anchoredPosition = new Vector2(0, botHeaderRect.anchoredPosition.y);
  43. slide = false;
  44. }
  45. }
  46. }
  47.  
  48. public void ifTouchisNotAButton()
  49. {
  50.  
  51. UnityEngine.SceneManagement.SceneManager.LoadScene("Game");
  52.  
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement