- Home /
How Are Scenes Handled?
Hi im asking this question because i honestly don't know so Say i make Scene 1 and i add a script to it then i save Scene 1 and Scene 1 is finished and i start Scene 2 if i change the said script does it change it for Scene 1 or Does Scene 1 Only Keep the script that was saved at the time?
Just like coding, a couple of full stops and capital letters in the right place will make a world of difference.
Answer by Landern · Oct 08, 2014 at 04:58 AM
Scripts are code, they are instructions for actions(methods/functions) and contain properties and fields(attributes of that script or type). If you have MyPlayerHealth.js which has every function needed to manipulate the players health as well as the health it self. If you attach that to a game object in a scene, save the scene, open a new scene, add a gameobject with that script, change that script, yes it will affect scene one.
The script is the blueprint for an object.
Think of the scripts like a cookie cutter, if you use it as a circle, then the instant you use it on the dough, you get a circular shape. However later you want to use it but bend it into some other sharp(a star). The next time you use it on the dough you get star shapes, but now you have an issue, you can't get the circular shape without bending it back(reverting/changing it) or creating a new cookie cutter.
The same happens with scenes and the reference to a script on the gameobjects, if you have a single script, then when a scene is created/edited the at the time referenced script is instantiated in memory, if you change it, the change will be reflected in that scene. If you have other scenes that reference it, then yes it the change will exist in that other scene(s) as well.
Answer by Kiwasi · Oct 08, 2014 at 05:16 AM
All of your assets (scripts, prefabs, textures, models, sounds....) are shared across all scenes.
So if you change an asset anywhere it will change everywhere.