- Home /
Refenced script on this behavior is missing?
I am getting this error twice every time I start my game. It isn't a red error that prevents you from starting, it's grey and doesn't do anything when I click on it. I don't know why it keeps appearing, but my script is not working how I thought it would. It was supposed to draw gui textures (which is working fine) but on the first OnGUI if statement, the rotation is not working how I thought. It is only moving up and down (more diagonally than straight) as I turn my character. The error is:
The refenced script on this Behavior is missing!
I have no idea why this is happening, or why my script is only moving the texture diagonally instead of rotating it around its center like I wanted. For reference purposes, here is my script:
var camera1 : Camera; var camera2 : Camera; var camera3 : Camera; var openButton : Texture2D; var closeButton : Texture2D; var mapMarker : Texture2D; var compass : Texture2D; var mapSkin : GUISkin; var characterTransform : Transform; var screenPos : Vector3; var playerDirection : float; var pivotPoint = Vector2(66.5,386.5);
function Update () { if (camera2.enabled) { screenPos = camera.WorldToScreenPoint (characterTransform.position); } }
function OnGUI() { GUI.skin = mapSkin; if (camera1.enabled) { playerDirection = characterTransform.transform.rotation.y; GUIUtility.RotateAroundPivot(playerDirection,pivotPoint);
GUI.DrawTexture(Rect(1145,3,290,290),compass); GUI.DrawTexture(Rect(1275,133,30,30),mapMarker); if (GUI.Button(new Rect(1115,270,50,50),openButton)) { camera1.enabled = false; camera2.enabled = true; camera3.enabled = false; } } if (camera2.enabled) { GUI.DrawTexture(Rect(screenPos.x - 12,730 - screenPos.y,20,20),mapMarker); if (GUI.Button(new Rect(1250,100,100,100),closeButton)) { camera1.enabled = true; camera2.enabled = false; camera3.enabled = true; } } }
function Start () { camera2.enabled = false; }
@qwertyqaz: And...? Didn't one of the answers (esp. the accepted) solve your problem? This question was answered over a year ago. This comment doesn't help much...
I just had this problem too but none of the solutions posted here worked.
The problem I faced was that the missing scripts were not visible in the inspector yet they were still somehow attached to the gameobject. What I did was I created a prefab of the broken gameobject, clicked on the prefab and now the empty scripts appeared as components in the inspector. I then deleted all the broken components, removed the original gameobject from the scene and then dragged the prefab back into the scene.
Hopefully this will help someone in the future.
I packed using my colleagues way and It's the method from unity3.6, so I did not know what setting that I may missed, so cause this problem, any one know about the assetbundle?
Answer by Steffen Franz · Jan 22, 2011 at 12:00 AM
like it says : one (or more) of your gameobjects in the scene is (are) missing an attached script. Look through your gameobjects in the scene and look for any script that reads None (Mono Script) where the script should be. Delete those or attached the correct script and you get rid of that error message. If you click the error message once it should highlight the gamobject in question in the Hierarchy if I'm not mistaken.
Sometimes, you can have weird stuff. For instance, with AngryAnts path finding, I sometimes have nodes disappearing, but not destroyed. Once the AngryAnt scripts were deleted, I had that error but the objects didn't show up in the hierarchy. This helped me find the issue.
You can use this helper editor script to find all missing references in your project, saves us a ton of time: http://www.tallior.com/fixing-missing-references/
Answer by unfox · Oct 26, 2012 at 12:09 PM
In my case it was not a game object in the Hierarchy, but its prefab in the Project.
The game object on the scene was ok and contained no attached scripts. Its prefab, however, did contain the script which I had recently deleted.
I found this mistake only by deleting objects one by one in the scene, then checking the log for 'referenced script' warning.
Hope this helps.
Pretty much same thing here... i had a prefab that had what I needed on it and never hit "Apply" to get it to update the prefabs that were getting instantiated.
Answer by milali · Feb 06, 2012 at 05:54 AM
I fixed this by selecting all (CTRL-A) in the heirachy view and copy then delete.
then click in the scene view and CTRL-A and delete.
then paste (CTRL-V) and all was fixed
Sure enough, this seems to have allowed me to select a ghost object in the scene called 'BreadCrumbs' and delete it. Printed the following message, but it worked!
"Cleaning up leaked objects in scene since no game object, component or manager is referencing them. $$anonymous$$onoScript has been leaked 1 times."
Fixed! I've been reading answers telling me the problem must be to do with deleted scripts, yet I haven't removed anything! Thank you so much
Answer by Nomibuilder · Dec 18, 2014 at 07:55 AM
Make a prefab of that gameObject which has missing script. And then click on the prefab. You will find them. Remove those missing scripts and apply that prefab in Heirarchy and remove the previous One. This is how I got rid of this problem
Answer by sathyaalias · Jul 21, 2015 at 11:42 AM
In one case, I had created a script with a misspelled name (Ex: PLayerCtrl - with a uppercase L) and the C# Class is named such. I corrected the script name within the editor to 'PlayerCtrl', the file name had changed, but still the Class name was the old 'PLayerCtrl'.
Naturally fixing the class name fixed this error. Hope this will help someone. Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613100517im_/https://answers.unity.com/themes/thub/images/avi.jpg)