/// <summary> /// Initialize the Chroma SDK /// </summary> /// <param name="baseInput"></param> /// <returns>PostChromaSdkResponse</returns> public PostChromaSdkResponse PostChromaSdk(ChromaSdkInput baseInput) { var path = "/chromasdk"; path = path.Replace("{format}", "json"); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(baseInput); // http body (model) parameter //UnityEngine.Debug.Log(postBody); // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling PostChromaSdk: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling PostChromaSdk: " + response.ErrorMessage, response.ErrorMessage); } return((PostChromaSdkResponse)ApiClient.Deserialize(response.Content, typeof(PostChromaSdkResponse), response.Headers)); }
public void SetupDefaultInfo() { _mInfo = new ChromaSdkInput(); _mInfo.Title = "UnityPlugin"; _mInfo.Description = "REST client for Unity"; _mInfo.Author = new ChromaSdkInputAuthor(); _mInfo.Author.Name = "Chroma Developer"; _mInfo.Author.Contact = "www.razerzone.com"; _mInfo.DeviceSupported = new List <string> { "keyboard", "mouse", "headset", "mousepad", "keypad", "chromalink", }; _mInfo.Category = "application"; }
public PostChromaSdkResponse PostChromaSdk(ChromaSdkInput baseInput) { string text = "/chromasdk"; text = text.Replace("{format}", "json"); Dictionary <string, string> queryParams = new Dictionary <string, string>(); Dictionary <string, string> headerParams = new Dictionary <string, string>(); Dictionary <string, string> formParams = new Dictionary <string, string>(); Dictionary <string, FileParameter> fileParams = new Dictionary <string, FileParameter>(); string postBody = this.ApiClient.Serialize(baseInput); string[] authSettings = new string[0]; IRestResponse restResponse = (IRestResponse)this.ApiClient.CallApi(text, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (restResponse.StatusCode >= HttpStatusCode.BadRequest) { throw new ApiException((int)restResponse.StatusCode, "Error calling PostChromaSdk: " + restResponse.Content, restResponse.Content); } if (restResponse.StatusCode == (HttpStatusCode)0) { throw new ApiException((int)restResponse.StatusCode, "Error calling PostChromaSdk: " + restResponse.ErrorMessage, restResponse.ErrorMessage); } return((PostChromaSdkResponse)this.ApiClient.Deserialize(restResponse.Content, typeof(PostChromaSdkResponse), restResponse.Headers)); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Version", ChromaUtils.VERSION); if (!EditorApplication.isCompiling) { //show parent base.OnInspectorGUI(); ChromaConnectionManager connectionManager = ChromaConnectionManager.Instance; if (null == connectionManager._mInfo) { connectionManager.SetupDefaultInfo(); } ChromaSdkInput info = connectionManager._mInfo; info.Author.Contact = EditorGUILayout.TextField("Author.Contact:", info.Author.Contact); info.Author.Name = EditorGUILayout.TextField("Author.Name:", info.Author.Name); info.Category = EditorGUILayout.TextField("Category:", info.Category); info.Description = EditorGUILayout.TextField("Description:", info.Description); foreach (string device in DEVICES) { string label = string.Format("Support {0}:", device); bool isChecked = EditorGUILayout.Toggle(label, info.DeviceSupported.Contains(device)); if (isChecked) { if (!info.DeviceSupported.Contains(device)) { info.DeviceSupported.Add(device); } } else { if (info.DeviceSupported.Contains(device)) { info.DeviceSupported.Remove(device); } } } info.Title = EditorGUILayout.TextField("Title:", info.Title); bool connected = connectionManager.Connected; bool connecting = connectionManager.Connecting; EditorGUILayout.LabelField("Connected:", connected ? "true" : "false"); EditorGUILayout.LabelField("Connecting:", connecting ? "true" : "false"); EditorGUILayout.LabelField("Connection Status:", connectionManager.ConnectionStatus); GUI.enabled = !connected && !connecting; if (GUILayout.Button("Connect")) { connectionManager.Connect(); Repaint(); } GUI.enabled = connected || connecting; if (GUILayout.Button("Disconnect")) { connectionManager.Disconnect(); Repaint(); } GUI.enabled = true; } Repaint(); }