Communication Issue Between Callback Classes and Main Class

0 votes

Hi 

I have Main class derived from Monobehaviour in which I do api calls(create user,authenticate,logout, etc) and related callback classes derived from App42CallBack. I want to access MainMenuPanel(which is a public gameobject variable) from AuthCallback class in order to make it visible. Can you please guide me how can I do that except making MainMenuPanel a static variable(Since static variables are not visible in unity editor, I dont want that)

public class DefaultController : MonoBehaviour 
{

public GameObject mainMenuPanel;

	public void GirişYapBtnClick()
	{
		string kullanıcıAdi = girişYapKA.text;
		string pass = girişYapPass.text;
		userService = sp.BuildUserService ();
		userService.Authenticate(kullanıcıAdi,pass,new AuthCallback());
	}

}

public class AuthCallback : App42CallBack  
{  
	public void OnSuccess(object response)  
	{ 
		Debug.Log("success ok");
		User user = (User) response;
		PlayerPrefs.SetString ("UserName", user.GetUserName());
		PlayerPrefs.SetString ("SessionId", user.GetSessionId ());
		Debug.Log ("UserName-A"+ user.GetUserName());
		Debug.Log ("SessionId-A"+ user.GetSessionId ());

//HOW DO I ACCESS public gameobject MainMenuPanel HERE?

	}  
	public void OnException(Exception e)  
	{ 
		Debug.Log("Exception : " + e);  
	}  
}

 

asked Feb 23, 2016 in Unity by gokhan (20 points)

1 Answer

0 votes

Hi Gokhan,

Please have a  look at this link which will help you access other game objects. Let me know if it helps.

Regards,

Himanshu Sharma

answered Feb 24, 2016 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...