Skip to content

Commit cc2256a

Browse files
committed
Removed test generator window
added generator button in the inspector of the modular shader Adjusted InspectorList uss
1 parent 9efd77b commit cc2256a

File tree

8 files changed

+35
-67
lines changed

8 files changed

+35
-67
lines changed

Editor/Editors/Elements/InspectorList.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private void CreateDrop()
159159
if (_currentDrop == dropArea) _currentDrop = null;
160160
}
161161
});
162-
162+
163163
_listContainer.Add(dropArea);
164164
_drops.Add(dropArea);
165165
}
@@ -273,17 +273,15 @@ public InspectorListItem(IInspectorList list, VisualElement element, SerializedP
273273
e.StopImmediatePropagation();
274274
return;
275275
}
276-
else
277-
{
278-
_list.draggedElement = this;
279-
_list.HighlightDrops();
280-
this.AddToClassList("inspector-list-drag-enabled");
281-
}
276+
277+
_list.draggedElement = this;
278+
_list.HighlightDrops();
279+
AddToClassList("inspector-list-drag-enabled");
282280
});
283281

284282
VisualElement buttonsArea = new VisualElement();
285283

286-
this.RegisterCallback<UnityEngine.UIElements.GeometryChangedEvent>(e =>
284+
RegisterCallback<GeometryChangedEvent>(e =>
287285
{
288286
buttonsArea.ClearClassList();
289287
if (e.newRect.height > 60)

Editor/Editors/Inspectors/ModularShaderEditor.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using UnityEditor;
23
using UnityEngine;
34
using UnityEngine.UIElements;
@@ -41,6 +42,27 @@ public override VisualElement CreateInspectorGUI()
4142
{
4243
propertiesTemplateField.style.display = x.newValue ? DisplayStyle.Flex : DisplayStyle.None;
4344
});
45+
46+
var generateButton = _root.Q<Button>("RegenerateShaderButton");
47+
48+
generateButton.clicked += () =>
49+
{
50+
var _issues = ShaderGenerator.CheckShaderIssues(_shader);
51+
if (_issues.Count > 0)
52+
{
53+
EditorUtility.DisplayDialog("Error", $"The modular shader has issues that must be resolved before generating the shader:\n {string.Join("\n ", _issues)}", "Ok");
54+
return;
55+
}
56+
57+
string path = EditorUtility.OpenFolderPanel("Select folder", "Assets", "");
58+
if (path.Length == 0)
59+
return;
60+
61+
string localPath = Environment.CurrentDirectory;
62+
localPath = localPath.Replace('\\', '/');
63+
path = path.Replace(localPath + "/", "");
64+
ShaderGenerator.GenerateShader(path, _shader);
65+
};
4466

4567
return _root;
4668
}

Editor/Resources/MSS/MSSUIElements/InspectorList.uss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,13 @@
113113

114114
.inspector-list-drop-area
115115
{
116-
height: 0px;
117-
116+
height: 5px;
118117
border-radius: 4px;
118+
119119
}
120120

121121
.inspector-list-drop-area-highlight
122122
{
123-
height: 8px;
124-
margin: 2px;
125123
background-color: rgba(128, 128, 190, 0.5);
126124
}
127125

Editor/Resources/MSS/MSSUIElements/ModularShaderEditor.uxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
<ui:Toggle binding-path="UseTemplatesForProperties" label="Properties from templates" name="UseTemplatesForPropertiesField" />
1515
<uie:ObjectField label="Shader Properties Template" binding-path="ShaderPropertiesTemplate" name="ShaderPropertiesTemplateField" allow-scene-objects="false" />
1616
<VRLabs.ModularShaderSystem.ModuleInspectorList name="BaseModulesField" binding-path="BaseModules" show-elements-text="false" />
17+
<ui:Button name="RegenerateShaderButton" text="Generate Shader"/>
1718
</ui:UXML>

Editor/ShaderModuleGenerationTest.cs

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

Editor/ShaderModuleGenerationTest.cs.meta

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

Examples/ExampleModularShader.asset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ MonoBehaviour:
1616
Name: Example Modular Shader
1717
Version: 1.0
1818
Author: VRLabs
19+
Description:
1920
UseTemplatesForProperties: 0
2021
ShaderPropertiesTemplate: {fileID: 0}
2122
ShaderPath: VRLabs/Examples/Example Modular Shader
@@ -52,3 +53,5 @@ MonoBehaviour:
5253
- {fileID: 11400000, guid: 5a456ab203c06e341bdbdf8d48c8c643, type: 2}
5354
AdditionalModules: []
5455
LockBaseModules: 0
56+
LastGeneratedShaders: []
57+
AdditionalSerializedData:

Examples/ExampleModule1.asset

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ MonoBehaviour:
1717
Version: 1.0
1818
Author: VRLabs
1919
Description:
20-
RequiredIncludes: []
2120
Enabled:
2221
Name:
2322
DisplayName:
@@ -31,19 +30,13 @@ MonoBehaviour:
3130
Type: Float
3231
DefaultValue: 0.0
3332
Attributes: []
34-
- Name:
35-
DisplayName:
36-
Type:
37-
DefaultValue: 0
38-
Attributes:
39-
- Header(hi)
4033
ModuleDependencies: []
4134
IncompatibleWith: []
4235
Templates: []
4336
Functions:
4437
- Name: DoSomething
4538
AppendAfter: '#K#MAINPASSENTRY'
46-
Priority: 99
39+
Queue: 99
4740
ShaderFunctionCode: {fileID: 1413292532103889072, guid: 55a288a5a8d45a74e8bf3f0ee396c57c,
4841
type: 3}
4942
UsedVariables:

0 commit comments

Comments
 (0)