public EndGameUI EngGame() { Canvas canvas = FindObjectOfType <Canvas>(); EndGameUI endGame = Instantiate <EndGameUI>(_endGamePrefab); RectTransform rect = endGame.GetComponent <RectTransform>(); rect.transform.parent = canvas.transform; rect.localScale = Vector3.one; rect.anchorMax = Vector2.one; rect.anchorMin = Vector2.one; endGame.EndGame(_score); return(endGame); }