How to Save Property Values of a Component on a Scriptable Object?

I would like to have two alternative layouts based on the configurations my users will select on settings - e.g., if playing the game on “super easy” the layout will be one, and if playing on “super hard” the layout will be another.

With Scriptable Objects, I could make the game objects on my scene know the values they should use based on the asset file that corresponds to the current difficulty - i.g., DifficultyConfiguration1 or DifficultyConfiguration2 files (from DifficultyConfiguration : Scriptable Object).

Now, I would like to avoid having to declare every single variable of every single property of any component, attached to a game object on my scene, that I want its properties to vary. For example, if I want the Rect Transform of a panel to vary (e.g., its width, height, pos x, etc.,), I would not like having to declare every single of them on my DifficultyConfiguration script. It would be just very tedious, because there are just enough panels that I want to readjust based on the values of my DifficultyConfiguration file.

This is what I attempted first, but then realized that it doesn’t work because Assets cannot reference GameObjects in the scene.

  • To create a ScriptableObject where I could “save” the property values that I would like to use depending on the “current” DifficultyConfiguration file.

  • But then, I can’t drag the components from my scene onto my DifficultyConfiguration files (again, because Assets can’t reference GameObjects on the scene - and this is how I realized it).

But, actually, I never intended to reference any GameObject on my scene, as I explained. What I want is to hold a copy of the property values of the, for example, RectTransform components (of the relevant GameObjects) on my difficulty configuration files. Is that even possible? Or any ideas on how I can achieve a similar mechanism?

(Again, in the worst case, I would declare every single variable for every property value of each relevant GameObject; but ones are trickier than others, like the Anchor Presets. I don’t want to go that way at all.)


Even if your question starts to get old, I guess it’s still valuable since you got no answer.
If I had to manage layouts depending on difficulty, I would put the layout into the ScriptableObject.

Something like :

public class MyConfig : DifficultyConfiguration {

    public GameObject uiPrefab;

Then, at the start of the scene, I would have a specific script whose role would be to instantiate the UI prefab of that difficulty file.
That way, I could put everything I want into this uiPrefab, with as many GameObjects as I want, with lots of properties, in a complicated hierarchy.

I would have a base UIPrefab and then have a Prefab Variant for each difficulty to reduce the amount of work needed to propagate a change to every layout I’ve created.

I hope this helps!