Hello Guest

Author Topic: Keep sprite, created dynamically from loaded texture, between scene  (Read 4304 times)

samix

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Hey Team,
I'm trying to keep sprite, created dynamically from loaded texture, between scene.

1. If I use tk2dSprite.CreateFromTexture to create the gameObject, and set it to DontDestroyOnLoad. My object is in the next scene, but the Variable Sprite in Tk2DSprite is empty.

2. I also try to keep the texture, it works, but the game slowdown when I use tk2dSprite.CreateFromTexture again.

Please let me know if you have an idea.

Thanks!
Sam

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Keep sprite, created dynamically from loaded texture, between scene
« Reply #1 on: February 23, 2016, 09:34:40 pm »
Hi there,

You need to set the sprite gameObject to DontDestroyOnLoad, and also the sprite.collection.gameObject to Don'tDestroyOnLoad. That should solve the issue you're having. If you look in the editor you'll see tk2d creates a gameobejct for the spritecollection.