- Home /
The question is answered, right answer was accepted
Programming/inspector question
I am sorry, if my question is stupid or vague, but it's bugging me for a whole day now.
I just started my very first game and I got an object that can have any number of 20 variables that change it's values every scene.
Is there a way to just pick a few of these variables and initialize in the inspector every scene instead of handling every variable in every scene?
Not sure I understand the problem. When you declare those variables you can set a default value: [SerializeField] int myValue = 23;
Then, you can adjust in the inspector if you want or, if not, leave the default....
Answer by szimmermann · Sep 16, 2016 at 11:37 AM
You can create a prefab from your object. The prefab can then be used in each of your scenes. As long as you edit the prefab in the project window and not in the hierarchy window, the changes you make will reflect in all your prefab instances. This comes very handy if you have for example an prefab called "Score Meter" which you want to reuse in every scene. If you want to make changes to that meter for all instances just make the changes on one prefab itself. If you want to make level specific changes open the scene where the prefab instance is and edit the value you want to override on the instance itself.
You can read about prefab heres: https://docs.unity3d.com/Manual/Prefabs.html
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Inspector Assigned Variables Not In Both Scenes 1 Answer
Accessing variables from other scripts 0 Answers
inspector isnt showing scripts 2 Answers