Tanoda
CheckPosition.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class CheckPosition : MonoBehaviour
6{
7 public Vector3 lastPosition;
8 void Update()
9 {
10 if (System.Math.Abs(GetComponent<RectTransform>().position.x) <= 10 && System.Math.Abs(GetComponent<RectTransform>().position.y) <= 10)
11 {
12 lastPosition = transform.position;
13 }
14 if (System.Math.Abs(GetComponent<RectTransform>().position.x) >= 10 || System.Math.Abs(GetComponent<RectTransform>().position.y) >= 10)
15 {
16 transform.position = lastPosition;
17 }
18 }
19}
Vector3 lastPosition
Definition: CheckPosition.cs:7