- Home /
Deleting objects
Please, help me because I am loosing my mind! I am told I have a memory leak leading to a Fatal Error in Flash. I try now to localize this by removing, one by one, the objects of my scene. I delete them in the Hierarchy menu and save it as a new scene. I then compile it as Flash and ... the objects are still there! I even tried it as Unity Web Player and they are still there! They are gone in the Editor, but still there once compiled.
... did I miss something?
what language are you writing in? this is VERY bizarre, as I understand it both C# and javascript are garbage collection languages. That makes a memory leak all but impossible.
I write JavaScript but ... the the memory leak, I can try to debug. What I don't understand is, when I delete objects from the Hierarchy menu (but not from the Project one) then run the Editor, those objects are gone. But when I compile the scene as a Flash or Unity Web Player, ... they are still there! It makes debugging by eli$$anonymous$$ation impossible! I don't understand!
Did you save the scene after removing them all? As a side note, it is not Javascript or C# which use garbage collection, it is the .Net framework. C# or Js are just languages using the whole runtime thing from .NET. But this is all secondary:).
Yes, I saved it. I started Unity3D, I saved a new scene called, Test, then I started deleting objects from the Hierarchy menu then I started it in the Editor, just to make sure I didn't delete scripts that exchanged data, and with no scripting error message, I went on to compile as a Flash object to test it as I have a Flash debugger on I$$anonymous$$ To my surprised, those objects (actually, two ships sailing at sea) were still there, although not when I animated in the Editor. I then saved again, left Unity3D (I have both Unity3D Pro and Flash Pro) and even restarted my computer! I am 65 years old and although new to Unity, I have programmed since 1979 and I have seen many strange things! Anyway, starting again, compiling for Flash, again, noticing that the file, with a new name, has the same size as the old file, I tried and still, it compiles with everything in the Assets folder, even though they are not in the Hierarchy menu and not visible in the Editor.
Answer by sparkzbarca · Mar 29, 2013 at 01:22 PM
well anything in the Resources folder is compiled into the project.
I mean if it's in your project folder it's part of the compilation you need to go into windows explorer actually and create a new temporary folder higher up so it's outside of the unity project folder all together then move assets into that slowly.
Does it? ... I am flabbergasted! Isn't the idea that you have a project with multiple scenes? Are all the objects in the project embedded in all the scenes then? It doesn't make sense. In any case, why have those objects disappeared when I watch it in the Editor yet, they come back when compiled as a Flash object? Is it made to confuse on purpose?
Of course, I can make a duplicate of the entire project folder in Windows, then remove entirely those objects but then ... it creates a lot of unnecessary folders and take much memory space. Why can't we just activate or deactivate an object, a property or a script by simply deselect it in the Hierarchy window?
http://answers.unity3d.com/questions/57909/find-unused-assets-in-project.html maybe you should look there
Resources is a sepcial folder. Check out Resources on the unity docs. Essentially the purpose of Resources is to allow for dynamic stuff. If you want to apply a shader to an object, but that object doesnt yet exist, and that object isn't even like a prefab your going to spawn later but is in fact an object not yet created. perhaps your going to weld prefabs together Borderlands style or something but basically at some point your going to create a completely new GameObject on the fly that doesn't currently exist, but you would like to do stuff to it that does exist. That's why Resources exists. You can grab scripts and textures and all that good stuff out of it to apply later to stuff that doesn't yet exist.
That's why it can end up lurking in a scene it's not in. It's not loaded into RA$$anonymous$$ but it's waiting for you to pull bits of into the scene or push bits of the scene out to it.
@sparkzbarca: I am sorry but I don't find any "Resources" folder in my Unity3D project. Could you detail?
@fafase: I did the test from that link: found the Editor.log file and read that, indeed, it includes the objects and scripts that I see in the compiled file, but that are no longer existing in the scene, as view from the Hierarchy window. The are still there in the Project window / folder because contrary to the other poster who simply wants a "clean-up" I know exactly what all the files in my project do and I want only to toggle on and off, in order to debug for memory leak. But from what I read from the link you gave me, what I experience should not happen: A scene that doesn't contain an object, should not display it. It doesn't make sense!
I can assure you that when I press the Play button in the Editor, those objects don't show and yet, when compiled as Flash, they are there! It's insane!
Answer by Michel Verheughe · Mar 31, 2013 at 02:28 PM
Sorry everyone! I found my mistake: I deleted objects, etc. then saved the scene under another name. Then I used "Build and Run" to test it as a Flash file ... but when you do that, you still have the previous scene as the selected one to build! And that is why I saw two different things: what the Editor shows and what the Flash build shows!
A silly error but ... I knew something was wrong and it must be my error! ;-)
Cheers,
Michel
Your answer