Search Unity

The referenced script on this Behaviour is missing!

Discussion in 'Editor & General Support' started by moritz-abeln, Jan 31, 2015.

  1. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    Hello guys!

    So, after countless hours of searching on the internet, i thought, maybe someone can figure this out.

    I'm getting this really weird error in the output_log.txt everytime i try to play the build of the game i'm working on. The game is playable in the Editor and the error only shows up when i play the build version. Here's a quick example of what my output_log looks like:

    [...]
    <RI> Initializing input.

    <RI> Input initialized.

    The referenced script on this Behaviour is missing!
    (Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Mono/MonoBehaviour.cpp Line: 1638)

    A script behaviour has a different serialization layout when loading. (Read 24 bytes but expected 28 bytes)
    Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
    (Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Serialize/SerializedFile.cpp Line: 1170)

    [...] repeating

    When i start the game, the powered by Unity logo shows up and after that the screen just stays black and the game freezes.

    I already tried to make a debug scene, to reproduce the error and i came to the conclusion that i have a gameobject (called "wolf") with a child attached (called "head"). The wolf has all the basic animations (walking, idle, ...) and the head is basically just one of it's special abilities, so there is one animation on that gameobject. Now, when i build the scene with both gameobjects, the above mentioned error occurs. If i delete the "head" child of the "wolf" gameobject, i can play the build without having problems.

    What i also noticed is that the error shows forward slashes while every other file/directory is called with normal backward slashes.

    Some other things to notice:
    • The Unity version i'm working with is version 4.6.0f3
    • Build target is windows
    • Scripts are written in C#
    • I checked every single object in the scene, there is no single missing script
    I'm gladly appreciating any help, if you have a guess or even a solution, let me know!

    Best,
    Moritz
     
  2. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    You wouldn't happen to be instantiating a prefab at runtime that has a broken script reference would you? You said you checked every object in the scene, did you do this at runtime?
     
  3. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    Yes i did that already. Not a single broken script...
     
  4. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    I just re-read your post, it seems like it's angry about deserializing an object. Do you explicitly load anything yourself? This is a random hunch, but you could take off the serializable attributes of your properties, run it, and then put them back on. This smells of a unity bug.
     
  5. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    Well, I'm kind of new to Unity (i've been using it for like 2 months), but i don't think i'm explicitly loading anything anywhere... How do i take off the attributes though?
     
  6. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    Do you have any lines like this in your scripts:
    Code (CSharp):
    1. [System.Serializable]
     
  7. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    I also found this post:
    Some more digging also said it could get angry if you have serialized classes/properties that reference non-serialized classes/properties. I've honestly never used that attribute and get by just fine.
     
  8. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    I don't have the [System.Serializable] anywhere, but i'll try the first option from the post you mentioned. I guess i'll have to re-add every script to the proper object after renaming my scripts folder, right?
    Or is this not related when i don't have a script with the serialize property in it?
     
  9. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    Bump, because the project needs to be finished on wednesday and this is kind of urgent...Any ideas? The error is still the same.
     
  10. moritz-abeln

    moritz-abeln

    Joined:
    Jan 31, 2015
    Posts:
    6
    Someone? Anyone?
     
  11. LeoZzc

    LeoZzc

    Joined:
    Apr 22, 2015
    Posts:
    1
    rename your script ,and rename it back ,and try again