Let's assume I have a GameObject 'Player' and two scenes A and B. If I add this GameObject 'Player' on both scenes and then make some changes (e.g. adding a script in Scene A), can I somehow achieve that the GameObject 'Player' stays the same in both A and B? Or do I have to update the GameObject in both scenes manually?
I couldn't find a convenient way to achieve this.
If you just need to persist GameObjects between scene transitions you can use DontDestroyOnLoad() method.
Something like this should makes de deal:
using UnityEngine;
using System.Collections;
public class MyPlayer : MonoBehaviour {
void Awake() {
DontDestroyOnLoad(this.gameObject);
}
// myPlayer behaviour....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With