質問編集履歴
3
ScreenUpdate()内のコードでした
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,90 +38,90 @@
|
|
38
38
|
|
39
39
|
content = GameObject.Find("ScrollView").transform;
|
40
40
|
|
41
|
+
ScreenUpdate();
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
public void AddButton() {
|
48
|
+
|
49
|
+
dl.Add(inputText.text);
|
50
|
+
|
51
|
+
print("保存しました。");
|
52
|
+
|
53
|
+
inputText.text = "";
|
54
|
+
|
55
|
+
DataUpdate();
|
56
|
+
|
57
|
+
ScreenUpdate();
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
public void DeleteButton() {
|
64
|
+
|
65
|
+
if(index == -1)
|
66
|
+
|
67
|
+
print("!!削除するアイテムを指定してください!!");
|
68
|
+
|
69
|
+
else {
|
70
|
+
|
71
|
+
dl.RemoveAt(index);
|
72
|
+
|
73
|
+
print("削除しました。");
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
DataUpDate();
|
78
|
+
|
79
|
+
ScreenUpdate();
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
//////////ここが例のファイル書き出し地点です//////////
|
86
|
+
|
87
|
+
static internal void DataUpdate() {
|
88
|
+
|
89
|
+
StreamWriter sw = new StreamWriter(Application.dataPath + @"/Resources/Data.txt");
|
90
|
+
|
91
|
+
sw.Write(string.Join("ゎ", words.ToArray()));
|
92
|
+
|
93
|
+
sw.Flush();
|
94
|
+
|
95
|
+
sw.Close();
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
void ScreenUpdate() {
|
102
|
+
|
41
103
|
dl.Clear();
|
42
104
|
|
43
105
|
string[] dl = Resources.Load("Data.txt").Split('ゎ');//not 'わ'
|
44
106
|
|
45
107
|
//→ゎなんて使うこと無いでしょってことで区切り記号にしました。改行は結構使うので
|
46
108
|
|
47
|
-
ScreenUpdate();
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
public void AddButton() {
|
54
|
-
|
55
|
-
dl.Add(inputText.text);
|
56
|
-
|
57
|
-
print("保存しました。");
|
58
|
-
|
59
|
-
inputText.text = "";
|
60
|
-
|
61
|
-
DataUpdate();
|
62
|
-
|
63
|
-
ScreenUpdate();
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
public void DeleteButton() {
|
70
|
-
|
71
|
-
if(index == -1)
|
72
|
-
|
73
|
-
print("!!削除するアイテムを指定してください!!");
|
74
|
-
|
75
|
-
else {
|
76
|
-
|
77
|
-
|
109
|
+
GameObject button;
|
110
|
+
|
78
|
-
|
111
|
+
while(button = GameObject.Find("ButtonPrefab(Clone)")) { Destroy(button);}
|
112
|
+
|
113
|
+
for(int i = 0, l = dl.Length; i < l; i++) {
|
114
|
+
|
115
|
+
button = Instantiate(wordBox,content);
|
116
|
+
|
117
|
+
button.GetComponent<RectTransform>().anchoredPosition
|
118
|
+
|
79
|
-
|
119
|
+
= new Vector2(0,-100*i);
|
120
|
+
|
121
|
+
words.Add(button.transform.GetChild(0).GetComponent<Text>().text = dl[i]);
|
80
122
|
|
81
123
|
}
|
82
124
|
|
83
|
-
DataUpDate();
|
84
|
-
|
85
|
-
ScreenUpdate();
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
//////////ここが例のファイル書き出し地点です//////////
|
92
|
-
|
93
|
-
static internal void DataUpdate() {
|
94
|
-
|
95
|
-
StreamWriter sw = new StreamWriter(Application.dataPath + @"/Resources/Data.txt");
|
96
|
-
|
97
|
-
sw.Write(string.Join("ゎ", words.ToArray()));
|
98
|
-
|
99
|
-
sw.Flush();
|
100
|
-
|
101
|
-
sw.Close();
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
void ScreenUpdate() {
|
108
|
-
|
109
|
-
GameObject button;
|
110
|
-
|
111
|
-
while(button = GameObject.Find("ButtonPrefab(Clone)")) { Destroy(button);}
|
112
|
-
|
113
|
-
for(int i = 0, l = dl.Length; i < l; i++) {
|
114
|
-
|
115
|
-
button = Instantiate(wordBox,content);
|
116
|
-
|
117
|
-
button.GetComponent<RectTransform>().anchoredPosition
|
118
|
-
|
119
|
-
= new Vector2(0,-100*i);
|
120
|
-
|
121
|
-
words.Add(button.transform.GetChild(0).GetComponent<Text>().text = dl[i]);
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
125
|
}
|
126
126
|
|
127
127
|
}
|
2
確認の仕方が分かるようにしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -160,7 +160,7 @@
|
|
160
160
|
|
161
161
|
削除ボタンが押されたら`DeleteButton()`を
|
162
162
|
|
163
|
-
呼ぶように組
|
163
|
+
呼ぶように組んだのですが、追加しても削除してもボタンの内容が変化してないです。
|
164
164
|
|
165
165
|
試したこと
|
166
166
|
|
1
呼び忘れた関数ScreenUpdate()の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,6 +60,8 @@
|
|
60
60
|
|
61
61
|
DataUpdate();
|
62
62
|
|
63
|
+
ScreenUpdate();
|
64
|
+
|
63
65
|
}
|
64
66
|
|
65
67
|
|
@@ -80,6 +82,8 @@
|
|
80
82
|
|
81
83
|
DataUpDate();
|
82
84
|
|
85
|
+
ScreenUpdate();
|
86
|
+
|
83
87
|
}
|
84
88
|
|
85
89
|
|