-
Notifications
You must be signed in to change notification settings - Fork 96
/
SCAN_BackgroundElement.cs
71 lines (58 loc) · 1.55 KB
/
SCAN_BackgroundElement.cs
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
#region license
/*
* [Scientific Committee on Advanced Navigation]
* S.C.A.N. Satellite
*
* SCAN_BackgroundElement - Script for controlling background scanning toggle elements
*
* Copyright (c)2014 David Grandy <david.grandy@gmail.com>;
* Copyright (c)2014 technogeeky <technogeeky@gmail.com>;
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
*/
#endregion
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using SCANsat.Unity.Interfaces;
namespace SCANsat.Unity.Unity
{
public class SCAN_BackgroundElement : MonoBehaviour
{
[SerializeField]
private TextHandler m_BodyText = null;
[SerializeField]
private SCAN_Toggle m_BodyToggle = null;
private bool loaded;
private string bodyName;
private ISCAN_Settings settingsInterface;
public string BodyName
{
get { return bodyName; }
}
public void Setup(string body, bool active, ISCAN_Settings settings)
{
if (settings == null)
return;
bodyName = body;
settingsInterface = settings;
if (m_BodyToggle != null)
m_BodyToggle.isOn = active;
if (m_BodyText != null)
m_BodyText.OnTextUpdate.Invoke(string.Format("{0} (0%)", body));
loaded = true;
}
public void UpdateText(double amount)
{
if (m_BodyText == null)
return;
m_BodyText.OnTextUpdate.Invoke(string.Format("{0} ({1:P0})", bodyName, amount));
}
public void ToggleBody(bool isOn)
{
if (!loaded || settingsInterface == null)
return;
settingsInterface.ToggleBody(bodyName);
}
}
}