Esempio n. 1
0
        void ToStringAndCompressVariable(IScriptType variable, string s, int maxChars, out string text, out Color color)
        {
            switch (variable)
            {
            case IScriptBoolean _:
                color = boolText;
                text  = CompressString(s, maxChars);
                break;

            case IScriptInteger _:
            case IScriptDouble _:
                color = numberText;
                text  = CompressString(s, maxChars, isNumberValue: true);
                break;

            case IScriptString _:
                color = stringText;
                text  = CompressString(s, maxChars, isStringValue: true);
                break;

            case ScriptNull _:
                color = nullText;
                text  = variable.ToString();
                break;

            default:
                color = nullText;
                text  = IDEColorCoding.RunColorCode(CompressString(s, maxChars));
                break;
            }
        }
        public void InitTextFields()
        {
            preText.text = IDEColorCoding.runColorCode(preCode);

            float preHeight = CalcAndSetPreCode();

            inputRect.anchoredPosition = new Vector2(inputRect.anchoredPosition.x, startYPos - preHeight);
        }
        public void SetMessageContent(string header, string body)
        {
            string[] all_splits = Regex.Split(body, @"(<code>[\s\S]+?<\/code>)").Where(s => s != string.Empty).ToArray();

            for (int i = 0; i < all_splits.Length; i++)
            {
                string str = all_splits[i];

                GameObject prefab;

                if (str.StartsWith("<code>") && str.EndsWith("</code>"))
                {
                    str    = str.Substring(6, str.Length - 13);
                    str    = IDEColorCoding.runColorCode(str);
                    prefab = codePrefab;
                }
                else
                {
                    prefab = rawTextPrefab;
                }

                // Remove 1 newline at end and start
                if (str[str.Length - 1] == '\n')
                {
                    str = str.Substring(0, str.Length - 1);
                }
                if (str.Length > 0 && str[0] == '\n')
                {
                    str = str.Substring(1, str.Length - 1);
                }
                if (str.Length == 0)
                {
                    continue;
                }

                GameObject clone = Instantiate(prefab, prefab.transform.parent);
                clone.SetActive(true);
                clone.GetComponentInChildren <Text>().text = str;
            }

            theHeaderText.text = header;
            ResizeToFit(theBodyGroup, bubbleRect);
        }
 /// <summary>Updates main code syntax highlighting and size of rects (for scrolling)</summary>
 public void ColorCodeDaCode()
 {
     visibleText.text           = IDEColorCoding.runColorCode(theInputField.text);
     inputRect.sizeDelta        = new Vector2(inputRect.sizeDelta.x, visibleText.preferredHeight + 6);
     contentContainer.sizeDelta = new Vector2(contentContainer.sizeDelta.x, inputRect.sizeDelta.y - inputRect.anchoredPosition.y);
 }