I'm making a game in Unity, I want to instantiate the network manager at a certain screen, so I use a prefab for the network manager, my code is as follows:-
void Start()
{
Transform cloneNetworkManager = Instantiate(networkManager, new Vector3(0, 0, 0), Quaternion.identity);
NetworkManagerScript networkManagerScript = cloneNetworkManager.GetComponent<NetworkManagerScript>();
networkManagerScript.OnButtonHost();
ip = Network.player.ipAddress;
}
and the code for the network manager is as follows:-
public class NetworkManagerScript : NetworkManager {
public GameObject player;
public void OnButtonHost()
{
networkPort = 10101;
playerPrefab = player;
StartHost();
}
public void OnButtonClient()
{
JoinMultiplayerScreenScript joinMultiplayerScreenScript = FindObjectOfType<JoinMultiplayerScreenScript>();
networkAddress = joinMultiplayerScreenScript.ip.text;
networkPort = 10101;
playerPrefab = player;
StartClient();
}
}
The problem now is when I run the project inside the Unity editor it runs correctly, displays the ip, and creates a player.
But when I deploy the project to a windows application or Android application it doesn't display the ip or create a player.