void Update() { //Set to preview GUI in editor if (Application.isPlaying == false) { if (calOnGUI == null && createGUI == false) { calOnGUI = new CalOnGUI(); createGUI = true; } for (int i = 0; i < itemStateSet.Count; i++) { if (isPreview) { itemStateSet[i].guiTexture.enabled = true; itemStateSet[i].guiText.enabled = true; if (itemStateSet[i].itemType == Item.TypeItem.ItemJump) { ShowGUI(i, 1); } if (itemStateSet[i].itemType == Item.TypeItem.ItemMagnet) { ShowGUI(i, 1); } if (itemStateSet[i].itemType == Item.TypeItem.ItemMultiply) { ShowGUI(i, 1); } if (itemStateSet[i].itemType == Item.TypeItem.ItemSprint) { ShowGUI(i, 1); } } else { itemStateSet[i].guiTexture.enabled = false; itemStateSet[i].guiText.enabled = false; } } for (int i = 0; i < menuButtonSet.Count; i++) { if (isPreview) { menuButtonSet[i].guiTexture.enabled = true; ShowGUIButton(i); } else { menuButtonSet[i].guiTexture.enabled = false; } } for (int i = 0; i < scoreSet.Count; i++) { if (isPreview) { scoreSet[i].guiTexture.enabled = true; ShowGUIScore(i); } else { scoreSet[i].guiTexture.enabled = false; } } } else { if (PatternSystem.instance.loadingComplete == true) { for (int i = 0; i < guiText.Length; i++) { //guiText[i].pixelOffset = new Vector2(calOnGUI.SetGUI(positionSet[i].x, positionSet[i].y, positionSet[i].sizeX).x // , calOnGUI.SetGUI(positionSet[i].x, positionSet[i].y, positionSet[i].sizeX).y); guiText[i].enabled = true; /* * guiText[i].pixelOffset = new Vector2(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(positionSet[i].x, positionSet[i].y), * new Vector2(positionSet[i].sizeX, positionSet[i].sizeY)).x, * GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(positionSet[i].x, positionSet[i].y), * new Vector2(positionSet[i].sizeX, positionSet[i].sizeY)).y); */ guiText[i].fontSize = GUI_Calculate.FontSize((int)positionSet[i].sizeX); if (positionSet[i].name == "Distance") { guiText[i].text = "" + (int)GameAttribute.gameAttribute.distance; } else if (positionSet[i].name == "Coin") { guiText[i].text = "" + (int)GameAttribute.gameAttribute.coin; } } //RectWithScrren_WidthAndHeight_Sizeheight for (int i = 0; i < scoreSet.Count; i++) { scoreSet[i].guiTexture.enabled = true; ShowGUIScore(i); } for (int i = 0; i < itemStateSet.Count; i++) { if (itemStateSet[i].itemType == Item.TypeItem.ItemJump) { if (Controller.instace.timeJump > 0) { itemStateSet[i].guiTexture.enabled = true; itemStateSet[i].guiText.enabled = true; ShowGUI(i, Controller.instace.timeJump); } else { itemStateSet[i].guiTexture.enabled = false; itemStateSet[i].guiText.enabled = false; } } if (itemStateSet[i].itemType == Item.TypeItem.ItemMagnet) { if (Controller.instace.timeMagnet > 0) { itemStateSet[i].guiTexture.enabled = true; itemStateSet[i].guiText.enabled = true; ShowGUI(i, Controller.instace.timeMagnet); } else { itemStateSet[i].guiTexture.enabled = false; itemStateSet[i].guiText.enabled = false; } } if (itemStateSet[i].itemType == Item.TypeItem.ItemMultiply) { if (Controller.instace.timeMultiply > 0) { itemStateSet[i].guiTexture.enabled = true; itemStateSet[i].guiText.enabled = true; ShowGUI(i, Controller.instace.timeMultiply); } else { itemStateSet[i].guiTexture.enabled = false; itemStateSet[i].guiText.enabled = false; } } if (itemStateSet[i].itemType == Item.TypeItem.ItemSprint) { if (Controller.instace.timeSprint > 0) { itemStateSet[i].guiTexture.enabled = true; itemStateSet[i].guiText.enabled = true; ShowGUI(i, Controller.instace.timeSprint); } else { itemStateSet[i].guiTexture.enabled = false; itemStateSet[i].guiText.enabled = false; } } } for (int i = 0; i < menuButtonSet.Count; i++) { ShowGUIButton(i); CheckTypeButtonActive(i); /* * if(menuButtonSet[i].guiTexture.HitTest(Input.mousePosition)){ * if(Input.GetMouseButtonDown(0)){ * menuButtonSet[i].guiTexture.texture = menuButtonSet[i].buttonActive; * } * * if(Input.GetMouseButtonUp(0)){ * //menuButtonSet[i].guiTexture.texture = menuButtonSet[i].buttonNormal; * CheckTypeButtonAction(i); * } * }else{ * //menuButtonSet[i].guiTexture.texture = menuButtonSet[i].buttonNormal; * }*/ } } else { for (int i = 0; i < guiText.Length; i++) { guiText[i].text = ""; } } } }
void OnGUI() { SetStyle(); guiLabelName.guiText.text = players[indexSelect].name; guiLabelName.guiText.pixelOffset = new Vector2(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelName.rect.x, guiLabelName.rect.y), new Vector2(guiLabelName.rect.width, guiLabelName.rect.height)).x, GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelName.rect.x, guiLabelName.rect.y), new Vector2(guiLabelName.rect.width, guiLabelName.rect.height)).y); guiLabelName.guiText.fontSize = GUI_Calculate.FontSize(guiLabelName.fontSize); guiLabelCoinCurrent.guiText.text = coin.ToString(); guiLabelCoinCurrent.guiText.pixelOffset = new Vector2(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelCoinCurrent.rect.x, guiLabelCoinCurrent.rect.y), new Vector2(guiLabelCoinCurrent.rect.width, guiLabelCoinCurrent.rect.height)).x, GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelCoinCurrent.rect.x, guiLabelCoinCurrent.rect.y), new Vector2(guiLabelCoinCurrent.rect.width, guiLabelCoinCurrent.rect.height)).y); guiLabelCoinCurrent.guiText.fontSize = GUI_Calculate.FontSize(guiLabelCoinCurrent.fontSize); GUI.DrawTexture(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(iconCoinCurrent.rect.x, iconCoinCurrent.rect.y), new Vector2(iconCoinCurrent.rect.width, iconCoinCurrent.rect.height)), iconCoinCurrent.normal); if (players [indexSelect].isUnLock == false) { GUI.DrawTexture(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(iconCoinBuy.rect.x, iconCoinBuy.rect.y), new Vector2(iconCoinBuy.rect.width, iconCoinBuy.rect.height)), iconCoinBuy.normal); guiLabelPrice.guiText.enabled = true; guiLabelPrice.guiText.text = players[indexSelect].price.ToString(); guiLabelPrice.guiText.pixelOffset = new Vector2(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelPrice.rect.x, guiLabelPrice.rect.y), new Vector2(guiLabelPrice.rect.width, guiLabelPrice.rect.height)).x, GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(guiLabelPrice.rect.x, guiLabelPrice.rect.y), new Vector2(guiLabelPrice.rect.width, guiLabelPrice.rect.height)).y); guiLabelPrice.guiText.fontSize = GUI_Calculate.FontSize(guiLabelPrice.fontSize); if (GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnBuy.rect.x, btnBuy.rect.y), new Vector2(btnBuy.rect.width, btnBuy.rect.height)), "", guiStyleBtnBuy)) { if (coin >= players[indexSelect].price) { coin -= players[indexSelect].price; GameData.SaveCoin(coin); players[indexSelect].isUnLock = true; PlayerPrefs.SetString("Player_" + indexSelect, "True"); PlayerPrefs.SetInt("SelectPlayer", selecCorrect); Debug.Log("Buy : " + indexSelect + " : " + PlayerPrefs.GetString("Player_" + indexSelect)); } if (sfxButton != null) { AudioSource.PlayClipAtPoint(sfxButton, transform.position); } } } if (players [indexSelect].isUnLock == true) { guiLabelPrice.guiText.enabled = false; if (indexSelect == selecCorrect) { GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnOnSelect.rect.x, btnOnSelect.rect.y), new Vector2(btnOnSelect.rect.width, btnOnSelect.rect.height)), "", guiStyleBtnOnSelect); } else { if (GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnSelect.rect.x, btnSelect.rect.y), new Vector2(btnSelect.rect.width, btnSelect.rect.height)), "", guiStyleBtnSelect)) { selecCorrect = indexSelect; PlayerPrefs.SetInt("SelectPlayer", selecCorrect); if (sfxButton != null) { AudioSource.PlayClipAtPoint(sfxButton, transform.position); } } } } if (GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnArrowLeft.rect.x, btnArrowLeft.rect.y), new Vector2(btnArrowLeft.rect.width, btnArrowLeft.rect.height)), "", guiStyleBtnArrowLeft)) { indexSelect++; if (indexSelect >= players.Length - 1) { indexSelect = players.Length - 1; } if (sfxButton != null) { AudioSource.PlayClipAtPoint(sfxButton, transform.position); } } if (GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnArrowRight.rect.x, btnArrowRight.rect.y), new Vector2(btnArrowRight.rect.width, btnArrowRight.rect.height)), "", guiStyleBtnArrowRight)) { indexSelect--; if (indexSelect <= 0) { indexSelect = 0; } if (sfxButton != null) { AudioSource.PlayClipAtPoint(sfxButton, transform.position); } } if (GUI.Button(GUI_Calculate.RectWithScrren_WidthAndHeight_Sizeheight(new Vector2(btnBack.rect.x, btnBack.rect.y), new Vector2(btnBack.rect.width, btnBack.rect.height)), "", guiStyleBtnBack)) { PlayerPrefs.SetInt("SelectPlayer", selecCorrect); Application.LoadLevel("001"); if (sfxButton != null) { AudioSource.PlayClipAtPoint(sfxButton, transform.position); } } }