private void DrawDependencyListElement(Rect rect, int index, bool isActive, bool isFocused) { var list = m_DependenciesList.serializedProperty; var dependency = list.GetArrayElementAtIndex(index); var packageName = dependency.FindPropertyRelative("packageName"); var version = dependency.FindPropertyRelative("version"); var w = rect.width; rect.x += 4; rect.width = w / 3 * 2 - 2; rect.height -= EditorGUIUtility.standardVerticalSpacing; packageName.stringValue = EditorGUI.DelayedTextField(rect, packageName.stringValue); if (!IsNullOrEmptyTrim(packageName.stringValue) && !PackageValidation.ValidateName(packageName.stringValue)) { errorMessages.Add($"Invalid Dependency Package Name '{packageName.stringValue}'"); } using (new EditorGUI.DisabledScope(IsNullOrEmptyTrim(packageName.stringValue))) { rect.x += w / 3 * 2; rect.width = w / 3 - 4; version.stringValue = EditorGUI.DelayedTextField(rect, version.stringValue); if (!IsNullOrEmptyTrim(version.stringValue) && !PackageValidation.ValidateVersion(version.stringValue)) { errorMessages.Add( $"Invalid Dependency Version '{version.stringValue}' for '{packageName.stringValue}'"); } } }
private void PerformValidation() { var canBuildCompleteName = true; if (!PackageValidation.ValidateOrganizationName(m_OrganizationName.stringValue) && !string.IsNullOrWhiteSpace(m_OrganizationName.stringValue)) { canBuildCompleteName = false; errorMessages.Add($"Invalid Package Organization Name '{m_OrganizationName.stringValue}'"); } if (!PackageValidation.ValidateName(m_Name.stringValue)) { canBuildCompleteName = false; errorMessages.Add($"Invalid Package Name '{m_Name.stringValue}'"); } if (canBuildCompleteName) { var completePackageName = BuildCompletePackageName(packageState.info.packageName.domain, m_OrganizationName.stringValue, m_Name.stringValue); if (!PackageValidation.ValidateCompleteName(completePackageName)) { errorMessages.Add($"Invalid Complete Package Name '{completePackageName}'"); } } ValidateVersion(null, m_Version.stringValue, errorMessages, warningMessages); if (m_UnityVersionEnabled.boolValue) { if (!PackageValidation.ValidateUnityVersion(m_UnityMajor.stringValue, m_UnityMinor.stringValue, m_UnityRelease.stringValue)) { var unityVersion = string.Join(".", new[] { m_UnityMajor.stringValue, m_UnityMinor.stringValue }); if (!string.IsNullOrWhiteSpace(m_UnityRelease.stringValue)) { unityVersion += "." + m_UnityRelease.stringValue.Trim(); } errorMessages.Add($"Invalid Unity Version '{unityVersion}'"); } } if (string.IsNullOrWhiteSpace(m_DisplayName.stringValue) || m_DisplayName.stringValue.Trim().Length == 0) { warningMessages.Add("Display name should be provided."); } if (string.IsNullOrWhiteSpace(m_Description.stringValue) || m_Description.stringValue.Trim().Length == 0) { warningMessages.Add("Package description should be provided."); } if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysHidden) { warningMessages.Add("This package and all its assets will be hidden by default in Editor because its visibility is set to 'Always Hidden'"); } if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysVisible) { warningMessages.Add("This package and all its assets will be visible by default in Editor because its visibility is set to 'Always Visible'"); } }
private void PerformValidation() { if (!PackageValidation.ValidateOrganizationName(m_OrganizationName.stringValue) && !IsNullOrEmptyTrim(m_OrganizationName.stringValue)) { errorMessages.Add($"Invalid Package Organization Name '{m_OrganizationName.stringValue}'"); } if (!PackageValidation.ValidateName(m_Name.stringValue)) { errorMessages.Add($"Invalid Package Name '{m_Name.stringValue}'"); } if (!PackageValidation.ValidateVersion(m_Version.stringValue)) { errorMessages.Add($"Invalid Version '{m_Version.stringValue}'"); } if (m_UnityVersionEnabled.boolValue) { if (!PackageValidation.ValidateUnityVersion(m_UnityMajor.stringValue, m_UnityMinor.stringValue, m_UnityRelease.stringValue)) { var unityVersion = string.Join(".", new[] { m_UnityMajor.stringValue, m_UnityMinor.stringValue }); if (!IsNullOrEmptyTrim(m_UnityRelease.stringValue)) { unityVersion += "." + m_UnityRelease.stringValue.Trim(); } errorMessages.Add($"Invalid Unity Version '{unityVersion}'"); } } if (IsNullOrEmptyTrim(m_DisplayName.stringValue) || m_DisplayName.stringValue.Trim().Length == 0) { warningMessages.Add("Display name should be provided."); } if (IsNullOrEmptyTrim(m_Description.stringValue) || m_Description.stringValue.Trim().Length == 0) { warningMessages.Add("Package description should be provided."); } if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysHidden) { warningMessages.Add("This package and all its assets will be hidden by default in Editor because its visibility is set to 'Always Hidden'"); } if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysVisible) { warningMessages.Add("This package and all its assets will be visible by default in Editor because its visibility is set to 'Always Visible'"); } else { if (IsNullOrEmptyTrim(packageState.info.type)) { warningMessages.Add("This package and all its assets will be hidden by default in Editor because its type is empty"); } else if (PackageInfo.GetPredefinedHiddenByDefaultPackageTypes().Contains(packageState.info.type)) { warningMessages.Add($"This package and all its assets will be hidden by default in Editor because its type is '{packageState.info.type}'"); } else { warningMessages.Add($"This package and all its assets will be visible by default in Editor because its type is '{packageState.info.type}'"); } } }