Tanoda
Remove.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
6using UnityEngine.UI;
7
8public class Remove : MonoBehaviour
9{
10 float width;
11 float height;
12 RectTransform rt;
13 GameObject collector;
15
16 public void Start()
17 {
18 collector = GetComponentInParent<CollectorAction>().gameObject;
19 rt = (RectTransform)collector.transform;
20 rs = gameObject.GetComponent<ReferenceSaver>();
21
22 }
23 public void removeItem()
24 {
25 width = rt.rect.width;
26 height = rt.rect.height;
27 if (height > 450)
28 {
29 rs.transform.localScale = new Vector3(0, 0, 0);
30 rs.Reference.transform.localScale = new Vector3(0, 0, 0);
31 StartCoroutine(RemoveGameObject(new Vector2(width, height), new Vector2(width, height - 350)));
32 }
33 }
34 public void hideButton()
35 {
36 StartCoroutine(PreviewGameObject(1, 0));
37 }
38
39 public void showButton()
40 {
41 StartCoroutine(PreviewGameObject(0, 1));
42 }
43 IEnumerator RemoveGameObject(Vector2 startSize, Vector2 endSize)
44 {
45 float time = 0;
46 float duration = 0.75f;
47
48 while (time <= duration)
49 {
50 time += Time.deltaTime;
51 rt.sizeDelta = Vector2.Lerp(startSize, endSize, time / duration);
52 yield return null;
53 }
56
57 }
58
59 IEnumerator PreviewGameObject(float startAlpha, float endAlpha)
60 {
61 float time = 0;
62 float duration = 0.75f;
63
64 CanvasGroup cggo = gameObject.transform.Find("Remove").gameObject.GetComponent<CanvasGroup>();
65 while (time <= duration)
66 {
67 time += Time.deltaTime;
68 cggo.alpha = Mathf.Lerp(startAlpha, endAlpha, time / duration);
69 yield return null;
70 }
71
72
73 }
74}
static Controller Instance
Definition: Controller.cs:16
void RemoveAction(string id)
Definition: Controller.cs:727
GameObject Reference
Definition: Remove.cs:9
void hideButton()
Definition: Remove.cs:34
void showButton()
Definition: Remove.cs:39
void removeItem()
Definition: Remove.cs:23
void Start()
Definition: Remove.cs:16