public void Initialize(ProposalElement proposal, AutoCompletionWindow autoCompleteWindow) { this.autoCompleteWindow = autoCompleteWindow; this.proposalElement = proposal; proposalOutput.text = proposal.simple; }
public void ApplyCurrentProposal() { if (currentProposal != null && currentSelectedElementID < currentProposal.proposalElements.Count) { ProposalElement currentProposalElement = currentProposal.proposalElements[currentSelectedElementID]; ApplyProposal(currentProposalElement); } }
void SpawnItem(ProposalElement proposal) { GameObject proposalItemGO = Instantiate(proposalItemPrefab) as GameObject; proposalItemGO.transform.SetParent(proposalItemContainer, false); AutoCompletionProposalItem proposalItem = proposalItemGO.GetComponent <AutoCompletionProposalItem>(); proposalItem.Initialize(proposal, this); proposalItems.Add(proposalItem); }
/// <summary> /// Adds the selected proposal to the input field. /// </summary> /// <param name="proposalElement"></param> public void ApplyProposal(ProposalElement proposalElement) { if (currentProposal == null) { return; } ClearItems(); currentSelectedElementID = 0; try { string beginning = consoleInput.text.Substring(0, currentProposal.replaceStringStart); string end = consoleInput.text.Substring(currentProposal.replaceStringEnd, consoleInput.text.Length - currentProposal.replaceStringEnd); consoleInput.text = beginning + proposalElement.full + end; consoleInput.caretPosition = currentProposal.replaceStringStart + proposalElement.full.Length; } catch (Exception e) { Debug.Log("Problem with autocompletion:"); Debug.LogException(e); currentProposal = null; } }