Search Unity

Question Enums created inside assemblies are not exposed to the scripting environment

Discussion in 'Visual Scripting' started by max_autious, Oct 4, 2022.

  1. max_autious

    max_autious

    Joined:
    Dec 29, 2017
    Posts:
    9
    Hey there! We're experiementing with visual scripting for our project in Unity.

    We're using Unity 2021.3.5f1 and Visual Scripting 1.7.8

    We're having an issue where enums that are created in a custom assembly is not exposed and visible in the visual scripting environment. The Assembly is included, all nodes have been regenerated, and other types in the assembly is visible and accessible. I can make it accessible by moving the enum to the default unity assembly, but not otherwise.

    I can't find any material online regarding this behaviour, has anyone had similar experiences and issues?
     
  2. myanko

    myanko

    Joined:
    Nov 9, 2013
    Posts:
    56
    You added the assembly, but did you also added the enum in the types? It is in the Project Settings panel on top of the assemblies.
    upload_2022-10-4_7-50-33.png

    In some versions of visual scripting, just adding the Assembly to the Node Library section, will gather the types, but not in all versions.
     
  3. max_autious

    max_autious

    Joined:
    Dec 29, 2017
    Posts:
    9
    I did make an attempt, but the enum type isn't listed in the dropdown for the Type Options.
     
  4. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    where does this custom assembly come from?
    is the error with the custom nature of the assembly not being seen i wonder
     
  5. max_autious

    max_autious

    Joined:
    Dec 29, 2017
    Posts:
    9
    I suspect something similar, that there might be a bug or difference in behaviour in VisualScripting's reflection routine that misses enums when they are part of an assembly.

    We've separated out our project into separate assemblies to clarify some codebase bounderies and improve recompile times. As far as i'm aware it's a pretty standard and recommended approach to Unity development.
     
  6. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    what is the actual property you want to change?
     
  7. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    I was able to try a public enum in an assembly and everything work in Visual Scripting package 1.7.6. haven't tried in 1.7.7 or other versions. This is how it look like on my side.
    upload_2022-10-6_10-36-31.png


    This is my setup.

    I have this basic enim in a c# file named MyEnum.cs
    Code (CSharp):
    1. namespace MyNamespace
    2. {
    3.         public enum MySeason
    4.         {
    5.             Spring,
    6.             Summer,
    7.             Autumn,
    8.             Winter
    9.         }
    10. }
    My Assembly is just set with the default Values. If your have only Editor in it, it may be the cause of the problem.
    upload_2022-10-6_10-42-29.png

    I have only set the Assembly to be in my node library. Did nothing for the type.
    upload_2022-10-6_10-44-33.png

    Clicked Regenerate and I was able to see it.

    If it still doesn't work, I would like to see what version of the visual scripting package you have, and the Operating system you are using.
     
    REDACT3D_ likes this.
  8. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
    Try turning off AOT Safety mode and see if that changes anything. Perhaps UVS considers the assembly to be AOT unsafe and filters certain results out.
     
  9. max_autious

    max_autious

    Joined:
    Dec 29, 2017
    Posts:
    9
    ericb, thanks for the verification, makes me think there's something special about our project configuration that makes this happen.

    PanthenEye, i'll try that out!
     
  10. max_autious

    max_autious

    Joined:
    Dec 29, 2017
    Posts:
    9
    Where can i find the AOT Safety mode setting in 2021.3.5f1 with visual scripting 1.7.8?
     
  11. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
    Either in Preferences or Project Settings under Visual Scripting section. I don't recall which one.