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 /
avatar image
0
Question by markfm · Jan 15, 2013 at 05:40 PM · prefabdestroy

Cannot Destroy Instanitaed prefab.

Gents,

This is mind boggling to me, for whatever reason ( maybe a bug) I cannot destroy an instantiated object after being transferred from one GameObject Variable to Another.

 void OnCreateHolder()
 {            
 
 if (Holder != null)
             {
             if (Holder2 != null)
                 {
                     Destroy(Holder2.gameObject);
                 }
             Holder2 = Holder.gameObject;
             }


Holder is an instantiated Object that if I try and destroy does not give me the error message. However I am assigning Holder to Holder2 without or without using the .gameobject tag it gives me the following error:

Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate (theObject, true); UnityEngine.Object:Destroy(Object)

Please help, thank you.

Comment
Add comment · Show 5
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 markfm · Jan 15, 2013 at 05:51 PM 0
Share

Also please note that it does actually delete it, even though the error pops up. However in IOS, it just stops working..

avatar image markfm · Jan 15, 2013 at 09:08 PM 0
Share

Any ideas anyone?

avatar image greatestprez · Jan 15, 2013 at 09:42 PM 0
Share

Can you post the entire script?

avatar image markfm · Jan 15, 2013 at 09:49 PM 0
Share

Hi,

The script is around 500 lines long.. however i finally found the problem, i had assigned a gameobject to holder first time round, therefore it was transferring it and then trying to destroy the prefab.

Thanks anyway.

avatar image Bunny83 · Jan 15, 2013 at 10:36 PM 0
Share

Not the whole script but when you talk about some strange variables where we have no idea what type they have we can't say much about that.

Next thing is that you don't try to destroy the instantiated object. You try to destroy the asset, the source object. That's why it would help to see where and how the reference in Holder and Holder2 are set. The variable name doesn't give any hint what's in it.

Program$$anonymous$$g is a kind of communication, mainly with a PC / compiler. The compiler can interpret what you've written but it can never understand what it does. The compiler don't care about variable names, but humans do.

I'm getting tired of those "maybe a bug" annotations. The most common source of errors is **B$$anonymous$$AC ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Jan 15, 2013 at 10:36 PM

If you really want to remove an asset use DestroyImmediate (theObject, true);

Destroy does not let go the object until after the frame

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Clone of rigid body prefab destruction if at certain position 3 Answers

Create a prefab at same position where its destroyed 3 Answers

How to destroy a game object within an instance of prefab 1 Answer

Instantiated Prefab doesnt destroy 2 Answers

Destroying Instantiated Prefab 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