Ejemplo n.º 1
0
        private void SetNormalArgRows()
        {
            for (int i = 0; i < arguments.Length || i < argRows.Count; i++)
            {
                if (i >= arguments.Length)
                {
                    if (i >= argRows.Count)
                    {
                        break;
                    }
                    else
                    {
                        // exceeded actual args, but still iterating so there must be views left, disable them
                        argRows[i].SetActive(false);
                    }
                    continue;
                }

                var arg = arguments[i];


                if (i >= argRows.Count)
                {
                    AddArgRow(i, false);
                }

                argRows[i].SetActive(true);
                argLabels[i].text = $"{SignatureHighlighter.Parse(arg.ParameterType, false)} <color={SignatureHighlighter.LOCAL_ARG}>{arg.Name}</color>";
                if (arg.ParameterType == typeof(string))
                {
                    argInputFields[i].PlaceholderText.text = "";
                }
                else
                {
                    var elemType = arg.ParameterType;
                    if (elemType.IsByRef)
                    {
                        elemType = elemType.GetElementType();
                    }
                    argInputFields[i].PlaceholderText.text = $"eg. {ParseUtility.GetExampleInput(elemType)}";
                }
            }
        }
Ejemplo n.º 2
0
        public void OnBorrowed(EvaluateWidget evaluator, ParameterInfo paramInfo)
        {
            this.evaluator = evaluator;
            this.paramInfo = paramInfo;

            this.paramType = paramInfo.ParameterType;
            if (paramType.IsByRef)
            {
                paramType = paramType.GetElementType();
            }

            this.argNameLabel.text =
                $"{SignatureHighlighter.Parse(paramType, false)} <color={SignatureHighlighter.LOCAL_ARG}>{paramInfo.Name}</color>";

            if (ParseUtility.CanParse(paramType) || typeof(Type).IsAssignableFrom(paramType))
            {
                usingBasicLabel = false;

                this.inputField.Component.gameObject.SetActive(true);
                this.basicLabelHolder.SetActive(false);
                this.typeCompleter.Enabled = typeof(Type).IsAssignableFrom(paramType);
                this.enumCompleter.Enabled = paramType.IsEnum;
                this.enumHelperButton.Component.gameObject.SetActive(paramType.IsEnum);

                if (!typeCompleter.Enabled)
                {
                    if (paramType == typeof(string))
                    {
                        inputField.PlaceholderText.text = "...";
                    }
                    else
                    {
                        inputField.PlaceholderText.text = $"eg. {ParseUtility.GetExampleInput(paramType)}";
                    }
                }
                else
                {
                    inputField.PlaceholderText.text = "Enter a Type name...";
                    this.typeCompleter.BaseType     = typeof(object);
                    this.typeCompleter.CacheTypes();
                }

                if (enumCompleter.Enabled)
                {
                    enumCompleter.EnumType = paramType;
                    enumCompleter.CacheEnumValues();
                }
            }
            else
            {
                // non-parsable, and not a Type
                usingBasicLabel = true;

                this.inputField.Component.gameObject.SetActive(false);
                this.basicLabelHolder.SetActive(true);
                this.typeCompleter.Enabled = false;
                this.enumCompleter.Enabled = false;
                this.enumHelperButton.Component.gameObject.SetActive(false);

                SetDisplayedValueFromPaste();
            }
        }