/// <summary> /// Copiar os teclado Virtual de outros existente (Editor) /// </summary> /// <param name="_index"></param> /// <param name="_currentIndex"></param> public void copyToUseVirtualKeyBoard(int _index, int _currentIndex) { if (listKeyBoard == null || _index == _currentIndex) { return; } StructKeyBoard _keyboard = this.listKeyBoard[_index]; GameObject _child = gameObject.transform.GetChild(0).gameObject; _keyboard.listStructKeyButton.Clear(); _keyboard.namePainel = this.listKeyBoard[_currentIndex].namePainel; _keyboard.anchored = this.listKeyBoard[_currentIndex].anchored; _keyboard.sizedelta = this.listKeyBoard[_currentIndex].sizedelta; int count = _child.transform.childCount; for (int i = 0; i < count; i++) { StrucKeyButton _keyButton = new StrucKeyButton(); _keyButton.active = _child.transform.GetChild(i).gameObject.activeSelf; _keyButton.anchored = this.listKeyBoard[_currentIndex].listStructKeyButton[i].anchored; _keyButton.sizedelta = this.listKeyBoard[_currentIndex].listStructKeyButton[i].sizedelta; _keyButton.capital = this.listKeyBoard[_currentIndex].listStructKeyButton[i].capital; _keyButton.tiny = this.listKeyBoard[_currentIndex].listStructKeyButton[i].tiny; _keyboard.listStructKeyButton.Add(_keyButton); } SaveKeyBoard(); }
/// <summary> /// Atualizar o Teclado Virtual (Editor) /// </summary> /// <param name="index"></param> public void updateVirtualKeyBoard(int index) { if (listKeyBoard == null) { Debug.Log("Não existe uma lista"); return; } StructKeyBoard _keyboard = listKeyBoard[index]; _keyboard.listStructKeyButton.Clear(); _keyboard.namePainel = nameVirtualKeyBoard; GameObject _child = gameObject.transform.GetChild(0).gameObject; _keyboard.anchored = _child.GetComponent <RectTransform>().anchoredPosition; _keyboard.sizedelta = _child.GetComponent <RectTransform>().sizeDelta; int count = _child.transform.childCount; for (int i = 0; i < count; i++) { StrucKeyButton _keyButton = new StrucKeyButton(); _keyButton.active = _child.transform.GetChild(i).gameObject.activeSelf; _keyButton.anchored = _child.transform.GetChild(i).gameObject.GetComponent <RectTransform>().anchoredPosition; _keyButton.sizedelta = _child.transform.GetChild(i).gameObject.GetComponent <RectTransform>().sizeDelta; _keyButton.capital = _child.transform.GetChild(i).gameObject.GetComponent <VirtualKeyBoardBehaviour>().capital; _keyButton.tiny = _child.transform.GetChild(i).gameObject.GetComponent <VirtualKeyBoardBehaviour>().tiny; _keyboard.listStructKeyButton.Add(_keyButton); } SaveKeyBoard(); }
/// <summary> /// Salvar um Teclado Virtual novo criado no Editor (EDITOR) /// </summary> public void saveVirtualKeyBoard() { ///Verifica se a lista é nula if (listKeyBoard == null) { /// Inicializa a lista this.listKeyBoard = new List <StructKeyBoard>(); } ///Cria um objeto keyboard StructKeyBoard _keyboard = new StructKeyBoard(); ///Inicializa a lista das configurações do botão _keyboard.listStructKeyButton = new List <StrucKeyButton>(); ///Atribui o nome do Teclado _keyboard.namePainel = nameVirtualKeyBoard; ///Pega a referencia do Filho(que contem a estrutura do teclado) GameObject _child = gameObject.transform.GetChild(0).gameObject; ///Salva as configurações das valores anchored do painel ///Salva asw connfigurações dos valores do sizedelta do painel _keyboard.anchored = _child.GetComponent <RectTransform>().anchoredPosition; _keyboard.sizedelta = _child.GetComponent <RectTransform>().sizeDelta; ///Pega a quantidade de filhos int count = _child.transform.childCount; ///Cria um laço de repetição para percorrer todos os filhos existentes dentro do Teclado virtual for (int i = 0; i < count; i++) { ///Cria um objeto botão StrucKeyButton _keyButton = new StrucKeyButton(); ///Salva o estado do botão "i" (Ligado/Desligado). _keyButton.active = _child.transform.GetChild(i).gameObject.activeSelf; ///Salva as configurações dos valores do Anchored do botão. _keyButton.anchored = _child.transform.GetChild(i).gameObject.GetComponent <RectTransform>().anchoredPosition; ///Salva as configurações dos valores do sizedelta do botão. _keyButton.sizedelta = _child.transform.GetChild(i).gameObject.GetComponent <RectTransform>().sizeDelta; ///Salva as informações do texto MAIUSCULO que tem configura no botão (VirtualKeyboardBehaviour) _keyButton.capital = _child.transform.GetChild(i).gameObject.GetComponent <VirtualKeyBoardBehaviour>().capital; ///Salva as informações do texto MINUSCULO que tem configura no botão (VirtualKeyboardBehaviour) _keyButton.tiny = _child.transform.GetChild(i).gameObject.GetComponent <VirtualKeyBoardBehaviour>().tiny; ///Salva o botão em uma lista de copnfigurações de botões _keyboard.listStructKeyButton.Add(_keyButton); } ///Adiciona o este teclado virtual criado detro da lista de teclados criados ///Salva o teclado virtual dentro do Json this.listKeyBoard.Add(_keyboard); SaveKeyBoard(); }
/// <summary> /// Método responsavel por setar o uso do teclado de acordo com o index passado dos teclados configurados /// </summary> /// <param name="_index"></param> public bool useVirtualKeyBoard(int _index) { ///Verifica se o teclado está disativado ou se o index está dentro dos parametros if (!this.gameObject.transform.GetChild(0).gameObject.activeSelf || _index < 0 || _index > this.listKeyBoard.Count) { return(false); } ///Pega a referencia GameObject _painel = gameObject.transform.GetChild(0).gameObject; StructKeyBoard _keyBoard = listKeyBoard[_index]; this.nameVirtualKeyBoard = _keyBoard.namePainel; RectTransform _painelRectTransform = _painel.transform.GetComponent <RectTransform>(); _painelRectTransform.anchoredPosition = _keyBoard.anchored; _painelRectTransform.sizeDelta = _keyBoard.sizedelta; for (int i = 0; i < _keyBoard.listStructKeyButton.Count; i++) { RectTransform _rectTransform = _painel.transform.GetChild(i).GetComponent <RectTransform>(); VirtualKeyBoardBehaviour _virtual = _painel.transform.GetChild(i).GetComponent <VirtualKeyBoardBehaviour>(); _rectTransform.gameObject.SetActive(_keyBoard.listStructKeyButton[i].active); if (_rectTransform.gameObject.activeSelf) { _rectTransform.anchoredPosition = _keyBoard.listStructKeyButton[i].anchored; _rectTransform.sizeDelta = _keyBoard.listStructKeyButton[i].sizedelta; _virtual.capital = _keyBoard.listStructKeyButton[i].capital; _virtual.tiny = _keyBoard.listStructKeyButton[i].tiny; } _virtual.HandleChargeCapsLock(false); } return(true); }