Skip to content
Snippets Groups Projects
Commit b1cb1543 authored by baletiballo's avatar baletiballo
Browse files

Some cleanup

A script can reference the gameObject it is attached to by default. Requiring a explicit reference just invites bugs caused by miss-clicks.
parent 340ac9c8
Branches
No related tags found
No related merge requests found
......@@ -7,17 +7,16 @@
public class IngameUI_OnOff_mobile : MonoBehaviour
{
public GameObject myself_GObj;
public int myUI_ID;
public int default_value;
private bool cA;
private bool myUI_ID_is_valid;
private int lasttime = -99;
void Start()
{
cA = CheckArray();
if (cA)
myUI_ID_is_valid = myUI_ID >= 0 && myUI_ID < UIconfig.CanvasOnOff_Array.Length;
if (myUI_ID_is_valid)
{
if (UIconfig.CanvasOnOff_Array[myUI_ID] != 2 || UIconfig.CanvasOnOff_Array[myUI_ID] != 3)
{
......@@ -30,7 +29,7 @@ void Start()
private void Update()
{
if (cA && lasttime != UIconfig.CanvasOnOff_Array[myUI_ID])
if (myUI_ID_is_valid && lasttime != UIconfig.CanvasOnOff_Array[myUI_ID])
{
switch (UIconfig.CanvasOnOff_Array[myUI_ID])
{
......@@ -55,38 +54,29 @@ private void Update()
}
}
private bool CheckArray()
{
if (myUI_ID >= 0 && myUI_ID < UIconfig.CanvasOnOff_Array.Length)
{
return true;
}
return false;
}
/// <summary>
/// Deactivates all Pages.
/// activates all child objects.
/// </summary>
private void ActivateUIC()
{
for (int i = 0; i < myself_GObj.transform.childCount; i++)
for (int i = 0; i < gameObject.transform.childCount; i++)
{
myself_GObj.transform.GetChild(i).gameObject.SetActive(true);
gameObject.transform.GetChild(i).gameObject.SetActive(true);
}
}
/// <summary>
/// Deactivates all Pages.
/// Deactivates all child objects.
/// </summary>
private void ClearUIC()
{
for (int i = 0; i < myself_GObj.transform.childCount; i++)
for (int i = 0; i < gameObject.transform.childCount; i++)
{
myself_GObj.transform.GetChild(i).gameObject.SetActive(false);
gameObject.transform.GetChild(i).gameObject.SetActive(false);
}
}
......
......@@ -9,7 +9,6 @@ public class InputUI_Ctrl_mobile : MonoBehaviour
//public int myUI_ID;
public GameObject myself_GObj;
//public GameObject parent_GObj;
//public int backUI_ID;
//public int optionsUI_ID;
......@@ -23,59 +22,62 @@ void Awake()
switch (UIconfig.FrameITUIversion)
{
case 1:
toMouseUI();
ClearUIC();
FrameITUI_GObj.SetActive(true);
break;
case 2:
toMobileUI();
ClearUIC();
FrameITUI_mobile_GObj.SetActive(true);
break;
}
}
public void toMouseUI()
{
if (FrameITUIversion_temp != 1)
{
toMouseUI2();
FrameITUIversion_temp = 1;
}
}
public void toMobileUI()
/// <summary>
/// Deactivates all Pages.
/// </summary>
private void ClearUIC()
{
if (FrameITUIversion_temp != 2)
for (int i = 0; i < gameObject.transform.childCount - 1; i++) // -1: dont affect Gadgets
{
toMobileUI2();
FrameITUIversion_temp = 2;
gameObject.transform.GetChild(i).gameObject.SetActive(false);
}
}
public void toMouseUI2()
{
ClearUIC();
//UIconfig.Andr_Start_menu_counter = 1;
FrameITUI_GObj.SetActive(true);
// I cannot see benefit
//public void toMouseUI()
//{
// if (FrameITUIversion_temp != 1)
// {
// toMouseUI2();
// FrameITUIversion_temp = 1;
// }
//}
//public void toMobileUI()
//{
// if (FrameITUIversion_temp != 2)
// {
// toMobileUI2();
// FrameITUIversion_temp = 2;
// }
//}
//public void toMouseUI2()
//{
// ClearUIC();
// //UIconfig.Andr_Start_menu_counter = 1;
// FrameITUI_GObj.SetActive(true);
}
public void toMobileUI2()
{
ClearUIC();
//UIconfig.Andr_Start_menu_counter = 1;
FrameITUI_mobile_GObj.SetActive(true);
//}
//public void toMobileUI2()
//{
// ClearUIC();
// //UIconfig.Andr_Start_menu_counter = 1;
// FrameITUI_mobile_GObj.SetActive(true);
}
/// <summary>
/// Deactivates all Pages.
/// </summary>
private void ClearUIC()
{
for (int i = 0; i < myself_GObj.transform.childCount - 1; i++) // -1: dont affect Gadgets
{
myself_GObj.transform.GetChild(i).gameObject.SetActive(false);
}
}
//}
}
\ No newline at end of file
......@@ -27,10 +27,10 @@ EditorUserSettings:
value: 520107035d0c510c080d547215760b4413154d2e7a2c226129281c65e3b63768
flags: 0
RecentlyUsedSceneGuid-7:
value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
value: 5b01035553515d0e0b0f5b7415725d444e4f1d2b2e782332757f4863e4e6673c
flags: 0
RecentlyUsedSceneGuid-8:
value: 5b01035553515d0e0b0f5b7415725d444e4f1d2b2e782332757f4863e4e6673c
value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
flags: 0
RecentlyUsedSceneGuid-9:
value: 0502505152005e020c0d0e2446275e44144f19287f707e362c7c4b60b2b9353c
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment