Skip to content

File tree

2 files changed

+29
-1
lines changed
  • Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL
  • Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests

2 files changed

+29
-1
lines changed

Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/CustomHLSL.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private void ParseCodeIfNeeded()
324324
m_Properties = new List<VFXPropertyWithValue>();
325325
foreach (var input in m_Function.inputs)
326326
{
327-
if (input.type != null && input.type != typeof(VFXAttribute) && input.access is HLSLAccess.IN)
327+
if (input.type != null && input.type != typeof(VFXAttribute) && input.access is HLSLAccess.IN or HLSLAccess.NONE)
328328
{
329329
m_Properties.Add(CreateProperty(input));
330330
}

Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/CustomHLSLBlockTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,34 @@ public IEnumerator Check_CustomHLSL_Block_VFXAttributes_Wrong_Access_Modifier()
456456
Assert.AreEqual("Missing `inout` access modifier before the VFXAttributes type.\nNeeded because your code writes to at least one attribute.", report.description);
457457
}
458458

459+
[UnityTest]
460+
public IEnumerator Check_CustomHLSL_Block_VFXAttributes_Without_Access_Modifier()
461+
{
462+
// Arrange
463+
var hlslCode =
464+
"void TestFunction(inout VFXAttributes attributes, float param)\n" +
465+
"{\n" +
466+
" attributes.position = float3(param, param, param);\n" +
467+
"}";
468+
var hlslBlock = ScriptableObject.CreateInstance<CustomHLSL>();
469+
hlslBlock.SetSettingValue("m_HLSLCode", hlslCode);
470+
471+
MakeSimpleGraphWithCustomHLSL(hlslBlock, out var view, out var graph);
472+
yield return null;
473+
474+
// Act
475+
graph.errorManager.GenerateErrors();
476+
477+
// Assert
478+
var report = graph.errorManager.errorReporter.GetDirtyModelErrors(hlslBlock);
479+
Assert.IsFalse(report.Any());
480+
481+
//Check input slot contents
482+
Assert.AreEqual(1, hlslBlock.inputSlots.Count);
483+
Assert.AreEqual("param", hlslBlock.inputSlots[0].name);
484+
Assert.AreEqual(VFXValueType.Float, hlslBlock.inputSlots[0].valueType);
485+
}
486+
459487
[Test]
460488
public void Check_CustomHLSL_Block_Includes()
461489
{

0 commit comments

Comments
 (0)