I’ve got my head in a bit of a bender at the moment. I’ve been putting together a function to do a bit of validation of lightmap UVs before exporting, but the Out Parameters (pointers?) aren’t behaving at all the way I’d expect them to.
Basically, the following code snippet works fine when evaluated as is, either in the script editor or in the listener window.
I get the expected values printed out in the listener console.
Stick that code block between parentheses, however (be that a simple block, or in a function), and I consistently get the following values returned:
1e+030
1e+030
-2e+030
-2e+030
0.0
0.0
0.0
For kicks, I’ve tried declaring x, y, width, etc prior to the function, inside the function prior to the getArea() call, but still get the same results.
I can’t for the life of me figure out why this is, and I haven’t been able to find any help via google. Anybody know why this might be happening? Am I missing something?
Yeah, that seems to be the case on my end as well, cheers for finding that. Well, not being able to reset the UVWs makes it less than useful for the purpose I’d envisioned :\ Still finding it completely bizarre that it works perfectly well outside a codeblock (with the reset).
In addition to the more obvious function of essentially reverting your UVs, Reset also is the only way of actually accessing different UV channels.
Basically, if you switch map channels (whether in script or via the UI), the only way you’re actually going to be able to access that channel’s UVs is by Resetting.
So I’d sorta shelved this for a bit, then as I was looking at an unrelated thread on polycount, I found some good info that the UnwrapUVW modifier has a bit of trouble actually refreshing itself sometimes while in a script, and that
forcecompleteredraw dodisabled:true
might help.
So I went ahead and stuck that right after
uv.unwrap.reset()
and I received the correct return info. Looks like I can get that lightmap unwrap validator done up for the environment asset exporter after all