Script Unknown on Gameobject null missing...

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Script Unknown on Gameobject null missing...

Post by HawkX »

New subject for a new weird error... and while i REALLY STRONGLY doubt it is related to pixelcrusher or the dialoguesystem, in the trace of the error, it shows 1 of your scripts! :P

I think this started happening when i deleted an old prefab that we were no longer using...

The referenced script (Unknown) on this Behaviour is missing!
UnityEngine.StackTraceUtility:ExtractStackTrace ()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:HandlePlayModeStateChanged () (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:203)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:OnPlayModeStateChanged (UnityEditor.PlayModeStateChange) (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:191)
UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)

and

The referenced script on this Behaviour (Game Object '<null>') is missing!
UnityEngine.StackTraceUtility:ExtractStackTrace ()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:HandlePlayModeStateChanged () (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:203)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:OnPlayModeStateChanged (UnityEditor.PlayModeStateChange) (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:191)
UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)


When i double click on either of those, i get to : private void HandlePlayModeStateChanged()
in the file DialogueEditorWindowMain.cs

I have searched in my scene and in every prefab I could think of to see if there was any "missing" script, or invalid link but was not able to find any...

Considering your insanely vast knowledge, what would you suggest? :)
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script Unknown on Gameobject null missing...

Post by Tony Li »

When you enter and exit play mode while the Dialogue Editor window is open, the Dialogue Editor window calls UnityEditor.AssetDatabase.SaveAssets() to tell Unity to flush asset changes to disk. If the open scene has any missing scripts, Unity will report this error.

The editor script in this video should help you identify which GameObjects have missing scripts:

User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Script Unknown on Gameobject null missing...

Post by HawkX »

Again, thank you so much for coming to the rescue!

However, I am following the video, double checking that I got everything right...

NullReferenceException: Object reference not set to an instance of an object
FindMissing.FindMissingScriptInProject () (at Assets/Scripts/EditorOnly/FindMissingScript_Editor/FindMissing.cs:25)

which refers to "this line"

foreach(Component component in prefab.GetComponentsInChildren<Component>())

I re-checked a bunch of time and couldnt find any typos from the video to what I had written...

Here is my whole script just in case (its often something stupid which make it so frustrating) :

Code: Select all

[MenuItem("Tools/Find Missing Scripts Tony")]
    static void FindMissingScriptInProject()
    {
        string[] prefabPaths = AssetDatabase.GetAllAssetPaths().Where(path => path.EndsWith(".prefab", System.StringComparison.OrdinalIgnoreCase)).ToArray();

        foreach (string path in prefabPaths)
        {
            GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);

            foreach(Component component in prefab.GetComponentsInChildren<Component>())
            {
                if (component == null)
                {
                    Debug.Log("Prefab found with missing script " + path, prefab);
                    break;
                }
            }
        }
    }
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script Unknown on Gameobject null missing...

Post by Tony Li »

Try adding this code before that line:

Code: Select all

if (prefab == null) 
{
    Debug.Log("Can't load prefab at: " + path);
    continue;
}
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Script Unknown on Gameobject null missing...

Post by HawkX »

THANK you again so freakin much!! :)

What would I do without your help...

As suspsected it had NOTHING to do at all with Dialogue system (as you said it was just being reported by its editor)

Probably a batch of shaders that someone from my team cleaned up last week...
all 4 of them are :Can't load prefab at: Assets/Particles/Cartoon FX/CFX4 Prefabs (Mobile)/.... (etc) .prefab
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script Unknown on Gameobject null missing...

Post by Tony Li »

Glad to help!
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Script Unknown on Gameobject null missing...

Post by HawkX »

While the scripts/video you suggested DID find 8 broken prefabs that I was able to replace/fix fully...

I am still getting these 2 errors whenever I press "play" in my scene...
(i think it might be because of previously deleted prefabs and/or scripts)... but if they are completely deleted and no longer referenced by anything, they just shouldnt even be mentionned...
Again, I know its a Unity issue at this point and only being called out by your system but you might have some valid suggestion or insight on how to solve this :)

Code: Select all

The referenced script (Unknown) on this Behaviour is missing!
UnityEngine.StackTraceUtility:ExtractStackTrace ()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:HandlePlayModeStateChanged () (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:203)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:OnPlayModeStateChanged (UnityEditor.PlayModeStateChange) (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:191)
UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)

Code: Select all

The referenced script on this Behaviour (Game Object '<null>') is missing!
UnityEngine.StackTraceUtility:ExtractStackTrace ()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:HandlePlayModeStateChanged () (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:203)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:OnPlayModeStateChanged (UnityEditor.PlayModeStateChange) (at Assets/Scripts/EditorOnly/PixelCrusher/DialogueSystem/Scripts/Editor/Dialogue Editor/DialogueEditorWindowMain.cs:191)
UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script Unknown on Gameobject null missing...

Post by Tony Li »

No, sorry, I can't think of anything except brute force -- make a copy of your entire project. Open the copy, delete about half of the content, and enter play mode. If the error is gone, you know the issue is in the half you deleted. If the issue is still present, it's in the content that you kept.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Script Unknown on Gameobject null missing...

Post by HawkX »

hahahaha i love it! :)

Alright then i guess i'll start doing that when i got some free time!
Post Reply