protected virtual void OnValueChanged(DropdownWindowEventArgs e) { ValueChangedEventHandler handler = ValueChanged; if (handler != null) { handler(this, e); } }
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; } }