2
\$\begingroup\$

I have made a simple LAN multi-player game in Unity (just for learning purposes).

This is the main code (for connection):

using UnityEngine;
using System.Collections;

public class StartServer : MonoBehaviour 
{
    public Transform Makan;
    public Transform CubeOBJ;
    public string SSS; 

    void OnGUI () 
    {
        GUILayout.Box (Network.player.ipAddress);

        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            SSS = GUILayout.TextField (SSS);

            if (GUILayout.Button ("StartServer"))
            {
                Network.InitializeServer(10, 25000);
            }

            if (GUILayout.Button ("Connect"))
            {
                Network.Connect (SSS, 25000);
            }
        } 
        else 
        {
            if (GUILayout.Button ("creatCube")) 
            {
                Network.Instantiate (CubeOBJ, Makan.transform.position, Makan.transform.rotation, 0);
            }
        }
    }
}

It works good. The problem is that in mobile devices I should turn on hotspot by myself for one of the devices.

How can I do this automatically from code?

\$\endgroup\$
  • \$\begingroup\$ Why do you want to activate it automatically? Just alert the user that it is not active. \$\endgroup\$ – S. Tarık Çetin Jul 30 '16 at 17:36
  • \$\begingroup\$ u mean there is no way to active it automatically? \$\endgroup\$ – dave Jul 30 '16 at 17:40
  • \$\begingroup\$ No, I don't mean that. I said that what you want to do is not necessary. \$\endgroup\$ – S. Tarık Çetin Jul 30 '16 at 17:43
  • \$\begingroup\$ maybe some users don't know how to turn on hotspot xD. anyway i want to know how to do it. and why there is nothing about it in unity documentation? \$\endgroup\$ – dave Jul 30 '16 at 17:49
  • \$\begingroup\$ Because it has nothing to do with Unity itself, it is about the device you run your game on. \$\endgroup\$ – S. Tarık Çetin Jul 30 '16 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.