Ejemplo n.º 1
0
        private static void SetConnectionData(bool runtime)
        {
            if (_connectionData == null)
            {
                if (runtime)
                {
                    if (driveConnectorRuntime == null)
                    {
                        driveConnectorRuntime = GameObject.FindObjectOfType <DriveConnection>();
                    }

                    if (driveConnectorRuntime == null)
                    {
                        UpdateStatus("Cannot find CloudConnector script on scene, cannot execute the request.");
                    }

                    _connectionData = driveConnectorRuntime.connectionData;
                }
#if UNITY_EDITOR
                else
                {
                    if (driveConnectionEditor == null)
                    {
                        driveConnectionEditor = UnityEditor.Editor.CreateInstance <DriveConnectionEditor>();
                    }

                    if (driveConnectionEditor == null)
                    {
                        UpdateStatus("Cannot find CloudConnector script on project, cannot execute the request.");
                    }

                    _connectionData = driveConnectionEditor.connectionData;
                }
#endif
            }

            if (_connectionData == null)
            {
                Debug.Log("망");
            }

            if (_connectionData.webServiceUrl == "")
            {
                UpdateStatus("Connection data does not specified web service address.");
                _connectionData = null;
            }

            if (_connectionData == null)
            {
                UpdateStatus("Error, connection data not found.");
            }
        }
Ejemplo n.º 2
0
        private static void CreateRequest(Dictionary <string, string> dataForm, bool runtime)
        {
            SetConnectionData(runtime);
            if (_connectionData == null)
            {
                return;
            }

            var form = CompleteForm(dataForm);

            if (form == null)
            {
                return;
            }

            UnityWebRequest www;

            if (_connectionData.usePOST)
            {
                UpdateStatus("Establishing Connection at URL ", _connectionData.webServiceUrl);
                www = UnityWebRequest.Post(_connectionData.webServiceUrl, form);
            }
            else
            {
                string urlParams = "?";
                foreach (KeyValuePair <string, string> item in form)
                {
                    urlParams += item.Key + "=" + item.Value + "&";
                }
                UpdateStatus("Establishing Connection at URL ", _connectionData.webServiceUrl, urlParams);
                www = UnityWebRequest.Get(_connectionData.webServiceUrl + urlParams);
            }

            if (runtime)
            {
                driveConnectorRuntime.ExecuteRequest(www, form);
            }
#if UNITY_EDITOR
            else
            {
                if (driveConnectionEditor == null)
                {
                    driveConnectionEditor = UnityEditor.Editor.CreateInstance <DriveConnectionEditor>();
                }

                driveConnectionEditor.ExecuteRequest(www, form);
            }
#endif
        }