-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBtnBack.cs
More file actions
49 lines (40 loc) · 1.14 KB
/
BtnBack.cs
File metadata and controls
49 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;
public class BtnBack : MonoBehaviour
{
public bool isOnBtn;
public Vector2 BtnOut, BtnIn;
private void Start()
{
BtnOut = new Vector2(this.gameObject.transform.localPosition.x-60, this.gameObject.transform.localPosition.y);
BtnIn = this.gameObject.transform.localPosition;
}
private void Update()
{
if (isOnBtn)
{
this.gameObject.transform.localPosition = Vector2.MoveTowards(this.gameObject.transform.localPosition, BtnOut, 1f);
}
else
{
this.gameObject.transform.localPosition = Vector2.MoveTowards(this.gameObject.transform.localPosition, BtnIn, 1f);
}
}
public void OnClickBtnBack()
{
GameManager.I.continueScene = SceneManager.GetActiveScene().name;
GameManager.I.JsonSave();
SceneManager.LoadScene("Main");
}
public void PointEnter()
{
isOnBtn = true;
}
public void PointExit()
{
isOnBtn = false;
}
}