/* * セーブデータを読み込む */ public void Load() { bool is_shown_map = (SceneManager.GetActiveScene().name == "SimpleMapping"); if (PlayerPrefs.HasKey("mappedPosList")) { if (this.mapped.transform.childCount > 0) { foreach (Transform child in this.mapped.transform) { GameObject.Destroy(child.gameObject); } } Vector3[] posList = PlayerPrefsX.GetVector3Array("mappedPosList"); Quaternion[] rotList = PlayerPrefsX.GetQuaternionArray("mappedRotList"); Vector3[] scaleList = PlayerPrefsX.GetVector3Array("mappedScaleList"); for (int i = 0; i < posList.Length; i++) { GameObject obj = Object.Instantiate(this.originBox) as GameObject; obj.transform.position = posList[i]; obj.transform.rotation = rotList[i]; obj.transform.localScale = scaleList[i]; obj.transform.parent = this.mapped.transform; obj.GetComponent <Renderer>().enabled = is_shown_map; } } else { //セーブデータがない場合,何もしない } }
private void ActivateCoinFromArr(List <GameObject> coin_lst, string prefix, float mass) { if (PlayerPrefs.HasKey(prefix + "Count")) { int coinCount = PlayerPrefs.GetInt(prefix + "Count"); if (coinCount > 0) { Vector3[] positions = PlayerPrefsX.GetVector3Array(prefix + "Position"); Quaternion[] rotations = PlayerPrefsX.GetQuaternionArray(prefix + "Quaternion"); string[] names = PlayerPrefsX.GetStringArray(prefix + "Name"); for (int i = 0; i < coin_lst.Count; ++i) { if (i < coinCount) { if (!coin_lst[i].activeInHierarchy) { coin_lst[i].SetActive(true); } coin_lst[i].GetComponent <Rigidbody>().freezeRotation = false; coin_lst[i].GetComponent <Rigidbody>().mass = mass; coin_lst[i].transform.rotation = rotations[i]; coin_lst[i].transform.position = positions[i]; coin_lst[i].name = names[i]; coin_lst[i].transform.parent = coin_parent; coin_lst[i].GetComponent <CoinScript>().isLanded = false; coin_lst[i].GetComponent <CoinScript>().giantShake = true; coin_lst[i].GetComponent <CoinScript>().enabled = false; } else { if (coin_lst[i].activeInHierarchy) { coin_lst[i].GetComponent <CoinScript>().enabled = false; coin_lst[i].SetActive(false); coin_lst[i].GetComponent <Rigidbody>().freezeRotation = true; //////////////////////// Freeze Rotation } } } } } }
public void LoadGiftsRev2(List <GameObject> objects, string prefix) { if (PlayerPrefs.HasKey(prefix + "Count")) { int count = PlayerPrefs.GetInt(prefix + "Count"); if (count > 0) { Quaternion[] rotations = PlayerPrefsX.GetQuaternionArray(prefix + "Quaternion"); Vector3[] positions = PlayerPrefsX.GetVector3Array(prefix + "Position"); string[] names = PlayerPrefsX.GetStringArray(prefix + "Name"); for (int i = 0; i < count; i++) { GameObject gobject = GetInActiveObject(objects); gobject.transform.rotation = rotations[i]; gobject.transform.position = positions[i]; gobject.name = names[i]; gobject.SetActive(true); Debug.Log(gobject.name); } } } }