- Home /
unload an object? C#
Hi again,
I'm loading an object using:
Instantiate(Resources.Load("star", typeof(GameObject)));
How can i unload it when the animation is finished?
Thanks guys :)
Have you read the Documentation for Resources? http://docs.unity3d.com/ScriptReference/Resources.UnloadAsset.html
Answer by malekbakeer · Dec 01, 2014 at 11:25 AM
First go to Edit > Project Settings > Tags And Layers and add a tag named star then select your star in the assets and click on tags and tag it with "star" tag then add the following to your script
void Update ()
{
if ("Change this with your if animation finished bool")
{
GameObject.Destroy(GameObject.FindGameObjectWithTag("star"));
}
}
Answer by FlashX · Dec 02, 2014 at 02:04 AM
Thanks Malebakeer!
So I'm kinda noonish at this stuff, what would be the syntax to check if the animation has finished?
Thank you so much for your help!! :)
Cheers
Your answer
Follow this Question
Related Questions
Load FBX from Script 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
What is the proper way to wait for an Animator Controller to update? 1 Answer