-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinalPanelBackButton.cs
More file actions
81 lines (69 loc) · 2.58 KB
/
Copy pathFinalPanelBackButton.cs
File metadata and controls
81 lines (69 loc) · 2.58 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FinalPanelBackButton : MonoBehaviour
{
public AudioClip acClickOn;
private Button button;
private GameObject playPanel;
private FinalPlayPanel fpPanel;
private AudioSource audioOut;
private PlayerController pScript;
private Text[] bbText;
// Use this for initialization
void Start()
{
playPanel = GameObject.FindGameObjectWithTag("uiFinalPlayPanel");
if (playPanel == null)
Debug.Log("FinalPlay Back Button couldnt get a reference to the FinalPlayPanel Object");
else
{
fpPanel = playPanel.GetComponent<FinalPlayPanel>();
if (fpPanel == null)
Debug.Log("FinalPlay Back button couldnt get reference to the Final Play Panel Script");
}
bbText = new Text[2]; // should be only two...
button = GetComponent<Button>();
if (button == null)
Debug.Log("FinalPlay Back Button script could not get a reference to the button sript.");
else
{
button.onClick.AddListener(GoBack);
Text[] t = button.gameObject.GetComponentsInChildren<Text>();
if (t != null)
for (int i = 0; i < t.Length; i++)
{
bbText[i] = t[i];
if (bbText[i] == null)
Debug.Log("FinalPlay Back Button couldnt get a reference to one of its child Text component.");
}
}
audioOut = GetComponent<AudioSource>();
if (audioOut == null)
Debug.Log("FinalPlay Back Button couldnt get its Audio Source component.");
pScript = GameObject.FindGameObjectWithTag("PlayerController").GetComponent<PlayerController>();
if (pScript == null)
Debug.Log("FinalPlay Back Button script could not get a reference to the Player controller.");
//playPanel.SetActive(false);
}
// Update is called once per frame
void Update()
{
Image img = GetComponent<Image>();
Color cA = pScript.GetCharColorA();
Color cB = pScript.GetCharColorB();
Color foo = Color.Lerp(cB, cA, pScript.GetLerpVal());
foo.a = 255f;
img.color = foo;
if(Input.GetKey(KeyCode.Escape))
{
GoBack();
}
}
public void GoBack()
{
audioOut.PlayOneShot(acClickOn, 0.8f);
fpPanel.CloseFinalPanel();
}
}