Skip to content

InsightArgs

uwee edited this page Feb 10, 2019 · 2 revisions

This static class can be used to load the command line arguments that were passed when the application started. In the example scenes they are primarily used to setup Mirror or Insight before they are started.

The included variables can be expanded as only the bare minimum needed for the examples are included.

How to access them? Example from GameRegistration.cs

private void GatherCmdArgs()
{
    InsightArgs args = new InsightArgs();
    if (args.IsProvided("-NetworkAddress"))
    {
        Debug.Log("[Args] - NetworkAddress: " + args.NetworkAddress);
        NetworkAddress = args.NetworkAddress;
    }

    if (args.IsProvided("-NetworkPort"))
    {
        Debug.Log("[Args] - NetworkPort: " + args.NetworkPort);
        NetworkPort = (ushort)args.NetworkPort;
        networkManagerTelepathyTransport.port = (ushort)args.NetworkPort;
    }

    if (args.IsProvided("-SceneName"))
    {
        Debug.Log("[Args] - SceneName: " + args.SceneName);
        GameScene = args.SceneName;
        SceneManager.LoadScene(args.SceneName);
    }

    if (args.IsProvided("-UniqueID"))
    {
        Debug.Log("[Args] - UniqueID: " + args.UniqueID);
        UniqueID = args.UniqueID;
    }

    //Start NetworkManager
    networkManager.StartServer();
}
Clone this wiki locally