Пример #1
0
        void OnGUI()
        {
            // workaround for OnEnable weirdness when initialising values
            if (logo == null)
            {
                logo = AssetDatabase.LoadAssetAtPath <Texture>(WindowHelper.FindFile("Editor/Resources/Logo.png"));
            }
            if (styleFoldout == null)
            {
                styleFoldout = new GUIStyle(EditorStyles.foldout)
                {
                    fontStyle = FontStyle.Bold,
                    fontSize  = 12
                }
            }
            ;

            SerializedObject cfg = GetSerializedConfig();

            GUILayout.Label(logo, GUILayout.ExpandWidth(false));

            GUILayout.Space(WindowHelper.HEIGHT_SEPARATOR);
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            foldoutAnalytics = CreateFoldout(
                foldoutAnalytics,
                "Analytics",
                true,
                styleFoldout);
            if (foldoutAnalytics)
            {
                GUILayout.Label("Required", EditorStyles.boldLabel);

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("environmentKeyDev"),
                    new GUIContent(
                        "Environment key (dev)",
                        "Enter your game's development environment key"));

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("environmentKeyLive"),
                    new GUIContent(
                        "Environment key (live)",
                        "Enter your game's live environment key"));

                SerializedProperty env_key = cfg.FindProperty("environmentKey");

                env_key.intValue = EditorGUILayout.Popup(

                    new GUIContent(
                        "Selected key",
                        "Select which environment key to use for the build"),
                    env_key.intValue,
                    new GUIContent[] {
                    new GUIContent("Development"),
                    new GUIContent("Live")
                });

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("collectUrl"),
                    new GUIContent(
                        "Collect URL",
                        "Enter your game's collect URL"));

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("engageUrl"),
                    new GUIContent(
                        "Engage URL",
                        "Enter your game's engage URL"));



                GUILayout.Label("Optional", EditorStyles.boldLabel);

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("hashSecret"),
                    new GUIContent(
                        "Hash secret",
                        "Enter your game's hash secret if hashing is enabled"));

                EditorGUI.BeginDisabledGroup(cfg.FindProperty("useApplicationVersion").boolValue);

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("clientVersion"),
                    new GUIContent(
                        "Client version",
                        "Enter your game's version or use the Editor value by enabling the checkbox below"));

                EditorGUI.EndDisabledGroup();

                EditorGUILayout.PropertyField(
                    cfg.FindProperty("useApplicationVersion"),
                    new GUIContent(
                        "Use application version",
                        "Check to use the application/bundle version as set in the Editor"));

                if (cfg.hasModifiedProperties)
                {
                    cfg.ApplyModifiedProperties();
                    AssetDatabase.SaveAssets();
                }
            }

            GUILayout.Space(WindowHelper.HEIGHT_SEPARATOR);

            EditorGUI.BeginChangeCheck();

            foldoutAndroidNotifications = CreateFoldout(
                foldoutAndroidNotifications,
                "Android Notifications",
                true,
                styleFoldout);
            if (foldoutAndroidNotifications)
            {
                if (!AreAndroidNotificationsInProject())
                {
                    GUILayout.Label("Configuration not available due to notification dependencies not present in project.");
                }
                else
                {
                    notifications.appId = EditorGUILayout.TextField(
                        new GUIContent(
                            "Application ID",
                            "Enter the Application ID for your application in the Firebase Console"),
                        notifications.appId);
                    notifications.senderId = EditorGUILayout.TextField(
                        new GUIContent(
                            "Sender ID",
                            "Enter the Sender ID for your application in the Firebase Console"),
                        notifications.senderId);
                    notifications.projectId = EditorGUILayout.TextField(
                        new GUIContent(
                            "Project ID",
                            "Enter the Project ID for your application in the Firebase Console"),
                        notifications.projectId);
                    notifications.apiKey = EditorGUILayout.TextField(
                        new GUIContent(
                            "Firebase API Key",
                            "Enter the API Key for your application in the Firebase Console"),
                        notifications.apiKey);
                    notifications.listenerService = EditorGUILayout.TextField(
                        new GUIContent(
                            "Listener Service",
                            "If you have your own implementation of the NotificationListenerService you should set the field to use your own class"),
                        notifications.listenerService);

                    notifications.notificationIcon = EditorGUILayout.TextField(
                        new GUIContent(
                            "Notification Icon",
                            "The icon for the notification should be the name of the drawable resource, for example 'icon_notification' if you have 'icon_notification.png' in the 'res/drawable' folder"),
                        notifications.notificationIcon);
                    notifications.notificationTitle = EditorGUILayout.TextField(
                        new GUIContent(
                            "Notification Title",
                            "The title should be the string literal that you would like to appear in the notification, or a localisable string resource from the 'res/values' folder such as '@string/resource_name'"),
                        notifications.notificationTitle);

                    if (GUILayout.Button("Apply Android Notification Settings"))
                    {
                        ApplyAndroidNotificationSettings();
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (AreAndroidNotificationsInProject())
                {
                    notifications.Apply();
                    Debug.Log("[DeltaDNA] Changes have been applied to XML configuration files, please commit the updates to version control");
                }
            }

            GUILayout.Space(WindowHelper.HEIGHT_SEPARATOR);


            foldoutiOSNotifications = CreateFoldout(
                foldoutiOSNotifications,
                "iOS Rich Push Notifications",
                true,
                styleFoldout);
            if (foldoutiOSNotifications)
            {
#if UNITY_2019_3_OR_NEWER
                DrawIOSRichPushNotificationSettings();
#elif UNITY_2018_4_OR_NEWER || UNITY_2019_1 || UNITY_2019_2
                EditorGUILayout.HelpBox("In order to support iOS Rich Push Notifications in this version of Unity, you must change the build system in the built XCode project to 'legacy' (File -> Project Settings -> Build System). This is done automatically in 2019.3 or newer.", MessageType.Warning);
                DrawIOSRichPushNotificationSettings();
#else
                EditorGUILayout.HelpBox("iOS rich push notifications can only be used in Unity 2018.4 or newer; 2019.3 or newer is recommended.", MessageType.Warning);
#endif
            }

            EditorGUILayout.EndScrollView();
        }