CUI_MoveAlong.cs 655 B

12345678910111213141516171819
  1. using UnityEngine;
  2. using System.Collections;
  3. public class CUI_MoveAlong : MonoBehaviour {
  4. // Use this for initialization
  5. void Start () {
  6. }
  7. // Update is called once per frame
  8. void Update () {
  9. (transform as RectTransform).anchoredPosition = new Vector2((transform as RectTransform).anchoredPosition.x + (transform as RectTransform).anchoredPosition.x / 100.0f, (transform as RectTransform).anchoredPosition.y);
  10. if((transform as RectTransform).anchoredPosition.x > (transform.parent as RectTransform).rect.width)
  11. (transform as RectTransform).anchoredPosition = new Vector2(20, (transform as RectTransform).anchoredPosition.y);
  12. }
  13. }