Hello Guest

Author Topic: About Destorying tk2dAnimatedSprite  (Read 3682 times)

kliqingk

  • Newbie
  • *
  • Posts: 14
    • View Profile
About Destorying tk2dAnimatedSprite
« on: May 23, 2013, 03:30:02 am »
Hey guys:
I have a problem. Please help.
I created a prefab using a tk2dAnimatedSprite. Then I created a instance like this:

tk2dAnimatedSprite temp = Instantiate(prefab, new Vector3(0,0,0), Quaternion.identity) as tk2dAnimatedSprite;
Destory(temp);

But the instance didn't destoryed. It still showed in the Hierarchy View.

I did another test. I created a prefab using a Cube.Then Coding like this:
GameObject temp = Instantiate(cubePrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject ;
Destory(temp);

The cub destoyed. It didn't show in the Hierarchy View.

How did I destoy a tk2dAnimatedSprite instance?
« Last Edit: May 24, 2013, 06:38:26 am by kliqingk »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: About Destorying tk2dAnimatedSprite
« Reply #1 on: May 23, 2013, 10:17:15 am »
You should always destroy the gameobject. This applies to all Unity objects.
so...
Destroy(temp.gameObject); will destroy the game object the sprite is attached to.

kliqingk

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: About Destorying tk2dAnimatedSprite
« Reply #2 on: May 24, 2013, 06:38:16 am »
Thank you for helping me. ;D ;D