ModelStitching
ModelStitching copied to clipboard
Stitcher.Stitch Can only be called once per frame
If I execute:
if (Input.GetKeyDown(KeyCode.G))
{
GameObject equippedPants = (GameObject)GameObject.Instantiate(Pants);
wornPants = stitcher.Stitch(equippedPants, Avatar);
GameObject equippedShoes = (GameObject)GameObject.Instantiate(Shoes);
wornShoes = stitcher.Stitch(equippedShoes, Avatar);
}
only the pants are equipped. However, If I separate it to:
if (Input.GetKeyDown(KeyCode.G))
{
GameObject equippedPants = (GameObject)GameObject.Instantiate(Pants);
wornPants = stitcher.Stitch(equippedPants, Avatar);
}
if (Input.GetKeyDown(KeyCode.H))
{
GameObject equippedShoes = (GameObject)GameObject.Instantiate(Shoes);
wornShoes = stitcher.Stitch(equippedShoes, Avatar);
}
It works as expected.
I'm assuming this has to do with the Avatar not being "updated" until the end of the current frame cycle. This may be simply Unity's limitations and not much you can do about it within your code specifically.
Regardless, this script has been TREMENDOUSLY helpful and thank you very much for it.
I'm having the same issue, I'll try to call the Stitch function on different frames. And thanks for this script! Really helps me a lot.
Is there any solution to this issue?
My assumption is that @FoleyX90 is correct. Perhaps creating some sort of coroutine that does all the stitching (doing a wait for update or late update) in between each one is the solution.