Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug When I switched platform to Android, I can not add new List variables

Discussion in 'Visual Scripting' started by URocks, Aug 9, 2021.

  1. URocks

    URocks

    Joined:
    May 1, 2014
    Posts:
    158
    I am using visual scripting and unity 2021.1.f16, I created my game on the windows platform selected, and everything worked as it should. The problem started when I switched the platform to android and when I wanted to add new functionality. What I realized was that I could not add a List variable to my visual scripts (flow, graph, scene, app, or saved). What I needed was a list of game objects. In the dropdown, there was only an AOT list available. I spend a lot of time figuring out how to solve this problem and only solution I found was to switch back to the windows platform, make all new visual scripting with list variables and then switch back to Android.

    Do you know why is this happening?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,045
    Generic collections can't be used on AOT (IL2CPP) platforms. They're filtered out by AOT Safe Mode, that's why you don't see them on Android. If you have generic collections such as List<GameObject> present in the project, the game won't run on AOT platform builds (doesn't matter if it runs in the editor since editor is not an AOT platform).

    So you can either swap the scripting backend to Mono which supports generic collections or use AoTList type for lists to get AOT compatibility.

    There's also an option to disable AOT Safe Mode in Unity Visual Scripting preferences which will stop filtering out AOT unsafe results such as generic collections. But that won't solve the AOT compatibility issues.
     
    Last edited: Aug 9, 2021
  3. URocks

    URocks

    Joined:
    May 1, 2014
    Posts:
    158
    But my game run perfectly on android (I don't mean the editor) even if I am using list variables added on windows build target, the problem is I can't add them when I am already switched to the android platform, btw I already see the lists variables added from windows build target on the android build target script machine, I just can't add new ones. The game runs exactly the same on android as on the Windows platform (I am using a lot of lists operations there). And also if I am on android and I switch to MONO, I still can't add generic lists
     
    Last edited: Aug 9, 2021
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,045
    Then disable AoT Safe Mode in UVS preferences. It's filtering out what it considers AOT unsafe search results including generic lists. upload_2021-8-9_13-47-55.png
     
    Last edited: Aug 10, 2021
  5. Vion

    Vion

    Joined:
    Jul 28, 2014
    Posts:
    1
    I'm not sure if this is related. But in Bolt's Graph the sidebar has Variable Object greyed out. So I right clicked and added one manually and I cannot change the name. This is the latest Unity with fresh install.

    (If you are going to grey things out so we cannot even reach the feedback of a proper error message then at least change the tooltip please)
     
  6. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,045
    Completely unrelated to this topic. GameObject variables are greyed out when you don't have a GameObject with UnityVS GameObject Variables component attached to it selected. UnityVS Variables component is automatically attached when you add a ScriptMachine or StateMachine UnityVS components.

    So in short, you can't create GameObject variables if you don't have a GameObject with Variables component selected. Therefore, greying it out makes sense. It's not an error or anything.