Пример #1
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField(EditorConstants.PackageJsonHeader, EditorStyles.boldLabel);
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty(IdPropertyName));
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.PropertyField(serializedObject.FindProperty(NamePropertyName));
            EditorGUILayout.PropertyField(serializedObject.FindProperty(DisplayNameProperty));
            EditorGUILayout.PropertyField(serializedObject.FindProperty(PackageVersionPropertyName));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty(UnityVersionPropertyName));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(serializedObject.FindProperty(DescriptionPropertyName));
            EditorGUILayout.PropertyField(serializedObject.FindProperty(CategoryPropertyName));

            _keywordReorderableList.DoLayoutList();
            _dependenciesReorderableList.DoLayoutList();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(EditorConstants.PackageContentHeader, EditorStyles.boldLabel);

            _sourcePathsReorderableList.DoLayoutList();
            _excludePathsReorderableList.DoLayoutList();

            EditorGUILayout.BeginHorizontal();
            var destinationPathProperty = serializedObject.FindProperty(DestinationPathPropertyName);

            EditorGUILayout.PropertyField(
                destinationPathProperty,
                GUILayout.Height(EditorConstants.FolderPathPickerHeight));
            GUILayoutTools.DrawFolderPickerLayout(
                destinationPathProperty,
                EditorConstants.SelectPackageExportPathPickerTitle);
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(EditorConstants.PackageActionsHeader, EditorStyles.boldLabel);

            if (GUILayout.Button(EditorConstants.UpdatePackageButtonText))
            {
                FileTools.CreateOrUpdatePackageSource((PackageManifestConfig)target);
            }
        }
Пример #2
0
        private void DrawSourcePathElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect.width -= EditorConstants.FolderPathPickerHeight * 2;
            rect.height = EditorConstants.FolderPathPickerHeight;
            var sourcePathRect = new Rect(rect);

            var sourcePathProperty =
                serializedObject.FindProperty(SourcePathsPropertyName).GetArrayElementAtIndex(index);

            EditorGUI.PropertyField(
                sourcePathRect,
                sourcePathProperty,
                new GUIContent(string.Format(EditorConstants.SourcePathElementLabelFormat, index)));

            var filePickerRect = new Rect
            {
                position = new Vector2(
                    sourcePathRect.width + EditorConstants.FolderPathPickerBuffer,
                    sourcePathRect.position.y),
                width  = EditorConstants.FolderPathPickerHeight,
                height = EditorConstants.FolderPathPickerHeight,
            };

            var folderPickerRect = new Rect
            {
                position = new Vector2(
                    sourcePathRect.width + EditorConstants.FolderPathPickerHeight + EditorConstants.FolderPathPickerBuffer,
                    sourcePathRect.position.y),
                width  = EditorConstants.FolderPathPickerHeight,
                height = EditorConstants.FolderPathPickerHeight,
            };

            GUILayoutTools.DrawFilePicker(
                filePickerRect,
                sourcePathProperty,
                EditorConstants.SelectSourcePathFilePickerTitle);

            GUILayoutTools.DrawFolderPicker(
                folderPickerRect,
                sourcePathProperty,
                EditorConstants.SelectSourcePathPickerFolderTitle);
        }
        private void DrawPathElement(string propertyName, Rect rect, int index, bool isActive, bool isFocused)
        {
            rect.width -= EditorConstants.FOLDER_PATH_PICKER_HEIGHT * 2;
            rect.height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT;
            var sourcePathRect = new Rect(rect);

            var sourcePathProperty =
                serializedObject.FindProperty(propertyName).GetArrayElementAtIndex(index);

            EditorGUI.PropertyField(
                sourcePathRect,
                sourcePathProperty,
                new GUIContent(string.Format(EditorConstants.SOURCE_PATH_ELEMENT_LABEL_FORMAT, index)));

            var filePickerRect = new Rect {
                position = new Vector2(
                    sourcePathRect.width + EditorConstants.FOLDER_PATH_PICKER_BUFFER,
                    sourcePathRect.position.y),
                width  = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
                height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
            };

            var folderPickerRect = new Rect {
                position = new Vector2(
                    sourcePathRect.width + EditorConstants.FOLDER_PATH_PICKER_HEIGHT + EditorConstants.FOLDER_PATH_PICKER_BUFFER,
                    sourcePathRect.position.y),
                width  = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
                height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
            };

            GUILayoutTools.DrawFilePicker(
                filePickerRect,
                sourcePathProperty,
                EditorConstants.SELECT_SOURCE_PATH_FILE_PICKER_TITLE);

            GUILayoutTools.DrawFolderPicker(
                folderPickerRect,
                sourcePathProperty,
                EditorConstants.SELECT_SOURCE_PATH_PICKER_FOLDER_TITLE);
        }
        public override void OnInspectorGUI()
        {
            var config = (PackageManifestConfig)target;

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.LabelField(EditorConstants.PACKAGE_JSON_HEADER, EditorStyles.boldLabel);
                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty(ID_PROPERTY_NAME));
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty(NAME_PROPERTY_NAME));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(DISPLAY_NAME_PROPERTY));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(PACKAGE_VERSION_PROPERTY_NAME));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(UNITY_VERSION_PROPERTY_NAME));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(DESCRIPTION_PROPERTY_NAME));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(CATEGORY_PROPERTY_NAME));

                _keywordReorderableList.DoLayoutList();
                _dependenciesReorderableList.DoLayoutList();

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(EditorConstants.PACKAGE_CONTENT_HEADER, EditorStyles.boldLabel);

                _sourcePathsReorderableList.DoLayoutList();
                _excludePathsReorderableList.DoLayoutList();

                // Package Source Export
                using (new EditorGUILayout.HorizontalScope())
                {
                    var destinationPathProperty = serializedObject.FindProperty(DESTINATION_PATH_PROPERTY_NAME);
                    EditorGUILayout.PropertyField(
                        destinationPathProperty,
                        GUILayout.Height(EditorConstants.FOLDER_PATH_PICKER_HEIGHT));
                    GUILayoutTools.DrawFolderPickerLayout(
                        destinationPathProperty,
                        EditorConstants.SELECT_PACKAGE_EXPORT_PATH_PICKER_TITLE);
                }

                // Legacy Package Export
                using (new EditorGUILayout.HorizontalScope())
                {
                    var legacyPackagePathProperty = serializedObject.FindProperty(LEGACY_PACKAGE_PATH_PROPERTY_NAME);
                    EditorGUILayout.PropertyField(
                        legacyPackagePathProperty,
                        GUILayout.Height(EditorConstants.FOLDER_PATH_PICKER_HEIGHT));
                    GUILayoutTools.DrawFolderPickerLayout(
                        legacyPackagePathProperty,
                        EditorConstants.SELECT_PACKAGE_EXPORT_PATH_PICKER_TITLE);
                }

                // Version Constants Export
                using (new EditorGUILayout.VerticalScope(EditorConstants.GROUP_BOX))
                {
                    // Namespace
                    var namespaceProperty = serializedObject.FindProperty(VERSION_CONSTANTS_NAMESPACE_PROPERTY_NAME);
                    EditorGUILayout.PropertyField(namespaceProperty);
                    if (string.IsNullOrEmpty(namespaceProperty.stringValue))
                    {
                        EditorGUILayout.HelpBox(EditorConstants.GLOBAL_NAMESPACE_WARNING, MessageType.Info);
                    }

                    // Output folder
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        var versionConstantsPathProperty = serializedObject.FindProperty(VERSION_CONSTANTS_PATH_PROPERTY_NAME);
                        EditorGUILayout.PropertyField(
                            versionConstantsPathProperty,
                            GUILayout.Height(EditorConstants.FOLDER_PATH_PICKER_HEIGHT));
                        GUILayoutTools.DrawFolderPickerLayout(
                            versionConstantsPathProperty,
                            EditorConstants.SELECT_VERSION_CONSTANTS_PATH_PICKER_TITLE);
                    }
                }

                if (scope.changed)
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(EditorConstants.PACKAGE_ACTIONS_HEADER, EditorStyles.boldLabel);

            if (GUILayout.Button(new GUIContent(
                                     EditorConstants.GENERATE_VERSION_CONSTANTS_BUTTON_TEXT,
                                     EditorConstants.GENERATE_VERSION_CONSTANTS_TOOLTIP)))
            {
                CodeGenTools.GenerateVersionConstants(config);
            }

            if (GUILayout.Button(EditorConstants.UPDATE_PACKAGE_BUTTON_TEXT))
            {
                FileTools.CreateOrUpdatePackageSource(config);
            }

            if (GUILayout.Button(EditorConstants.EXPORT_LEGACY_PACKAGE_BUTTON_TEXT))
            {
                UnityFileTools.CompileLegacyPackage(config);
            }
        }