I can not seem to access an Method associated to an Object in a Class in another Class, The Class provided blow is associated to a blank object on a new Scene and just prints TEST on the GUI BOX:
using UnityEngine;
using System.Collections;
public class Temp : MonoBehaviour, MultiPlayerLobbyListener
{
public GUISkin guiSkin;
private string _lobbyMessage = "TEST";
void OnGUI()
{
GUI.skin = guiSkin;
GUI.Box(new Rect(Screen.width * 0.25f, Screen.height * 0.4f, Screen.width * 0.5f, Screen.height * 0.5f), _lobbyMessage);
}
// Use this for initialization
void Start()
{
MultiplayerController.Instance.SignInAndStartMPGame();
}
// Update is called once per frame
void Update()
{
}
public void SetLobbyStatusMessage(string message)
{
_lobbyMessage = message;
}
}
The Class trying to call it, in which case the runtime for now always defaults to :
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
using GooglePlayGames;
using GooglePlayGames.BasicApi.Multiplayer;
using System;
public class MultiplayerController : MonoBehaviour, RealTimeMultiplayerListener
{
private uint minimumOpponents = 1;
private uint maximumOpponents = 1;
private uint gameVariation = 0;
public Temp temp; /////REFERENCING HERE
private static MultiplayerController _instance = null;
private MultiplayerController()
{
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
public static MultiplayerController Instance
{
get
{
if (_instance == null)
{
_instance = new MultiplayerController();
}
return _instance;
}
}
public void SignInAndStartMPGame()
{
if (!PlayGamesPlatform.Instance.localUser.authenticated)
{
PlayGamesPlatform.Instance.localUser.Authenticate((bool success) =>
{
if (success)
{
Debug.Log("We're signed in! Welcome " + PlayGamesPlatform.Instance.localUser.userName);
// We could start our game now
SceneManager.LoadScene("Main Menu");
}
else
{
Debug.Log("Oh... we're not signed in.");
//SSceneManager.LoadScene("Main Menu", LoadSceneMode.Additive);
//temp.SetLobbyStatusMessage("Oh... we're not signed in.");
temp = GameObject.GetComponent<Temp>(temp);
if(temp==null) /////STILL NULL HERE
{
Debug.Log("TEMP IS FREAKING NULL");
} else
{
temp.SetLobbyStatusMessage("Oh... we're not signed in.");
}
}
});
}
else
{
Debug.Log("You're already signed in.");
// We could also start our game now
}
}
}
The google play stuff is working perfectly fine and have already tested that, It is the actual referencing of the script that is not working, I am not too sure why. Any help would be much appreciated
Thanks in Advanced