internal void AddAPIKey(string apiKey)
    {
        XmlNode newMetadata = this.CreateNode(XmlNodeType.Element, "meta-data", null);

        var          settings = FritzConfiguration.GetSerializedSettings();
        XmlAttribute nameAttr = CreateAndroidAttribute("name", "fritz_api_key");
        XmlAttribute valAttr  = CreateAndroidAttribute("value", apiKey);

        newMetadata.Attributes.Append(nameAttr);
        newMetadata.Attributes.Append(valAttr);

        ApplicationElement.AppendChild(newMetadata);
    }
Exemple #2
0
    public static SettingsProvider CreateFritzConfigProvider()
    {
        // First parameter is the path in the Settings window.
        // Second parameter is the scope of this setting: it only appears in the Project Settings window.
        var provider = new SettingsProvider("Project/Fritz", SettingsScope.Project)
        {
            // By default the last token of the path is used as display name if no label is provided.
            label = "Fritz",

            // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
            guiHandler = (searchContext) =>
            {
                var settings = FritzConfiguration.GetSerializedSettings();

                EditorGUILayout.HelpBox(apiKeyMessage, MessageType.Info);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Register", GUILayout.Width(smallButtonSize)))
                {
                    Application.OpenURL(fritzSignup);
                }
                if (GUILayout.Button("Login", GUILayout.Width(smallButtonSize)))
                {
                    Application.OpenURL(fritzLogin);
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.LabelField("iOS", EditorStyles.boldLabel);

                string bundleID = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS);
                EditorGUILayout.LabelField("iOS Bundle ID", bundleID);
                EditorGUILayout.PropertyField(settings.FindProperty("iOSAPIKey"), new GUIContent("Fritz iOS API Key"));

                EditorGUILayout.PropertyField(settings.FindProperty("sdkVersion"), new GUIContent("SDK Version"));

                if (GUILayout.Button("Download", GUILayout.Width(mediumButtonSize)))
                {
                    var sdkVersion = settings.FindProperty("sdkVersion").stringValue;
                    var download   = new DownloadFramework(sdkVersion);
                    download.Download();
                }

                var property = settings.FindProperty("frameworks");
                for (int i = 0; i < property.arraySize; i++)
                {
                    var element = property.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(element);
                }

                // Android Section
                EditorGUILayout.LabelField("Android", EditorStyles.boldLabel);

                string packageId = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
                EditorGUILayout.LabelField("Android Application ID", packageId);
                EditorGUILayout.PropertyField(settings.FindProperty("androidAPIKey"), new GUIContent("Fritz Android API Key"));

                settings.ApplyModifiedProperties();
            },

            // Populate the search keywords to enable smart search filtering and label highlighting:
            keywords = new HashSet <string>(new[] { "Pose", "Fritz" })
        };

        return(provider);
    }