I post my code for explain
public class UsersTest : MonoBehaviour, App42CallBack {
string result = "";
public Button createUserButton;
public InputField username;
public InputField password;
public Text connectionStatus;
UserService userService;
// Use this for initialization
void Start () {
App42Log.SetDebug(true); //Print output in your editor console
App42API.Initialize("API_KEY","API_SECRET_KEY");
userService = App42API.BuildUserService();
createUserButton.onClick.AddListener (TaskOnClick);
}
// Update is called once per frame
void Update () {
}
void TaskOnClick()
{
userService.Authenticate (username.text, password.text, new UsersTest());
Debug.Log (result);
}
public void OnSuccess(object response)
{
User user = (User) response;
result = "succes";
App42Log.Console("userName is " + user.GetUserName());
App42Log.Console("sessionId is " + user.GetSessionId());
}
public void OnException(Exception e)
{
result = "exception";
App42Log.Console("Exception : " + e);
}
So, i create a listener on my button for execute TaskOnClick when the button is pressed. You tell me to do the callback inside my class so its what i do here, the problem its when OnSucces or OnException work, he dont find my result string anymore, i need to recreate her. So if i want to modify a gameObject inside of the OnSucces or OnException i need to find it again and i dont like this way, its why i want to get the string like "succes" etc and do my stuff in my class. So if you can help my on this code it would be cool (sorry for my bad english).
Debug.Log is executed just after the Authenticate function and not the callback.