Forum rules - please read before posting.

Help! Destroying assets is not permitted to avoid data loss.

Running AC ver. 1.57 and Unity 5.6.0f3. I'm attempting to add prefabs from my project folder using "object add/remove - add" and then destroy them using "object add/remove - remove." I get the following error:

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

I found some old threads where it mentioned that changing line 118 of ActionInstantiate.cs would fix the problem, but the solution longer seems to work. 

Note: the add/remove operation works fine in the Editor (it adds and removes the prefabs without issue), but when I build the error stops the prefabs from being added and removed.

Any suggestions? I'm on a tight deadline and this error is going to make or break my project.    

Comments

  • edited June 2017
    Welcome to the community, @rechni.

    The problem here is that it is trying to delete the asset itself - rather than the scene instance of the object.

    Please post the error in full as it appears in the Console window - script line numbers included - as well as images showing the Actions involved.

    Are you trying to add multiple instances of the same prefab into the scene and destroy it one-by-one, or all at once?  The more detail you can provide, the more quickly a solution can be found for you.

    If you are on too tight a deadline, a quick-fix might be to keep the prefab(s) in the scene file and simply show/hide them using Object: Teleport instead.
  • edited June 2017
    Thanks for your quick response, Chris. So here's the issue: I'm using an embedded browser asset to embed multiple browsers in my game. Each needs to be instantiated at different hotspot locations and then destroyed when the user click on an exit button, otherwise the content from one browser will continue to play when another browser is opened (sort of like adding tabs in a browser window). I made each browser a separate prefab, gave all of them constant ID's, and put them in a Resources folder. 

    I've since been able to remove the error in the console and the build (the error did not have any script line numbers associated with it, btw) by first checking for the presence of the browser and then, if it's found, removing it if from the scene. The issue I'm running into now is that, even though the game object is supposedly being "removed" from the scene (and the browsers do disappear when I click the exit button), I can still hear the audio playing, which must mean that the instantiated prefab isn't really being destroyed, right? This ONLY happens in the build. In the editor, everything works as expected and both the browser and its accompanying audio are removed from the scene. 

    I wish I could use Object:Teleport, but the content of some of the browsers plays automatically when the pages load, and having multiple browsers running in the scene makes everything run really slowly. 

    I'm not sure what kind of screenshots would be helpful, but I'm attaching a link to the action list that I'm calling when the user clicks on the exit button (the action list is too long to post). Please let me know if there's anything else I can provide that would be valuable to know.

    Thanks again, Chris. I really appreciate your help. This game is for incoming university students, so I'm trying to get it out to them well before they arrive on campus.  
  • Alright, so I might have narrowed it down a bit. Built the game for Windows and don't have this problem. When I build for Mac x86_64, the issue persists. Any thoughts?
  • edited June 2017
    Raw asset files can't import succesfully, I'm afraid - particularly ActionLists that affect objects that are not included.  If the asset is too long to post as a screenshot, I would suggest breaking it into smaller chunks so that you can isolate which Actions are actually causing the problem - then you can post the ones that need to be looked at.

    How is sound coming from the browser?  Is it on a child of the browser object?  It may be that only the parent is being destroyed, but that's only guesswork.

    What happens when testing in the Editor on a Mac?  AC doesn't have any platform-dependent code between a PC and a Mac, so as unhelpful as it may sound it could well be an issue with Unity itself rather than AC - in which case you should try the latest release of Unity 5.6.2.  If things are fine in the Editor but not in builds, having the Editor on the Mac would at least allow you to run it with the debugger / Profiler active at the same time so you can see what's going on.

    It may also be that destroying browsers is more complicated than simply calling DestroyImmediate like the Object: Add or remove Action does - you should contact the author of that asset to find out if there are special considerations to take.

    If need be, you could include a custom Action that removes the browser in the "proper" way.  Custom Actions can be made to work with Constant IDs (see the tutorial chain), but I would recommend starting with a test scene that has a specific browser you want to destroy and only continue from there once it's confirmed to work.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.