UnityEngine.UI.Graphic.OnRebuildRequested errors
Does anyone knows what this means?
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UI.Graphic.OnRebuildRequested () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:399)
UnityEngine.UI.GraphicRebuildTracker.OnRebuildRequested () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/GraphicRebuildTracker.cs:33)
UnityEngine.CanvasRenderer.RequestRefresh () (at C:/buildslave/unity/build/artifacts/generated/common/modules/CanvasRendererBindings.gen.cs:244)
It appears on Play and on saving scene.
i am getting the same error. Rebooted machine, rebooted Unity, but still it won't go away
I am experiencing the same issue after upgrading to 5.2.1
Answer by Rajeesh_AR · Sep 30, 2015 at 06:16 AM
Hi, I also had that same issue. I found that a class having one name and its file having other name. eg if " abcdefg " is the name of the class, and its file name was " uvwxyz ". I changed the class name as the file name. Then the error was cleared. Please check that.
All the best
It took me a while to track down, but yes, this was indeed the issue. Thanks!
Looks like you are right. Error disappeared after I removed an old unused script. Thanks!
any help for how to find that error? In my case I have so many scripts.
This is unreal. How can Unity expect someone to fix this issue in a big project?
Note that this error can also happen if you have a missing script somewhere in your canvas tree. See isidro02139's answer.
Answer by isidro02139 · Nov 05, 2015 at 03:44 PM
Solved -- indeed there was a missing script! fwiw this is how I find missing scripts in my project:
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
// from: http://wiki.unity3d.com/index.php?title=FindMissingScripts
public class FindMissingScriptsRecursively : EditorWindow
{
static int go_count = 0, components_count = 0, missing_count = 0;
[MenuItem("Window/Find Missing Scripts (All)")]
static void FindInAll()
{
go_count = 0;
components_count = 0;
missing_count = 0;
foreach (var root in SceneRoots())
{
//Debug.Log(root);
FindInGO(root);
}
Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
}
static void FindInGO(GameObject g)
{
go_count++;
Component[] components = g.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
components_count++;
if (components[i] == null)
{
missing_count++;
string s = g.name;
Transform t = g.transform;
while (t.parent != null)
{
s = t.parent.name +"/"+s;
t = t.parent;
}
Debug.Log (s + " has an empty script attached in position: " + i, g);
}
}
// Now recurse through each child GO (if there are any):
foreach (Transform childT in g.transform)
{
//Debug.Log("Searching " + childT.name + " " );
FindInGO(childT.gameObject);
}
}
static IEnumerable<GameObject> SceneRoots()
{
var prop = new HierarchyProperty(HierarchyType.GameObjects);
var expanded = new int[0];
while (prop.Next(expanded)) {
yield return prop.pptrValue as GameObject;
}
}
}
This is the correct solution for me. Just save it to Assets/Editor/Find$$anonymous$$issingScripts.cs, (remove those pesky line numbers...)
Go to WINDOW and select Find $$anonymous$$issing Scripts (All)
Found 1 missing scrip from a button. Thanks!
Searched 592 GameObjects, 1706 components, found 0 missing UnityEngine.Debug:Log(Object) Find$$anonymous$$issingScriptsRecursively:FindInAll() (at Assets/Editor/Find$$anonymous$$issingScripts.cs.cs:21)
I'm still getting the error even after running that script and having it return 0 missing scripts. Any ideas?
I tried using this script and I am getting hundreds of false positives.
STATIC OBJECTS/Water4Example (Advanced)/Tile has an empty script attached in position: 4
UnityEngine.Debug:Log(Object, Object)
Yet I will go and check this object and its components, and the 4th component is there with a proper script reference.
If this is a case with the numbering beginning with 0, it should be noted that there is no 5th component, just the shader which is also correctly configured.
Any thoughts on what could be causing this issue?
Answer by Philon · Oct 23, 2015 at 08:08 PM
I have removed a script from the project, but still one game object referenced to it. After removing the reference to missing script in objects inspector the problem dissapeared.
Check all your prefabs and game object in inspector for missing scripts in components.
Same solution here.
For anyone else having this problem: If you recently deleted a script from your project folder make sure you double check that no gameobjects are still referencing it.
Answer by altaf_navalur · Dec 01, 2015 at 08:22 AM
For me it was a missing script that was causing this exception.
Answer by johnpine · Dec 17, 2015 at 09:59 AM
are you on WebPlayer platform ? because at least on my computer on that platform all Unity UI elements causes this error. don't even have to click Play. just by using unity keeps flooding this error in console.