From 7b9eedbcff05afb3d98cffcd5f68a2831da66d0b Mon Sep 17 00:00:00 2001 From: orels1 Date: Sat, 26 Aug 2023 03:25:03 +0400 Subject: [PATCH 1/5] updated automation to support partial releases --- .github/workflows/pack-package.yml | 1 + .github/workflows/release.yml | 35 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pack-package.yml b/.github/workflows/pack-package.yml index 5dd1ebc..ffdd871 100644 --- a/.github/workflows/pack-package.yml +++ b/.github/workflows/pack-package.yml @@ -72,6 +72,7 @@ jobs: if: startsWith(github.ref, 'refs/heads/main') with: tag_name: "v${{ steps.version.outputs.prop }}" + draft: true files: | ${{ env.zipFile }} # ${{ env.unityPackage }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e0b3296..7f2d95a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,16 @@ name: Build Release on: workflow_dispatch: + inputs: + package-name: + description: 'Name of the package to release' + required: true + type: choice + options: + - All + - Shaders + - Generator + - Inspector # push: # branches: # - main @@ -13,19 +23,22 @@ on: jobs: pack-shaders: + if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Shaders' }} uses: ./.github/workflows/pack-package.yml with: package-name: "sh.orels.shaders" pack-inspector: uses: ./.github/workflows/pack-package.yml - needs: pack-shaders + if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Inspector' }} +# needs: pack-shaders with: package-name: "sh.orels.shaders.inspector" pack-generator: + if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Generator' }} uses: ./.github/workflows/pack-package.yml - needs: [pack-shaders, pack-inspector] +# needs: [pack-shaders, pack-inspector] with: package-name: "sh.orels.shaders.generator" @@ -35,6 +48,7 @@ jobs: update-release: needs: [pack-shaders, pack-inspector, pack-generator] + if: ${{ always() }} runs-on: ubuntu-latest steps: @@ -42,11 +56,28 @@ jobs: uses: actions/checkout@v3 - name: get version + if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Shaders' }} id: version uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 with: path: "Packages/sh.orels.shaders/package.json" prop_path: "version" + + - name: get version (Generator) + if: ${{ inputs.package-name == 'Generator' }} + id: version + uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 + with: + path: "Packages/sh.orels.shaders.generator/package.json" + prop_path: "version" + + - name: get version (Inspector) + if: ${{ inputs.package-name == 'Inspector' }} + id: version + uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 + with: + path: "Packages/sh.orels.shaders.inspector/package.json" + prop_path: "version" - name: Make Release uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 From 9aa04f6ac6bc0b0e3faa9860bc0d92552903d07b Mon Sep 17 00:00:00 2001 From: orels1 Date: Sat, 26 Aug 2023 03:25:27 +0400 Subject: [PATCH 2/5] made ambient CG library 2019-thing only for now --- .../Editor/MaterialLibraries/AmbientCGBrowser.cs | 6 ++++-- Packages/sh.orels.shaders.inspector/Editor/Requests.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Packages/sh.orels.shaders.inspector/Editor/MaterialLibraries/AmbientCGBrowser.cs b/Packages/sh.orels.shaders.inspector/Editor/MaterialLibraries/AmbientCGBrowser.cs index 74b1bf3..746e993 100644 --- a/Packages/sh.orels.shaders.inspector/Editor/MaterialLibraries/AmbientCGBrowser.cs +++ b/Packages/sh.orels.shaders.inspector/Editor/MaterialLibraries/AmbientCGBrowser.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_2019_4 +using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; @@ -438,4 +439,5 @@ public override void OnClose() _onClose(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Packages/sh.orels.shaders.inspector/Editor/Requests.cs b/Packages/sh.orels.shaders.inspector/Editor/Requests.cs index e2a9446..cabcee4 100644 --- a/Packages/sh.orels.shaders.inspector/Editor/Requests.cs +++ b/Packages/sh.orels.shaders.inspector/Editor/Requests.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_2019_4 +using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; @@ -105,4 +106,5 @@ public static async Task GetImage(string url, bool refetch = false) return image; } } -} \ No newline at end of file +} +#endif \ No newline at end of file From a1fe40ed1187f2d8223c87d5499792223ef9b186 Mon Sep 17 00:00:00 2001 From: orels1 Date: Sat, 26 Aug 2023 03:25:38 +0400 Subject: [PATCH 3/5] fixed up the layout for 2022 and above --- .../Editor/Drawers/HeaderDrawer.cs | 3 ++ .../Editor/InspectorGUI.cs | 54 +++++++++++++++++++ .../Editor/Styles.cs | 6 +++ .../sh.orels.shaders.inspector/package.json | 2 +- 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Packages/sh.orels.shaders.inspector/Editor/Drawers/HeaderDrawer.cs b/Packages/sh.orels.shaders.inspector/Editor/Drawers/HeaderDrawer.cs index 736ee49..1a6ca4c 100644 --- a/Packages/sh.orels.shaders.inspector/Editor/Drawers/HeaderDrawer.cs +++ b/Packages/sh.orels.shaders.inspector/Editor/Drawers/HeaderDrawer.cs @@ -43,6 +43,9 @@ public bool OnGUI( var rect = EditorGUILayout.GetControlRect(); rect.yMax += 1f * EditorGUIUtility.pixelsPerPoint; rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #if UNITY_2022_1_OR_NEWER + rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #endif rect.xMax += 5f * EditorGUIUtility.pixelsPerPoint; var dividerRect = rect; dividerRect.y -= 1f; diff --git a/Packages/sh.orels.shaders.inspector/Editor/InspectorGUI.cs b/Packages/sh.orels.shaders.inspector/Editor/InspectorGUI.cs index 61c6e18..2d06092 100644 --- a/Packages/sh.orels.shaders.inspector/Editor/InspectorGUI.cs +++ b/Packages/sh.orels.shaders.inspector/Editor/InspectorGUI.cs @@ -446,12 +446,34 @@ private bool DrawUIProp(MaterialEditor editor, MaterialProperty[] properties, Ma .ToList() .ForEach(g => groups.Add(g.Value)); } + #if UNITY_2022_1_OR_NEWER + var oldIndentLevel = EditorGUI.indentLevel; + var shouldRestore = oldIndentLevel != -1; + EditorGUI.indentLevel = oldIndentLevel != -1 ? Mathf.Max(0, EditorGUI.indentLevel - 1) : oldIndentLevel; + #endif drawn = MatchDrawerFuncStack(groups, editor, properties, property, index); + #if UNITY_2022_1_OR_NEWER + if (shouldRestore && EditorGUI.indentLevel != -1) + { + EditorGUI.indentLevel = oldIndentLevel; + } + #endif } if (!drawn) { + #if UNITY_2022_1_OR_NEWER + var oldIndentLevel = EditorGUI.indentLevel; + var shouldRestore = oldIndentLevel != -1; + EditorGUI.indentLevel = oldIndentLevel != -1 ? Mathf.Max(0, EditorGUI.indentLevel - 1) : oldIndentLevel; + #endif drawn = MatchDrawerStack(drawerStack, editor, properties, property, index); + #if UNITY_2022_1_OR_NEWER + if (shouldRestore && EditorGUI.indentLevel != -1) + { + EditorGUI.indentLevel = oldIndentLevel; + } + #endif } return drawn; } @@ -460,6 +482,12 @@ private bool DrawUIProp(MaterialEditor editor, MaterialProperty[] properties, Ma public void DrawRegularProp(MaterialEditor editor, MaterialProperty[] properties, MaterialProperty property, int index) { + #if UNITY_2022_1_OR_NEWER + var oldIndentLevel = EditorGUI.indentLevel; + var shouldRestore = oldIndentLevel != -1; + EditorGUI.indentLevel = oldIndentLevel != -1 ? Mathf.Max(0, EditorGUI.indentLevel - 1) : oldIndentLevel; + #endif + var strippedName = Utils.StripInternalSymbols(property.displayName); var isSingleLine = property.type == MaterialProperty.PropType.Texture && _singleLineRegex.IsMatch(property.displayName); var defaultProps = @@ -486,6 +514,12 @@ public void DrawRegularProp(MaterialEditor editor, MaterialProperty[] properties if (property.textureDimension != TextureDimension.Tex2D) return; var packerKey = property.name + "_packer"; _uiState[packerKey] = TexturePacker.DrawPacker(buttonRect, (bool) _uiState[packerKey], ref _uiState, packerKey, editor.target as Material, property, editor); + #if UNITY_2022_1_OR_NEWER + if (shouldRestore) + { + EditorGUI.indentLevel = oldIndentLevel; + } + #endif return; } @@ -507,9 +541,21 @@ public void DrawRegularProp(MaterialEditor editor, MaterialProperty[] properties if (property.textureDimension != TextureDimension.Tex2D) return; var packerKey = property.name + "_packer"; _uiState[packerKey] = TexturePacker.DrawPacker(buttonRect, (bool) _uiState[packerKey], ref _uiState, packerKey, editor.target as Material, property, editor); + #if UNITY_2022_1_OR_NEWER + if (shouldRestore && EditorGUI.indentLevel != -1) + { + EditorGUI.indentLevel = oldIndentLevel; + } + #endif return; } editor.ShaderProperty(controlRect, property, new GUIContent(strippedName, tooltip)); + #if UNITY_2022_1_OR_NEWER + if (shouldRestore) + { + EditorGUI.indentLevel = oldIndentLevel; + } + #endif } #endregion @@ -517,6 +563,9 @@ private void DrawFooter(MaterialEditor editor) { Styles.DrawStaticHeader("Extras"); EditorGUI.indentLevel = 1; + #if UNITY_2022_1_OR_NEWER + EditorGUI.indentLevel = 0; + #endif editor.RenderQueueField(); editor.EnableInstancingField(); editor.LightmapEmissionFlagsProperty(0, true, true); @@ -535,6 +584,11 @@ private void DrawDebug(MaterialEditor editor, Material material) } if (!newValue) return; + + #if UNITY_2022_1_OR_NEWER + // Unity 2022 is 1 more level nested + EditorGUI.indentLevel = 0; + #endif EditorGUILayout.LabelField("Active Keywords", EditorStyles.boldLabel); using (new EditorGUI.DisabledGroupScope(true)) { diff --git a/Packages/sh.orels.shaders.inspector/Editor/Styles.cs b/Packages/sh.orels.shaders.inspector/Editor/Styles.cs index bececa3..64fca08 100644 --- a/Packages/sh.orels.shaders.inspector/Editor/Styles.cs +++ b/Packages/sh.orels.shaders.inspector/Editor/Styles.cs @@ -141,6 +141,9 @@ public static void DrawStaticHeader(string text) var rect = EditorGUILayout.GetControlRect(); rect.yMax += 1f * EditorGUIUtility.pixelsPerPoint; rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #if UNITY_2022_1_OR_NEWER + rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #endif rect.xMax += 5f * EditorGUIUtility.pixelsPerPoint; var dividerRect = rect; dividerRect.y -= 1f; @@ -160,6 +163,9 @@ public static bool DrawFoldoutHeader(string text, bool open) { var rect = EditorGUILayout.GetControlRect(); rect.yMax += 1f * EditorGUIUtility.pixelsPerPoint; rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #if UNITY_2022_1_OR_NEWER + rect.xMin -= 15f * EditorGUIUtility.pixelsPerPoint; + #endif rect.xMax += 5f * EditorGUIUtility.pixelsPerPoint; var dividerRect = rect; dividerRect.y -= 1f; diff --git a/Packages/sh.orels.shaders.inspector/package.json b/Packages/sh.orels.shaders.inspector/package.json index 8867bb7..683f238 100644 --- a/Packages/sh.orels.shaders.inspector/package.json +++ b/Packages/sh.orels.shaders.inspector/package.json @@ -2,7 +2,7 @@ "name": "sh.orels.shaders.inspector", "displayName": "ORL Shader Inspector", "description": "A simple property-based shader inspector with extension support", - "version": "6.2.0", + "version": "6.2.1", "unity": "2019.4", "author": { "name": "orels1", From 8c1e3d3a11609e1298a122ea80a5e1a5691ee38d Mon Sep 17 00:00:00 2001 From: orels1 Date: Sat, 26 Aug 2023 03:29:34 +0400 Subject: [PATCH 4/5] adjusted the version step references --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f2d95a..f31dbc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,7 +57,7 @@ jobs: - name: get version if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Shaders' }} - id: version + id: version-all uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 with: path: "Packages/sh.orels.shaders/package.json" @@ -65,7 +65,7 @@ jobs: - name: get version (Generator) if: ${{ inputs.package-name == 'Generator' }} - id: version + id: version-generator uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 with: path: "Packages/sh.orels.shaders.generator/package.json" @@ -73,7 +73,7 @@ jobs: - name: get version (Inspector) if: ${{ inputs.package-name == 'Inspector' }} - id: version + id: version-inspector uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31 with: path: "Packages/sh.orels.shaders.inspector/package.json" @@ -83,14 +83,14 @@ jobs: uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 if: startsWith(github.ref, 'refs/heads/main') with: - tag_name: "v${{ steps.version.outputs.prop }}" + tag_name: "v${{ (inputs.package-name == 'All' || inputs.package-name == 'Shaders') ? steps.version-all.outputs.prop : (inputs.package-name == 'Generator' ? steps.version-generator.outputs.prop : steps.version-inspector.outputs.prop ) }}" generate_release_notes: true - name: Make Pre-Release uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 if: startsWith(github.ref, 'refs/heads/dev') with: - tag_name: "v${{ steps.version.outputs.prop }}" + tag_name: "v${{ (inputs.package-name == 'All' || inputs.package-name == 'Shaders') ? steps.version-all.outputs.prop : (inputs.package-name == 'Generator' ? steps.version-generator.outputs.prop : steps.version-inspector.outputs.prop ) }}" draft: true prerelease: true generate_release_notes: true From d24dd60851bcf4733692a6b67b6343b597baa936 Mon Sep 17 00:00:00 2001 From: orels1 Date: Sat, 26 Aug 2023 03:32:14 +0400 Subject: [PATCH 5/5] adjusted version conditions some more --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f31dbc2..8813dda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,14 +83,14 @@ jobs: uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 if: startsWith(github.ref, 'refs/heads/main') with: - tag_name: "v${{ (inputs.package-name == 'All' || inputs.package-name == 'Shaders') ? steps.version-all.outputs.prop : (inputs.package-name == 'Generator' ? steps.version-generator.outputs.prop : steps.version-inspector.outputs.prop ) }}" + tag_name: "v${{ ((inputs.package-name == 'All' || inputs.package-name == 'Shaders') && steps.version-all.outputs.prop) || (inputs.package-name == 'Generator' && steps.version-generator.outputs.prop) || steps.version-inspector.outputs.prop }}" generate_release_notes: true - name: Make Pre-Release uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 if: startsWith(github.ref, 'refs/heads/dev') with: - tag_name: "v${{ (inputs.package-name == 'All' || inputs.package-name == 'Shaders') ? steps.version-all.outputs.prop : (inputs.package-name == 'Generator' ? steps.version-generator.outputs.prop : steps.version-inspector.outputs.prop ) }}" + tag_name: "v${{ ((inputs.package-name == 'All' || inputs.package-name == 'Shaders') && steps.version-all.outputs.prop) || (inputs.package-name == 'Generator' && steps.version-generator.outputs.prop) || steps.version-inspector.outputs.prop }}" draft: true prerelease: true generate_release_notes: true