質問編集履歴
1
ソースを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,123 @@
|
|
28
28
|
|
29
29
|
```ここに言語を入力
|
30
30
|
|
31
|
+
# スクリプトの一部
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
MonoBehaviour継承クラス
|
36
|
+
|
37
|
+
```MapManagerClass
|
38
|
+
|
39
|
+
public List<List<int>> map;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
void Start() {
|
44
|
+
|
45
|
+
Debug.Log(map);
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
public void SetMap(List<List<BlockStatus>> newMap) {
|
50
|
+
|
51
|
+
map = newMap;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Editorスクリプト
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
void OnGUI() {
|
64
|
+
|
65
|
+
mapManager = EditorGUILayout.ObjectField("MapManagerコンポーネント を持ったオブジェクト", mapManager, typeof(MapManager), true) as MapManager;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
if (mapManager == null)
|
70
|
+
|
71
|
+
return;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
List<List<int>> map = mapManager.map;
|
76
|
+
|
77
|
+
int mapSize = 0;
|
78
|
+
|
79
|
+
Debug.Log(map);
|
80
|
+
|
81
|
+
if (map != null) {
|
82
|
+
|
83
|
+
mapSize = map.Count;
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
else {
|
88
|
+
|
89
|
+
mapManager.map = new List<List<int>>();
|
90
|
+
|
91
|
+
map = mapManager.map;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
foldoutMapList = EditorGUILayout.Foldout(foldoutMapList, "map");
|
98
|
+
|
31
|
-
|
99
|
+
if (this.foldoutMapList) {
|
100
|
+
|
101
|
+
mapSize = EditorGUILayout.IntField("Size", mapSize);
|
102
|
+
|
103
|
+
mapSize = Mathf.Clamp(mapSize, 1, 5);
|
104
|
+
|
105
|
+
EditorGUILayout.BeginHorizontal(GUI.skin.box);
|
106
|
+
|
107
|
+
{
|
108
|
+
|
109
|
+
for (int index = 0; index < mapSize; index++) {
|
110
|
+
|
111
|
+
EditorGUILayout.BeginVertical(GUI.skin.box);
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
if (index < map.Count) {
|
116
|
+
|
117
|
+
EditorGUILayout.LabelField(index.ToString());
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
else {
|
122
|
+
|
123
|
+
map.Add(new List<int>());
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
EditorGUILayout.EndVertical();
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
EditorGUILayout.EndHorizontal();
|
134
|
+
|
135
|
+
if (mapSize < map.Count) {
|
136
|
+
|
137
|
+
map.RemoveRange(mapSize, map.Count - mapSize);
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
mapManager.SetMap(map);
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
```
|
32
148
|
|
33
149
|
```
|
34
150
|
|