2
votes

In unity3d i declared

var ribbon : GameObject;

In start function i have used code

Destroy (ribbon.gameObject, 5); 

which shows error "Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate (theObject, true);"

how can i destroy this gameobject?

Thanks in advance

2
hmm... have you tried DestroyImmediate?John Dvorak
@ Jan Dvorak: In game code it is recommended to use Object.Destroy instead.Sona Rijesh

2 Answers

2
votes

Try this

Destroy(gameObject.Find("ribbon"), 5);
1
votes

You could Just do Destroy(ribbon,5); if you have assigned the ribbon gameobject already ribbon is already a gameobject no need to do ribbon.gameObject