Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Kantenstain · Apr 29, 2011 at 08:18 PM · errorbehaviourmissing-reference

The referenced script on this Behaviour is missing!

var health1 : Texture2D; //one lives left var health2 : Texture2D; //two lives left var health3 : Texture2D; //full health

static var LIVES = 3;

function Update () { switch(LIVES) { case 3: guiTexture.texture = health3; break;

     case 2:
         guiTexture.texture = health2;
     break;

     case 1:
         guiTexture.texture = health1;
     break;

     case 0:
         //gameover script here
     break;
 }

}


var speed = 3.0; var rotateSpeed = 3.0; var bullitPrefab: Transform; private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = true; //substract life here HealthControl.LIVES -=1; } }

function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") rotateSpeed, 0); var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed);

 if(Input.GetButtonDown("Jump"))
 {
     var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
     bullit.rigidbody.AddForce(transform.forward * 2000);
 }

}

function LateUpdate() { if(dead) { transform.position = Vector3(0,4,0); gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10); dead = false; } }

@script RequireComponent(CharacterController)

After I made this scripts, I get the "The referenced script on this Behaviour is missing! " Warning...

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LKIM · Apr 29, 2011 at 08:26 PM 0
Share

Is the script actually connected to a game object? Sometimes unity seems to lose the connections.

4 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Bunny83 · Apr 29, 2011 at 09:17 PM

I don't think that this have anything to do with the content of this script. This error occurs when you have a script attached to a gameobject and you deleted, moved or renamed it outside of unity. Unity can't find the related script for the MonoBehaviour component.

If you want to rename or move a script do it always in Unity. To solve your error, just find the component that references this missing script and drag the right script onto the component.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Bovine · Sep 14, 2011 at 10:30 AM

I had this issue recently. For me the message appears when I run the game and it will only highlight the GameObject with the missing script if it is in the current scene.

I was able to load different scenes after running it and I was able to find the offending GameObjects.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Apr 17, 2013 at 05:17 PM 0
Share

For anyone caught out by this. pause the game play when the warning appears. highlight the warning in your console. look in your hierarchy - Unity does highlight the problem item in the hierarchy once you click on the warning in the console. you'll then see the script is simply missing. As Bov says it has to be the current scene, so pause the game is scenes are changing quickly.

avatar image ShinyTaco · Jul 31, 2013 at 01:30 AM 0
Share

Thanks. I've tried pausing and highlighting the error, but it does not work for me. Any other ideas?

avatar image Loius · Jul 31, 2013 at 02:22 AM 0
Share

It is caused by a missing behaviour. Clicking the error while the object is alive is the only way to find it besides manually checking everything. Are you dynamically destroying objects? It might only exist for long enough to throw the error. Enable the 'Pause on error' option in the console window (control+shift+C) and the game should stop before the object disappers. If not, you'll have to check your instantiable objects and see which one is missing a script.

avatar image
0

Answer by Tekksin · Mar 05, 2015 at 12:38 PM

If you're having trouble finding where the error is coming from (sometimes unity doesn't highlight it, especially in cases where the gameobject is turned off), what works best for me is duplicating the scene where the error appears, and deleting chunks of the duplicated scene, until I get down to the last few gameobjects (run the scene each time you delete something to see if the warning goes away. If it does, then undo and delete other game gameobjects while inspecting the apparent culprit(s)). Once I find the problem, I just remove the component from that game object, save the prefab, and delete the duplicated scene.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image risingsunshine · Apr 07, 2016 at 10:33 PM 0
Share

This is a bit complex. The easier way is using this plugin.

avatar image javiercampos · May 24, 2017 at 10:41 AM 0
Share

I did that. I have an empty scene and I still have the warning haha. No idea what is going on

avatar image
0

Answer by PFC-Ben-W · Jan 02, 2020 at 01:58 PM

In case you get this error, while preloading the next szene with the AsyncOperation : If you have in the preloaded Szene any Objects or components, that are missing, the present scene will print out all the errors of your next preloaded szene. So in that case, it would be better, to check your next szene, otherwise you will never get clear on that.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Refenced script on this behavior is missing? 17 Answers

Easy explosion script 1 Answer

The referenced script on this Behaviour is missing! 0 Answers

The referenced script on this Behaviour is missing! please help me 1 Answer

Error: Reference on this Behavior is Missing. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges