i have 3 classes.
static class in which i declared 2 game objects
public static Gameobject attacker; public static Gameobject defender;
attack combination in which i chose attacker and defender , in this scene it gets and display values fine ,
staticclass.attacker = gameObject; Debug.Log("I am attacker" + staticclass.attacker);
but it is not displaying values n 3rd class result class , any idea how to do that
diceresult
Debug.Log(" ATTAKERRRRRRRRRRRR " + staticclass.attacker);
dice result is in another scene
When you make GameObject, Component or any script/component that derives from the Unity's Object static
, it will still be destroyed/cleaned up when you load new scene.
If you don't want this to happen that you must call DontDestroyOnLoad
on all those Unity Object static
variables immediately after initializing them.
DontDestroyOnLoad(attacker);
DontDestroyOnLoad(defender);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.