ModelStitching icon indicating copy to clipboard operation
ModelStitching copied to clipboard

Stitcher.Stitch Can only be called once per frame

Open FoleyX90 opened this issue 6 years ago • 5 comments

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.

FoleyX90 avatar Oct 25 '18 08:10 FoleyX90

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.

FoleyX90 avatar Oct 25 '18 08:10 FoleyX90

Regardless, this script has been TREMENDOUSLY helpful and thank you very much for it.

FoleyX90 avatar Oct 25 '18 08:10 FoleyX90

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.

brunodcastilho avatar May 04 '20 15:05 brunodcastilho

Is there any solution to this issue?

darkfriend77 avatar May 16 '21 22:05 darkfriend77

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.

masterprompt avatar May 17 '21 13:05 masterprompt