質問編集履歴
3
誤って追加したソースを削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,64 +9,4 @@
|
|
9
9
|
|
10
10
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
11
11
|
Unity 2017
|
12
|
-
C#
|
12
|
+
C#
|
13
|
-
|
14
|
-
# スクリプトの一部
|
15
|
-
|
16
|
-
MonoBehaviour継承クラス
|
17
|
-
```MapManagerClass
|
18
|
-
public List<List<int>> map;
|
19
|
-
|
20
|
-
void Start() {
|
21
|
-
Debug.Log(map);
|
22
|
-
}
|
23
|
-
public void SetMap(List<List<BlockStatus>> newMap) {
|
24
|
-
map = newMap;
|
25
|
-
}
|
26
|
-
```
|
27
|
-
|
28
|
-
Editorスクリプト
|
29
|
-
```
|
30
|
-
void OnGUI() {
|
31
|
-
mapManager = EditorGUILayout.ObjectField("MapManagerコンポーネント を持ったオブジェクト", mapManager, typeof(MapManager), true) as MapManager;
|
32
|
-
|
33
|
-
if (mapManager == null)
|
34
|
-
return;
|
35
|
-
|
36
|
-
List<List<int>> map = mapManager.map;
|
37
|
-
int mapSize = 0;
|
38
|
-
Debug.Log(map);
|
39
|
-
if (map != null) {
|
40
|
-
mapSize = map.Count;
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
mapManager.map = new List<List<int>>();
|
44
|
-
map = mapManager.map;
|
45
|
-
}
|
46
|
-
|
47
|
-
foldoutMapList = EditorGUILayout.Foldout(foldoutMapList, "map");
|
48
|
-
if (this.foldoutMapList) {
|
49
|
-
mapSize = EditorGUILayout.IntField("Size", mapSize);
|
50
|
-
mapSize = Mathf.Clamp(mapSize, 1, 5);
|
51
|
-
EditorGUILayout.BeginHorizontal(GUI.skin.box);
|
52
|
-
{
|
53
|
-
for (int index = 0; index < mapSize; index++) {
|
54
|
-
EditorGUILayout.BeginVertical(GUI.skin.box);
|
55
|
-
{
|
56
|
-
if (index < map.Count) {
|
57
|
-
EditorGUILayout.LabelField(index.ToString());
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
map.Add(new List<int>());
|
61
|
-
}
|
62
|
-
EditorGUILayout.EndVertical();
|
63
|
-
}
|
64
|
-
}
|
65
|
-
EditorGUILayout.EndHorizontal();
|
66
|
-
if (mapSize < map.Count) {
|
67
|
-
map.RemoveRange(mapSize, map.Count - mapSize);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
mapManager.SetMap(map);
|
71
|
-
}
|
72
|
-
```
|
2
抜けがあったので修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,6 +20,9 @@
|
|
20
20
|
void Start() {
|
21
21
|
Debug.Log(map);
|
22
22
|
}
|
23
|
+
public void SetMap(List<List<BlockStatus>> newMap) {
|
24
|
+
map = newMap;
|
25
|
+
}
|
23
26
|
```
|
24
27
|
|
25
28
|
Editorスクリプト
|
1
スクリプトを上げるように言われたので上げました
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,4 +9,61 @@
|
|
9
9
|
|
10
10
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
11
11
|
Unity 2017
|
12
|
-
C#
|
12
|
+
C#
|
13
|
+
|
14
|
+
# スクリプトの一部
|
15
|
+
|
16
|
+
MonoBehaviour継承クラス
|
17
|
+
```MapManagerClass
|
18
|
+
public List<List<int>> map;
|
19
|
+
|
20
|
+
void Start() {
|
21
|
+
Debug.Log(map);
|
22
|
+
}
|
23
|
+
```
|
24
|
+
|
25
|
+
Editorスクリプト
|
26
|
+
```
|
27
|
+
void OnGUI() {
|
28
|
+
mapManager = EditorGUILayout.ObjectField("MapManagerコンポーネント を持ったオブジェクト", mapManager, typeof(MapManager), true) as MapManager;
|
29
|
+
|
30
|
+
if (mapManager == null)
|
31
|
+
return;
|
32
|
+
|
33
|
+
List<List<int>> map = mapManager.map;
|
34
|
+
int mapSize = 0;
|
35
|
+
Debug.Log(map);
|
36
|
+
if (map != null) {
|
37
|
+
mapSize = map.Count;
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
mapManager.map = new List<List<int>>();
|
41
|
+
map = mapManager.map;
|
42
|
+
}
|
43
|
+
|
44
|
+
foldoutMapList = EditorGUILayout.Foldout(foldoutMapList, "map");
|
45
|
+
if (this.foldoutMapList) {
|
46
|
+
mapSize = EditorGUILayout.IntField("Size", mapSize);
|
47
|
+
mapSize = Mathf.Clamp(mapSize, 1, 5);
|
48
|
+
EditorGUILayout.BeginHorizontal(GUI.skin.box);
|
49
|
+
{
|
50
|
+
for (int index = 0; index < mapSize; index++) {
|
51
|
+
EditorGUILayout.BeginVertical(GUI.skin.box);
|
52
|
+
{
|
53
|
+
if (index < map.Count) {
|
54
|
+
EditorGUILayout.LabelField(index.ToString());
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
map.Add(new List<int>());
|
58
|
+
}
|
59
|
+
EditorGUILayout.EndVertical();
|
60
|
+
}
|
61
|
+
}
|
62
|
+
EditorGUILayout.EndHorizontal();
|
63
|
+
if (mapSize < map.Count) {
|
64
|
+
map.RemoveRange(mapSize, map.Count - mapSize);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
mapManager.SetMap(map);
|
68
|
+
}
|
69
|
+
```
|