Skip to content

Commit a288cc2

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.0] [ShaderGraph]properties bugfixes
1 parent 0a73b76 commit a288cc2

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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",
@@ -529,8 +535,11 @@ void BuildHLSLDeclarationOverrideFields(PropertySheet propertySheet, AbstractSha
529535
property.hlslDeclarationOverride = evt.newValue;
530536
property.overrideHLSLDeclaration = true;
531537
UpdateEnableState();
532-
this._exposedFieldChangedCallback(evt.newValue != HLSLDeclaration.Global);
533-
property.generatePropertyBlock = evt.newValue != HLSLDeclaration.Global;
538+
if ((evt.newValue == HLSLDeclaration.Global) ^ (evt.previousValue == HLSLDeclaration.Global))
539+
{
540+
this._exposedFieldChangedCallback(evt.newValue != HLSLDeclaration.Global);
541+
property.generatePropertyBlock = evt.newValue != HLSLDeclaration.Global;
542+
}
534543
this._postChangeValueCallback(true, ModificationScope.Graph);
535544
});
536545

@@ -562,7 +571,7 @@ void BuildPrecisionField(PropertySheet propertySheet, AbstractShaderProperty pro
562571

563572
void HandleVector1ShaderProperty(PropertySheet propertySheet, Vector1ShaderProperty vector1ShaderProperty)
564573
{
565-
var floatType = isCurrentPropertyGlobal ? FloatType.Default : vector1ShaderProperty.floatType;
574+
var floatType = (isSubGraph || isCurrentPropertyGlobal) ? FloatType.Default : vector1ShaderProperty.floatType;
566575
// Handle vector 1 mode parameters
567576
switch (floatType)
568577
{
@@ -1440,6 +1449,8 @@ void KeywordAddCallbacks()
14401449

14411450
if (EditorGUI.EndChangeCheck())
14421451
{
1452+
this._preChangeValueCallback("Edit Enum Keyword Entry");
1453+
14431454
displayName = GetSanitizedDisplayName(displayName);
14441455
referenceName = GetSanitizedReferenceName(displayName.ToUpper());
14451456
var duplicateIndex = FindDuplicateKeywordReferenceNameIndex(entry.id, referenceName);
@@ -1560,6 +1571,7 @@ void KeywordRemoveEntry(ReorderableList list)
15601571

15611572
void KeywordReorderEntries(ReorderableList list)
15621573
{
1574+
this._preChangeValueCallback("Reorder Keyword Entry");
15631575
this._postChangeValueCallback(true);
15641576
}
15651577

@@ -1619,7 +1631,6 @@ void BuildDropdownFields(PropertySheet propertySheet, ShaderInput shaderInput)
16191631
return;
16201632

16211633
BuildDropdownField(propertySheet, dropdown);
1622-
BuildExposedField(propertySheet);
16231634
}
16241635

16251636
void BuildDropdownField(PropertySheet propertySheet, ShaderDropdown dropdown)

0 commit comments

Comments
 (0)