Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

MonoBehaviours and ScriptableObjects are not recognized in 4.6 DLL

Discussion in 'Experimental Scripting Previews' started by LazloBonin, Mar 12, 2018.

  1. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    I'm in the process of compiling a .NET 4.6 version of Bolt, my visual scripting tool.

    I am running Unity 2017.1.0f3, the earliest version supported by my plugin.

    Multiple MonoBehaviours and ScriptableObjects are included in the DLLs I provide.

    In a .NET 3.5 project, everything works fine: they are recognized by Unity, can be created as components and assets, and even have their iconMap property applied. This is "confirmed" by the project window display of the DLL's, which expands to show the recognized classes derived from UnityEngine.Object:



    After compiling all these DLL's with .NET 4.6 as the target platform and importing them in a Unity project with the scripting runtime set to .NET 4.6, I get no error or warning outright, but none of these classes are recognized. Symptoms:
    • The Bolt components cannot be added to game objects
    • All Bolt scriptable objects throw this warning:
      No script asset for [Class Name]. Check that the definition is in a file of the same name.
    • Note that the inspectors for scriptable objects actually work, minus the icon
    • I can actually open the editor windows (via script), but the layouts using them fails to load
    • The iconMap properties do not apply
    • The project window does not show the classes inside the DLLs (screenshot)


    For the record, the GUID's of all these DLL's is manually enforced to be the same across the 3.5 and 4.6 projects, so this is unrelated to the issue.

    This is a major regression issue for me, as Bolt must be compiled via DLL's and many of my users require a .NET 4.6 version because of assembly name ambiguity errors.

    The only error I think I might be making is referencing the wrong version of UnityEngine.dll and UnityEditor.dll when compiling 4.6 DLLs. However, looking at my Unity install, there appears to be only one version of these, located at: [InstallPath]\Editor\Data\Managed

    For reference, here is one of my .csproj files for MSBuild:

    Code (Xml):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    3.   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
    4.   <!-- Project -->
    5.   <PropertyGroup>
    6.     <ProjectGuid>{0FE89C0A-B748-486B-AEDC-1AADB2D1FC31}</ProjectGuid>
    7.     <RootNamespace>Bolt</RootNamespace>
    8.     <AssemblyName>Bolt.Core.Runtime</AssemblyName>
    9.     <DefineConstants>GUID_c8d0ad23af520fe46aabe2b1fecf6462;TARGET_INCLUDE_ALL;TARGET_BACKEND_IL2CPP</DefineConstants>
    10.   </PropertyGroup>
    11.   <!-- Shared -->
    12.   <PropertyGroup>
    13.     <Platform>AnyCPU</Platform>
    14.     <PlatformTarget>AnyCPU</PlatformTarget>
    15.     <OutputType>Library</OutputType>
    16.     <AppDesignerFolder>Properties</AppDesignerFolder>
    17.     <FileAlignment>512</FileAlignment>
    18.     <TargetFrameworkProfile />
    19.     <LangVersion>6</LangVersion>
    20.     <ErrorReport>prompt</ErrorReport>
    21.     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    22.     <DebugSymbols>true</DebugSymbols>
    23.     <DebugType>full</DebugType>
    24.     <NoWarn>1591</NoWarn>
    25.     <Configuration Condition=" '$(Configuration)' == '' ">Debug35</Configuration>
    26.     <Stability Condition=" '$(Configuration)' == 'Debug35' Or '$(Configuration)' == 'Debug46' ">Debug</Stability>
    27.     <Stability Condition=" '$(Configuration)' == 'Release35' Or '$(Configuration)' == 'Release46' ">Release</Stability>
    28.     <TargetFrameworkVersionNumber Condition=" '$(Configuration)' == 'Debug35' Or '$(Configuration)' == 'Release35' ">3.5</TargetFrameworkVersionNumber>
    29.     <TargetFrameworkVersionNumber Condition=" '$(Configuration)' == 'Debug46' Or '$(Configuration)' == 'Release46' ">4.6</TargetFrameworkVersionNumber>
    30.     <OutputPath>bin\$(Stability)\$(TargetFrameworkVersionNumber)</OutputPath>
    31.     <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
    32.   </PropertyGroup>
    33.   <!-- Debug -->
    34.   <PropertyGroup Condition=" '$(Stability)' == 'Debug' ">
    35.     <DefineConstants>$(DefineConstants);DEBUG;TRACE;ENABLE_PROFILER</DefineConstants>
    36.   </PropertyGroup>
    37.   <!-- Release -->
    38.   <PropertyGroup Condition=" '$(Stability)' == 'Release' ">
    39.     <DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
    40.     <Optimize>true</Optimize>
    41.   </PropertyGroup>
    42.   <!-- .NET 3.5 -->
    43.   <PropertyGroup Condition=" '$(TargetFrameworkVersionNumber)' == 3.5 ">
    44.     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    45.     <DefineConstants>$(DefineConstants);NET35</DefineConstants>
    46.   </PropertyGroup>
    47.   <!-- .NET 4.6 -->
    48.   <PropertyGroup Condition=" '$(TargetFrameworkVersionNumber)' == 4.6 ">
    49.     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    50.     <DefineConstants>$(DefineConstants);NET46</DefineConstants>
    51.   </PropertyGroup>
    52.   <!-- References -->
    53.   <ItemGroup>
    54.     <Reference Include="System" />
    55.     <Reference Include="System.Core" />
    56.     <Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    57.       <SpecificVersion>False</SpecificVersion>
    58.       <HintPath>..\..\Unity\UnityEngine.dll</HintPath>
    59.     </Reference>
    60.     <Reference Include="UnityEngine.UI">
    61.       <HintPath>..\..\Unity\UnityEngine.UI.dll</HintPath>
    62.     </Reference>
    63.     <ProjectReference Include="..\..\Ludiq.Core\Runtime\Ludiq.Core.Runtime.csproj">
    64.       <Project>{8bda7b48-d6ea-4762-822f-eca6ea7d4345}</Project>
    65.       <Name>Ludiq.Core.Runtime</Name>
    66.     </ProjectReference>
    67.     <ProjectReference Include="..\..\Ludiq.Graphs\Runtime\Ludiq.Graphs.Runtime.csproj">
    68.       <Project>{aabbe8dc-1b61-4d5b-bf81-7b66aa2566ff}</Project>
    69.       <Name>Ludiq.Graphs.Runtime</Name>
    70.     </ProjectReference>
    71.   </ItemGroup>
    72.   <!-- Sources -->
    73.   <ItemGroup>
    74.     <Compile Include="Events\Framework\Animation\IBoltAnimationEvent.cs" />
    75.     <Compile Include="Events\Framework\Animation\IBoltNamedAnimationEvent.cs" />
    76.     <Compile Include="Events\Framework\Application\IOnApplicationFocus.cs" />
    77.     <Compile Include="Events\Framework\Application\IOnApplicationLostFocus.cs" />
    78.     <Compile Include="Events\Framework\Application\IOnApplicationPause.cs" />
    79.     <Compile Include="Events\Framework\Application\IOnApplicationQuit.cs" />
    80.     <Compile Include="Events\Framework\Application\IOnApplicationResume.cs" />
    81.     <Compile Include="Events\Framework\IBoltUnityEvent.cs" />
    82.     <Compile Include="Events\Framework\ICustomEvent.cs" />
    83.     <Compile Include="Events\Framework\Editor\IOnDrawGizmos.cs" />
    84.     <Compile Include="Events\Framework\Editor\IOnDrawGizmosSelected.cs" />
    85.     <Compile Include="Events\Framework\GUI\IOnButtonClick.cs" />
    86.     <Compile Include="Events\Framework\GUI\IOnDeselect.cs" />
    87.     <Compile Include="Events\Framework\GUI\IOnDropdownValueChanged.cs" />
    88.     <Compile Include="Events\Framework\GUI\IOnGUI.cs" />
    89.     <Compile Include="Events\Framework\GUI\IOnInputFieldEndEdit.cs" />
    90.     <Compile Include="Events\Framework\GUI\IOnInputFieldValueChanged.cs" />
    91.     <Compile Include="Events\Framework\GUI\IOnPointerClick.cs" />
    92.     <Compile Include="Events\Framework\GUI\IOnPointerDown.cs" />
    93.     <Compile Include="Events\Framework\GUI\IOnPointerEnter.cs" />
    94.     <Compile Include="Events\Framework\GUI\IOnPointerExit.cs" />
    95.     <Compile Include="Events\Framework\GUI\IOnPointerUp.cs" />
    96.     <Compile Include="Events\Framework\GUI\IOnScrollbarValueChanged.cs" />
    97.     <Compile Include="Events\Framework\GUI\IOnScrollRectValueChanged.cs" />
    98.     <Compile Include="Events\Framework\GUI\IOnSelect.cs" />
    99.     <Compile Include="Events\Framework\GUI\IOnSliderValueChanged.cs" />
    100.     <Compile Include="Events\Framework\GUI\IOnToggleValueChanged.cs" />
    101.     <Compile Include="Events\Framework\Hierarchy\IOnTransformChildrenChanged.cs" />
    102.     <Compile Include="Events\Framework\Hierarchy\IOnTransformParentChanged.cs" />
    103.     <Compile Include="Events\Framework\Input\IOnButtonInput.cs" />
    104.     <Compile Include="Events\Framework\Input\IOnKeyboardInput.cs" />
    105.     <Compile Include="Events\Framework\Input\IOnMouseDown.cs" />
    106.     <Compile Include="Events\Framework\Input\IOnMouseDrag.cs" />
    107.     <Compile Include="Events\Framework\Input\IOnMouseEnter.cs" />
    108.     <Compile Include="Events\Framework\Input\IOnMouseExit.cs" />
    109.     <Compile Include="Events\Framework\Input\IOnMouseInput.cs" />
    110.     <Compile Include="Events\Framework\Input\IOnMouseOver.cs" />
    111.     <Compile Include="Events\Framework\Input\IOnMouseUp.cs" />
    112.     <Compile Include="Events\Framework\Input\IOnMouseUpAsButton.cs" />
    113.     <Compile Include="Events\Framework\Lifecycle\IFixedUpdate.cs" />
    114.     <Compile Include="Events\Framework\Lifecycle\ILateUpdate.cs" />
    115.     <Compile Include="Events\Framework\Lifecycle\IOnDestroy.cs" />
    116.     <Compile Include="Events\Framework\Lifecycle\IOnDisable.cs" />
    117.     <Compile Include="Events\Framework\Lifecycle\IOnEnable.cs" />
    118.     <Compile Include="Events\Framework\Lifecycle\IStart.cs" />
    119.     <Compile Include="Events\Framework\Lifecycle\IUpdate.cs" />
    120.     <Compile Include="Events\Framework\Navigation\IOnDestinationReached.cs" />
    121.     <Compile Include="Events\Framework\Physics 2D\ICollisionEvent2D.cs" />
    122.     <Compile Include="Events\Framework\Physics 2D\IOnCollisionEnter2D.cs" />
    123.     <Compile Include="Events\Framework\Physics 2D\IOnCollisionExit2D.cs" />
    124.     <Compile Include="Events\Framework\Physics 2D\IOnCollisionStay2D.cs" />
    125.     <Compile Include="Events\Framework\Physics 2D\IOnJointBreak2D.cs" />
    126.     <Compile Include="Events\Framework\Physics 2D\IOnTriggerEnter2D.cs" />
    127.     <Compile Include="Events\Framework\Physics 2D\IOnTriggerExit2D.cs" />
    128.     <Compile Include="Events\Framework\Physics 2D\IOnTriggerStay2D.cs" />
    129.     <Compile Include="Events\Framework\Physics 2D\ITriggerEvent2D.cs" />
    130.     <Compile Include="Events\Framework\Physics\ICollisionEventUnit.cs" />
    131.     <Compile Include="Events\Framework\Physics\IOnCollisionEnter.cs" />
    132.     <Compile Include="Events\Framework\Physics\IOnCollisionExit.cs" />
    133.     <Compile Include="Events\Framework\Physics\IOnCollisionStay.cs" />
    134.     <Compile Include="Events\Framework\Physics\IOnControllerColliderHit.cs" />
    135.     <Compile Include="Events\Framework\Physics\IOnJointBreak.cs" />
    136.     <Compile Include="Events\Framework\Physics\IOnParticleCollision.cs" />
    137.     <Compile Include="Events\Framework\Physics\IOnTriggerEnter.cs" />
    138.     <Compile Include="Events\Framework\Physics\IOnTriggerExit.cs" />
    139.     <Compile Include="Events\Framework\Physics\IOnTriggerStay.cs" />
    140.     <Compile Include="Events\Framework\Physics\ITriggerEvent.cs" />
    141.     <Compile Include="Events\Framework\Rendering\IOnBecameInvisible.cs" />
    142.     <Compile Include="Events\Framework\Rendering\IOnBecameVisible.cs" />
    143.     <Compile Include="Events\Framework\Time\IOnTimerElapsed.cs" />
    144.     <Compile Include="Events\GameObjectEvent.cs" />
    145.     <Compile Include="Events\GlobalEvent.cs" />
    146.     <Compile Include="Events\GlobalMessageListener.cs" />
    147.     <Compile Include="Events\IEvent.cs" />
    148.     <Compile Include="Events\IEventGraph.cs" />
    149.     <Compile Include="Events\IGameObjectEvent.cs" />
    150.     <Compile Include="Events\IGlobalEvent.cs" />
    151.     <Compile Include="Events\IManualEvent.cs" />
    152.     <Compile Include="Events\MessageListener.cs" />
    153.     <Compile Include="Events\UnityMessageListener.cs" />
    154.     <Compile Include="Properties\AssemblyInfo.cs" />
    155.     <Compile Include="Variables\ApplicationVariables.cs" />
    156.     <Compile Include="Variables\InspectorVariableNameAttribute.cs" />
    157.     <Compile Include="Variables\IVariableGraph.cs" />
    158.     <Compile Include="Variables\ObjectVariables.cs" />
    159.     <Compile Include="Variables\SavedVariables.cs" />
    160.     <Compile Include="Variables\SceneVariables.cs" />
    161.     <Compile Include="Variables\VariableDeclaration.cs" />
    162.     <Compile Include="Variables\VariableDeclarationCollection.cs" />
    163.     <Compile Include="Variables\VariableDeclarations.cs" />
    164.     <Compile Include="Variables\VariableKind.cs" />
    165.     <Compile Include="Variables\VariableKindAttribute.cs" />
    166.     <Compile Include="Variables\Variables.cs" />
    167.     <Compile Include="Variables\VariablesAsset.cs" />
    168.     <Compile Include="Variables\VariablesSaver.cs" />
    169.   </ItemGroup>
    170.   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    171.   <!-- Events -->
    172.   <PropertyGroup>
    173.     <PostBuildEvent>
    174. echo $(DefineConstants) &gt; "$(TargetDir)\$(TargetName).defines"
    175.  
    176. robocopy "$(TargetDir)." "$(SolutionDir)Bolt.Unity.$(ConfigurationName)\Assets\Ludiq\Assemblies" *.dll *.dll.mdb *.pdb *.xml *.defines /xf Unity*.* nunit*.*
    177.  
    178. if errorlevel 1 exit 0 else exit %25errorlevel%25
    179.     </PostBuildEvent>
    180.   </PropertyGroup>
    181. </Project>
    Please advise!
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'd recommend trying this with the latest 2018.1 beta version of Unity (b10 at the moment, I think). We've made a number of improvements around issues like this since 2017.1, and we're probably not going to back port fixes for the new scripting runtime to 2017.1, as it was experimental then.

    We do want to make sure everything works in 2018.1 though.
     
  3. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    That's unfortunate, because Bolt is meant to support 2017.1+.

    I'll give it a try and let you know.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    If I understand your original post correctly, Blot does work with the old scripting runtime (.NET equivalent). Is that correct?

    The new scripting runtime was experimental in the 2017.x series, so the fact that Bolt doesn't work with it says nothing about Bolt, but rather about the new scripting runtime in Unity. I'd like to be able to back port all of the fixes to all 2017.x versions, but we just don't have enough time to do that for experimental features.
     
  5. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    I totally understand! I'll just have to communicate that clearly to my users. No worries.

    However, I did update to 2018.1.0b10 and the issue persists as is.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks, can you submit a bug report then? We'll need to have a closer look.
     
  7. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Just sent it, it is titled exactly like this thread.

    I only included the .NET 4.6 version of the project from Unity 2018.1b10 because the older runtime version works without a problem.

    Note that source files and build configs are not included, but I believe it's theoretically unrelated. A msbuild XML is pasted in the original post here in case you want to have a look.
     
    JoshPeterson likes this.
  8. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Hi @JoshPeterson ! Did the team find a moment to have a look at this?
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm not sure, can you let me know the bug report number? I can't track it down a the moment.
     
  10. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Ok, so it looks like this is still being investigated then.