Search Unity

Question Failed build because Visual scripting arguing with Photon Fusion 2

Discussion in 'Visual Scripting' started by unity_BA7585876382ABEED78F, Mar 25, 2024.

  1. unity_BA7585876382ABEED78F

    unity_BA7585876382ABEED78F

    Joined:
    Feb 16, 2022
    Posts:
    4
    When I do a build, during Finding AOT Stubs in plugins. I am using Photons Fusion 2 for networking and since I've installed visual scripting to do AI behaviour-related things, I've been unable to do a build as I get the following errors. When I search for this I get absolutely nothing but the occasional person saying it's a visual scripting issue in unity. Does anyone have a solution for this, or know a route to go to solve this issue?

    A few of the steps I've taken are adding all of the fusion libraries to Node libraries, running fix missing scripts and even regenerating the nodes.

    I'd really prefer not to have to rip visual scripting out as resetting up all the AI stuff with an alternative solution would take a substantial amount of time.

    Thank you for all your help, this is the first time i've had no idea where to start with an issue in all of my years using unity.

    //short error
    Error building Player: TypeLoadException: Could not instantiate Unity.VisualScripting.InstancePropertyAccessor`2[TTarget,TProperty] due to generic type cannot be instantiated with type 'Fusion.NetworkBehaviourBuffer' assembly:<unknown assembly> type:<unknown type> member:(null)


    //long error
    TypeLoadException: Could not instantiate Unity.VisualScripting.InstancePropertyAccessor`2[TTarget,TProperty] due to generic type cannot be instantiated with type 'Fusion.NetworkBehaviourBuffer' assembly:<unknown assembly> type:<unknown type> member:(null)
    System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) (at <605bf8b31fcb444b85176da963870aa7>:0)
    System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) (at <605bf8b31fcb444b85176da963870aa7>:0)
    System.RuntimeType.GetConstructors (System.Reflection.BindingFlags bindingAttr) (at <605bf8b31fcb444b85176da963870aa7>:0)
    System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) (at <605bf8b31fcb444b85176da963870aa7>:0)
    System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) (at <605bf8b31fcb444b85176da963870aa7>:0)
    System.Activator.CreateInstance (System.Type type, System.Object[] args) (at <605bf8b31fcb444b85176da963870aa7>:0)
    Unity.VisualScripting.OptimizedReflection.GetPropertyAccessor (System.Reflection.PropertyInfo propertyInfo) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Runtime/VisualScripting.Core/Reflection/Optimization/OptimizedReflection.cs:229)
    Unity.VisualScripting.OptimizedReflection.Prewarm (System.Reflection.PropertyInfo propertyInfo) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Runtime/VisualScripting.Core/Reflection/Optimization/OptimizedReflection.cs:185)
    Unity.VisualScripting.PropertyInfoStubWriter.GetOptimizedAccessor (System.Reflection.PropertyInfo propertyInfo) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/PropertyInfoStubWriter.cs:12)
    Unity.VisualScripting.AccessorInfoStubWriter`1+<GetStubStatements>d__2[TAccessor].MoveNext () (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AccessorInfoStubWriter.cs:57)
    System.Collections.Generic.LargeArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) (at <7b5547b4335144ceb60840e62be9f312>:0)
    System.Collections.Generic.EnumerableHelpers.ToArray[T] (System.Collections.Generic.IEnumerable`1[T] source) (at <7b5547b4335144ceb60840e62be9f312>:0)
    System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <7b5547b4335144ceb60840e62be9f312>:0)
    Unity.VisualScripting.AotPreBuilder.CreateCodeCompileUnitFromStubWriters (System.Collections.Generic.IEnumerable`1[T] stubWriters) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:354)
    Unity.VisualScripting.AotPreBuilder.GenerateCodeAndWriteToStream (System.Collections.Generic.IEnumerable`1[T] stubWriters, System.IO.TextWriter writer) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:296)
    Unity.VisualScripting.AotPreBuilder.FindAndWriteAotStubs (System.IO.TextWriter writer) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:291)
    Unity.VisualScripting.AotPreBuilder.GenerateStubScript (System.String scriptFilePath) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:282)
    Unity.VisualScripting.AotPreBuilder.GenerateAotStubs () (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:94)
    UnityEngine.Debug:LogException(Exception)
    Unity.VisualScripting.AotPreBuilder:GenerateAotStubs() (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:98)
    Unity.VisualScripting.AotPreBuilder:OnPreprocessBuild(BuildReport) (at ./Library/PackageCache/com.unity.visualscripting@1.8.0/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:86)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,080
    From the error message, it appears you are trying to instantiate Fusion.NetworkBehaviourBuffer, which is a generic type. Visual Scripting does not support generic types. To fix this, you'd have to port the instantiation part of the code and any other visual scripting code dealing with generic types to C#, then add that custom C# script as a new Visual Scripting type so it can be added back to the graph as node. i.e. you have to write a C# wrapper for incompatible code Visual Scripting can't deal with natively.
     
  3. unity_BA7585876382ABEED78F

    unity_BA7585876382ABEED78F

    Joined:
    Feb 16, 2022
    Posts:
    4
    I can confirm i am not doing any instantiating or networking within the fusion related things. Additionally i am also intentionally not using generic types in any of my custom nodes specifically because of this.

    Is there any way to get more detailed errors from unitys visual scripting or is this as good as it gets?
     
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,080
    Perhaps they've changed how AOT prebuild step is done, but back in the day it used to generate AOT stubs only for nodes present in graphs. So any compilation errors would've pointed to some node in some graph.

    Debugging these issues ain't easy. Perhaps you can try to get Node Finder for Visual Scripting from the asset store and search for the type in question to make sure it's not actually in any graphs. AOT stubs are generated for all asset graphs that exist in the project no matter if they are used somewhere in the game or not.
     
  5. unity_BA7585876382ABEED78F

    unity_BA7585876382ABEED78F

    Joined:
    Feb 16, 2022
    Posts:
    4
    I solved the issue by deleting scripts until I found the offender. It turns out it was none of them, it ended up being a broken connection (that didn't look broken and worked fine in editor as well as before hand in previous builds) in the graph itself, as well as an exposed variable. Once I removed the exposed variable and fixed the connection it built perfectly fine.

    It sure is difficult trouble shooting these. The errors are so vague it's hard to even know where to start.
     
  6. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,080
    Huh, makes sense why it's a type load exception then. This is the unfortunate result of the tool still being based on the defunct FullSerializer, which is not native to Unity and hasn't been updated for many years now. They'll get rid of it sometime in the future, but not this year.