void OnGUI()
    {
        GUILayout.Label("Binary Content", EditorStyles.boldLabel);
        shortCode = EditorGUILayout.TextField("ShortCode", shortCode);


        EditorGUILayout.BeginHorizontal();
        userName = EditorGUILayout.TextField("User Name", userName);
        password = EditorGUILayout.PasswordField("Password", password);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("GET"))
        {
            result = GameSparksRestApi.getDownloadable(GameSparksSettings.ApiKey, userName, password, shortCode);
        }

        if (GUILayout.Button("POST"))
        {
            result = GameSparksRestApi.setDownloadable(GameSparksSettings.ApiKey, userName, password, shortCode, fileName);
        }

        if (GUILayout.Button(fileName))
        {
            fileName = EditorUtility.OpenFilePanel("Select file to upload", "", "");
        }


        EditorGUILayout.EndHorizontal();
        GUILayout.Label("REST Output", EditorStyles.label);
        GUILayout.TextArea(result, EditorStyles.textField);
    }
    public override void OnInspectorGUI()
    {
        GameSparksSettings settings = (GameSparksSettings)target;

        GameSparksSettings.SetInstance(settings);

        GUILayout.TextArea("SDK Version : " + GameSparks.Core.GS.Version, EditorStyles.wordWrappedLabel);

        EditorGUILayout.HelpBox("Add the GameSparks Api Key and Secret associated with this game", MessageType.None);

        EditorGUILayout.BeginHorizontal();
        GameSparksSettings.ApiKey = EditorGUILayout.TextField(apiKeyLabel, GameSparksSettings.ApiKey);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GameSparksSettings.ApiSecret = EditorGUILayout.TextField(apiSecretLabel, GameSparksSettings.ApiSecret);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GameSparksSettings.PreviewBuild = EditorGUILayout.Toggle(previewLabel, GameSparksSettings.PreviewBuild);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GameSparksSettings.DebugBuild = EditorGUILayout.Toggle(debugLabel, GameSparksSettings.DebugBuild);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();


        String testScenePath = "Assets/GameSparks/TestUI/GameSparksTestUI.unity";

        String testButtonText = "Test Configuration";

        if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
        {
            testButtonText = "Stop Test";
        }

        if (GameSparksSettings.ApiKey != null && GameSparksSettings.ApiSecret != null)
        {
            String myApiPath = "Assets/GameSparks/MyGameSparks.cs";
            GUILayout.TextArea("Download your custom data structures into your own SDK. Be sure to update this if you change the structure of Events and Leaderboards within the developer portal", EditorStyles.wordWrappedLabel);
            if (GUILayout.Button("Get My Custom SDK"))
            {
                String myApi = GameSparksRestApi.getApi();
                if (myApi != null)
                {
                    Debug.Log("Updating GameSparks Api for game." + GameSparksSettings.ApiKey);
                    Directory.CreateDirectory(Path.GetDirectoryName(myApiPath));
                    using (StreamWriter outfile = new StreamWriter(myApiPath))
                    {
                        outfile.Write(myApi);
                    }
                }
                EditorUtility.SetDirty(settings);
                AssetDatabase.Refresh();
            }

//			GUILayout.TextArea("Get the latest GameSparks SDK version.", EditorStyles.wordWrappedLabel);
//
//			if(GUILayout.Button("Update SDK")){
//				System.Xml.XmlReader sdkInfo = GameSparksRestApi.GetSDKInfo();
//				if(sdkInfo != null){
//					while(sdkInfo.Read()){
//
//						if((sdkInfo.NodeType == System.Xml.XmlNodeType.Element) && (sdkInfo.Name == "sdk"))
//						{
//							string serverVersion = sdkInfo.GetAttribute("version");
//							Debug.Log ("Server Version " + serverVersion);
//							if(GameSparksSettings.SdkVersion == null || !GameSparksSettings.SdkVersion.Equals(serverVersion)){
//								Debug.Log ("Updating GameSparks SDK");
//								System.Xml.XmlReader files = sdkInfo.ReadSubtree();
//								while(files.Read()){
//									if((files.NodeType == System.Xml.XmlNodeType.Element) && (files.Name == "file")){
//										GameSparksRestApi.UpdateSDKFile(files.GetAttribute("source"), files.GetAttribute("target"));
//									}
//								}
//								Debug.Log ("Updating GameSparks Version: from (" + GameSparksSettings.SdkVersion + ") to (" + serverVersion + ")");
//								GameSparksSettings.SdkVersion = serverVersion;
//								EditorUtility.SetDirty(instance);
//								AssetDatabase.Refresh();
//							} else {
//								break;
//							}
//						}
//					}
//				}
//
//			}
        }

        GUILayout.TextArea("Run the GameSparks test harness in the editor. ", EditorStyles.wordWrappedLabel);
        if (GUILayout.Button(testButtonText))
        {
            EditorUtility.SetDirty(settings);
            if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = false;
            }
            else
            {
                if (!EditorApplication.currentScene.Equals(testScenePath))
                {
                    if (EditorApplication.SaveCurrentSceneIfUserWantsTo())
                    {
                        if (!EditorApplication.OpenScene(testScenePath))
                        {
                            EditorApplication.NewScene();
                            new GameObject("GameSparks", typeof(GameSparksTestUI), typeof(GameSparksUnity));
                            EditorApplication.SaveScene(testScenePath);
                        }
                        EditorApplication.isPlaying = true;
                    }
                }
                else
                {
                    EditorApplication.isPlaying = true;
                }
            }
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(settings);
            AssetDatabase.SaveAssets();
        }
    }