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
0
Question by 3dMaia · Apr 19, 2013 at 12:13 AM · missingbehaviour

What's the cause of "The referenced script on this Behaviour is missing!" in my script?

Hi people! I'm having a problem with my script and i tried everything to end the warning message but I couldn't find what's the cause. I have these two scripts in my scene:

 using UnityEngine;
 using System.Collections;
 
 public class CharacterAssets : MonoBehaviour {
     
     public GameObject[] characterMesh;
     
     void Awake ()
     {
         DontDestroyOnLoad(this);
     }
     
     // Use this for initialization
     void Start () 
     {
     
     }
     
     // Update is called once per frame
     void Update () 
     {
     
     }
 }
 

and...

 using UnityEngine;
 using System.Collections;
 
 public class Customize : MonoBehaviour {
     
     private int characterMeshIndex = 0;
     private string charMeshName = "Warrior";
     private CharacterAssets scriptCA;
     
     // Use this for initialization
     void Start () 
     {
         scriptCA = GameObject.Find("CharacterAssetManager").GetComponent<CharacterAssets>();
         InstantiateCharacterMesh();
     }
     
     
     void OnGUI()
     {
         ChangeCharacterMesh();
     }
     
 
     void InstantiateCharacterMesh() 
     {
         switch(characterMeshIndex)
         {
         case 1:
             charMeshName = "Hunter";
             break;
         case 2:
             charMeshName = "Rogue";
             break;
         default:
             characterMeshIndex = 0;
             charMeshName = "Warrior";
             break;
         }
         if(transform.childCount>0)
         {
             for(int cnt=0 ; cnt < transform.childCount ; cnt++)
             {
                 Destroy(transform.GetChild(cnt).gameObject);
             }
         }
                 
         GameObject mesh = Instantiate(scriptCA.characterMesh[characterMeshIndex], transform.position, Quaternion.identity)as GameObject;
         mesh.transform.parent = transform;
         mesh.transform.rotation = transform.rotation;
     }
     
     
     
     void ChangeCharacterMesh()
     {
         if(GUI.Button(new Rect( Screen.width/2-60 , Screen.height-40 , 120 , 30),charMeshName))
         {
             characterMeshIndex++;
             InstantiateCharacterMesh();
         }
     }
         
         
 }
 



so... the problem is a warning that appears every time that i call the function "InstantiateCharacterMesh" on the second script.

The warning says: The referenced script on this Behaviour is missing! UnityEngine.Object:Instantiate(Object, Vector3, Quaternion) Customize:InstantiateCharacterMesh() (at Assets/Scripts/Customize.cs:47) Customize:Start() (at Assets/Scripts/Customize.cs:14)

The game run and works ok but this warning message is pissing me of! If i simply comment the lines 47,48 and 49, the error disappears(but the code become incomplete i don't do the most important thing that is the instantiate).

Comment
Add comment · Show 2
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 whebert · Apr 19, 2013 at 12:43 AM 1
Share

Are you populating the GameObject array in CharacterAssets via the Editor? Sounds like at least one of those objects has lost a reference to an attached script. You should be able to view each in the Inspector and fix any missing scripts that way if so.

avatar image 3dMaia · Apr 19, 2013 at 07:08 PM 0
Share

Thanks man, the error was exactly in the prefabs that I used to put in this array! Each of these objects had a script component (monobehaviour) with a message of missing script. I deleted this component on these objects and the message of warning is gone, thanks man!

1 Reply

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

Answer by iwaldrop · Apr 19, 2013 at 01:42 AM

Indeed, this error doesn't come from script, but rather because there is a component on a game object that doesn't know what script it is supposed to use. You probably renamed a script from outside of Unity or something...

Usually you can double-click that error message and it'll take you to the GameObject in question. Hopefully you can remember whats supposed to go there.

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 3dMaia · Apr 19, 2013 at 07:10 PM 0
Share

thanks for the answer, in one of the objects that I used in the array had a missing script!

avatar image iwaldrop · Apr 20, 2013 at 12:57 AM 0
Share

Could you mark this as answered, please?

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

13 People are following this question.

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

Related Questions

Reference script on Behaviour is Missing, but IT'S NOT MISSING 0 Answers

The referenced script on this Behaviour is missing! 0 Answers

Missing Behaviours still process as if they exist? 0 Answers

Free Camera 2 Answers

Spawned units disappear 2 Answers


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