using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Result : MonoBehaviour { Scene scene; Score score; //リザルト画面で使うオブジェクト public GameObject[] ResultObj = new GameObject[3]; public GameObject[] ResultScr = new GameObject[2]; public Sprite[] Resultworl = new Sprite[3]; //UIの移動スピード public float speed = 0.6f; // Use this for initialization void Start() { scene = GetComponent(); score = GetComponent(); ResultObj[0] = GameObject.Find("Result"); ResultObj[1] = GameObject.Find("scoreboard"); ResultObj[2] = GameObject.Find("MenuButtun"); ResultScr[0] = GameObject.Find("rScore_1"); ResultScr[1] = GameObject.Find("rScore_2"); } void Update() { // if (scene.sceneChenge && !scene.blackfade) { UIMove(ResultObj[0], 1f); UIMove(ResultObj[1], -1f); UIMove(ResultObj[2], -1f); if (score.win) { GameObject.Find("WinOrLose").GetComponent().sprite = Resultworl[0]; } else if (score.draw) { GameObject.Find("WinOrLose").GetComponent().sprite = Resultworl[2]; } else { GameObject.Find("WinOrLose").GetComponent().sprite = Resultworl[1]; } score.displayScore(ResultScr[0], 0); score.displayScore(ResultScr[1], 1); } } //UIの移動 左に移動 type=-1: 右に移動 type=1: void UIMove(GameObject UIobj, float type) { float posX, posY; posX = UIobj.GetComponent().anchoredPosition.x; posY = UIobj.GetComponent().anchoredPosition.y; if (type * posX < 0) { UIobj.GetComponent().anchoredPosition = new Vector2(posX + type * speed, posY); } else if (type * posX > 0) { UIobj.GetComponent().anchoredPosition = new Vector2(0f, posY); } } }