public static void SaveUfoData(UfoControl ufoControl) { BinaryFormatter formatter = new BinaryFormatter(); string path = Path.Combine(Application.persistentDataPath, "ufo.fun"); FileStream stream = new FileStream(path, FileMode.Create); UfoData ufoData = new UfoData(ufoControl); formatter.Serialize(stream, ufoData); stream.Close(); }
private void LoadUfoData() { UfoData ufoData = SaveSystem.LoadUfoData(); if (ufoData != null) { ufoSpeed = ufoData.ufoSpeed; ufoDurability = ufoData.ufoDurability; durEffectValue = ufoData.durEffectValue; } }
public static UfoData LoadUfoData() { string path = Path.Combine(Application.persistentDataPath, "ufo.fun"); if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); UfoData ufoData = formatter.Deserialize(stream) as UfoData; stream.Close(); return(ufoData); } else { Debug.LogError("Save file not found in " + path); return(null); } }
private void OnEnable() { if (device == null) { device = GetComponent <EnergyDevice>(); } if (ud == null) { ud = GetComponent <UfoData>(); } if (hazardManager == null) { hazardManager = FindObjectOfType <DeviceHazardManager>(); } rigid = GetComponent <Rigidbody>(); device.forceDeactive = true; interactable = GetComponent <VRTK_InteractableObject>(); interactable.InteractableObjectGrabbed += OnGrabbed; interactable.InteractableObjectUngrabbed += OnUnGrabbed; }