For the past couple of weeks I've found something odd happening within Unity. My player can connect and login - I know because the SFS2X logs are showing him/her logged in. But for some reason after the login my join room request is not sent like it was doing before and my Debug.Log and print commands are not working when something happens in Unity just in this specific project, and it's only not working when needing a response back from SFS, so let's say I have a random button in another scene and on that button click I call a Debug.Log("Hi"); that button will print Hi in the console. But in regards to SFS nothing comes back and I can't even switch scenes now. Also, other SFS Example projects are able to use Debug.Log.
Here's my only script so far:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
public class Connect : MonoBehaviour {
public Button loginbtn;
public Text debugText;
SmartFox sfs = new SmartFox();
void Start() {
sfs.Connect ("**.**.**.***", 9933);
sfs.AddEventListener (SFSEvent.CONNECTION, onConnect);
sfs.AddEventListener (SFSEvent.CONNECTION_LOST, onConnectFail);
sfs.AddEventListener (SFSEvent.LOGIN, onLogin);
sfs.AddEventListener (SFSEvent.CRYPTO_INIT, onCryptoInit);
sfs.AddEventListener (SFSEvent.ROOM_JOIN, onRoomJoin);
}
void Update() {
}
void onConnect (BaseEvent evt) {
print ("Connected");
debugText.text = "Loaded";
}
void onConnectFail(BaseEvent evt) {
Debug.Log("It didn't work.");
}
void onCryptoInit(BaseEvent evt) {
Debug.Log ("Succesful Encryption");
}
void onLogin(BaseEvent evt) {
Debug.Log ("YAY!");
sfs.Send (new Sfs2X.Requests.JoinRoomRequest ("Village"));
}
public InputField username;
public string Username;
//fries is the Username game object.
public void getInput(string Username) {
Debug.Log ("Username entered :" + Username);
GetComponent<InputField> ();
Username = username.text;
//sendLogin ();
}
public InputField password;
public string Password;
//straw is the Password game object.
public void getInputP(string Password) {
GetComponent<InputField> ();
Debug.Log ("Password entered :" + password);
Password = password.text;
//sendLogin ();
}
public void sendLogin() {
GetComponent<InputField> ();
sfs.Send (new Sfs2X.Requests.LoginRequest (username.text, password.text, "SP"));
}
public void onRoomJoin(BaseEvent evt) {
SceneManager.LoadScene ("Game");
}
}