実現したいこと
NullReferenceExceptionを解決したい
c#
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class InputManager : MonoBehaviour
{
public GameObject hint; string text;
InputField inputField;
bool rightText; void Start() { inputField= GetComponent<InputField>(); }
void Update()
{
} public void PushPCButton() { text = inputField.text; switch (text) { case "RPNS": { rightText = true; } break; } if (rightText == true) { hint.SetActive(true); } else { resettext(); } } void resettext() { inputField.text = ""; }
}
text = inputField.text;のところに、けいこくがでているのですが、一応inputFieldが宣言した形と会っているかなどを調べましたが、あっていたので、なぜこのような警告が出ているかわからない状況です。
質問①
null型になった原因は何でしょうか?
質問②
どういったことをすれば、治るのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/12/03 07:19
2018/12/03 14:33