// 更新 void Update() { // オブジェクトからTextコンポーネントを取得 Text[] score_text = new Text[2]; score_text[0] = score_object.GetComponent <Text>(); score_text[1] = score_object2.GetComponent <Text>(); // テキストの表示を入れ替える score_num = Score.GetScore(); score_text[0].text = "" + score_num; score_num = Score2.GetScore(); score_text[1].text = "" + score_num; }
//2人用リザルトシーン void DoubleInit() { Win = GameObject.Find("Win"); Lose = GameObject.Find("Lose"); Draw = GameObject.Find("Draw"); Win.SetActive(true); Lose.SetActive(true); Draw.SetActive(false); // オブジェクトからTextコンポーネントを取得 score_text[0] = score_object.GetComponent <Text>(); score_text[1] = score_object2.GetComponent <Text>(); // テキストの表示を入れ替える n_score = Score.GetScore(); score_text[0].text = "" + n_score; n_score2 = Score2.GetScore(); score_text[1].text = "" + n_score2; if (n_score < n_score2) { score_text[1].transform.parent = Win.transform; //プレイヤー2をWinの子に score_text[0].transform.parent = Lose.transform; //プレイヤー1をLoseの子に Win.gameObject.transform.position = new Vector3(Win.gameObject.transform.position.x + ResultUIMove, Win.gameObject.transform.position.y, 0.0f); Lose.gameObject.transform.position = new Vector3(Lose.gameObject.transform.position.x - ResultUIMove, Lose.gameObject.transform.position.y, 0.0f); } else if (n_score > n_score2) { score_text[0].transform.parent = Win.transform; //プレイヤー1をWinの子に score_text[1].transform.parent = Lose.transform; //プレイヤー2をLoseの子に Win.gameObject.transform.position = new Vector3(Win.gameObject.transform.position.x - ResultUIMove, Win.gameObject.transform.position.y, 0.0f); Lose.gameObject.transform.position = new Vector3(Lose.gameObject.transform.position.x + ResultUIMove, Lose.gameObject.transform.position.y, 0.0f); } else if (n_score == n_score2) { Lose.SetActive(false); Draw.SetActive(true); score_text[0].transform.parent = Win.transform; //プレイヤー1をWinの子に score_text[1].transform.parent = Draw.transform; //プレイヤー2をLoseの子に Win.gameObject.transform.position = new Vector3(Win.gameObject.transform.position.x - ResultUIMove, Win.gameObject.transform.position.y, 0.0f); Draw.gameObject.transform.position = new Vector3(Draw.gameObject.transform.position.x + ResultUIMove, Draw.gameObject.transform.position.y, 0.0f); } }