Search Unity

Question Struct overridden in Dictonary

Discussion in 'Visual Scripting' started by joeee19, Apr 29, 2021.

  1. joeee19

    joeee19

    Joined:
    Jul 14, 2012
    Posts:
    56
    Hi there.

    In Unity 2021 Visual Scripting (bolt), I want to use int and myStruct as saved variables in a Dictionary.
    I was able to get the variables to show up in the bolt inspector.
    However, when I set AAA for timeLinePrefab in dictionary key0 and BBB in key1, AAA in key0 is also overridden by BBB.
    How can I work around this?

    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.VisualScripting;
    3.  
    4. [System.Serializable]
    5. [Inspectable]
    6. public Struct StageStruct
    7. {
    8.     [Inspectable] public GameObject timeLinePrefab;
    9.     [Inspectable] public Material backGroundMaterial;
    10.     [Inspectable] public bool isCleard;
    11.     [Inspectable] public int cleardScore = 0;
    12. }
     

    Attached Files:

    Last edited: May 2, 2021
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,073
    Huh, I thought saved variables are just a wrapper for serializing stuff to player prefs and player prefs only support serializing primitives by default.
     
  3. joeee19

    joeee19

    Joined:
    Jul 14, 2012
    Posts:
    56
    Thanks for the replies.

    However, when I tried setting it to an object variable, it was the same.
    The code you described is Class, but it is a mistake for Struct.

    However, the same thing happens with both Class and Struct.