-
-
Save todorok1/9b69c30fe9296d0ebf83deacb4e0dced to your computer and use it in GitHub Desktop.
FindAnyObjectByTypeを使って参照を取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| public class FindAnyTest : MonoBehaviour | |
| { | |
| void Start() | |
| { | |
| // それぞれのShowMessage()を呼び出してみると…… | |
| var pikachu = FindAnyObjectByType<BasePikachu>(); | |
| pikachu.ShowMessage(); | |
| var raichu = FindAnyObjectByType<DerivedRaichu>(); | |
| raichu.ShowMessage(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment