123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace SC.XR.Unity.Module_Keyboard
- {
- public class SCKeyboard2DMono : SCKeyboardMono
- {
- #region Initialize
- public override void Initialize(SCKeyboardType keyboardType = SCKeyboardType.Default)
- {
- base.Initialize(keyboardType);
- InitializePromptWords();
- Keyboard2DPrompt.isOpen = false;
- }
- protected override void DefaultKeyboardInitialize()
- {
- switch (SCKeyboard.currentSystemLanguage)
- {
- case KeyboardSystemLanguage.Chinese:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.Cn);
- break;
- default:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.En);
- break;
- }
- ActiveKeyboard(KeyboardEnum.Delete);
- ActiveKeyboard(KeyboardEnum.Number);
- }
- protected override void ASCIICapableKeyboardInitialize()
- {
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.En);
- ActiveKeyboard(KeyboardEnum.Delete);
- ActiveKeyboard(KeyboardEnum.Number);
- }
- protected override void URLKeyboardInitialize()
- {
- switch (SCKeyboard.currentSystemLanguage)
- {
- case KeyboardSystemLanguage.Chinese:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.Cn);
- break;
- default:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.En);
- break;
- }
- ActiveKeyboard(KeyboardEnum.Delete);
- ActiveKeyboard(KeyboardEnum.Number);
- ActiveKeyboard(KeyboardEnum.Prompt);
- }
- protected override void SearchKeyboardInitialize()
- {
- switch (SCKeyboard.currentSystemLanguage)
- {
- case KeyboardSystemLanguage.Chinese:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.Cn);
- break;
- default:
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.En);
- break;
- }
- ActiveKeyboard(KeyboardEnum.Delete);
- ActiveKeyboard(KeyboardEnum.Number);
- }
- #endregion
- #region Keyboards
- protected SCKeyboard2DPrompt Keyboard2DPrompt
- {
- get
- {
- return keyboard_prompt as SCKeyboard2DPrompt;
- }
- }
- public GameObject keyboard_symbol;
- public GameObject keyboard_meme;
- public GameObject keyboard_morePrompt;
- public GameObject keyboard_language;
- public GameObject keyboard_delete;
- public GameObject keyboard_num;
- #endregion
- #region Key Clicks
- public override void OnNumberKeyClick(string value)
- {
- if (preInputStringBuilder.Length != 0)
- {
- OnPinyinKeyClick(value);
- }
- else
- {
- base.OnNumberKeyClick(value);
- }
- }
- public override void OnPinyinKeyClick(string value)
- {
- chinesePagesDic = new Dictionary<int, Dictionary<int, Dictionary<int, string>>>();
- preInputStringBuilder.Append(value);
- ActiveKeyboard(KeyboardEnum.Prompt);
- Keyboard2DPrompt.SetEnteredText(preInputStringBuilder.ToString());
- PinyinKeyHandler(preInputStringBuilder.ToString());
- }
- public override void OnPromptKeyClick(string value)
- {
- base.OnPromptKeyClick(value);
- InitializePromptWords();
- }
- #endregion
- #region Special Key Click Events
- public override void OnDeleteClick()
- {
- if (keyboard_prompt.isActiveAndEnabled)
- {
- if (preInputStringBuilder.Length == 0)
- {
- OnWebKeyClick?.Invoke("Backspace");
- OnDeleteKeyClick?.Invoke();
- return;
- }
- preInputStringBuilder.Remove(preInputStringBuilder.Length - 1, 1);
- Keyboard2DPrompt.SetEnteredText(preInputStringBuilder.ToString());
- if (preInputStringBuilder.Length == 0)
- {
- InitializePromptWords();
- return;
- }
- PinyinKeyHandler(preInputStringBuilder.ToString());
- }
- else
- {
- OnWebKeyClick?.Invoke("Backspace");
- OnDeleteKeyClick?.Invoke();
- }
- }
- public override void OnEnterClick()
- {
- OnKeyClick?.Invoke(preInputStringBuilder.ToString());
- for (int i = 0; i < preInputStringBuilder.Length; i++)
- {
- OnWebKeyClick?.Invoke(preInputStringBuilder[i].ToString());
- }
- base.OnEnterClick();
- OnEnterKeyClick?.Invoke();
- }
- public override void OnLanguageClick()
- {
- base.OnLanguageClick();
- InitializePromptWords();
- }
- public override void OnCnClick()
- {
- base.OnCnClick();
- InitializePromptWords();
- //HideKeyboardPrompt();
- }
- public override void OnEnClick()
- {
- base.OnEnClick();
- InitializePromptWords();
- // HideKeyboardPrompt();
- }
- private int currentPage = 1;
- private int minPage = 1;
- private int maxPage = 10000;
- public override void OnPromptPageDownClick()
- {
- currentPage++;
- if (currentPage > maxPage)
- {
- currentPage = maxPage;
- }
- GenerateChinesePages(currentPage);
- }
- public override void OnPromptPageUpClick()
- {
- currentPage--;
- if (currentPage < minPage)
- {
- currentPage = minPage;
- }
- GenerateChinesePages(currentPage);
- }
- #endregion
- #region UGUI Key Click Events
- protected override void OnOpenMoreClick()
- {
- if (!Keyboard2DPrompt.isOpen)
- {
- if (preInputStringBuilder.Length != 0)
- {
- Keyboard2DPrompt.isOpen = true;
- ActiveKeyboard(KeyboardEnum.MorePrompt);
- GenerateChinesePages(1);
- }
- //GenerateMorePromptKeys(1);
- LayoutRebuilder.ForceRebuildLayoutImmediate(keyboard_morePrompt.transform.GetChild(0).GetChild(0).transform as RectTransform);
- }
- else
- {
- Keyboard2DPrompt.isOpen = false;
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.Cn);
- }
- }
- #endregion
- #region Key Handlers
- private Text m_font;
- private RectTransform m_PromptPage;
- private RectTransform m_MorePromptPage;
- public Text Font
- {
- get
- {
- if (m_font == null)
- {
- m_font = Resources.Load<SCKeyboard2DKey>(keyPath).GetComponentInChildren<Text>();
- }
- return m_font;
- }
- }
- public RectTransform PromptPage
- {
- get
- {
- if (m_PromptPage == null)
- {
- m_PromptPage = Keyboard2DPrompt.promptInput;
- }
- return m_PromptPage;
- }
- }
- public RectTransform MorePromptPage
- {
- get
- {
- if (m_MorePromptPage == null)
- {
- m_MorePromptPage = keyboard_morePrompt.transform.GetChild(0).GetChild(0).GetComponent<RectTransform>();
- }
- return m_MorePromptPage;
- }
- }
-
- private int maxChineseWordCount;
- private static int currentChineseWordIndex = 0;
- public virtual void GenerateURLPages(int page = 0)
- {
- Keyboard2DPrompt.alreadyInput.gameObject.transform.parent.parent.gameObject.SetActive(false); //隐藏AlreadyInput
- Keyboard2DPrompt.promptInput.sizeDelta = new Vector2(484.88f, Keyboard2DPrompt.promptInput.sizeDelta.y); //拉长promptRow长度
- GenerateURLKeys();
- }
- public virtual void GenerateChinesePages(int page)
- {
- Keyboard2DPrompt.alreadyInput.gameObject.transform.parent.parent.gameObject.SetActive(true); //显示AlreadyInput
- Keyboard2DPrompt.promptInput.sizeDelta = new Vector2(268.88f, Keyboard2DPrompt.promptInput.sizeDelta.y); //缩短promptRow长度
- if (chinesePagesDic.ContainsKey(page))
- {
- if (page == 0)
- {
- HideAllPromptPages();
- foreach (int row in chinesePagesDic[page].Keys)
- {
- foreach (int word in chinesePagesDic[page][row].Keys)
- {
- SCKeyboardBaseKey key = promptPagesDic[0][row][word];
- string text = chinesePagesDic[page][row][word];
- key.Value = text;
- key.gameObject.SetActive(true);
- }
- }
- }
- else
- {
- HidePromptPage(1);
- foreach (int row in chinesePagesDic[page].Keys)
- {
- foreach (int word in chinesePagesDic[page][row].Keys)
- {
- SCKeyboardBaseKey key = promptPagesDic[1][row][word];
- string text = chinesePagesDic[page][row][word];
- key.Value = text;
- key.gameObject.SetActive(true);
- }
- }
- }
- StartCoroutine(RebuildLayout(PromptPage));
- }
- else
- {
- // Prompte Keys
- if (page == 0)
- {
- GenerateChineseKeys();
- }
- // More Prompt Keys
- else
- {
- GenerateMoreChineseKeys(page);
- }
- }
- }
- private void GenerateChineseKeys()
- {
- maxPage = 10000;
- HideAllPromptPages();
- maxChineseWordCount = Keyboard2DPrompt.GetChinese(preInputStringBuilder.ToString());
- currentChineseWordIndex = 0;
- GenerateChineseKeys(0, PromptPage, new List<string>());
- StartCoroutine(RebuildLayout(PromptPage));
- }
- private void GenerateURLKeys()
- {
- HideAllPromptPages();
- GenerateURLKeys(0, PromptPage, new List<string>());
- StartCoroutine(RebuildLayout(PromptPage));
- }
- private void GenerateMoreChineseKeys(int pageIndex = 1)
- {
- HidePromptPage(1);
- if (pageIndex < 1) pageIndex = 1;
- GenerateMoreChineseKeys(0, 0, pageIndex, new List<string>());
- StartCoroutine(RebuildLayout(MorePromptPage));
- }
- private void GenerateChineseKeys(int keyIndex, RectTransform promptRow, List<string> messages)
- {
- if (currentChineseWordIndex > maxChineseWordCount - 1)
- {
- return;
- }
- if (!promptPagesDic.ContainsKey(0)) promptPagesDic[0] = new Dictionary<int, Dictionary<int, SCKeyboardBaseKey>>();
- if (!promptPagesDic[0].ContainsKey(0)) promptPagesDic[0][0] = new Dictionary<int, SCKeyboardBaseKey>();
- if (!chinesePagesDic.ContainsKey(0)) chinesePagesDic[0] = new Dictionary<int, Dictionary<int, string>>();
- if (!chinesePagesDic[0].ContainsKey(0)) chinesePagesDic[0][0] = new Dictionary<int, string>();
- SCKeyboard2DKey promptKey;
-
- string text = Keyboard2DPrompt.GetChinese(currentChineseWordIndex);
- if (promptPagesDic[0][0].ContainsKey(keyIndex))
- {
- promptKey = promptPagesDic[0][0][keyIndex] as SCKeyboard2DKey;
- promptKey.Value = text;
- promptKey.GetComponentInChildren<ContentSizeFitter>().enabled = true; //改回来
- messages.Add(promptKey.Value);
- if (!WithinTheLimits(messages, promptRow.GetComponent<HorizontalLayoutGroup>(), promptRow.sizeDelta.x))
- {
- promptKey.gameObject.SetActive(false);
- return;
- }
- promptKey.gameObject.SetActive(true);
- chinesePagesDic[0][0][keyIndex] = text;
- }
- else
- {
- promptKey = InstantiateKey(keyPath, promptRow, text);
- messages.Add(promptKey.Value);
- promptPagesDic[0][0][keyIndex] = promptKey;
- if (!WithinTheLimits(messages, promptRow.GetComponent<HorizontalLayoutGroup>(), promptRow.sizeDelta.x))
- {
- promptKey.gameObject.SetActive(false);
- return;
- }
- promptKey.gameObject.SetActive(true);
- chinesePagesDic[0][0][keyIndex] = text;
- }
- //Debug.Log("promptKey [ " + promptKey.Value + " ] :" + currentChineseWordIndex);
- currentChineseWordIndex++;
- GenerateChineseKeys(keyIndex + 1, promptRow, messages);
- }
- private void GenerateURLKeys(int keyIndex, RectTransform promptRow, List<string> messages)
- {
- if (!promptPagesDic.ContainsKey(0)) promptPagesDic[0] = new Dictionary<int, Dictionary<int, SCKeyboardBaseKey>>();
- if (!promptPagesDic[0].ContainsKey(0)) promptPagesDic[0][0] = new Dictionary<int, SCKeyboardBaseKey>();
- if (urlPagesDic[0][0].ContainsKey(keyIndex))
- {
- SCKeyboard2DKey promptKey;
- string text = urlPagesDic[0][0][keyIndex];
- if (promptPagesDic[0][0].ContainsKey(keyIndex))
- {
- promptKey = promptPagesDic[0][0][keyIndex] as SCKeyboard2DKey;
- }
- else
- {
- promptKey = InstantiateKey(keyPath, promptRow, text);
- promptPagesDic[0][0][keyIndex] = promptKey;
- }
- promptKey.Value = text;
- promptKey.GetComponentInChildren<ContentSizeFitter>().enabled = false; //更改promptKey
- promptKey.GetComponentInChildren<Text>().GetComponent<RectTransform>().sizeDelta = new Vector2(1000f, 240f); //更改promptKey
- messages.Add(promptKey.Value);
- if (!WithinTheLimits(messages, promptRow.GetComponent<HorizontalLayoutGroup>(), promptRow.sizeDelta.x))
- {
- promptKey.gameObject.SetActive(false);
- return;
- }
- promptKey.gameObject.SetActive(true);
- //Debug.Log("URLKey [ " + promptKey.Value + " ] :" + keyIndex);
- GenerateURLKeys(keyIndex + 1, promptRow, messages);
- }
- }
- private void GenerateMoreChineseKeys(int keyIndex, int rowIndex, int pageIndex, List<string> messages)
- {
- if (currentChineseWordIndex > maxChineseWordCount - 1)
- {
- maxPage = currentPage;
- return;
- }
- if (rowIndex > 4)
- {
- return;
- }
- SCKeyboard2DKey promptKey;
- RectTransform promptRow;
- if (promptRowRectTransformsDic.ContainsKey(rowIndex)) promptRow = promptRowRectTransformsDic[rowIndex];
- else promptRowRectTransformsDic.Add(rowIndex, promptRow = InstantiateRow(rowPath, MorePromptPage));
- string text = Keyboard2DPrompt.GetChinese(currentChineseWordIndex);
- if (!promptPagesDic.ContainsKey(1)) promptPagesDic[1] = new Dictionary<int, Dictionary<int, SCKeyboardBaseKey>>();
- if (!promptPagesDic[1].ContainsKey(rowIndex)) promptPagesDic[1][rowIndex] = new Dictionary<int, SCKeyboardBaseKey>();
- if (!chinesePagesDic.ContainsKey(pageIndex)) chinesePagesDic[pageIndex] = new Dictionary<int, Dictionary<int, string>>();
- if (!chinesePagesDic[pageIndex].ContainsKey(rowIndex)) chinesePagesDic[pageIndex][rowIndex] = new Dictionary<int, string>();
- if (promptPagesDic[1][rowIndex].ContainsKey(keyIndex))
- {
- promptKey = promptPagesDic[1][rowIndex][keyIndex] as SCKeyboard2DKey;
- promptKey.Value = text;
- messages.Add(promptKey.Value);
- if (!WithinTheLimits(messages, promptRow.GetComponent<HorizontalLayoutGroup>(), 443f))
- {
- promptKey.gameObject.SetActive(false);
- GenerateMoreChineseKeys(0, rowIndex + 1, pageIndex, new List<string>());
- return;
- }
- promptKey.gameObject.SetActive(true);
- chinesePagesDic[pageIndex][rowIndex][keyIndex] = text;
- }
- else
- {
- promptKey = InstantiateKey(keyPath, promptRow, text);
- messages.Add(promptKey.Value);
- promptPagesDic[1][rowIndex].Add(keyIndex, promptKey);
- if (!WithinTheLimits(messages, promptRow.GetComponent<HorizontalLayoutGroup>(), 443f))
- {
- promptKey.gameObject.SetActive(false);
- GenerateMoreChineseKeys(0, rowIndex + 1, pageIndex, new List<string>());
- return;
- }
- promptKey.gameObject.SetActive(true);
- chinesePagesDic[pageIndex][rowIndex][keyIndex] = text;
- }
- //Debug.Log("promptKey [ " + promptKey.Value + " ] :" + currentChineseWordIndex);
- currentChineseWordIndex++;
- GenerateMoreChineseKeys(keyIndex + 1, rowIndex, pageIndex, messages);
- }
- private void HidePromptPage(int page)
- {
- if (promptPagesDic.ContainsKey(page))
- {
- foreach (var rowIndex in promptPagesDic[page].Keys)
- {
- foreach (var keyIndex in promptPagesDic[page][rowIndex].Keys)
- {
- promptPagesDic[page][rowIndex][keyIndex].gameObject.SetActive(false);
- }
- }
- }
- }
- private void HideAllPromptPages()
- {
- HidePromptPage(0);
- HidePromptPage(1);
- }
- IEnumerator RebuildLayout(RectTransform rect)
- {
- yield return new WaitForEndOfFrame();
- LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
- }
- public override void PinyinKeyHandler(string preInput)
- {
- chinesePagesDic = new Dictionary<int, Dictionary<int, Dictionary<int, string>>>();
- if (keyboard_morePrompt.activeSelf == false)
- {
- GenerateChinesePages(0);
- }
- else
- {
- GenerateChinesePages(0);
- GenerateChinesePages(1);
- }
- }
- private SCKeyboard2DKey InstantiateKey(string path, Transform parent, string value)
- {
- SCKeyboard2DKey prefab = Resources.Load<SCKeyboard2DKey>(path);
- SCKeyboard2DKey promptKey = GameObject.Instantiate(prefab);
- promptKey.transform.SetParent(parent);
- promptKey.transform.localPosition = Vector3.zero;
- promptKey.transform.localRotation = Quaternion.identity;
- promptKey.transform.localScale = Vector3.one;
- promptKey.Value = value;
- return promptKey;
- }
- private RectTransform InstantiateRow(string path, Transform parent)
- {
- GameObject prefab = Resources.Load<GameObject>(path);
- GameObject promptRow = GameObject.Instantiate(prefab);
- promptRow.transform.SetParent(parent);
- promptRow.transform.localPosition = Vector3.zero;
- promptRow.transform.localRotation = Quaternion.identity;
- promptRow.transform.localScale = Vector3.one;
- return promptRow.GetComponent<RectTransform>();
- }
-
- private bool WithinTheLimits(List<string> messages, HorizontalLayoutGroup group, float LimitWidth)
- {
- float rectWidth = LimitWidth;
- float totalWidth = 0;
- float left = group.padding.left;
- float right = group.padding.right;
- float space = group.spacing;
- float width = 0;
- int wordCount = messages.Count;
- string message = "";
- for (int i = 0; i < messages.Count; i++)
- {
- message += messages[i];
- width += 12;
- }
- width += KeyboardUtils.CaculateTextLength(message, Font) / 10;
- totalWidth = (wordCount - 1) * space + left + width;
- return totalWidth <= rectWidth;
- }
- #endregion
- #region ActiveKeyboards
- protected override void ActiveKeyboard(KeyboardEnum keyboardEnum, KeyboardState keyboardState = KeyboardState.Cn)
- {
- base.ActiveKeyboard(keyboardEnum, keyboardState);
- switch (keyboardEnum)
- {
- case KeyboardEnum.ABC:
- OnActiveABCKeyboard(keyboardState);
- switch (presentKeyboardType)
- {
- case SCKeyboardType.Default:
- case SCKeyboardType.ASCIICapable:
- case SCKeyboardType.Search:
- break;
- case SCKeyboardType.URL:
- ActiveKeyboard(KeyboardEnum.Prompt);
- break;
- }
- break;
- case KeyboardEnum.Symbol:
- OnActiveSymbolKeyboard();
- break;
- case KeyboardEnum.Number:
- OnActiveNumberKeyboard();
- break;
- case KeyboardEnum.Meme:
- OnActiveMemeKeyboard();
- break;
- case KeyboardEnum.Prompt:
- OnActivePromptKeyboard();
- break;
- case KeyboardEnum.MorePrompt:
- OnActiveMorePromptKeyboard();
- break;
- case KeyboardEnum.Language:
- OnActiveLanguageKeyboard();
- break;
- case KeyboardEnum.Delete:
- OnActiveDeleteKeyboard();
- break;
- }
- }
- protected override void HideKeyboardPrompt(bool inputPreString = false)
- {
- if (keyboard_prompt.isActiveAndEnabled)
- {
- switch (presentKeyboardType)
- {
- case SCKeyboardType.URL:
- break;
- default:
- //if (inputPreString) OnNormalKeyClick(preInputStringBuilder.ToString());
- preInputStringBuilder.Clear();
- Keyboard2DPrompt.gameObject.SetActive(false);
- ChangePromptOpenBtnState(true);
- break;
- }
- }
- }
- protected void ChangePromptOpenBtnState(bool isOpen)
- {
- Keyboard2DPrompt.open.gameObject.SetActive(isOpen);
- Keyboard2DPrompt.close.gameObject.SetActive(!isOpen);
- }
- public void OnActiveABCKeyboard(KeyboardState keyboardState)
- {
- if (presentKeyboard != null)
- previousKeyboard = presentKeyboard;
- keyboard_abc.SetActive(true);
- presentKeyboard = keyboard_abc;
- if (previousKeyboard != null && previousKeyboard != presentKeyboard)
- previousKeyboard.SetActive(false);
- presentKeyboardState = keyboardState;
- OnKeyboardStateChange?.Invoke(keyboardState);
- }
- public void OnActiveSymbolKeyboard()
- {
- if (presentKeyboard != null)
- previousKeyboard = presentKeyboard;
- keyboard_symbol.SetActive(true);
- HideKeyboardPrompt();
- presentKeyboard = keyboard_symbol;
- if (previousKeyboard != null && previousKeyboard != presentKeyboard)
- previousKeyboard.SetActive(false);
- }
- public void OnActiveNumberKeyboard()
- {
- keyboard_num.SetActive(true);
- }
- public void OnActiveMemeKeyboard()
- {
- keyboard_meme.SetActive(true);
- }
- public void OnActivePromptKeyboard()
- {
- keyboard_prompt.gameObject.SetActive(true);
- }
- public void OnActiveMorePromptKeyboard()
- {
- if (presentKeyboard != null)
- previousKeyboard = presentKeyboard;
- keyboard_morePrompt.gameObject.SetActive(true);
- presentKeyboard = keyboard_morePrompt;
- if (previousKeyboard != null && previousKeyboard != presentKeyboard)
- previousKeyboard.SetActive(false);
- }
- public void OnActiveLanguageKeyboard()
- {
- if (presentKeyboard != null)
- previousKeyboard = presentKeyboard;
- keyboard_language.SetActive(true);
- HideKeyboardPrompt();
- presentKeyboard = keyboard_language;
- if (previousKeyboard != null && previousKeyboard != presentKeyboard)
- previousKeyboard.SetActive(false);
- }
- public void OnActiveDeleteKeyboard()
- {
- keyboard_delete.SetActive(true);
- }
- #endregion
- #region Methods
- private void InitializePromptWords()
- {
- HideAllPromptPages();
- switch (presentKeyboardType)
- {
- case SCKeyboardType.Default:
- case SCKeyboardType.Search:
- case SCKeyboardType.ASCIICapable:
- preInputStringBuilder.Clear();
- Keyboard2DPrompt.SetEnteredText("");
- Keyboard2DPrompt.gameObject.SetActive(false);
- break;
- case SCKeyboardType.URL:
- preInputStringBuilder.Clear();
- Keyboard2DPrompt.SetEnteredText("");
- if (!urlPagesDic.ContainsKey(0)) urlPagesDic[0] = new Dictionary<int, Dictionary<int, string>>();
- if (!urlPagesDic[0].ContainsKey(0)) urlPagesDic[0][0] = new Dictionary<int, string>();
- for (int i = 0; i < Keyboard2DPrompt.URLWords.Count; i++)
- {
- urlPagesDic[0][0][i] = Keyboard2DPrompt.URLWords[i];
- }
- //urlPagesDic[0][0][0] = "http://";
- //urlPagesDic[0][0][1] = "www.";
- //urlPagesDic[0][0][2] = ".com";
- //urlPagesDic[0][0][3] = "@";
- GenerateURLPages();
- break;
- }
- if (keyboard_morePrompt.gameObject.activeSelf)
- {
- keyboard_morePrompt.gameObject.SetActive(false);
- Keyboard2DPrompt.isOpen = false;
- ActiveKeyboard(KeyboardEnum.ABC, KeyboardState.Cn);
- }
- }
- #endregion
- #region Extend Methods
- #endregion
- }
- }
|