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 Visual Scripting - Prefabs handling of object variables. Any solution?

Discussion in 'Authoring Dev Blitz Day 2023' started by Marou1, Jan 26, 2023.

  1. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    130
    Hi,

    If you have a prefab with these 2 variables:


    PrefabID does not change because it is the ID of the prefab.
    But SpecificValue will be different for each instance of the prefab in the environment.

    Let's say I place 50 instances and I set their SpecificValue to different values.

    Then I figure out that I need to add a new variable in the prefab:


    The NewVariable will not be inherited by 50 the instances. It seems that the link of the Variables component with the prefab is broken because the value of one variable was changed.

    So I see 2 ways to handle this, and both are tedious:
    1- Going through the 50 instances, reverting the Variables component and setting again the SpecificValue.
    2-Going through the 50 instances and adding the NewVariable.

    I tried a 3rd possibility, but it does not work. In the prefab, I created a second Variables component.
    The idea was to put all the variables that will not be modified in the first component (the link with the prefab will not be broken), and the variables that need to be specific to the instance, in the second component.
    So at least, if I need to add a new variable that is not specific to the instance, I could add it in the first component and it will be inherited by all the 50 instances.

    However, all the variables that are in the second component are ignored by the scripts and I get an error saying that these variables were not found, even though they are there in inspector.

    Any solution/workaround to handle this?

    Thanks
     
  2. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    130
    Hi,

    Is no answer means no solution or workaround?

    Thanks
     
  3. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    130
    Still waiting...