Example #1
0
        public void UpdateList(IProcessor processor)
        {
            foreach (VariableInWindow v in currentVariables)
            {
                v.Remove();
            }

            currentVariables.Clear();

            foreach (KeyValuePair <string, IScriptType> variable in processor.CurrentScope.Variables)
            {
                VariableInWindow clone = Instantiate(variablePrefab, contentRect.transform, false);

                string valueString = variable.Value.ToString();

                float width    = CalcVariableWidth(Mathf.Max(variable.Key.Length, valueString.Length));
                int   maxChars = CalcNoCharacters(width);
                clone.SetWidth(width);

                ToStringAndCompressVariable(variable.Value, valueString, maxChars, out valueString, out Color valueColor);
                clone.InitVariable(variable.Key, nameTextColor, valueString, valueColor);

                currentVariables.Add(clone);
            }

            theWindow.SetActive(true);
        }
        public void addVariable(Variable newVariable)
        {
            if (currentVariables.Count == 0)
            {
                theWindow.SetActive(true);
            }

            VariableInWindow clone = Instantiate(variablePrefab);

            clone.transform.SetParent(contentRect.transform, false);

            float width = calcVariableWidth(newVariable);

            clone.setWidth(width);
            clone.maxChars = calcNoCharacters(width);

            clone.initVariable(newVariable);

            currentVariables.Add(clone);
        }