Skip to content

Commit b547e5d

Browse files
Refactor shader generation scripts and paths
Co-authored-by: sindharta.tanuwijaya <sindharta.tanuwijaya@unity3d.com>
1 parent c8ecd49 commit b547e5d

File tree

11 files changed

+47
-1558
lines changed

11 files changed

+47
-1558
lines changed

UnityToon_Generated_Test.shader

Lines changed: 0 additions & 1535 deletions
This file was deleted.

com.unity.toon-graphics-test/Editor/README_ShaderGenerator.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ If you prefer to generate shaders manually, you can run the Python helper from t
6565

6666
```bash
6767
cd /workspace
68-
python3 com.unity.toon-graphics-test/generate_shaders.py
68+
python3 generate_UnityToon.py
6969
```
7070

71-
Convenience launchers are provided as `generate_shaders.sh` and `generate_shaders.bat`.
71+
Convenience launchers are provided as `generate_UnityToon.sh` and `generate_UnityToon.bat`.
7272

7373
## Troubleshooting
7474

@@ -80,19 +80,19 @@ Convenience launchers are provided as `generate_shaders.sh` and `generate_shader
8080

8181
```
8282
com.unity.toon-graphics-test/
83-
├── Editor/
84-
│ ├── ShaderGenerator.cs # Unity Editor script
85-
│ ├── ShaderGeneratorTest.cs # Editor test harness
86-
│ └── README_ShaderGenerator.md # This file
87-
├── generate_shaders.py # Python generator
88-
├── test_generation.py # Python smoke test
89-
└── test_shader_generation.cs # .NET console smoke test
83+
└── Editor/
84+
├── ShaderGenerator.cs # Unity Editor script
85+
├── ShaderGeneratorTest.cs # Editor test harness
86+
└── README_ShaderGenerator.md # This file
9087
9188
com.unity.toonshader/Runtime/Integrated/Shaders/
9289
├── CommonPropertiesPart.shader # Shared properties with comments (hidden shader asset)
9390
├── TessellationPropertiesPart.shader # Tessellation-specific properties (hidden shader asset)
9491
├── UnityToon.shader # Generated shader (regular)
9592
└── UnityToonTessellation.shader # Generated shader (tessellation)
9693
97-
generate_shaders.sh / generate_shaders.bat # Platform launchers for the Python generator
94+
generate_UnityToon.py # Python generator (root)
95+
test_generate_UnityToon.py # Python smoke test (root)
96+
test_shader_generation.cs # .NET console smoke test (root)
97+
generate_UnityToon.sh / .bat # Platform launchers for the Python generator
9898
```

com.unity.toon-graphics-test/Editor/ShaderGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ namespace UnityEditor.Rendering.Toon
1717
public class ShaderGenerator : EditorWindow
1818
{
1919
private static readonly Regex PropertyNameRegex = new Regex(@"([A-Za-z_][A-Za-z0-9_]*)\s*\(", RegexOptions.Compiled);
20-
private const string COMMON_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesPart.shader";
21-
private const string TESSELATION_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationPropertiesPart.shader";
22-
private const string UNITY_TOON_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";
23-
private const string UNITY_TOON_TESSELATION_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader";
20+
private const string COMMON_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesPart.shader";
21+
private const string TESSELATION_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationPropertiesPart.shader";
22+
private const string UNITY_TOON_SHADER_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";
23+
private const string UNITY_TOON_TESSELATION_SHADER_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader";
2424

2525
[MenuItem("Unity Toon Shader/Generate Shader Files")]
2626
public static void ShowWindow()

com.unity.toon-graphics-test/Editor/ShaderGeneratorTest.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void TestShaderGeneration()
1818
try
1919
{
2020
// Test reading the common properties file
21-
string commonPropertiesPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesPart.shader";
21+
string commonPropertiesPath = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesPart.shader";
2222
string commonPropertiesShader = File.ReadAllText(commonPropertiesPath);
2323

2424
if (string.IsNullOrEmpty(commonPropertiesShader))
@@ -36,7 +36,7 @@ public static void TestShaderGeneration()
3636
Debug.Log($"Successfully extracted common properties. Length: {commonProperties.Length} characters");
3737

3838
// Test reading the tessellation properties file
39-
string tessellationPropertiesPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationPropertiesPart.shader";
39+
string tessellationPropertiesPath = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationPropertiesPart.shader";
4040
string tessellationPropertiesShader = File.ReadAllText(tessellationPropertiesPath);
4141

4242
if (string.IsNullOrEmpty(tessellationPropertiesShader))
@@ -54,7 +54,7 @@ public static void TestShaderGeneration()
5454
Debug.Log($"Successfully extracted tessellation properties. Length: {tessellationProperties.Length} characters");
5555

5656
// Test reading the original shader files
57-
string unityToonPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";
57+
string unityToonPath = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";
5858
string unityToonContent = File.ReadAllText(unityToonPath);
5959

6060
if (string.IsNullOrEmpty(unityToonContent))
@@ -99,11 +99,17 @@ public static void TestShaderGeneration()
9999
Debug.Log($"Generated new shader content. Original length: {unityToonContent.Length}, New length: {newContent.Length}");
100100

101101
// Write test file
102-
string testPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon_Generated_Test.shader";
102+
string testPath = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon_Generated_Test.shader";
103103
File.WriteAllText(testPath, newContent);
104104
AssetDatabase.Refresh();
105105

106106
Debug.Log($"Test shader written to {testPath}");
107+
108+
if (File.Exists(testPath))
109+
{
110+
File.Delete(testPath);
111+
AssetDatabase.Refresh();
112+
}
107113
}
108114
else
109115
{

com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Wed Nov 05 05:23:38 UTC 2025
1+
//Auto-generated on Wed Nov 05 05:42:38 UTC 2025
22
//Unity Toon Shader
33
//nobuyuki@unity3d.com
44
//toshiyuki@unity3d.com (Intengrated)

com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Wed Nov 05 05:23:38 UTC 2025
1+
//Auto-generated on Wed Nov 05 05:42:38 UTC 2025
22
//Unity Toon Shader
33
//nobuyuki@unity3d.com
44
//toshiyuki@unity3d.com (Intengrated)

generate_shaders.bat renamed to generate_UnityToon.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ echo ==========================
44
echo.
55

66
echo Generating shader files from common properties...
7-
python3 com.unity.toon-graphics-test/generate_shaders.py
7+
python3 generate_UnityToon.py
88

99
if %ERRORLEVEL% EQU 0 (
1010
echo.
File renamed without changes.

generate_shaders.sh renamed to generate_UnityToon.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo "=========================="
55
echo
66

77
echo "Generating shader files from common properties..."
8-
python3 com.unity.toon-graphics-test/generate_shaders.py
8+
python3 generate_UnityToon.py
99

1010
if [ $? -eq 0 ]; then
1111
echo

com.unity.toon-graphics-test/test_generation.py renamed to test_generate_UnityToon.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python3
22

3+
import os
34
import re
45

5-
from generate_shaders import (
6+
from generate_UnityToon import (
67
extract_properties_from_shader_content,
78
apply_auto_generated_comment,
89
)
@@ -117,6 +118,12 @@ def test_shader_generation():
117118
print(f"Test shader written to {test_path}")
118119
print("Shader generation test completed successfully!")
119120

121+
try:
122+
import os
123+
os.remove(test_path)
124+
except OSError:
125+
pass
126+
120127
except Exception as e:
121128
print(f"ERROR: {e}")
122129
import traceback

0 commit comments

Comments
 (0)