-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteAlarm.cs
138 lines (102 loc) · 3.68 KB
/
DeleteAlarm.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class DeleteAlarm : MonoBehaviour
{
public AlarmManager AM;
public int child;
public int count;
public Toggle toggle;
public bool check;
void Start()
{
toggle = transform.Find("Toggle").GetComponent<Toggle>();
}
void FixedUpdate()
{
child = transform.GetSiblingIndex();
count = AM.alarms.AlarmName.Count;
try
{
AM.alarms.AlarmSet[child] = PlayerPrefs.GetInt("AlarmSet" + child);
if(AM.alarms.AlarmSet[child] == 1)
{
toggle.isOn = true;
check = true;
}
if(AM.alarms.AlarmSet[child] == 0)
{
toggle.isOn = false;
check = false;
}
}
catch(ArgumentOutOfRangeException ar)
{
Debug.Log("main button");
}
}
public void Delete()
{
int delete = transform.GetSiblingIndex();
DeleteA(delete);
AM.alarms.AlarmHour.Clear();
AM.alarms.AlarmMinutes.Clear();
AM.alarms.AlarmDesign.Clear();
AM.alarms.AlarmName.Clear();
AM.alarms.AlarmSet.Clear();
foreach (Transform child in AM.content.transform)
{
Destroy(child.gameObject);
}
AM.LoadAlarm();
}
void DeleteA(int index)
{
for (int i = index; i < count-1; i++)
{
AM.alarms.AlarmName[i] = AM.alarms.AlarmName[i+1];
AM.alarms.AlarmDesign[i] = AM.alarms.AlarmDesign[i+1];
AM.alarms.AlarmHour[i] = AM.alarms.AlarmHour[i+1];
AM.alarms.AlarmMinutes[i] = AM.alarms.AlarmMinutes[i+1];
AM.alarms.AlarmSet[i] = AM.alarms.AlarmSet[i+1];
PlayerPrefs.SetString("AlarmNames" + i, AM.alarms.AlarmName[i+1]);
PlayerPrefs.SetString("AlarmDesigns" + i, AM.alarms.AlarmDesign[i+1]);
PlayerPrefs.SetInt("AlarmMinutes" + i, AM.alarms.AlarmMinutes[i+1]);
PlayerPrefs.SetInt("AlarmHours" + i, AM.alarms.AlarmHour[i+1]);
PlayerPrefs.SetInt("AlarmSet" + i, AM.alarms.AlarmSet[i+1]);
}
count = count-1;
/*int setindex = count-1;
AM.alarms.AlarmName.RemoveAt(setindex);
AM.alarms.AlarmMinutes.RemoveAt(setindex);
AM.alarms.AlarmDesign.RemoveAt(setindex);
AM.alarms.AlarmHour.RemoveAt(setindex);
AM.alarms.AlarmSet.RemoveAt(setindex);
PlayerPrefs.DeleteKey("AlarmNames" + setindex);
PlayerPrefs.DeleteKey("AlarmDesigns" + setindex);
PlayerPrefs.DeleteKey("AlarmMinutes" + setindex);
PlayerPrefs.DeleteKey("AlarmHours" + setindex);
PlayerPrefs.DeleteKey("AlarmSet" + setindex);*/
PlayerPrefs.SetInt("CountAlarmName", count);
Destroy(gameObject);
}
public void AlarmActive()
{
if(check == true)
{
AM.alarms.AlarmSet[child] = 0;
toggle.isOn = false;
PlayerPrefs.SetInt("AlarmSet" + child, AM.alarms.AlarmSet[child]);
check = false;
}else
if(check == false)
{
AM.alarms.AlarmSet[child] = 1;
toggle.isOn = true;
PlayerPrefs.SetInt("AlarmSet" + child, AM.alarms.AlarmSet[child]);
check = true;
}
}
}