예제 #1
0
    void Start()
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        csCamera = FindObjectOfType <CloudSLAMCamera>();
        if (csCamera == null)
        {
            Debug.Log("CloudSLAM camera not found.");
            return;
        }

        if (PlayerPrefs.HasKey("CloudSLAM.demo.configAddress"))
        {
            configAddress = PlayerPrefs.GetString("CloudSLAM.demo.configAddress");
        }

        CloudSLAMConfig config = CloudSLAMConfig.LoadFromPlayerPrefs();

        if (config != null)
        {
            csCamera.config = config;
        }

        poiStorage = GetComponent <POIStorage>();
        if (fetchPOIs && !string.IsNullOrEmpty(configAddress))
        {
            StartCoroutine(FetchPOIsFromServer());
        }

        swipeObserver = new SwipeObserver();
        swipeObserver.Setup();

        ShowHelpText();
    }
예제 #2
0
    IEnumerator FetchConfigurationFromServer()
    {
        textBox.text = "Fetching configuration ...";
        UnityWebRequest www = CloudSLAMConfig.BuildGetConfigRequest(configAddress);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            textBox.text = "Configuration complete!";
            // Show results as text
            Debug.Log(www.downloadHandler.text);

            CloudSLAMConfig cc = JsonUtility.FromJson <CloudSLAMConfig>(www.downloadHandler.text);

            Debug.Log("server_ip: " + cc.server_ip);
            Debug.Log("websocket_port: " + cc.websocket_port);
            Debug.Log("framerate: " + cc.framerate);
            Debug.Log("bitrate: " + cc.bitrate);
            Debug.Log("interval: " + cc.keyframe_interval);
            Debug.Log("contrast: " + cc.contrast);

            csCamera.config = cc;
            cc.SaveToPlayerPrefs();
        }
    }