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
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.
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.