Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

External MonoBehaviours within single assembly (unity 2017

Discussion in 'Scripting' started by rrdu, Oct 19, 2017.

  1. rrdu

    rrdu

    Joined:
    Jul 21, 2017
    Posts:
    5
    I've got an assembly that contains two mono behaviours, however, it would appear that unity doesn't support more than one per assembly? When I try and attach the behaviour to a game object unity complains it can't find the script object?

    However, if i rename the assembly to the name of one of the scripts it works.

    Regards,
    Ron.
     
  2. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    This is the only way that I build MonoBehaviours and, I assure you, you can have more than one.

    Do you expand the assembly and drag the individual MonoBehaviour definitions out of it onto your GameObject?

    Maybe post a .zip with a few of the behavior definitions in it or your .csproj or something?
     
  3. rrdu

    rrdu

    Joined:
    Jul 21, 2017
    Posts:
    5
    Yep I see the individual scripts when the assembly is expanded, but once i drag'n'drop unity complains. I'll put together a simple example

    Thanks,
    Ron.
     
  4. rrdu

    rrdu

    Joined:
    Jul 21, 2017
    Posts:
    5
    This is my unity test project the assembly simply has two empty mono behaviours B1 & B2. If you attempt to drag the script to the cube you'll get an error. The project is using .net 4.6

    Regards,
    Ron.
     

    Attached Files:

  5. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    When I open up that .dll in the object browser, I don't even see B2. I also can't browse dependencies.

    Something weird is going on, here.

    Are you using Visual Studio 2017 to build this? If so, can you check to make sure it's set to the right build target (one of the Unity build targets).
     
  6. rrdu

    rrdu

    Joined:
    Jul 21, 2017
    Posts:
    5
    Hmm appears that the problem was .... Select Platforms for plugins had Exclude Platforms Editor selected. Not sure why it would give such a vague error. I will go through the steps again to ensure that this is in fact the root cause of the original error. Thanks for your help.