Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

[SOLVED] The Referenced Script On This Behaviour Is Missing

Discussion in 'Scripting' started by busterlock, Jan 24, 2016.

  1. busterlock

    busterlock

    Joined:
    Sep 26, 2015
    Posts:
    47
    I have a Game Object where I store a prefab and a script to use on a GUI button. Basically, you click on the button and the script instantiates a clone of the prefab (and another function that destroy such clone). The script works fine but Unity keeps giving me these error messages:


    The referenced script on this Behaviour (Game Object 'Capsule') is missing!
    The referenced script on this Behaviour (Game Object '<null>') is missing!
    The referenced script on this Behaviour (Game Object 'Capsule') is missing!

    Again, the game works and runs perfectly, the script just as much, but these messages are starting to bother me. Here's a sample of my script:

    Code (CSharp):
    1. public class BuildMenu : MonoBehaviour
    2. {
    3.     public GameObject tower;
    4.     public bool towerTrigger;
    5.     public Transform tPosition;
    6.     GameObject towerClone;
    7.  
    8.     void Start()
    9.     {
    10.         towerTrigger = true;
    11.     }
    12.  
    13.     public void TowerSpawn()
    14.     {
    15.         if (towerTrigger)
    16.         {
    17.         towerClone = Instantiate(tower, tPosition.position, tPosition.rotation) as GameObject;
    18.         towerTrigger = false;
    19.         Debug.Log("Tower Created");
    20.         }
    21.     }
    22.     public void TowerDestroy()
    23.     {
    24.         if (!towerTrigger)
    25.         {
    26.             Destroy(GameObject.Find("Capsule(Clone)"));
    27.             Debug.Log("There's already a tower here");
    28.             towerTrigger = true;
    29.         }
    30.     }
    31. }
    The object where the script is stored is being used in the GUI button on the Mouse Down () void.

    SOLUTION = I had created a script and attached it to the prefab but later on erased it, so Unity was telling me that this script (outside from the one posted in the thread) was missing. Noob mistake.
     
    Last edited: Mar 9, 2018
    malexeev likes this.
  2. Jack_Black_1

    Jack_Black_1

    Joined:
    Mar 30, 2017
    Posts:
    1
  3. ryanfry88

    ryanfry88

    Joined:
    Feb 24, 2018
    Posts:
    1
    thanks man i was scratching my head about this all night.
     
    busterlock likes this.
  4. busterlock

    busterlock

    Joined:
    Sep 26, 2015
    Posts:
    47
    Hey, man, the only thing I would think about changing is the GameObject.Find, since everyone around the forum say the function sucks. Maybe use the tag of the collider it is hitting seems like a better strategy? Hope it helps.
     
  5. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    I got a lot of "The referenced script on this Behaviour (Game Object '<null>') is missing!" (note the <null>) warnings and couldn't find it with any "FindMissingReference" script and paid tools from the asset store in the scene or prefabs. Apparently the problem was a corrupt scene file. Solution: Create a new scene, load it into the bogus scene and copy all objects. You should also check the references of the scripts and UI input handling. Some references were lost in copyation and I had to remove and readd the EventSystem o_O.
     
  6. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    268
    Thank you a thousand times over for this! I had just about given up hope. I knew what removed script was causing the issue, and bringing it back removed the warning. I was certain there were no references to it in my project. I stumbled upon this, created a new scene, copied the contents across and sure enough the warnings are gone!
     
    Last edited: Jul 4, 2018
  7. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    I'm glad it helped. However I'm still seeing some warnings every now and then, so it didn't fix it completely.
     
  8. malexeev

    malexeev

    Joined:
    Oct 7, 2016
    Posts:
    1
    Thanks a lot for the update, I know this is a bit late but u saved me so much time I was head over heels trying to figure out whats wrong :p
     
  9. VRDUDEZ

    VRDUDEZ

    Joined:
    Dec 4, 2018
    Posts:
    4
    Hi @all

    I found this post by search a solution for my issue maybe someone can help me i search for months!!! ^^

    Its a livestream problem with my oculus rift into the facebook spaces app, when i go live the stream stops and give me a error text dat

    its look like that

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

    The referenced script on this Behaviour (Game Object '<null>') is missing!

    (Filename: Line: 1744)

    Thanks you so much for helping

    best regards
     
  10. VRDUDEZ

    VRDUDEZ

    Joined:
    Dec 4, 2018
    Posts:
    4
    https://www.mediafire.com/file/igf88ifz22oxhs3/facebook_spaces_crash.rar/file
     
  11. mibragg

    mibragg

    Joined:
    Apr 10, 2015
    Posts:
    1
    Bump. I just experienced this problem and, in my case, it was pretty easy to fix..

    The referenced script on this Behaviour (Game Object 'LineUp') is missing!
    The referenced script on this Behaviour ('Unknown') is missing!
    The referenced script on this Behaviour (Game Object 'LineDown') is missing!
    The referenced script on this Behaviour ('Unknown') is missing!

    I had created two game objects, each to hold a line renderer. I then created a script to work with them and attached it to the each game object.

    I later deleted this script in Visual Studio (not removing it from the LineUp gameobject in the Unity Editor by right clicking and choosing remove component) as the script was just for testing. This caused the problem in the two game objects (each missing the deleted script) and I had the above set of annoying and stressful messages.

    Of course, I made many changes to the project before I noticed the issue. Took me a bit to find this post. Best to stop and fix those issues!

    So, i think the errors were caused by deleting the script in Visual Studio without removing the script component in the Unity Editor first. Down at the bottom of each offending gameobject’s component list, you will see a script is attached with no name, it just says SCRIPT (I.e., no script name)

    The fix for me was to create a new empty game object, copy the linerenderer component from the old one to the new one and then go back and delete the offending old game object. Renamed the new one to the same name as before and the problem was solved.

    Hopefully a similar fix will work for others...

    Good luck
     
  12. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    875
    I don't get this at all! I removed the tools I was using and every script file from the prefabs in the scene and it still gives the error messages pointing me to the prefabs but the prefabs have nothing on them and everything works fine when I hit play.
     
  13. RandomPoint

    RandomPoint

    Joined:
    Jul 21, 2017
    Posts:
    12
    Wouldn't it be great if Unity saved the name of the script that was attached, so when it disappeared you had a chance of figuring out what was there so you could fix it? Apparently this is not enough to jog my memory: upload_2019-4-25_16-17-13.png

    Does anyone have a good suggestion for how to keep track of which script components are attached to which GameObjects? For me, they usually get broken during a Unity upgrade or in a Git merge of YAML files, and when the problem is discovered, I often can't remember what script was attached.