public void DoesContainVariable_Returns_False() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.False(profileGroupType.ContainsVariable(buildPath)); }
//UI magic to group the path pairs from profile variables List <ProfileGroupType> CreateGroupTypes(AddressableAssetProfileSettings.BuildProfile buildProfile) { Dictionary <string, ProfileGroupType> groups = new Dictionary <string, ProfileGroupType>(); foreach (var profileEntry in settings.profileSettings.profileEntryNames) { string[] parts = profileEntry.ProfileName.Split(k_PrefixSeparator); if (parts.Length > 1) { string prefix = String.Join(k_PrefixSeparator.ToString(), parts, 0, parts.Length - 1); string suffix = parts[parts.Length - 1]; string profileEntryValue = buildProfile.GetValueById(profileEntry.Id); ProfileGroupType group; groups.TryGetValue(prefix, out group); if (group == null) { group = new ProfileGroupType(prefix); } ProfileGroupType.GroupTypeVariable variable = new ProfileGroupType.GroupTypeVariable(suffix, profileEntryValue); group.AddVariable(variable); groups[prefix] = group; } } List <ProfileGroupType> groupList = new List <ProfileGroupType>(); groupList.AddRange(groups.Values.Where(group => group.IsValidGroupType())); return(groupList); }
public void GetName_Returns_ExpectedVariableName() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); Assert.AreEqual("prefix.BuildPath", profileGroupType.GetName(buildPath)); }
public void GetPathValuesBySuffix_Returns_ExpectedPathValues() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); Assert.AreEqual("Test Build Path", profileGroupType.GetVariableBySuffix(buildPath.Suffix).Value); }
public PathPairRenamePopup(float labelWidth, ProfileGroupType profileGroupType, AddressableAssetSettings settings) { m_LabelWidth = labelWidth; m_ProfileGroupType = profileGroupType; m_Settings = settings; m_NewName = profileGroupType.GroupTypePrefix; UnityEngine.GUI.enabled = true; }
public void RemoveNonExistentVariable_Returns_ExpectedAction() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.RemoveVariable(buildPath); LogAssert.Expect(LogType.Error, "prefix.BuildPath does not exist."); }
public void RemoveVariable_Returns_ExpectedAction() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); profileGroupType.RemoveVariable(buildPath); Assert.True(profileGroupType.Variables.Count == 0); }
public void AddDuplicateVariableToGroupType_Returns_NullVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.NotNull(profileGroupType.AddVariable(buildPath)); LogAssert.Expect(LogType.Error, "prefix.BuildPath already exists."); Assert.Null(profileGroupType.AddVariable(buildPath)); }
public void GetPathValuesBySuffix_Returns_ExpectedPathValues() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool variableAdded = profileGroupType.AddVariable(buildPath); Assert.IsTrue(variableAdded, "Failed to add GroupType variable"); Assert.AreEqual("Test Build Path", profileGroupType.GetVariableBySuffix(buildPath.Suffix).Value); }
public void AddDuplicateVariableToGroupType_FailsToAddVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.IsTrue(profileGroupType.AddVariable(buildPath)); LogAssert.Expect(LogType.Error, "prefix.BuildPath already exists."); Assert.IsFalse(profileGroupType.AddVariable(buildPath)); }
public void GetName_Returns_ExpectedVariableName() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool gtAdded = profileGroupType.AddVariable(buildPath); Assert.IsTrue(gtAdded, $"Failed to add groupType {gtAdded}"); Assert.AreEqual("prefix.BuildPath", profileGroupType.GetName(buildPath)); }
public void AddVariableToGroupType_Returns_ExpectedNotNullVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.NotNull(profileGroupType.AddVariable(buildPath)); Assert.NotNull(profileGroupType.AddVariable(loadPath)); Assert.True(profileGroupType.Variables.Count == 2); }
public void AddVariableToGroupType_AddsVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.IsTrue(profileGroupType.AddVariable(buildPath)); Assert.IsTrue(profileGroupType.AddVariable(loadPath)); Assert.True(profileGroupType.Variables.Count == 2); }
public void CreateValidProfileGroupType_Returns_ValidProfileGroupType() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); profileGroupType.AddVariable(loadPath); Assert.True(profileGroupType.IsValidGroupType()); }
public void NonExistentGroupFindGroupType_Returns_Null() { ProfileGroupType nonexistentGroup = new ProfileGroupType("Test"); bool v1Added = nonexistentGroup.AddVariable(new ProfileGroupType.GroupTypeVariable(AddressableAssetSettings.kBuildPath, "Test Build Path")); bool v2Added = nonexistentGroup.AddVariable(new ProfileGroupType.GroupTypeVariable(AddressableAssetSettings.kLoadPath, "Test Load Path")); Assert.IsTrue(v1Added && v2Added, "Failed to add the variables for GroupTypes"); var result = Settings.FindGroupType(nonexistentGroup); Assert.IsNull(result); }
public void CreateValidProfileGroupType_Returns_ValidProfileGroupType() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool aAdded = profileGroupType.AddVariable(buildPath); bool bAdded = profileGroupType.AddVariable(loadPath); Assert.IsTrue(aAdded && bAdded, "Failed to Add variables"); Assert.True(profileGroupType.IsValidGroupType()); }
void RenamePathPair(ProfileGroupType groupType, Rect parentWindow, Rect displayRect) { try { //Determines the current variable rect location Rect variableRect = new Rect(parentWindow.x + 2.5f, displayRect.y + 1.5f, m_LabelWidth, k_ToolbarHeight * 2); PopupWindow.Show(variableRect, new PathPairRenamePopup(m_LabelWidth, groupType, settings)); } catch (ExitGUIException) { // Exception not being caught through OnGUI call } }
void CreatePairPrefixContextMenu(Rect parentWindow, Rect menuRect, ProfileGroupType groupType, Event evt) { if (menuRect.Contains(evt.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(groupType.GroupTypePrefix)); menu.AddSeparator(""); menu.AddItem(new GUIContent("Rename Path Prefix (All Profiles)"), false, () => { RenamePathPair(groupType, parentWindow, menuRect); }); menu.AddItem(new GUIContent("Delete Path Pair (All Profiles)"), false, () => { DeletePathPair(groupType); }); menu.ShowAsContext(); evt.Use(); } }
public void AddOrUpdateVariableToGroupType_AddsVariable() { ProfileGroupType profileGroupType = new ProfileGroupType("TestPrefix"); var bp = profileGroupType.GetVariableBySuffix("TestSuffix"); Assert.IsNull(bp); profileGroupType.AddOrUpdateVariable(new ProfileGroupType.GroupTypeVariable("TestSuffix", "TestValue")); bp = profileGroupType.GetVariableBySuffix("TestSuffix"); Assert.IsNotNull(bp); Assert.AreEqual(bp.m_Value, "TestValue", "Unexpected GroupTypeVariable, variable value should be TestValue"); Assert.True(profileGroupType.Variables.Count == 1); }
void DeletePathPair(ProfileGroupType groupType) { var buildPathData = settings.profileSettings.GetProfileDataByName(groupType.GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + AddressableAssetSettings.kBuildPath); var loadPathData = settings.profileSettings.GetProfileDataByName(groupType.GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + AddressableAssetSettings.kLoadPath); if (loadPathData == default(AddressableAssetProfileSettings.ProfileIdData) || buildPathData == default(AddressableAssetProfileSettings.ProfileIdData)) { Debug.LogError("An error occured while getting one of the path pair variables."); return; } Undo.RecordObject(settings, "Profile Variable Deleted"); settings.profileSettings.RemoveValue(buildPathData.Id); settings.profileSettings.RemoveValue(loadPathData.Id); AddressableAssetUtility.OpenAssetIfUsingVCIntegration(settings); }
void DrawDataSourceDropDowns(Rect dsDropdownRect, ProfileGroupType groupType, bool showDropdown) { Rect fixedDropdownRect = new Rect( //Determine correct position for dropdown window new Vector2( dsDropdownRect.x, dsDropdownRect.y ), new Vector2(dsDropdownRect.width, 120) ); if (showDropdown) { ProfileDataSourceDropdownWindow dataSourceDropdownWindow = new ProfileDataSourceDropdownWindow(fixedDropdownRect, groupType); //TODO: Add Event Handler Here dataSourceDropdownWindow.ValueChanged += DataSourceDropdownValueChanged; PopupWindow.Show(dsDropdownRect, dataSourceDropdownWindow); } }
private string DetermineOptionString(ProfileGroupType groupType) { ProfileGroupType selectedGroupType = dataSourceSettings.FindGroupType(groupType); if (selectedGroupType != null) { bool custom; m_CustomGroupTypes.TryGetValue(groupType.GroupTypePrefix, out custom); if (custom && ProfileIndex == m_ProfileTreeView.lastClickedProfile) { return("Custom"); } m_CustomGroupTypes[groupType.GroupTypePrefix] = false; #if (ENABLE_CCD && UNITY_2019_4_OR_NEWER) //Could ERR if user has group type prefix that starts with CCD if (selectedGroupType.GroupTypePrefix.StartsWith("CCD")) { var parts = selectedGroupType.GroupTypePrefix.Split(ProfileGroupType.k_PrefixSeparator); var badgeName = String.Join(ProfileGroupType.k_PrefixSeparator.ToString(), parts, 3, parts.Length - 3); var bucketName = selectedGroupType.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}").Value; return(String.Join(ProfileGroupType.k_PrefixSeparator.ToString(), new string[] { "CCD", bucketName, badgeName })); } #endif return(selectedGroupType.GroupTypePrefix); } else { m_CustomGroupTypes[groupType.GroupTypePrefix] = true; return("Custom"); } }
public void CreateEmptyProfileGroupType_Returns_InvalidProfileGroupType() { ProfileGroupType profileGroupType = new ProfileGroupType(); Assert.False(profileGroupType.IsValidGroupType()); }
public void CreatePrefixedProfileGroupType_Returns_InvalidProfileGroupType() { ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.False(profileGroupType.IsValidGroupType()); }
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; } }
//Displays all variables for the currently selected profile and initializes each variable's context menu void VariablesPane(Rect variablesPaneRect) { DrawOutline(variablesPaneRect, 1); Event evt = Event.current; AddressableAssetProfileSettings.BuildProfile selectedProfile = GetSelectedProfile(); if (selectedProfile == null) { return; } if (evt.isMouse || evt.isKey) { m_ProfileTreeView.lastClickedProfile = ProfileIndex; } //ensures amount of visible text is not affected by label width float fieldWidth = variablesPaneRect.width - (2 * k_ItemRectPadding) + m_FieldBufferWidth; if (!EditorGUIUtility.labelWidth.Equals(m_LabelWidth)) { EditorGUIUtility.labelWidth = m_LabelWidth; } int maxLabelLen = 0; int maxFieldLen = 0; GUILayout.BeginArea(variablesPaneRect); EditorGUI.indentLevel++; List <ProfileGroupType> groupTypes = ProfileGroupType.CreateGroupTypes(selectedProfile); HashSet <string> drawnGroupTypes = new HashSet <string>(); //Displaying Path Groups foreach (ProfileGroupType groupType in groupTypes) { bool?foldout; m_foldouts.TryGetValue(groupType.GroupTypePrefix, out foldout); GUILayout.Space(5); Rect pathPairRect = EditorGUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Width(fieldWidth + k_VariableItemPadding - k_SplitterThickness), GUILayout.MinWidth(fieldWidth + k_VariableItemPadding - k_SplitterThickness) }); m_foldouts[groupType.GroupTypePrefix] = EditorGUILayout.Foldout(foldout != null ? foldout.Value : true, groupType.GroupTypePrefix, true); Rect dsDropdownRect = EditorGUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Width(fieldWidth - m_LabelWidth), GUILayout.MinWidth(fieldWidth - m_LabelWidth) }); string dropdownText = DetermineOptionString(groupType); bool dsDropdown = EditorGUILayout.DropdownButton(new GUIContent(dropdownText), FocusType.Keyboard, new GUILayoutOption[] { GUILayout.Width(fieldWidth - m_LabelWidth) }); if (evt.type == EventType.ContextClick) { CreatePairPrefixContextMenu(variablesPaneRect, pathPairRect, groupType, evt); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); DrawDataSourceDropDowns(dsDropdownRect, groupType, dsDropdown); //Specific Grouped variables List <ProfileGroupType.GroupTypeVariable> pathVariables = new List <ProfileGroupType.GroupTypeVariable>(); pathVariables.Add(groupType.GetVariableBySuffix(AddressableAssetSettings.kBuildPath)); drawnGroupTypes.Add(groupType.GetName(groupType.GetVariableBySuffix(AddressableAssetSettings.kBuildPath))); pathVariables.Add(groupType.GetVariableBySuffix(AddressableAssetSettings.kLoadPath)); drawnGroupTypes.Add(groupType.GetName(groupType.GetVariableBySuffix(AddressableAssetSettings.kLoadPath))); if (m_foldouts[groupType.GroupTypePrefix].Value) { bool custom; m_CustomGroupTypes.TryGetValue(groupType.GroupTypePrefix, out custom); EditorGUI.BeginDisabledGroup(!custom); EditorGUI.indentLevel++; //Displaying Path Groups foreach (var variable in pathVariables) { Rect newPathRect = EditorGUILayout.BeginVertical(); string newPath = EditorGUILayout.TextField(groupType.GetName(variable), variable.Value, new GUILayoutOption[] { GUILayout.Width(fieldWidth) }); EditorGUILayout.EndVertical(); if (newPath != variable.Value && ProfileIndex == m_ProfileTreeView.lastClickedProfile) { Undo.RecordObject(settings, "Variable value changed"); settings.profileSettings.SetValue(selectedProfile.id, groupType.GetName(variable), newPath); AddressableAssetUtility.OpenAssetIfUsingVCIntegration(settings); } } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); } } //Display all other variables for (var i = 0; i < settings.profileSettings.profileEntryNames.Count; i++) { AddressableAssetProfileSettings.ProfileIdData curVariable = settings.profileSettings.profileEntryNames[i]; if (!drawnGroupTypes.Contains(curVariable.ProfileName)) { GUILayout.Space(5); Rect newValueRect = EditorGUILayout.BeginVertical(); string newValue = EditorGUILayout.TextField(curVariable.ProfileName, selectedProfile.values[i].value, new GUILayoutOption[] { GUILayout.Width(fieldWidth) }); EditorGUILayout.EndVertical(); if (newValue != selectedProfile.values[i].value && ProfileIndex == m_ProfileTreeView.lastClickedProfile) { Undo.RecordObject(settings, "Variable value changed"); settings.profileSettings.SetValue(selectedProfile.id, settings.profileSettings.profileEntryNames[i].ProfileName, newValue); AddressableAssetUtility.OpenAssetIfUsingVCIntegration(settings); } if (evt.type == EventType.ContextClick) { CreateVariableContextMenu(variablesPaneRect, newValueRect, curVariable, evt); } } maxLabelLen = Math.Max(maxLabelLen, curVariable.ProfileName.Length); } EditorGUI.indentLevel--; GUILayout.EndArea(); //Update the label width to the maximum of the minimum acceptable label width and the amount of //space required to contain the longest variable name m_LabelWidth = Mathf.Max(maxLabelLen * k_ApproxCharWidth, k_MinLabelWidth); m_FieldBufferWidth = Mathf.Clamp((maxFieldLen * k_ApproxCharWidth) - fieldWidth, 0f, float.MaxValue); }
public ProfileDataSourceDropdownWindow(Rect fieldRect, ProfileGroupType groupType) { m_GroupType = groupType; m_WindowRect = fieldRect; }
void DrawRemoteCatalogPaths() { ProfileValueReference BuildPath = m_AasTarget.RemoteCatalogBuildPath; ProfileValueReference LoadPath = m_AasTarget.RemoteCatalogLoadPath; AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings; if (settings == null) { return; } List <ProfileGroupType> groupTypes = ProfileGroupType.CreateGroupTypes(settings.profileSettings.GetProfile(settings.activeProfileId)); List <string> options = groupTypes.Select(group => group.GroupTypePrefix).ToList(); //set selected to custom options.Add(AddressableAssetProfileSettings.customEntryString); int?selected = options.Count - 1; HashSet <string> vars = settings.profileSettings.GetAllVariableIds(); if (vars.Contains(BuildPath.Id) && vars.Contains(LoadPath.Id) && !m_UseCustomPaths) { for (int i = 0; i < groupTypes.Count; i++) { ProfileGroupType.GroupTypeVariable buildPathVar = groupTypes[i].GetVariableBySuffix("BuildPath"); ProfileGroupType.GroupTypeVariable loadPathVar = groupTypes[i].GetVariableBySuffix("LoadPath"); if (BuildPath.GetName(settings) == groupTypes[i].GetName(buildPathVar) && LoadPath.GetName(settings) == groupTypes[i].GetName(loadPathVar)) { selected = i; break; } } } if (selected.HasValue && selected != options.Count - 1) { m_UseCustomPaths = false; } else { m_UseCustomPaths = true; } EditorGUI.BeginChangeCheck(); var newIndex = EditorGUILayout.Popup("Build & Load Paths", selected.HasValue ? selected.Value : options.Count - 1, options.ToArray()); if (EditorGUI.EndChangeCheck() && newIndex != selected) { if (options[newIndex] != AddressableAssetProfileSettings.customEntryString) { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); BuildPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "BuildPath"); LoadPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "LoadPath"); m_UseCustomPaths = false; } else { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); m_UseCustomPaths = true; } EditorUtility.SetDirty(this); } if (m_UseCustomPaths) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogBuildPath"), m_RemoteCatBuildPath); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogLoadPath"), m_RemoteCatLoadPath); } EditorGUI.indentLevel++; m_ShowPaths = EditorGUILayout.Foldout(m_ShowPaths, "Path Preview", true); if (m_ShowPaths) { EditorStyles.helpBox.fontSize = 12; var baseBuildPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, BuildPath.Id); var baseLoadPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, LoadPath.Id); EditorGUILayout.HelpBox(String.Format("Build Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseBuildPathValue)), MessageType.None); EditorGUILayout.HelpBox(String.Format("Load Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseLoadPathValue)), MessageType.None); } EditorGUI.indentLevel--; }