Skip to content

Commit

Permalink
Merge pull request #39 from orels1/dev
Browse files Browse the repository at this point in the history
Inspector Release 6.2.1
  • Loading branch information
orels1 authored Aug 25, 2023
2 parents 541edb3 + d24dd60 commit b837b3b
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pack-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
41 changes: 36 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -35,31 +48,49 @@ jobs:

update-release:
needs: [pack-shaders, pack-inspector, pack-generator]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- name: get version
id: version
if: ${{ inputs.package-name == 'All' || inputs.package-name == 'Shaders' }}
id: version-all
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-generator
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-inspector
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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 54 additions & 0 deletions Packages/sh.orels.shaders.inspector/Editor/InspectorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 =
Expand All @@ -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;
}

Expand All @@ -507,16 +541,31 @@ 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

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);
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if UNITY_2019_4
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -438,4 +439,5 @@ public override void OnClose()
_onClose();
}
}
}
}
#endif
6 changes: 4 additions & 2 deletions Packages/sh.orels.shaders.inspector/Editor/Requests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -105,4 +106,5 @@ public static async Task<Texture2D> GetImage(string url, bool refetch = false)
return image;
}
}
}
}
#endif
6 changes: 6 additions & 0 deletions Packages/sh.orels.shaders.inspector/Editor/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Packages/sh.orels.shaders.inspector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b837b3b

Please sign in to comment.