FadeFX.cs
1.77 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class FadeFX : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
private BoxCollider COMPONENT_COLLIDER;
public GameObject update_box;
//Cria referência para o colider do avatar e torna a barra transparente
public void Start()
{
COMPONENT_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>();
Deactivate();
}
//Listeners de eventos do mouse
public void OnPointerEnter(PointerEventData eventData){ Activate(); }
public void OnPointerExit(PointerEventData eventData){ Deactivate(); }
/*
* Desabilita o colider do avatar para bloquear a rotação
* Em seguida retorna o visual padrão da barra de controles
* e reativa a interação com os botões
*/
private void Activate()
{
COMPONENT_COLLIDER.enabled = false;
foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED"))
GO.GetComponent<CanvasRenderer>().SetAlpha(1f);
foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS"))
GO.GetComponent<Button>().interactable = true;
}
/*
* Habilita o colider do avatar para desbloquear a rotação
* Em seguida diminui o alpha dos componentes da barra de controles tornando-os transparentes
* Logo após desativa a interação com os botões para impedir que fiquem em status "highlighted"
*/
private void Deactivate(){
if(!SwitchResolution.showbox && !update_box.activeSelf){
COMPONENT_COLLIDER.enabled = true;
foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED"))
GO.GetComponent<CanvasRenderer>().SetAlpha(.2f);
foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS"))
GO.GetComponent<Button>().interactable = false;
}
}
}