private void AddTemplate(ConObject command) { ConsoleAutoCompletionController controller = Instantiate(template, template.parent).GetComponent <ConsoleAutoCompletionController>(); currentControllers.Add(controller); topMoreCommands.transform.SetAsFirstSibling(); bottomMoreCommands.transform.SetAsLastSibling(); controller.Setup(command); }
public void Setup(ConObject command) { if (command == null) { Destroy(gameObject); return; } this.command = command; image = GetComponent <Image>(); Deselect(); string parametersString = ""; if (command is ConCommand) { foreach (var param in ((ConCommand)command).MethodInfo.GetParameters()) { if (param.HasDefaultValue) { parametersString += $"<{param.Name} : {param.ParameterType.Name} = {param.DefaultValue}> "; } else { parametersString += $"<{param.Name} : {param.ParameterType.Name}> "; } } } else { string type; if (((ConVar)command).PropertyInfo != null) { type = ((ConVar)command).PropertyInfo.PropertyType.Name; } else { type = ((ConVar)command).FieldInfo.FieldType.Name; } parametersString += $": {type}"; } commandName.text = $"{command.GetName()} {parametersString}"; commandDescription.text = command.GetDescription(); gameObject.SetActive(true); }