Пример #1
0
    public void UnregisterAutocompleter(AutocompleterInteractable autocompleter)
    {
        if (autocompleters.Contains(autocompleter) == false)
        {
            return;
        }

        autocompleter.OnAutoCompleterSelected.RemoveListener(OnAutoCompleterSelected);
        autocompleters.Remove(autocompleter);
    }
Пример #2
0
    public void RegisterAutocompleter(AutocompleterInteractable autocompleter)
    {
        if (autocompleters.Contains(autocompleter))
        {
            return;
        }

        autocompleter.OnAutoCompleterSelected.AddListener(OnAutoCompleterSelected);
        autocompleters.Add(autocompleter);

        int index = autocompleters.Count - 1;

        autocompleters[index].SetText(GetLevenshteinCorpus()[index]);
    }
Пример #3
0
    private void OnAutoCompleterSelected(AutocompleterInteractable autocompleter)
    {
        string        suggestedWord = autocompleter.GetText();
        List <string> inputText     = new List <string>();
        StringBuilder builder       = new StringBuilder();
        string        input         = activeInputField != null ? activeInputField.text : activeTMPInputField.text;

        string[] parts = input.Split(' ');
        parts = parts.Take(parts.Length - 1).ToArray();

        for (int i = 0; i < parts.Length; i++)
        {
            inputText.Add(parts[i]);
        }


        inputText.Add(suggestedWord);

        foreach (string w in inputText)
        {
            builder.Append(w).Append(" ");
        }


        if (activeInputField != null)
        {
            activeInputField.text = builder.ToString();
            activeInputField.ActivateInputField();
        }

        if (activeTMPInputField != null)
        {
            activeTMPInputField.text = builder.ToString();
            activeTMPInputField.ActivateInputField();
        }

        PredictNextWords(suggestedWord);
    }