Closed reveriejake closed 1 year ago
I tried to play it safe with defines. Let me know if this is not necessary. Not sure how universal [flatten] and [unroll()] are.
Does unity have any defines that can be checked to enable this?
I've tried a few of the Unity defines but they didn't seem to get recognized. I didn't see any HLSL specific directives that would work either. I could be wrong, I will keep an eye out for that.
If these [flatten] and [unroll()] tags solve Unity specific errors, it might make more sense to rename ENABLE_FLATTEN to UNITY_ENGINE or something.
Were you having the issue outside of Unity?
I haven't tested it outside of Unity, but I can try Unreal either tonight or sometime this weekend to see if it suffers a similar issue.
I'm not too worried about testing other compilers, I think everyone who reported the issue has been using Unity. I just thought from your wording that you weren't using Unity.
According to this: https://docs.unity3d.com/Manual/SL-PragmaDirectives.html
UNITY_VERSION
is defined
Hmm, I must have overlooked the UNITY_VERSION define on that page, I did a quick skim. I just tried it out and this one seems to have worked.
Instead of the current defines could you change it to this:
#define FNL_FLATTEN [flatten]
#define FNL_UNROLL [unroll(1)]
and define them as empty when not on Unity, assuming empty defines are allowed on HLSL?
I think that would be a bit cleaner and easier to read
Yep I was just working on that. Here is what I put instead.
#if UNITY_VERSION
#define FNL_FLATTEN [flatten]
#define FNL_UNROLL [unroll(1)]
#else
#define FNL_FLATTEN
#define FNL_UNROLL
#endif
Leaving the #else off causes issues in Unity when not included. So not sure if that is an issue, so I included the #else.
(Having a terrible time with this 'code' thing here haha
All changes have been pushed
Thanks!
Fixes errors which appear when loading in state data through variables.
Works on my end. Please double check before accepting pull request.
Original solution provided by: https://github.com/Akeyn