// Use this for initialization void Start() { playerDataArray = new List <PlayerStruct> (); P1Field = GameObject.Find("P1").GetComponent <InputField>(); P2Field = GameObject.Find("P2").GetComponent <InputField>(); P3Field = GameObject.Find("P3").GetComponent <InputField>(); P4Field = GameObject.Find("P4").GetComponent <InputField>(); //if (!isClient) { roomName = tempName; } P1Field.text = playerOneField; P2Field.text = playerTwoField; P3Field.text = playerThreeField; P4Field.text = playerFourField; P1Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure1.selected; P2Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure2.selected; P3Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure3.selected; P4Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure4.selected; }
public void CheckPassword(bool eventFromButton) { if (Input.GetButtonDown("Submit") || eventFromButton) { if (pwField.text.Equals(correctPassword)) { pwField.transform.parent.Find("User Label").GetComponent <Text>().text = welcomeText; pwField.gameObject.SetActive(false); Delayed(5f, () => { pwField.GetComponentInParent <Canvas>().enabled = false; filesCanvas.enabled = true; }); OnPuzzleSolved(System.EventArgs.Empty); } else { errorLabel.enabled = true; Delayed(3f, () => { errorLabel.enabled = false; if (!pwField.isFocused) { pwField.text = ""; } pwField.Select(); pwField.ActivateInputField(); }); Debug.Log("wrong pass"); } } }
public void SetBDData(InputField name) { // bdData = name.text; bdData = name.GetComponentInParent <HostSetup>().selectedBoard + " " + name.GetComponentInParent <HostSetup>().roomName + " " + name.GetComponentInParent <HostSetup>().selectedCoinsPerRoom.ToString(); //print ("This is bd data :" + bdData); if (NetworkTest.isLAN) { broadcastData = bdData; } else { print("this is online data " + bdData); if (InternetChecker.internetConnectBool) { LobbyManager.tempName = bdData; } } }
// Use this for initialization void Start() { //print("From lobby : " + SelectPlayField.whichBoard); if (!isServer) { CoinManager.DeductCoins(JoinAmount); CoinManager.justDeductedCoins = JoinAmount; } playerDataArray = new List <PlayerStruct> (); P1Field = GameObject.Find("P1").GetComponent <InputField>(); P2Field = GameObject.Find("P2").GetComponent <InputField>(); P3Field = GameObject.Find("P3").GetComponent <InputField>(); P4Field = GameObject.Find("P4").GetComponent <InputField>(); //if (!isClient) { roomName = tempName; } P1Field.text = playerOneField; P2Field.text = playerTwoField; P3Field.text = playerThreeField; P4Field.text = playerFourField; P1Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure1.selected; P2Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure2.selected; P3Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure3.selected; P4Field.GetComponentInParent <GameDataHolder>().isSelected = playerStructure4.selected; GameObject.Find("AudioManager").GetComponent <LudoLoader>().LevelLoadScreen = loadingScreen; //Display which board was chosen in the lobby scene if (!isServer) { BoardName.text = SelectPlayField.SelectedBoardName; print("Selected board : " + SelectPlayField.SelectedBoardName.Length + "yyyy" + BoardName.text + "KKKKK"); if (SelectPlayField.SelectedBoardName == "Classic") { print("00000"); SelectedBoardImage.sprite = boardImages [0]; } else if (SelectPlayField.SelectedBoardName == "Ruins") { print("11111"); SelectedBoardImage.sprite = boardImages [1]; } } else { SelectedBoardImage.sprite = boardImages [SelectPlayField.whichBoard]; BoardName.text = boardNames[SelectPlayField.whichBoard]; } }
public void UpdateText() { if (input.text.Length > 0) { ChatText = ChatText + " > " + input.text + "\n"; input.GetComponentInParent <ProcessInput> ().processInput(input.text); input.text = ""; input.ActivateInputField(); scroll.verticalNormalizedPosition = 0f; } }
new void Start() { base.Start(); inputField = this.gameObject.GetComponentInChildren <InputField>(); startingWidth = CalculateLengthOfMessage(inputField.textComponent, inputField.text); InputRectTran = inputField.GetComponentInParent <RectTransform>(); inputRect = InputRectTran.sizeDelta; BoxRectTran = this.gameObject.GetComponentInChildren <ExtendMe>().GetComponentInParent <RectTransform>(); boxRect = BoxRectTran.sizeDelta; resizeBox(); }
private IEnumerator InitializeOnNextFrame() { yield return(null); // Doing this here gives a chance for a dynamically added input field to be instantiated and then added to the canvas hierarchy. objParentCanvas = objUnityInput.GetComponentInParent <Canvas>(); this.PrepareNativeEdit(); #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR this.CreateNativeEdit(); this.SetTextNative(this.objUnityInput.text); objUnityInput.placeholder.gameObject.SetActive(false); objUnityText.enabled = false; objUnityInput.enabled = false; #endif }
public void SaveMonsterOrder(InputField input) { var enemPlaceholder = enemiesPlaceholders.GetComponentsInChildren <InputField>(); int aux = 0; foreach (var item in enemPlaceholder) { if (item.text != "") { aux++; } } if (aux == 3) { EnableArrowForNextMonster(); } else { next.gameObject.SetActive(false); } if (input.text != "") { try { if (Int32.Parse(input.text) > 3 || Int32.Parse(input.text) < 1) { input.text = ""; StartCoroutine(EnablePopUp(input)); } else { order[input.transform.parent.name][input.GetComponentInParent <PlaceholderTier>().id].orderNumber = Int32.Parse(input.text); logs[input.transform.parent.name].logs.Add("Order assigned: " + Int32.Parse(input.text) + " to monster of tier " + input.GetComponentInParent <PlaceholderTier>().tierName); } } catch (FormatException) { StartCoroutine(EnablePopUp(input)); } } }
private float scale_position; //how far along the forward direction to place the textbox // Start is called before the first frame update void Awake() { sm = GameObject.FindGameObjectWithTag("sceneMaster").GetComponent <GravityLab2DSceneMaster>(); canvas = GameObject.FindGameObjectWithTag("canvas").GetComponent <Canvas>(); new_text = Instantiate(text_prefab); new_text.transform.SetParent(canvas.transform); //set it to the canvas new_text.transform.position = Camera.main.WorldToScreenPoint(transform.position + scale_position * transform.forward - 1.5f * transform.up); if (text_prefab.GetComponent <InputField>() != null) { input_field = new_text.GetComponent <InputField>(); input_field.GetComponentInParent <RectTransform>().localScale = new Vector3(1f, 1f, 1f); //input_field.text = "TESTING"; } else { text_field = new_text.GetComponent <Text>(); //text_field.text = "TESTING"; } scale_position = transform.root.localScale.x * 2f; sm.ShowHideVelocity(); //the show velocity toggle may be switched off, so run this from the scenemaster }
public void SaveNewChallenge() { List <string> newData = new List <string> (); newData.Add(DummyPullDataFromID.GenerateNewChallengeID()); newData.Add("false"); newData.Add("false"); string[] challengeTitleBreakdown; string rewardPoints = ""; if (newChallengeTitle.text == "" || newChallengeTitle.text == null) { ErrorInField(newChallengeTitle.GetComponentInParent <InputField> ()); return; } else { try{ String challengeTitle = newChallengeTitle.text; Char[] delimiter = new Char[] { '(', ')' }; challengeTitleBreakdown = challengeTitle.Split(delimiter, 3); newData.Add(challengeTitleBreakdown[2].Trim()); rewardPoints = challengeTitleBreakdown[1]; } catch (UnityException ex) { Debug.Log(ex); ErrorInField(newChallengeTitle.GetComponentInParent <InputField> ()); return; } } if (newSkill1.text == "" || newSkill1.text == null) { ErrorInField(newSkill1.GetComponentInParent <InputField> ()); return; } else { newData.Add(newSkill1.text); } if (newSkill2.text == "" || newSkill2.text == null) { ErrorInField(newSkill2.GetComponentInParent <InputField> ()); return; } else { newData.Add(newSkill2.text); } if (newSkill3.text == "" || newSkill3.text == null) { ErrorInField(newSkill3.GetComponentInParent <InputField> ()); return; } else { newData.Add(newSkill3.text); } if (newDescription.text == "" || newDescription.text == null) { ErrorInField(newDescription.GetComponentInParent <InputField> ()); return; } else { newData.Add(newDescription.text); } if (newChallengeDate.text == "" || newChallengeDate.text == null) { ErrorInField(newChallengeDate.GetComponentInParent <InputField> ()); return; } else { newData.Add(newChallengeDate.text); } if (newChallengeDeadline.text == "" || newChallengeDeadline.text == null) { ErrorInField(newChallengeDeadline.GetComponentInParent <InputField> ()); return; } else { newData.Add(newChallengeDeadline.text); } newData.Add(myData [1]); newData.Add(rewardPoints); newData.Add(myData [0]); if (challengeTitleBreakdown [0].Trim().ToLower() == "true") { newData.Add("true"); } else { newData.Add("false"); } DummyPullDataFromID.AddChallenge(newData.ToArray(), DummyPullDataFromID.GetTestImage()); GetComponent <OnPopupPageOpen> ().ForceExit(); }
void addSlot() { if (LoginToPortal.Instance.userIsLoggedIn) { int maxRow = saveSlots.Count - 1; int maxCol = saveSlots[maxRow].Count - 1; maxCol++; if (maxCol > 2) { maxCol = 0; maxRow++; saveSlots.Add(new List <GameObject>()); } slotObject = Instantiate(slotPrefab); float yCoord = YCOORD - (maxRow * 240); float xCoord = XCOORD + (maxCol * 220); scrollToPos = (maxRow * 238); //Stores the value to scroll to //Disables input field newSlotInput = slotObject.GetComponentInChildren <InputField>(); newSlotInput.Select(); newSlotInput.ActivateInputField(); //Scroll up or down to the row where the slot is being made //scrollContent.GetComponent<RectTransform>().anchoredPosition3D = new Vector2(0, scrollToPos); isScrolling = true; int totalElements = totalCount(); newSlotInput.text = "Slot" + totalElements; string code = GameManager.movesString.Replace("<b><color=#00ff00ff>", ""); code = code.Replace("</color></b>", ""); Text[] slotText = slotObject.GetComponentsInChildren <Text>(); slotText[1].text = ""; //This block is what saves the data newSlotInput.onEndEdit.AddListener(delegate { slotText[1].text = "<size=17>Saving...</size>"; newSlotInput.transform.gameObject.SetActive(false); Transform newSlotParent = newSlotInput.GetComponentInParent <Transform>(); newSlotParent.transform.gameObject.SetActive(false); Text title = slotObject.GetComponentInChildren <Text>(); if (newSlotInput.text == "") { title.text = "Slot" + totalElements; } else { if (newSlotInput.text.Length > 8) { title.text = newSlotInput.text.Substring(0, 6) + "..."; } else { title.text = newSlotInput.text; } } string currentPlayerEmail = PlayerPrefs.GetString("CurrentPlayer").ToLower() + "_" + SaveAndLoad.dashEmail; string codeData = "{"; codeData += "\"email\": \"" + currentPlayerEmail + "\","; codeData += "\"name\": \"" + PlayerPrefs.GetString("CurrentPlayer") + "\","; codeData += "\"title\": \"" + title.text + "\","; codeData += "\"code\": \"" + code + "\""; codeData += "}"; SaveCode.Instance.saveTommyCode(codeData); }); Button[] slotBtns = slotObject.GetComponentsInChildren <Button>(); slotBtns[0].onClick.AddListener(loadSavedCode); slotBtns[1].onClick.AddListener(deleteSlot); slotBtns[0].gameObject.SetActive(false); slotBtns[1].gameObject.SetActive(false); Text[] indices = slotBtns[0].GetComponentsInChildren <Text>(); indices[0].text = maxRow.ToString(); indices[1].text = maxCol.ToString(); indices = slotBtns[1].GetComponentsInChildren <Text>(); indices[0].text = maxRow.ToString(); indices[1].text = maxCol.ToString(); slotObject.transform.SetParent(scrollContent.transform); slotObject.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(xCoord, yCoord); saveSlots[maxRow].Add(slotObject); slotObjectQueue.Enqueue(slotObject); maxCol++; if (maxCol > 2) { maxCol = 0; maxRow++; } yCoord = YCOORD - (maxRow * 240); xCoord = XCOORD + (maxCol * 220); addSlotObject.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(xCoord, yCoord); float scrollViewHeight = scrollContent.GetComponent <RectTransform>().rect.height; float addSlotObjectYPos = addSlotObject.GetComponent <RectTransform>().anchoredPosition3D.y; float position = Math.Abs(addSlotObjectYPos) + 98; if (position >= scrollViewHeight / 2) { scrollContent.GetComponent <RectTransform>().sizeDelta = new Vector2(0, scrollViewHeight * 2.0f); } } else { STEMDashInvitePanel.SetActive(true); } }
//Use to load all slots saved void loadSlots() { if (SaveAndLoad.savedCode.ContainsKey(PlayerPrefs.GetString("CurrentPlayer"))) { if (SaveAndLoad.savedCode[PlayerPrefs.GetString("CurrentPlayer")].Count > 0) { numberOfSlots = SaveAndLoad.savedCode[PlayerPrefs.GetString("CurrentPlayer")].Count; ROWSIZE = (int)Math.Ceiling((double)(numberOfSlots + 2) / COLSIZE); } } for (int i = 0; i < ROWSIZE; i++) { float column = YCOORD - (i * 240); saveSlots.Add(new List <GameObject>()); for (int j = 0; j < COLSIZE; j++) { float row = XCOORD + (j * 220); if (i == 0 && j == 0) //Load first example { exampleOneCode.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(row, column); Button[] slotBtns = exampleOneCode.GetComponentsInChildren <Button>(); Text[] indices = slotBtns[0].GetComponentsInChildren <Text>(); indices[0].text = i.ToString(); indices[1].text = j.ToString(); slotBtns[0].onClick.AddListener(loadSavedCode); saveSlots[i].Add(exampleOneCode); } else if (i == 0 && j == 1) //Load second example { exampleTwoCode.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(row, column); Button[] slotBtns = exampleTwoCode.GetComponentsInChildren <Button>(); Text[] indices = slotBtns[0].GetComponentsInChildren <Text>(); indices[0].text = i.ToString(); indices[1].text = j.ToString(); slotBtns[0].onClick.AddListener(loadSavedCode); saveSlots[i].Add(exampleTwoCode); } else if (numberOfSlots > 0) { try { slotObject = Instantiate(slotPrefab); //Disables input field InputField newSlotInput = slotObject.GetComponentInChildren <InputField>(); newSlotInput.transform.gameObject.SetActive(false); Transform newSlotParent = newSlotInput.GetComponentInParent <Transform>(); newSlotParent.transform.gameObject.SetActive(false); Text title = slotObject.GetComponentInChildren <Text>(); int index = j + (i * COLSIZE) - 2; //This is needed to calculate the position of the locally stored data var data = JSON.Parse(SaveAndLoad.savedCode[PlayerPrefs.GetString("CurrentPlayer")][index]); //Sets the title title.text = data["title"].Value; Button[] slotBtns = slotObject.GetComponentsInChildren <Button>(); slotBtns[0].onClick.AddListener(loadSavedCode); slotBtns[1].onClick.AddListener(deleteSlot); Text[] indices = slotBtns[0].GetComponentsInChildren <Text>(); indices[0].text = i.ToString(); indices[1].text = j.ToString(); indices = slotBtns[1].GetComponentsInChildren <Text>(); indices[0].text = i.ToString(); indices[1].text = j.ToString(); //Sets the code preview Text[] slotText = slotObject.GetComponentsInChildren <Text>(); string[] slotTxtArr = data["code"].Value.Replace("...", "...\n").Split('\n'); slotText[1].text = ""; for (int k = 0; k < slotTxtArr.Length; k++) { if (k == 5) { break; } slotText[1].text += slotTxtArr[k] + "\n"; } //Sets parent and positioning slotObject.transform.SetParent(scrollContent.transform); slotObject.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(row, column); saveSlots[i].Add(slotObject); } catch (ArgumentOutOfRangeException ex) { } } } } //Reposition the add slot button int maxRow = saveSlots.Count - 1; int maxCol = saveSlots[maxRow].Count - 1; maxCol++; if (maxCol > 2) { maxCol = 0; maxRow++; } float yCoord = YCOORD - (maxRow * 240); float xCoord = XCOORD + (maxCol * 220); addSlotObject = Instantiate(addSlotPrefab); addSlotObject.transform.SetParent(scrollContent.transform); Button addSlotBtn = addSlotObject.GetComponentInChildren <Button>(); addSlotBtn.onClick.AddListener(addSlot); addSlotObject.GetComponent <RectTransform>().anchoredPosition3D = new Vector2(xCoord, yCoord); float scrollViewHeight = scrollContent.GetComponent <RectTransform>().rect.height; float addSlotObjectYPos = addSlotObject.GetComponent <RectTransform>().anchoredPosition3D.y; float position = Math.Abs(addSlotObjectYPos) + 98; //Increases the size of the scrollContent when the add button hits the bottom if (position >= scrollViewHeight) { scrollContent.GetComponent <RectTransform>().sizeDelta = new Vector2(0, scrollViewHeight * 2.0f); } }
private void DoBestFit() { _title.BestFit(); _notesField.GetComponent <LayoutElement>().preferredHeight = _notesField.GetComponentInParent <ScrollRect>().RectTransform().rect.height; }