How to save run-time variables to dictionary?

I want to cache some calculations and save them to a dictionary (or similar data structure) during runtime. How can I do this? Thanks in advance.

If you are using C# you can use a Dictionary data type and its method Add(Key, Value).
See: Dictionary<TKey,TValue> Class (System.Collections.Generic) | Microsoft Learn)
If you need more than one game object to access this Dictionary you can make the variable static so it is shared among game objects.
See: static modifier - C# Reference | Microsoft Learn
Of course you need to attach a script with the Dictionary declaration to the game object or prefab that will use it.
If different game objects or prefabs needs to access the Dictionary you should move your Dictionary declaration to a separate static class in the Unity project Visual Studio (MonoDevelop) solution and use this class to access the Dictionary from different scripts.
I don’t know how much you know C# and programming in general so if you need a more in depth explanation with an example let me know :slight_smile:

I hope it helps !