- Home /
Save a Script Component as a variable.
I'm making a multiplayer game and every time I want to edit a setting, I have to edit it in every single player. To solve this, I'm writing a script that copies all settings to the player on Awake().
The issue is that I can't find a way to save the script from the player as a variable, so I have to call GetComponent about 30 times per player. Is there a way to save the script component for access to the variables?
PS: I've looked at a lot of similar questions but haven't found a satisfying answer yet. I've also tried to use the variables 'Script', 'Monobehavior' and just 'Component', but those either don't get recognized or don't work.
Answer by Mehrdad995 · May 27, 2020 at 02:12 PM
You can use Scriptable Object as a container that stores all settings and variables you need.
This also help optimizing your game as the data doesn't need to be copied for each instance.