Keep a long story short, ive suddenly gotten a bunch of these errors in unity when coding my game (The numbers keep going up)
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection)
Its my first template of a much larger project, but none of my objects' scripts reference anything to do with UIElements... just UI for setting the text of an ammo counter
You guys got any ideas? it doesnt affect my gameplay or my scripts it just is annoying in the console, and it happens when im not in game too. I think the amount of errors has maxed out at 35, in the time of writing this
Thanks! :D
You can try to delete the project's caching folder "library", this will make Unity reimport all your assets and generate new copies of intermediate DLLs.
Warning: It will take a long time to reimport all assets if your project is big.
Related
I keep getting this error when switching to my game scene from my death scene, and I can't find a definitive answer online. It showed up after I added my volume controls, and I have no clue how to fix it because that path (Packages/com.unity.collab-proxy/Lib/Editor/PlasticSCM/lz4x64Plastic.dl) is not in the package manager (I'm pretty sure). I can still play when it happens, but the volume resets. I have never seen that file before, and haven't imported any new plugins since then. Any ideas?
I'm working on a system that automatically generate and release scriptable object that represent uniqueness for gameobject with a given component attach.
The generation process seems to be working really fine, but I'm facing problem when I want to release the scriptable object.
The given script is tagged "ExecuteInEditMode" and is implementating OnDestroy method to advertise a manager that his scriptable object should be deleted.
The problem is that OnDestroy is called in 4 situation from what i can tell :
Click on play
Switching scene
Manual removal (the only one I want to work with)
On editor shutdown
I've been able to avoid the 2 first on with this :
if (Application.isPlaying == false && Math.Abs(Time.timeSinceLevelLoad) > 0.00001f)
But I don't find any good solution for "On editor shutdown" I've seen that EditorApplication.quitting can be use for that case, but documentation warn that this event is not called when unity crash or is forced to quit, and I don't want to lose all my scriptable object if the editor crash.
I'm looking for a robust solution to avoid this problem if someone can help me please.
Thanks, have a nice day
Just handle the application quitting event.
this event is not called when unity crash or is forced to quit, and I don't want to lose all my scriptable object if the editor crash.
When unity crashes, so will your program, so it won't work any ways. Just make sure that under normal operating procedure (so a normal shutdown) you save your modifications.
In Unity3D if you edit your scene and you don't save, if the editor crashes you lose all your changes. The same will happen for what you're building here. In order to mitigate this risk (since prevention is reasonably difficult if not impossible) you can opt to save every minute, always save each change to a temporary location, or save for example every play.
For example i added a script to my project that autosaves the scene(s) whenever i press play, so when editing the scene i press play now and then to test, and it all gets autosaved.
Using Unity 5.4.2.
I've created an editor script that implements an exporter for some prefab data when you press an export button. It recursively finds all the prefab files matching a certain type under its own directory and loads those prefabs so they can be exported in a custom manner.
The problem I'm having is that the prefabs on disk, that are loaded with
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(file);
do not match the current state in the editor. That is if you have modified some of the prefab data in the editor, it is not actually saved to disk. Note that this does not require any objects to be added to a scene, I am just exporting data directly out of components attached to prefabs.
I have tried adding AssetDatabase.SaveAssets(); to the top of my export function, which is supposed to save all the assets, but when I edit a value and then log the values loaded from the prefabs, they are not up to date. There are two (non-programatic) methods I have found so far that cause my exporter to be able to see the modified data:
If I exit Unity and restart it, the prefabs appear to get saved at that point and the exporter sees the updated data.
If I play and stop any scene, then export, the exporter can see the updated data, but oddly (according to git status) they have not been written to disk, so I suspect LoadAssetAtPath actually loads some cached version which is updated on 'play'.
Is there a way to force Unity to save everything to disk so that my exporter can operate on the most up to date values?
The following should do the trick
// Your changes go here
AssetDatabase.Save();
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); // perhaps even ForceSynchronousImport?
// You loading should go here
For more information about ImportAssetOptions see this documentation https://docs.unity3d.com/ScriptReference/ImportAssetOptions.html
Note: This does not answer the original question, but identifying and working around the cause may help anyone with the same/similar problem.
My problem was when exporting computed-and-cached properties in components attached to the prefabs. My assumption that LoadAssetAtPath would load a fresh instance from disk was wrong, it returns the version already in editor memory, which means cached values aren't invalidated like they would be with a fresh load.
The solution I used was to never cache when running in the editor, using #ifdef UNITY_EDITOR.
Unity won't let me select objects on my scene without first selecting the object in the Hierarchy. This was all I could find on the issue.
However, it seems that they decided that closing and opening the scene window fixed the bug, but not so with me. Also note that I am on a blank project. Its been really difficult to work around this bug.
Edit:
I have even uninstalled Unity and reinstalled with the hopes that this would solve the problem, but unfortunately it did not. Thanks for any help ahead of time.
Honestly this is such an odd problem that I'm having difficulty knowing how to try and fix the problem. I also reported the bug as recommended below by NoƫlWidmer, but even the staff who was very kind had no idea how to deal with the problem, and the advice he gave also didn't change a thing. Truly, I don't even know what more information I can give you guys because as I said I literally opened a new Unity project for the first time after reinstalling and was unable to select without first clicking on the hierarchy. Is this just a special freak case that landed with me or has this happened to anyone else?? Also I'm using a two year old Windows 8 Laptop with literally nothing installed on it but the Adobe suite and a few other game developer necessities, so my computer most likely is not the source of the problem.
Edit: a Clue??
Well I was messing around with the scene and hierarchy view in full screen, and I noticed something interesting after clicking on the object in the hierarchy and moving the object in the scene view:
Unfortunately my PrintScreen doesnt show the actual mouse, but as you can see the scene view acts as though I'm clicking on the object, but here at the same time I saw my real mouse off down to the right! Also while I've selected an object on the scene editor and I move my mouse off the scene window things get a bit off and the mouse will pop up on other sides of the window and so on. I don't know if that's normal and its that way for everyone or if it's just me and it might help figure out what's going on.
Man I've really been liking Unity but if this keeps up I think I'll have to drop it and find another software, because I certainly will never be able to design anything worth while if I have to select the object on the hierarchy every time for every single object.
Some bug for me on Mac platform. I resolve just entering and exit from fullscreen mode.
Probably may also work change layout with top-right combo.
I had similar issue while using older versions of unity (in addition inspector window lost the focus repeatedly). In my case rearraging editor windows and saving custom window layout solved it. As far as I remember, I just moved scene view outside Unity window (on the second screen) as well as hierarchy view, and saved resulting position as a new window layout.
Not sure if there is anything else I can tell about it, it's pretty mysterious problem.
I'm overwhelmed with joy right now!! The problem was indeed a bug. I was working on a project and moving objects around (still using the hierarchy to select objects) and then a split second later for absolutely no reason Unity decided to start working the way it should've!!! I guess its just one of those issues where you just have to cross your fingers and hope it'll resolve itself. I'm so glad this dumb issue resolved itself because I was about to tear my hair out and succumb to using another computer for my unity design, or even worse another software. Thank you to everyone who helped!
Last night I finished up on unity and saved my project and scene before closing unity.
This morning when I loaded up unity My Hierarchy, scene and game view are all empty, I don't even have a main camera. This has happened before so I closed off unity (Without Saving or anything) and opened it through the scene file, to my surprise again it does not work, Thinking it must have just not loaded the scene again I tried loading the scene in unity, again no result, now I've spent the last 2 hours browsing the internet trying to find the solution to the problem.
A few common answers I've seen for this problem that do not work for me:
Unity is not opening a new scene, it says at the top it is currently in the scene I want.
Pressing F does not fix anything since there is nothing in the hierarchy in the first place.
Also:
The project is saved in DropBox.
All the assets say they were last updated when I last saved and closed Unity.
Any help is greatly appreciated.
From my experience, Unity and Dropbox don't really get along, as one may lock files the other one wants to read/write, and that means sometimes files not saved properly.
If you want to share projects or just have an online backup, prefer other tools that don't scan the folder all the time, like Git.
open run prompt (windows+R)
%AppData% --> "Roaming" folder will open.
Search for Unity and delete this folder.
Go up one folder up (AppData) and do the same to Local/Unity and LocalLow/Unity