public void CannotRenameEntryToDuplicateName() { //Arrange Assert.IsNotNull(m_Settings.profileSettings); m_Settings.activeProfileId = null; m_Settings.profileSettings.Reset(); string entryName = "SomeName"; string newName = "NewerName"; string originalPath = "/Assets/Important"; m_Settings.profileSettings.CreateValue(entryName, originalPath); m_Settings.profileSettings.CreateValue(newName, originalPath); AddressableAssetProfileSettings.ProfileIdData currEntry = null; foreach (var entry in m_Settings.profileSettings.profileEntryNames) { if (entry.ProfileName == entryName) { currEntry = entry; break; } } //Act Assert.NotNull(currEntry); currEntry.SetName(newName, m_Settings.profileSettings); //Assert Assert.AreNotEqual(currEntry.ProfileName, newName); }
public override void OnGUI(Rect windowRect) { GUILayout.BeginArea(windowRect); Event evt = Event.current; bool hitEnter = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter); m_NewName = GUILayout.TextField(m_NewName); if (hitEnter) { if (string.IsNullOrEmpty(m_NewName)) { Debug.LogError("Variable name cannot be empty."); } else if (m_NewName != m_Settings.profileSettings.GetUniqueProfileEntryName(m_NewName)) { Debug.LogError("Profile variable '" + m_NewName + "' already exists."); } else if (m_NewName.Trim().Length == 0) // new name cannot only contain spaces { Debug.LogError("Name cannot be only spaces"); } else { Undo.RecordObject(m_Settings, "Profile Variable Renamed"); m_ProfileVariable.SetName(m_NewName, m_Settings.profileSettings); AddressableAssetUtility.OpenAssetIfUsingVCIntegration(m_Settings, true); editorWindow.Close(); } } GUILayout.EndArea(); }