こちらの動画(https://www.youtube.com/watch?v=Kta88gOe95Q
)を参考にphotonでのマッチング機能を作ろうとしています。(PUNネットワークに繋がったらルームを作ったり入れたりするボタンが表示される機能)
動画に則ってPhotonの登録や開発を進めていったのですが、
UnassignedReferenceException: The variable loadingPanel of PhotonManager has not been assigned.
You probably need to assign the loadingPanel variable of the PhotonManager script in the inspector.
PhotonManager.CloseMenuUI () (at Assets/Resources/Script/PhotonManager.cs:37)
PhotonManager.Start () (at Assets/Resources/Script/PhotonManager.cs:21)
というエラーが発生し、Photon Networkに接続できない状況です。
PhotonManager の変数 loadingPanel は割り当てられておらず、インスペクタでPhotonManagerスクリプトのloadingPanel変数を代入する必要があるという内容のエラーなのですが、コードも参考動画と同じことを書いてあるので何が原因かわかりません。(エラーの対象スクリプト部分の画像を添付しておきます
参考画像に添付している通り、 loadingPanelには対応オブジェクトをアタッチさせています。
詳しい方助けてください。
C#
1using System.Collections.Generic; 2using UnityEngine; 3using UnityEngine.UI; 4using Photon.Pun; 5using Photon.Realtime; 6 7public class PhotonManager : MonoBehaviourPunCallbacks 8{ 9 public static PhotonManager instance; 10 public GameObject loadingPanel; 11 public Text loadingText; 12 public GameObject buttons; 13 14 private void Awake() 15 { 16 instance = this; 17 } 18 // Start is called before the first frame update 19 private void Start() 20 { 21 CloseMenuUI(); 22 23 loadingPanel.SetActive(true); 24 loadingText.text = "ネットワークに接続中..."; 25 26 if (!PhotonNetwork.IsConnected) 27 { 28 PhotonNetwork.ConnectUsingSettings(); 29 } 30 31 } 32 33 // Update is called once per frame 34 35 public void CloseMenuUI() 36 { 37 loadingPanel.SetActive(false); 38 buttons.SetActive(false); 39 } 40 41 public void LobbyMenuDisplay() 42 { 43 CloseMenuUI(); 44 buttons.SetActive(true); 45 } 46 47 public override void OnConnectedToMaster() 48 { 49 //PhotonNetwork.JoinRandomRoom(); 50 PhotonNetwork.JoinLobby(); 51 loadingText.text = "ロビーへ参加中..."; 52 } 53 54 public override void OnJoinedLobby() 55 { 56 LobbyMenuDisplay(); 57 } 58 59 60 61} 62
回答1件
あなたの回答
tips
プレビュー