From 95661eb0329123a41d0d46e0296e778b921ec70c Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:18:42 -0700 Subject: [PATCH] fix getting shader values in hscript --- source/funkin/backend/shaders/FunkinShader.hx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source/funkin/backend/shaders/FunkinShader.hx b/source/funkin/backend/shaders/FunkinShader.hx index 5a63d804..ef91d128 100644 --- a/source/funkin/backend/shaders/FunkinShader.hx +++ b/source/funkin/backend/shaders/FunkinShader.hx @@ -370,15 +370,18 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour { var field = Reflect.field(data, name); var cl = Type.getClassName(Type.getClass(field)); - // cant do "field is ShaderInput" for some reason - if (cl.startsWith("openfl.display.ShaderParameter")) { - var sp = cast(field, ShaderParameter); - @:privateAccess - return (sp.__length > 1) ? sp.value : sp.value[0]; - } else if (cl.startsWith("openfl.display.ShaderInput")) { - var si = cast(field, ShaderInput); - return si.input; - } + // little problem we are facing boys... + + // cant do "field is ShaderInput" because ShaderInput has the @:generic metadata + // aka instead of ShaderInput it gets built as ShaderInput_Float + // this should be fine tho because we check the class, and the fields dont vary based on the type + + // thanks for looking in the code cne fans :D!! -lunar + + if (cl.startsWith("openfl.display.ShaderParameter")) + return (field.__length > 1) ? field.value : field.value[0]; + else if (cl.startsWith("openfl.display.ShaderInput")) + return field.input; return field; }