Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Feb 12, 2013 at 04:31 AM by sona.viswam for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by sona.viswam · Dec 19, 2012 at 07:52 AM · monodevelopjava

Destroy a gameobject in start function

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

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Alec Thilenius · Dec 19, 2012 at 08:03 AM 0
Share

Can you please be more specific? What is ribbon? How / when is it assigned? Did you attach this script to a prefab, and assign a GameObject there?

avatar image sona.viswam · Dec 19, 2012 at 08:10 AM 0
Share

@Alec Thileniu: Didnt attach anyscript to a prefab. Its just a gameobject, a plane attached a material

avatar image Alec Thilenius · Dec 19, 2012 at 08:12 AM 0
Share

What did you assign ribbon to be? Your trying to destroy the game object this script is attached to right? Try: Destroy(gameObject, 5);

avatar image sona.viswam · Dec 19, 2012 at 08:14 AM 0
Share

@Alec Thileniu: so many gameobjects i declared. i have 2 destroy a specific one

avatar image Alec Thilenius · Dec 19, 2012 at 08:19 AM 0
Share

Ok lets back up a little bit. This script is attached to a game object in the scene correct? And what are you trying to accomplish (Overall, not just with that specific line of code). I do not understand what you mean by you want to destroy a specific one. How do you chose witch one to destroy?

Show more comments

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by EtherIT · Dec 19, 2012 at 07:52 PM

Try this

 Destroy(gameObject.Find("ribbon"), 3);    

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sona.viswam · Feb 11, 2013 at 07:47 AM 0
Share

Thank you...

avatar image
0

Answer by PushpaK · Dec 21, 2012 at 12:57 AM

I think you cant destroy any object in start function. Start functions works mostly as constructor. You have to delete object in another function such as update.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sona.viswam · Dec 21, 2012 at 03:43 AM 0
Share

Destroy(gameObject.Find("ribbon"), 3); works in start function

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change a string into integer 2 Answers

Mid point of a object 1 Answer

What's my unity version? 1 Answer

Problem with getkey/getkeydown 1 Answer

Unity3D removing project references in MonoDevelop 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges