public override void OnGUI(Rect window)
#endif
        {
            Event evt = Event.current;
            Rect  horizontalBarRect = new Rect(0, 30, 0, 0);
            Rect  backButtonRect    = new Rect(5, 0, 30, 30);
            Rect  refreshButtonRect = new Rect(window.width - 30 + k_Margin, 0, 30, 30);

            switch (state)
            {
            case DropdownState.None:
                EditorGUILayout.LabelField("Bundle Locations", dropdownTitleStyle);
                EditorGUILayout.Space(10);
                EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                {
                    fixedWidth = window.width
                });
                //List all options
                foreach (var option in options)
                {
                    option.Draw(() =>
                    {
                        state = option.state;
                        switch (option.state)
                        {
                        case DropdownState.BuiltIn:
                        case DropdownState.EditorHosted:
                            var args       = new DropdownWindowEventArgs();
                            args.GroupType = m_GroupType;
                            args.Option    = option;
                            args.IsCustom  = false;
                            OnValueChanged(args);
                            return;

                        case DropdownState.Custom:
                            var custom       = new DropdownWindowEventArgs();
                            custom.GroupType = m_GroupType;
                            custom.Option    = option;
                            custom.IsCustom  = true;
                            OnValueChanged(custom);
                            return;

                        default:
                            return;
                        }
                    });
                }
                return;

            case DropdownState.CCD:
                switch (CCDState)
                {
                case CCDDropdownState.Bucket:
                    EditorGUI.LabelField(backButtonRect, EditorGUIUtility.IconContent(backIcon));
                    if (evt.type == EventType.MouseDown && backButtonRect.Contains(evt.mousePosition))
                    {
                        state               = DropdownState.None;
                        CCDState            = CCDDropdownState.Bucket;
                        m_WindowRect.height = 120;
                        return;
                    }
#if (ENABLE_CCD && UNITY_2019_4_OR_NEWER)
                    if (CloudProjectSettings.projectId != String.Empty)
                    {
                        EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
                        if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
                        {
                            m_isRefreshingCCDDataSources = true;
                            await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);

                            SyncProfileGroupTypes();
                            m_isRefreshingCCDDataSources = false;
                            return;
                        }
                    }
#endif

                    EditorGUILayout.LabelField("Cloud Content Delivery Buckets", dropdownTitleStyle);
                    EditorGUILayout.Space(10);
                    EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                    {
                        fixedWidth = window.width
                    });

                    if (CloudProjectSettings.projectId == String.Empty)
                    {
                        EditorStyles.helpBox.fontSize = 12;
                        EditorGUILayout.LabelField("Connecting to Cloud Content Delivery requires enabling Cloud Project Settings in the Services Window.", EditorStyles.helpBox);
                    }
                    else
                    {
#if !ENABLE_CCD                 //Used to Display whether or not a user has the CCD Package
                        EditorStyles.helpBox.fontSize = 12;
                        EditorGUILayout.HelpBox("Connecting to Cloud Content Delivery requires the CCD Management SDK Package", MessageType.Warning);
                        var installPackageButton = GUILayout.Button("Install CCD Management SDK Package");
                        if (installPackageButton)
                        {
                            editorWindow.Close();
                            AddressableAssetUtility.InstallCCDPackage();
                        }
#else
                        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true));

                        m_WindowRect.height = m_ProfileGroupTypes.Count > 0 ? k_MaxHeight : 80;


                        Dictionary <string, ProfileGroupType> buckets = new Dictionary <string, ProfileGroupType>();
                        m_ProfileGroupTypes.ForEach((groupType) =>
                        {
                            var parts      = groupType.GroupTypePrefix.Split(ProfileGroupType.k_PrefixSeparator);
                            var bucketId   = parts[2];
                            var bucketName = groupType.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}");
                            if (!buckets.ContainsKey(bucketId))
                            {
                                buckets.Add(bucketId, groupType);
                            }
                        });

                        CCDOption.DrawBuckets(buckets,
                                              (KeyValuePair <string, ProfileGroupType> bucket) =>
                        {
                            CCDState   = CCDDropdownState.Badge;
                            m_BucketId = bucket.Key;
                            m_Bucket   = bucket.Value;
                        });
                        EditorGUILayout.EndScrollView();
#endif
                    }
                    break;

#if (ENABLE_CCD && UNITY_2019_4_OR_NEWER)
                case CCDDropdownState.Badge:
                    EditorGUI.LabelField(backButtonRect, EditorGUIUtility.IconContent(backIcon));
                    if (evt.type == EventType.MouseDown && backButtonRect.Contains(evt.mousePosition))
                    {
                        state               = DropdownState.CCD;
                        CCDState            = CCDDropdownState.Bucket;
                        m_WindowRect.height = 120;
                    }
                    EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
                    if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
                    {
                        m_isRefreshingCCDDataSources = true;
                        await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);

                        SyncProfileGroupTypes();
                        m_isRefreshingCCDDataSources = false;
                        return;
                    }
                    EditorGUILayout.LabelField(String.Format("{0} Badges", m_Bucket.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}").Value), dropdownTitleStyle);
                    EditorGUILayout.Space(10);
                    EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                    {
                        fixedWidth = window.width
                    });
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true));
                    if (bool.Parse(m_Bucket.GetVariableBySuffix("PromoteOnly").Value))
                    {
                        const string promotionOnlyBucketInfo = "Using Build & Release directly to this bucket is not supported, but you can load content.";
                        EditorStyles.helpBox.fontSize = 11;
                        EditorStyles.helpBox.margin   = new RectOffset(20, 20, 5, 5);
                        EditorGUILayout.HelpBox(promotionOnlyBucketInfo, MessageType.Info);
                    }
                    var selectedProfileGroupTypes = m_ProfileGroupTypes.Where(groupType =>
                                                                              groupType.GroupTypePrefix.StartsWith(
                                                                                  String.Join(
                                                                                      ProfileGroupType.k_PrefixSeparator.ToString(), new string[] { "CCD", CloudProjectSettings.projectId, m_BucketId }
                                                                                      ))).ToList();

                    m_WindowRect.height = m_ProfileGroupTypes.Count > 0 ? k_MaxHeight : 80;

                    HashSet <ProfileGroupType> groupTypes = new HashSet <ProfileGroupType>();
                    selectedProfileGroupTypes.ForEach((groupType) =>
                    {
                        var parts     = groupType.GroupTypePrefix.Split(ProfileGroupType.k_PrefixSeparator);
                        var badgeName = String.Join(ProfileGroupType.k_PrefixSeparator.ToString(), parts, 3, parts.Length - 3);
                        if (!groupTypes.Contains(groupType))
                        {
                            groupTypes.Add(groupType);
                        }
                    });


                    CCDOption.DrawBadges(groupTypes, m_BucketId, (ProfileGroupType groupType) =>
                    {
                        var args              = new DropdownWindowEventArgs();
                        args.GroupType        = m_GroupType;
                        args.Option           = new CCDOption();
                        args.Option.BuildPath = groupType.GetVariableBySuffix("BuildPath").Value;
                        args.Option.LoadPath  = groupType.GetVariableBySuffix("LoadPath").Value;
                        args.IsCustom         = false;
                        OnValueChanged(args);
                        editorWindow.Close();
                    });
                    EditorGUILayout.EndScrollView();
                    break;

                default:
                    CCDState = CCDDropdownState.Bucket;
                    break;
#endif
                }
                break;

            case DropdownState.BuiltIn:
            case DropdownState.EditorHosted:
            default:
                editorWindow.Close();
                break;
            }
        }
        public override void OnInspectorGUI()
        {
            m_QueuedChanges.Clear();
            serializedObject.UpdateIfRequiredOrScript(); // use updated values
            EditorGUI.BeginChangeCheck();

            GUILayout.Space(8);
            if (GUILayout.Button("Manage Groups", "Minibutton", GUILayout.ExpandWidth(true)))
            {
                AddressableAssetsWindow.Init();
            }

            GUILayout.Space(12);
            m_ProfilesFoldout = EditorGUILayout.Foldout(m_ProfilesFoldout, "Profile");
            if (m_ProfilesFoldout)
            {
                if (m_AasTarget.profileSettings.profiles.Count > 0)
                {
                    if (m_CurrentProfileIndex < 0 || m_CurrentProfileIndex >= m_AasTarget.profileSettings.profiles.Count)
                    {
                        m_CurrentProfileIndex = 0;
                    }
                    var profileNames = m_AasTarget.profileSettings.GetAllProfileNames();

                    int currentProfileIndex = m_CurrentProfileIndex;
                    // Current profile in use was changed by different window
                    if (AddressableAssetSettingsDefaultObject.Settings.profileSettings.profiles[m_CurrentProfileIndex].id != AddressableAssetSettingsDefaultObject.Settings.activeProfileId)
                    {
                        currentProfileIndex = profileNames.IndexOf(AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileName(AddressableAssetSettingsDefaultObject.Settings.activeProfileId));
                        if (currentProfileIndex != m_CurrentProfileIndex)
                        {
                            m_QueuedChanges.Add(() => m_CurrentProfileIndex = currentProfileIndex);
                        }
                    }
                    currentProfileIndex = EditorGUILayout.Popup(m_ProfileInUse, currentProfileIndex, profileNames.ToArray());
                    if (currentProfileIndex != m_CurrentProfileIndex)
                    {
                        m_QueuedChanges.Add(() => m_CurrentProfileIndex = currentProfileIndex);
                    }

                    AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(profileNames[currentProfileIndex]);

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Manage Profiles", "Minibutton"))
                    {
                        EditorWindow.GetWindow <ProfileWindow>().Show(true);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.LabelField("No valid profiles found");
                }
            }

            GUILayout.Space(6);
            m_DiagnosticsFoldout = EditorGUILayout.Foldout(m_DiagnosticsFoldout, "Diagnostics");
            if (m_DiagnosticsFoldout)
            {
                ProjectConfigData.PostProfilerEvents = EditorGUILayout.Toggle(m_SendProfilerEvents, ProjectConfigData.PostProfilerEvents);
                bool logResourceManagerExceptions = EditorGUILayout.Toggle(m_LogRuntimeExceptions, m_AasTarget.buildSettings.LogResourceManagerExceptions);

                if (logResourceManagerExceptions != m_AasTarget.buildSettings.LogResourceManagerExceptions)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.buildSettings.LogResourceManagerExceptions = logResourceManagerExceptions);
                }
            }

            GUILayout.Space(6);
            m_CatalogFoldout = EditorGUILayout.Foldout(m_CatalogFoldout, "Catalog");
            if (m_CatalogFoldout)
            {
                string overridePlayerVersion = EditorGUILayout.TextField(m_OverridePlayerVersion, m_AasTarget.OverridePlayerVersion);
                if (overridePlayerVersion != m_AasTarget.OverridePlayerVersion)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.OverridePlayerVersion = overridePlayerVersion);
                }

                bool bundleLocalCatalog = EditorGUILayout.Toggle(m_BundleLocalCatalog, m_AasTarget.BundleLocalCatalog);
                if (bundleLocalCatalog != m_AasTarget.BundleLocalCatalog)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.BundleLocalCatalog = bundleLocalCatalog);
                }

                bool optimizeCatalogSize = EditorGUILayout.Toggle(m_OptimizeCatalogSize, m_AasTarget.OptimizeCatalogSize);
                if (optimizeCatalogSize != m_AasTarget.OptimizeCatalogSize)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.OptimizeCatalogSize = optimizeCatalogSize);
                }
            }

            GUILayout.Space(6);
            m_ContentUpdateFoldout = EditorGUILayout.Foldout(m_ContentUpdateFoldout, "Content Update");
            if (m_ContentUpdateFoldout)
            {
                bool disableCatalogOnStartup = EditorGUILayout.Toggle(m_CheckForCatalogUpdateOnInit, m_AasTarget.DisableCatalogUpdateOnStartup);
                if (disableCatalogOnStartup != m_AasTarget.DisableCatalogUpdateOnStartup)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.DisableCatalogUpdateOnStartup = disableCatalogOnStartup);
                }

                string contentStateBuildPath = EditorGUILayout.TextField(m_ContentStateFileBuildPath, m_AasTarget.ContentStateBuildPath);
                if (contentStateBuildPath != m_AasTarget.ContentStateBuildPath)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.ContentStateBuildPath = contentStateBuildPath);
                }

                bool buildRemoteCatalog = EditorGUILayout.Toggle(m_BuildRemoteCatalog, m_AasTarget.BuildRemoteCatalog);
                if (buildRemoteCatalog != m_AasTarget.BuildRemoteCatalog)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.BuildRemoteCatalog = buildRemoteCatalog);
                }
                if ((m_AasTarget.RemoteCatalogBuildPath != null && m_AasTarget.RemoteCatalogLoadPath != null) && // these will never actually be null, as the accessor initializes them.
                    (buildRemoteCatalog))
                {
                    DrawRemoteCatalogPaths();
                }
            }

            GUILayout.Space(6);
            m_DownloadsFoldout = EditorGUILayout.Foldout(m_DownloadsFoldout, "Downloads");
            if (m_DownloadsFoldout)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_CertificateHandlerType"), m_CertificateHandlerType);

                var maxWebReqs = EditorGUILayout.IntSlider(m_MaxConcurrentWebRequests, m_AasTarget.MaxConcurrentWebRequests, 1, 1024);
                if (maxWebReqs != m_AasTarget.MaxConcurrentWebRequests)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.MaxConcurrentWebRequests = maxWebReqs);
                }

                var catalogTimeouts = EditorGUILayout.IntField(m_CatalogTimeout, m_AasTarget.CatalogRequestsTimeout);
                if (catalogTimeouts != m_AasTarget.CatalogRequestsTimeout)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.CatalogRequestsTimeout = catalogTimeouts);
                }
            }

            GUILayout.Space(6);
            m_BuildFoldout = EditorGUILayout.Foldout(m_BuildFoldout, "Build");
            if (m_BuildFoldout)
            {
#if UNITY_2021_2_OR_NEWER
                int index    = (int)m_AasTarget.BuildAddressablesWithPlayerBuild;
                int newIndex = EditorGUILayout.Popup(m_BuildAddressablesWithPlayerBuild, index, new[]
                {
                    "Use global Settings (stored in preferences)",
                    "Build Addressables content on Player Build",
                    "Do not Build Addressables content on Player build"
                });
                if (index != newIndex)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.BuildAddressablesWithPlayerBuild = (AddressableAssetSettings.PlayerBuildOption)newIndex);
                }
                if (newIndex == 0)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        bool enabled = EditorPrefs.GetBool(AddressablesPreferences.kBuildAddressablesWithPlayerBuildKey, true);
                        EditorGUILayout.TextField(" ", enabled ? "Enabled" : "Disabled");
                    }
                }
#endif

                bool ignoreUnsupportedFilesInBuild = EditorGUILayout.Toggle(m_IgnoreUnsupportedFilesInBuild, m_AasTarget.IgnoreUnsupportedFilesInBuild);
                if (ignoreUnsupportedFilesInBuild != m_AasTarget.IgnoreUnsupportedFilesInBuild)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.IgnoreUnsupportedFilesInBuild = ignoreUnsupportedFilesInBuild);
                }

                bool uniqueBundleIds = EditorGUILayout.Toggle(m_UniqueBundles, m_AasTarget.UniqueBundleIds);
                if (uniqueBundleIds != m_AasTarget.UniqueBundleIds)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.UniqueBundleIds = uniqueBundleIds);
                }

                bool contiguousBundles = EditorGUILayout.Toggle(m_ContiguousBundles, m_AasTarget.ContiguousBundles);
                if (contiguousBundles != m_AasTarget.ContiguousBundles)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.ContiguousBundles = contiguousBundles);
                }

#if !NONRECURSIVE_DEPENDENCY_DATA
                EditorGUI.BeginDisabledGroup(true);
#endif
                bool nonRecursiveBuilding = EditorGUILayout.Toggle(m_NonRecursiveBundleBuilding, m_AasTarget.NonRecursiveBuilding);
                if (nonRecursiveBuilding != m_AasTarget.NonRecursiveBuilding)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.NonRecursiveBuilding = nonRecursiveBuilding);
                }
#if !NONRECURSIVE_DEPENDENCY_DATA
                EditorGUI.EndDisabledGroup();
#endif

                ShaderBundleNaming shaderBundleNaming = (ShaderBundleNaming)EditorGUILayout.Popup(m_ShaderBundleNaming,
                                                                                                  (int)m_AasTarget.ShaderBundleNaming, new[] { "Project Name Hash", "Default Group GUID", "Custom" });
                if (shaderBundleNaming != m_AasTarget.ShaderBundleNaming)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.ShaderBundleNaming = shaderBundleNaming);
                }
                if (shaderBundleNaming == ShaderBundleNaming.Custom)
                {
                    string customShaderBundleName = EditorGUILayout.TextField(m_ShaderBundleCustomNaming, m_AasTarget.ShaderBundleCustomNaming);
                    if (customShaderBundleName != m_AasTarget.ShaderBundleCustomNaming)
                    {
                        m_QueuedChanges.Add(() => m_AasTarget.ShaderBundleCustomNaming = customShaderBundleName);
                    }
                }

                MonoScriptBundleNaming monoBundleNaming = (MonoScriptBundleNaming)EditorGUILayout.Popup(m_MonoBundleNaming,
                                                                                                        (int)m_AasTarget.MonoScriptBundleNaming, new[] { "Disable MonoScript Bundle Build", "Project Name Hash", "Default Group GUID", "Custom" });
                if (monoBundleNaming != m_AasTarget.MonoScriptBundleNaming)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.MonoScriptBundleNaming = monoBundleNaming);
                }
                if (monoBundleNaming == MonoScriptBundleNaming.Custom)
                {
                    string customMonoScriptBundleName = EditorGUILayout.TextField(m_MonoBundleCustomNaming, m_AasTarget.MonoScriptBundleCustomNaming);
                    if (customMonoScriptBundleName != m_AasTarget.MonoScriptBundleCustomNaming)
                    {
                        m_QueuedChanges.Add(() => m_AasTarget.MonoScriptBundleCustomNaming = customMonoScriptBundleName);
                    }
                }

                bool stripUnityVersion = EditorGUILayout.Toggle(m_StripUnityVersionFromBundleBuild, m_AasTarget.StripUnityVersionFromBundleBuild);
                if (stripUnityVersion != m_AasTarget.StripUnityVersionFromBundleBuild)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.StripUnityVersionFromBundleBuild = stripUnityVersion);
                }

                bool disableVisibleSubAssetRepresentations = EditorGUILayout.Toggle(m_DisableVisibleSubAssetRepresentations, m_AasTarget.DisableVisibleSubAssetRepresentations);
                if (disableVisibleSubAssetRepresentations != m_AasTarget.DisableVisibleSubAssetRepresentations)
                {
                    m_QueuedChanges.Add(() => m_AasTarget.DisableVisibleSubAssetRepresentations = disableVisibleSubAssetRepresentations);
                }
            }

            GUILayout.Space(6);
            m_DataBuildersFoldout = EditorGUILayout.Foldout(m_DataBuildersFoldout, "Build and Play Mode Scripts");
            if (m_DataBuildersFoldout)
            {
                m_DataBuildersRl.DoLayoutList();
            }

            GUILayout.Space(6);
            m_GroupTemplateObjectsFoldout = EditorGUILayout.Foldout(m_GroupTemplateObjectsFoldout, "Asset Group Templates");
            if (m_GroupTemplateObjectsFoldout)
            {
                m_GroupTemplateObjectsRl.DoLayoutList();
            }

            GUILayout.Space(6);
            m_InitObjectsFoldout = EditorGUILayout.Foldout(m_InitObjectsFoldout, "Initialization Objects");
            if (m_InitObjectsFoldout)
            {
                m_InitObjectsRl.DoLayoutList();
            }

#if UNITY_2019_4_OR_NEWER
            GUILayout.Space(6);
            m_CCDEnabledFoldout = EditorGUILayout.Foldout(m_CCDEnabledFoldout, "Cloud Content Delivery");
            if (m_CCDEnabledFoldout)
            {
                var toggle = EditorGUILayout.Toggle(m_CCDEnabled, m_AasTarget.CCDEnabled);
                if (toggle != m_AasTarget.CCDEnabled)
                {
                    if (toggle)
                    {
                        toggle = AddressableAssetUtility.InstallCCDPackage();
                    }
                    else
                    {
                        toggle = AddressableAssetUtility.RemoveCCDPackage();
                    }
                    m_QueuedChanges.Add(() => m_AasTarget.CCDEnabled = toggle);
                }
            }
#endif

            if (EditorGUI.EndChangeCheck() || m_QueuedChanges.Count > 0)
            {
                Undo.RecordObject(m_AasTarget, "AddressableAssetSettings before changes");
                foreach (var change in m_QueuedChanges)
                {
                    change.Invoke();
                }
                m_AasTarget.SetDirty(AddressableAssetSettings.ModificationEvent.BatchModification, null, true, true);
                serializedObject.ApplyModifiedProperties();
            }
        }