Missing script after build, but no referenced gameobject in scene.

Hi all!

I have been building a VR thingy… :slight_smile: I was using the Playway Water system for it. The project actually doesn’t even need water in it, but I used it just because it looks so darn nice.

After I tested to build the project, it gave me some weird shader errors (related to the playway water) in the output log. And because the water is not necessary, I decided to delete the plugin and check if it builds correctly without it.

Now I get this error in the output_log after it crashes on start:

(Filename: Line: 381)
The referenced script on this Behaviour (Game Object ‘PlayWay Water Spectrum Sampler’) is missing!
(Filename: Line: 1754)
Crash!!!

It says that a script is missing from a gameobject called ‘PlayWay Water Spectrum Sampler’. (…right?)
It just happens to be that there is no such gameobject in the scene/project… I don’t think there even has been…?

I already posted a question to the assets own forum, but I’m starting to think this might be something that’s not directly related to the water system.

If anyone has some ideas, or this has happened to someone, I could surely use some help…

2017.1.0bxxx Referenced Script on this Behaviour Missing. But its not visible to remove.

Short Term : I’m a pro user from Unity version 5 and I work the latest possible 2017 version that has enabled the dark pro skin. Later versions than 2017.1.0b10 doesn’t except the pro U5 registration and show the light UI.

However. If a component was deleted, or the class was renamed during any reason (by script or manually or outside of Unity) and you go into play mode and stop. Then you get the Referenced Script on this Behaviour Missing info. BUT the inspector didn’t show the missing component on the GameObject. So your not able to remove the component! The warning stays for ever, or you have to delete the GameObject. There are some wiki scripts in this case of this issue, but they all don’t work, because it’s not possible to remove a component by script it’s already null.

I found a solution to make the component on the game object visible, and the curiosity is, unity show a shadow reference for this missing component for one time at the GameObject. Means, if the scripts does not exist any more in unity, you can see what scripts it was and it’s properties too. I tried this several times with new projects an it works always in 2017.1xx.

Make a backup of your project to be assured nothing goes wrong.

How to:
Save this script in an Editor folder. Read the steps exactly and follow them.

[100277-untitled-1.png*|100277]

using UnityEngine;
using UnityEditor;
public class FindMissingScriptsRecursively : EditorWindow {
	static int go_count = 0, components_count = 0, missing_count = 0;

	[MenuItem("Window/FindMissingScriptsRecursively")]
	public static void ShowWindow() {
		EditorWindow.GetWindow(typeof(FindMissingScriptsRecursively));
	}

	public void OnGUI() {

		GUILayout.Label("1) Select ALL GameObject in the Hierarchy.");
		GUILayout.Label("2) Click Button [Find Missing Scripts...]");
		
		if (GUILayout.Button("Find Missing Scripts in selected GameObjects")) {
			FindInSelected();
		}
		GUILayout.Label("3) Read the result in Console.");
		GUILayout.Label("4) Open this script with Mono or VS.");
		GUILayout.Label("5) Select the GameObject where missing scripts occur.");
		GUILayout.Label("6) Edit and Undo any line in FindMissingScriptsRecursively script and save the script");
		GUILayout.Label("7) Click back onto the Unity Editor and let recompile the FindMissingScriptsRecursively script.");
		GUILayout.Label("8) Now the missing component on the gameobject is now visible for deteltion.");
		GUILayout.Label("9) Repeat this procedure for each missing script/component.");

	}
	private static void FindInSelected() {
		GameObject[] go = Selection.gameObjects;
		go_count = 0;
		components_count = 0;
		missing_count = 0;
		foreach (GameObject g in go) {
			FindInGO(g);
		}
		Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
	}

	private static void FindInGO(GameObject g) {
		go_count++;
		Component[] components = g.GetComponents<Component>();
		for (int i = 0; i < components.Length; i++) {
			components_count++;
			if (components *== 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);*
    
  •  }*
    
  • }*
    }

Haven’t the playway water asset, but now found all game objects having missed and invisible components. Finding all assets are hidden in the scene without selecting should b possible too.
@Quatum1000