private void SaveCoinFromArr(List <GameObject> coin_lst, string prefix) { List <Quaternion> coin_rotation = new List <Quaternion>(); List <Vector3> coin_position = new List <Vector3>(); List <string> coin_names = new List <string>(); for (int i = 0; i < coin_lst.Count; i++) { if (coin_lst[i] != null) { if (coin_lst[i].activeInHierarchy == true) {/////////////////////////// change from != false if (coin_lst[i].activeInHierarchy) { coin_rotation.Add(coin_lst[i].transform.rotation); coin_position.Add(coin_lst[i].transform.position); coin_names.Add(coin_lst[i].name); } } } } PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", coin_rotation.ToArray()); PlayerPrefsX.SetVector3Array(prefix + "Position", coin_position.ToArray()); PlayerPrefsX.SetStringArray(prefix + "Name", coin_names.ToArray()); if (coin_names.Count > 0) { PlayerPrefs.SetInt(prefix + "Count", coin_names.Count); } else { PlayerPrefs.SetInt(prefix + "Count", 0); } }
public void SaveGifts() { GameObject[] gifts_array = GameObject.FindGameObjectsWithTag("Gift"); if (gifts_array.Length > 0) { Quaternion[] gift_rotation = new Quaternion[gifts_array.Length]; Vector3[] gift_position = new Vector3[gifts_array.Length]; string[] gift_names = new string[gifts_array.Length]; for (int i = 0; i < gifts_array.Length; i++) { gift_rotation[i] = gifts_array[i].transform.rotation; gift_position[i] = gifts_array[i].transform.position; gift_names[i] = gifts_array[i].name; } PlayerPrefsX.SetQuaternionArray("GiftQuaternion", gift_rotation); PlayerPrefsX.SetVector3Array("GiftPosition", gift_position); PlayerPrefsX.SetStringArray("GiftName", gift_names); PlayerPrefs.SetInt("GiftCount", gifts_array.Length); } else { PlayerPrefs.SetInt("GiftCount", 0); } }
public void SaveGiftsRev2(List <GameObject> objects, string prefix) { List <Vector3> positions = new List <Vector3>(); List <Quaternion> rotations = new List <Quaternion>(); List <string> names = new List <string>(); for (int i = 0; i < objects.Count; i++) { if (objects[i].activeInHierarchy) { positions.Add(objects[i].transform.position); rotations.Add(objects[i].transform.rotation); names.Add(objects[i].name); } } if (names.Count > 0) { PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", rotations.ToArray()); PlayerPrefsX.SetVector3Array(prefix + "Position", positions.ToArray()); PlayerPrefsX.SetStringArray(prefix + "Name", names.ToArray()); PlayerPrefs.SetInt(prefix + "Count", names.Count); } else { PlayerPrefs.SetInt(prefix + "Count", 0); } }
/* * データをPlayerPrefsXに保存する */ public void Save() { this.MapSelectedObjects(); //選択したオブジェクトをマッピングする List <Vector3> savingPosList = new List <Vector3>() { }; List <Quaternion> savingRotList = new List <Quaternion>() { }; List <Vector3> savingScaleList = new List <Vector3>() { }; foreach (Transform transform in this.mapped.transform) { savingPosList.Add(transform.position); savingRotList.Add(transform.rotation); savingScaleList.Add(transform.localScale); } PlayerPrefsX.SetVector3Array("mappedPosList", savingPosList.ToArray()); PlayerPrefsX.SetQuaternionArray("mappedRotList", savingRotList.ToArray()); PlayerPrefsX.SetVector3Array("mappedScaleList", savingScaleList.ToArray()); }