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.

Question [SOLVED] List type variable changes type during run time.

Discussion in 'Visual Scripting' started by SkullKing, Dec 5, 2021.

  1. SkullKing

    SkullKing

    Joined:
    May 31, 2012
    Posts:
    40
    I have an object variable whose type is "list of Game Objects".

    I add objects without problems. However if I remove objects until there is only one element the variable type changes to "Game Object" and then all my list logic breaks because the variable is no longer a list (e.g.: I can´t add more Objects to the list)

    How can I avoid this?
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    8,792
    Show us your script, something is not right, there is no such thing as "changes type" just like that.
     
  3. SkullKing

    SkullKing

    Joined:
    May 31, 2012
    Posts:
    40
    Thanks for your reply.

    It was just a dumb mistake I was far too tired and sleep to code yesterday. Turn out when I was leaving the list with only one game object I was actually setting it´s value as another variable that was type "game object" and that caused the change.