回答編集履歴

1

メソッド名修正

2017/11/07 01:33

投稿

sakura_hana
sakura_hana

スコア11427

test CHANGED
@@ -1,4 +1,6 @@
1
1
  単純にメソッドにしたい場合……そのまま書けばいいだけだと思いますが。
2
+
3
+ (メソッド名は数字から開始にできないので変更してます)
2
4
 
3
5
  ```C#
4
6
 
@@ -6,7 +8,7 @@
6
8
 
7
9
 
8
10
 
9
- void 2DInit (string parentName, string imageName) {
11
+ void Init2D (string parentName, string imageName) {
10
12
 
11
13
  hoge_image.transform.parent = GameObject.Find(parentName).transform;
12
14
 
@@ -28,7 +30,7 @@
28
30
 
29
31
  hoge_image = GameObject.Find("hoge_image"); //ここは適当(何かしらの方法でセットされていると想定する)
30
32
 
31
- 2DInit("Panel", "image"); //hoge_imageはstaticなので渡す必要は無い
33
+ Init2D("Panel", "image"); //hoge_imageはstaticなので渡す必要は無い
32
34
 
33
35
  }
34
36
 
@@ -52,7 +54,7 @@
52
54
 
53
55
 
54
56
 
55
- void 2DInit (string objName, string parentName, string imageName) {
57
+ void Init2D (string objName, string parentName, string imageName) {
56
58
 
57
59
  GameObject obj = Instantiate(imagePrehab, GameObject.Find(parentName).transform); //親子関係セットされる
58
60
 
@@ -66,7 +68,7 @@
66
68
 
67
69
  void Hoge () {
68
70
 
69
- 2DInit("hoge_image", "Panel", "image");
71
+ Init2D("hoge_image", "Panel", "image");
70
72
 
71
73
  }
72
74