Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug after 2021.3.27 Sprite Swap not work in same frame as Instantiate

Discussion in 'Animation' started by Gordon_G, Jul 11, 2023.

  1. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    358
    Hey, after upgrading from 2021.3.16 to 2021.3.27f1, the SpriteSwap method no longer works in the same frame as our avatar multiplayer instantiation code. And it fails silently. We have to wait for one or more frames after our instantiation to get SpriteSwap to work.

    Code (CSharp):
    1. GameObject newAvatarGO = (GameObject) PhotonNetwork.Instantiate(  avatarPrefab );
    2. SpriteResolver sr = newAvatarGO.GetComponent<SpriteResolver>();
    3. sr.SetCategoryAndLabel( "shoes", "hiking_boots" );
    does not swap sprites. If I put the last 2 lines in a coroutine and wait 1 or more frames, it works.

    What could be going on there?
     
    Last edited: Jul 11, 2023