private void Awake() { // load data if possible StaticHealth healthFromLoad = StaticHealthStorage.loadData(gameObject.name); if (healthFromLoad != null) { health = healthFromLoad; return; } // else create one health = new StaticHealth(healthData, gameObject.name, isFreezable); }
// This method will delete data in health Storage (Only use it when this script is lastly appear in scene) public void DeleteData() { StaticHealthStorage.RemoveData(health); }
// Private private void SaveData() { StaticHealthStorage.StoreData(this); }