メインカメラにInitController.csがアタッチされ、
プレハブにPlayerController.csがアタッチされた状態です。
PlayerControllerからInitControllerのクラスメンバにアクセスしたいのですが、
以下のようにするとNullReferenceExceptionになります。
C#
1[PlayerController.cs] 2public class PlayerController : MonoBehaviour { 3 public InitController initController; 4 5void function1() { 6 initController.score = 10; // NullReferenceExceptionになる 7}
プレハブのPlayerControllerのInitControllerがNone(InitController)となっているので、アタッチされていないのが原因だと思いますが、
アタッチしようとするとマウスカーソルが
になってアタッチできません。
何か間違った操作をしているのでしょうか?
◆環境
Windows10
Unity2017.3.1f1
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。