回答編集履歴

1

数字がおかしかったので修正

2023/02/26 03:28

投稿

fiveHundred
fiveHundred

スコア9827

test CHANGED
@@ -1,6 +1,6 @@
1
1
  この場合、インターフェースを使うのがいいでしょう。
2
2
 
3
- 1. Action()があるinterface(ここではIActionComponentとする)を用意する
3
+ 1. Action()があるinterface(ここではIActionComponentとする)を用意する
4
4
 
5
5
  ```C#
6
6
  public interface IActionComponent
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ```
11
11
 
12
- 2. 呼び出し先のクラスにIActionComponentを継承させ、Action()を実装
12
+ 2. 呼び出し先のクラスにIActionComponentを継承させ、Action()を実装
13
13
 
14
14
  ```C#
15
15
  public class FooScript : MonoBehaviour, IActionComponent
@@ -21,7 +21,7 @@
21
21
  }
22
22
  ```
23
23
 
24
- 3. GetComponentでIActionComponentを含むスクリプトを取得し、Action()を呼び出す
24
+ 3. GetComponentでIActionComponentを含むスクリプトを取得し、Action()を呼び出す
25
25
 
26
26
  ```C#
27
27
  private void OnTriggerEnter2D(Collider2D collision)