Search Unity

Bugs that only appear when I "build & run"?

Discussion in 'Scripting' started by Jejkobb, Aug 16, 2017.

  1. Jejkobb

    Jejkobb

    Joined:
    Aug 10, 2017
    Posts:
    19
    So I have this dialogue system. This is what the script looks like:



    The dialogues are stored in .asset files, this is what they look like in the project folders:



    This is what it looks like when I edit the dialogue:



    In the interactables in my game I just drag the dialogue and handle them inside the script, this is what it looks like in the inspector:



    Everything runs perfectly when I just run it inside of unity, but when I do "build & run" this happens:



    If you know what this problem is and how to fix it please respond. If you need more information from my project I'll be sure to reply with it. THANK YOU!!!
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    The Script None bit in the Inspector certainly is odd and is the source of your issue.

    First thing to try - I believe MonoBehaviours and ScriptableObjects need to be in their own files and the filename has to match the class name.
     
    Jejkobb and LiterallyJeff like this.
  3. Jejkobb

    Jejkobb

    Joined:
    Aug 10, 2017
    Posts:
    19
    "MonoBehaviours and ScriptableObjects need to be in their own files and the filename has to match the class name."

    I don't quite understand what you mean there, is it not supposed to be ".asset" files? I wrapped the script in a ScriptableObject now, this is what it looks like:

    https://i.gyazo.com/d33e2601010221ba529ae107af019b01.png
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Make a file called Dialogue.cs and put your Dialogue scriptableobject in it with nothing else.
     
  5. Jejkobb

    Jejkobb

    Joined:
    Aug 10, 2017
    Posts:
    19
    YES!! I got it working now! Thank you so much for the help.