private void OnClick(CommonButton btn) { if (isBusy) { return; } string key = btn.param as string; if (key == "Shift") { isShift = !isShift; RefreshKeyboard(); } else if (key == "Back") { if (outputString.Length > 0) { outputString = outputString.Substring(0, outputString.Length - 1); } } else if (key == "Return") { callbackInputFinish?.Invoke(outputString); } else { outputString += key; } }
private void AddKeyButton(Key key, Transform parentArea) { int w = key.width * width + (key.width - 1) * widthInterval; int h = key.height * height + (key.height - 1) * heightInterval; int x = startX + key.x * (width + widthInterval) + w / 2; int y = startY - key.y * (height + heightInterval) - h / 2; GameObject keyObj = Instantiate(keyPrefab) as GameObject; keyObj.name = key.text; RectTransform keyTrans = keyObj.transform as RectTransform; keyTrans.SetParent(parentArea); keyTrans.localPosition = new Vector3(x, y, 0); keyTrans.localRotation = Quaternion.identity; keyTrans.localScale = Vector3.one; CommonButton button = keyObj.GetComponent <CommonButton>(); button.ButtonName = key.text; button.SetSize(w, h); button.param = key.key; button.callbackClick = OnClick; }
private void OnExit(CommonButton btn) { callbackExit?.Invoke(); }