Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created January 22, 2026 03:59
Show Gist options
  • Select an option

  • Save todorok1/9b69c30fe9296d0ebf83deacb4e0dced to your computer and use it in GitHub Desktop.

Select an option

Save todorok1/9b69c30fe9296d0ebf83deacb4e0dced to your computer and use it in GitHub Desktop.
FindAnyObjectByTypeを使って参照を取得する
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