Skip to content

Commit e26259f

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.1] [ShaderGraph]properties bugfixes
1 parent de82ef9 commit e26259f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

Packages/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,15 @@ void BuildExposedField(PropertySheet propertySheet)
182182
propertySheet.Add(toggleDataPropertyDrawer.CreateGUI(
183183
evt =>
184184
{
185+
if (shaderInput is AbstractShaderProperty property &&
186+
(!property.overrideHLSLDeclaration || property.hlslDeclarationOverride == HLSLDeclaration.DoNotDeclare))
187+
{
188+
property.hlslDeclarationOverride = property.GetDefaultHLSLDeclaration();
189+
property.overrideHLSLDeclaration = true;
190+
}
185191
this._preChangeValueCallback("Change Exposed Toggle");
186192
this._exposedFieldChangedCallback(evt.isOn);
187-
this._postChangeValueCallback(false, ModificationScope.Graph);
193+
this._postChangeValueCallback(true, ModificationScope.Graph);
188194
},
189195
new ToggleData(shaderInput.isExposed),
190196
shaderInput is ShaderKeyword ? "Generate Material Property" : "Show In Inspector",
@@ -528,8 +534,11 @@ void BuildHLSLDeclarationOverrideFields(PropertySheet propertySheet, AbstractSha
528534
property.hlslDeclarationOverride = evt.newValue;
529535
property.overrideHLSLDeclaration = true;
530536
UpdateEnableState();
531-
this._exposedFieldChangedCallback(evt.newValue != HLSLDeclaration.Global);
532-
property.generatePropertyBlock = evt.newValue != HLSLDeclaration.Global;
537+
if ((evt.newValue == HLSLDeclaration.Global) ^ (evt.previousValue == HLSLDeclaration.Global))
538+
{
539+
this._exposedFieldChangedCallback(evt.newValue != HLSLDeclaration.Global);
540+
property.generatePropertyBlock = evt.newValue != HLSLDeclaration.Global;
541+
}
533542
this._postChangeValueCallback(true, ModificationScope.Graph);
534543
});
535544

@@ -561,7 +570,7 @@ void BuildPrecisionField(PropertySheet propertySheet, AbstractShaderProperty pro
561570

562571
void HandleVector1ShaderProperty(PropertySheet propertySheet, Vector1ShaderProperty vector1ShaderProperty)
563572
{
564-
var floatType = isCurrentPropertyGlobal ? FloatType.Default : vector1ShaderProperty.floatType;
573+
var floatType = (isSubGraph || isCurrentPropertyGlobal) ? FloatType.Default : vector1ShaderProperty.floatType;
565574
// Handle vector 1 mode parameters
566575
switch (floatType)
567576
{
@@ -1461,6 +1470,8 @@ void KeywordAddCallbacks()
14611470

14621471
if (EditorGUI.EndChangeCheck())
14631472
{
1473+
this._preChangeValueCallback("Edit Enum Keyword Entry");
1474+
14641475
displayName = GetSanitizedDisplayName(displayName);
14651476
referenceName = GetSanitizedReferenceName(displayName.ToUpper());
14661477
var duplicateIndex = FindDuplicateKeywordReferenceNameIndex(entry.id, referenceName);
@@ -1581,6 +1592,7 @@ void KeywordRemoveEntry(ReorderableList list)
15811592

15821593
void KeywordReorderEntries(ReorderableList list)
15831594
{
1595+
this._preChangeValueCallback("Reorder Keyword Entry");
15841596
this._postChangeValueCallback(true);
15851597
}
15861598

@@ -1640,7 +1652,6 @@ void BuildDropdownFields(PropertySheet propertySheet, ShaderInput shaderInput)
16401652
return;
16411653

16421654
BuildDropdownField(propertySheet, dropdown);
1643-
BuildExposedField(propertySheet);
16441655
}
16451656

16461657
void BuildDropdownField(PropertySheet propertySheet, ShaderDropdown dropdown)

0 commit comments

Comments
 (0)