I’m currently working on a 2d platform bike based game. I’ve created a customise scene where you can change the colour of the bike, but when you hit play and the main scene loads, the colour changes don’t appear. Is there a way to have one gameObject in two scenes, so the changes from one scene affect the other? I’m working in C# btw
There are different ways you can achieve this. Two of the most common:
Have the object created in only one scene (like the initial scene) and mark it so that it will not be destroyed automatically when loading a new scene.
Example:
public class example : MonoBehaviour {
void Awake() {
DontDestroyOnLoad(transform.gameObject);
}
}
Make the bike a prefab. Then instantiate a GameObject from that prefab in each scene when it starts up. Then you can modify the prefab (like the color) and the copies that are created at runtime will have that color regardless of what scene that is done in.