fix getting shader values in hscript

This commit is contained in:
lunarcleint
2024-03-21 20:18:42 -07:00
parent 8681fc503e
commit 95661eb032
+12 -9
View File
@@ -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<Dynamic>);
@:privateAccess
return (sp.__length > 1) ? sp.value : sp.value[0];
} else if (cl.startsWith("openfl.display.ShaderInput")) {
var si = cast(field, ShaderInput<Dynamic>);
return si.input;
}
// little problem we are facing boys...
// cant do "field is ShaderInput" because ShaderInput has the @:generic metadata
// aka instead of ShaderInput<Float> 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;
}