public override void RefreshUIForValue()
        {
            if (!Owner.HasEvaluated)
            {
                GetDefaultLabel();
                m_baseLabel.text = DefaultLabel;
                return;
            }

            m_valueInput.gameObject.SetActive(true);

            m_baseLabel.text  = UISyntaxHighlight.ParseFullSyntax(FallbackType, false);
            m_valueInput.text = Value.ToString();

            if (Owner.CanWrite)
            {
                if (!m_applyBtn.gameObject.activeSelf)
                {
                    m_applyBtn.gameObject.SetActive(true);
                }
            }

            if (!m_valueInput.gameObject.activeSelf)
            {
                m_valueInput.gameObject.SetActive(true);
            }
        }
Пример #2
0
        internal void AddGenericArgRow(int i, GameObject parent)
        {
            var arg = GenericArgs[i];

            string constrainTxt = "";

            if (this.GenericConstraints[i].Length > 0)
            {
                foreach (var constraint in this.GenericConstraints[i])
                {
                    if (constrainTxt != "")
                    {
                        constrainTxt += ", ";
                    }

                    constrainTxt += $"{UISyntaxHighlight.ParseFullSyntax(constraint, false)}";
                }
            }
            else
            {
                constrainTxt = $"Any";
            }

            var rowObj    = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
            var rowLayout = rowObj.AddComponent <LayoutElement>();

            rowLayout.minHeight     = 25;
            rowLayout.flexibleWidth = 5000;
            var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>();

            rowGroup.childForceExpandHeight = true;
            rowGroup.spacing = 4;

            var argLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
            //var argLayout = argLabelObj.AddComponent<LayoutElement>();
            //argLayout.minWidth = 20;
            var argText = argLabelObj.GetComponent <Text>();

            argText.text = $"{constrainTxt} <color={UISyntaxHighlight.Enum}>{arg.Name}</color>";

            var argInputObj    = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
            var argInputLayout = argInputObj.AddComponent <LayoutElement>();

            argInputLayout.flexibleWidth = 1200;

            var argInput = argInputObj.GetComponent <InputField>();

            argInput.onValueChanged.AddListener((string val) => { m_genericArgInput[i] = val; });

            //var constraintLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
            //var constraintLayout = constraintLabelObj.AddComponent<LayoutElement>();
            //constraintLayout.minWidth = 60;
            //constraintLayout.flexibleWidth = 100;
            //var constraintText = constraintLabelObj.GetComponent<Text>();
            //constraintText.text = ;
        }
Пример #3
0
        public override void RefreshUIForValue()
        {
            base.RefreshUIForValue();

            if (this.SubIValue == null)
            {
                m_baseLabel.gameObject.SetActive(true);
                m_baseLabel.text = $"<i><color=grey>not editing</color></i> ({UISyntaxHighlight.ParseFullSyntax(ElementType, false)})";
            }
            else
            {
                m_baseLabel.gameObject.SetActive(false);
                SubIValue.RefreshUIForValue();
            }

            UpdateCreateDestroyBtnState();
        }
Пример #4
0
        internal void AddArgRow(int i, GameObject parent)
        {
            var arg = m_arguments[i];

            var rowObj    = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
            var rowLayout = rowObj.AddComponent <LayoutElement>();

            rowLayout.minHeight     = 25;
            rowLayout.flexibleWidth = 5000;
            var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>();

            rowGroup.childForceExpandHeight = false;
            rowGroup.childForceExpandWidth  = true;
            rowGroup.spacing = 4;

            var argLabelObj    = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
            var argLabelLayout = argLabelObj.AddComponent <LayoutElement>();

            argLabelLayout.minHeight = 25;
            var argText    = argLabelObj.GetComponent <Text>();
            var argTypeTxt = UISyntaxHighlight.ParseFullSyntax(arg.ParameterType, false);

            argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.Local}>{arg.Name}</color>";

            var argInputObj    = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
            var argInputLayout = argInputObj.AddComponent <LayoutElement>();

            argInputLayout.flexibleWidth  = 1200;
            argInputLayout.preferredWidth = 150;
            argInputLayout.minWidth       = 20;
            argInputLayout.minHeight      = 25;
            argInputLayout.flexibleHeight = 0;
            //argInputLayout.layoutPriority = 2;

            var argInput = argInputObj.GetComponent <InputField>();

            argInput.onValueChanged.AddListener((string val) => { m_argumentInput[i] = val; });

            if (arg.IsOptional)
            {
                var phInput = argInput.placeholder.GetComponent <Text>();
                phInput.text = " = " + arg.DefaultValue?.ToString() ?? "null";
            }
        }
Пример #5
0
        internal void AddSLPackTemplateButton(ContentTemplate template)
        {
            var rowObj    = UIFactory.CreateHorizontalGroup(m_pageContent, new Color(0.15f, 0.15f, 0.15f));
            var rowLayout = rowObj.AddComponent <LayoutElement>();

            rowLayout.minHeight = 25;
            var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>();

            rowGroup.childForceExpandWidth  = false;
            rowGroup.childForceExpandHeight = true;
            rowGroup.spacing = 5;
            rowGroup.padding = new RectOffset(2, 2, 2, 2);

            var labelObj  = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
            var labelText = labelObj.GetComponent <Text>();

            labelText.text = $"{template.SerializedFilename} ({UISyntaxHighlight.ParseFullSyntax(template.GetType(), false)})";
            var labelLayout = labelObj.AddComponent <LayoutElement>();

            labelLayout.flexibleWidth = 9999;

            var inspectBtnObj = UIFactory.CreateButton(rowObj, new Color(0.1f, 0.3f, 0.1f));
            var inspectLayout = inspectBtnObj.AddComponent <LayoutElement>();

            inspectLayout.minWidth      = 60;
            inspectLayout.flexibleWidth = 0;
            var inspectText = inspectBtnObj.GetComponentInChildren <Text>();

            inspectText.text = "Edit";
            var inspectBtn = inspectBtnObj.GetComponent <Button>();

            var refTemplate = template;

            inspectBtn.onClick.AddListener(() =>
            {
                if (m_currentPack == null)
                {
                    SL.LogWarning("Trying to inspect an SL Pack template, but current pack is null!");
                    return;
                }

                InspectorManager.Instance.Inspect(refTemplate, m_currentPack);
            });
        }
Пример #6
0
        public override void RefreshUIForValue()
        {
            if (!Owner.HasEvaluated)
            {
                GetDefaultLabel();
                m_baseLabel.text = DefaultLabel;
                return;
            }

            m_baseLabel.text  = UISyntaxHighlight.ParseFullSyntax(FallbackType, false);
            m_valueInput.text = Value.ToString();

            var type = Value.GetType();

            if (type == typeof(float) ||
                type == typeof(double) ||
                type == typeof(decimal))
            {
                m_valueInput.characterValidation = InputField.CharacterValidation.Decimal;
            }
            else
            {
                m_valueInput.characterValidation = InputField.CharacterValidation.Integer;
            }

            if (Owner.CanWrite)
            {
                if (!m_applyBtn.gameObject.activeSelf)
                {
                    m_applyBtn.gameObject.SetActive(true);
                }
            }

            if (!m_valueInput.gameObject.activeSelf)
            {
                m_valueInput.gameObject.SetActive(true);
            }
        }
Пример #7
0
        public override void ConstructUI(GameObject parent, GameObject subGroup)
        {
            base.ConstructUI(parent, subGroup);

            GetDefaultLabel(false);
            m_richValueType = UISyntaxHighlight.ParseFullSyntax(FallbackType, false);

            m_labelLayout = m_baseLabel.gameObject.GetComponent <LayoutElement>();

            var readonlyInputObj = UIFactory.CreateLabel(m_valueContent, TextAnchor.MiddleLeft);

            m_readonlyInput = readonlyInputObj.GetComponent <Text>();
            m_readonlyInput.horizontalOverflow = HorizontalWrapMode.Overflow;

            var testFitter = readonlyInputObj.AddComponent <ContentSizeFitter>();

            testFitter.verticalFit = ContentSizeFitter.FitMode.MinSize;

            var labelLayout = readonlyInputObj.AddComponent <LayoutElement>();

            labelLayout.minHeight       = 25;
            labelLayout.preferredHeight = 25;
            labelLayout.flexibleHeight  = 0;
        }
        public override void ConstructUI(GameObject parent, GameObject subGroup)
        {
            base.ConstructUI(parent, subGroup);

            GetDefaultLabel(false);
            m_richValueType = UISyntaxHighlight.ParseFullSyntax(FallbackType, false);

            m_labelLayout = m_baseLabel.gameObject.GetComponent <LayoutElement>();

            var groupObj = UIFactory.CreateHorizontalGroup(m_valueContent, new Color(1, 1, 1, 0));
            var group    = groupObj.GetComponent <HorizontalLayoutGroup>();

            group.spacing        = 4;
            group.padding.top    = 3;
            group.padding.left   = 3;
            group.padding.right  = 3;
            group.padding.bottom = 3;
            m_stringGroupObj     = groupObj;

            m_hiddenObj = UIFactory.CreateLabel(groupObj, TextAnchor.MiddleLeft);
            m_hiddenObj.SetActive(false);
            var hiddenText = m_hiddenObj.GetComponent <Text>();

            hiddenText.color           = Color.clear;
            hiddenText.fontSize        = 14;
            hiddenText.raycastTarget   = false;
            hiddenText.supportRichText = false;
            var hiddenFitter = m_hiddenObj.AddComponent <ContentSizeFitter>();

            hiddenFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
            var hiddenLayout = m_hiddenObj.AddComponent <LayoutElement>();

            hiddenLayout.minHeight      = 25;
            hiddenLayout.flexibleHeight = 500;
            hiddenLayout.minWidth       = 125;
            hiddenLayout.flexibleWidth  = 9000;
            var hiddenGroup = m_hiddenObj.AddComponent <HorizontalLayoutGroup>();

            hiddenGroup.childForceExpandWidth  = true;
            hiddenGroup.childControlWidth      = true;
            hiddenGroup.childForceExpandHeight = true;
            hiddenGroup.childControlHeight     = true;

            var inputObj    = UIFactory.CreateInputField(m_hiddenObj, 14, 3);
            var inputLayout = inputObj.AddComponent <LayoutElement>();

            inputLayout.minWidth       = 120;
            inputLayout.minHeight      = 25;
            inputLayout.flexibleWidth  = 5000;
            inputLayout.flexibleHeight = 5000;

            m_valueInput          = inputObj.GetComponent <InputField>();
            m_valueInput.lineType = InputField.LineType.MultiLineNewline;

            m_placeholderText = m_valueInput.placeholder.GetComponent <Text>();

            m_placeholderText.supportRichText          = false;
            m_valueInput.textComponent.supportRichText = false;

            m_valueInput.onValueChanged.AddListener((string val) =>
            {
                hiddenText.text = val ?? "";
                LayoutRebuilder.ForceRebuildLayoutImmediate(Owner.m_mainRect);
            });

            if (Owner.CanWrite)
            {
                var applyBtnObj = UIFactory.CreateButton(groupObj, new Color(0.2f, 0.2f, 0.2f));
                var applyLayout = applyBtnObj.AddComponent <LayoutElement>();
                applyLayout.minWidth      = 50;
                applyLayout.minHeight     = 25;
                applyLayout.flexibleWidth = 0;

                var applyBtn = applyBtnObj.GetComponent <Button>();
                applyBtn.onClick.AddListener(OnApplyClicked);

                var applyText = applyBtnObj.GetComponentInChildren <Text>();
                applyText.text = "Apply";
            }
            else
            {
                m_valueInput.readOnly = true;
            }

            m_createDestroyBtn?.transform.SetAsLastSibling();

            RefreshUIForValue();
        }
Пример #9
0
 private string GetRichTextName()
 {
     return(m_richTextName = UISyntaxHighlight.ParseFullSyntax(MemInfo.DeclaringType, false, MemInfo));
 }
Пример #10
0
        internal void RefreshComponentList()
        {
            var go = GameObjectInspector.ActiveInstance.TargetGO;

            s_allComps = go.GetComponents <Component>().ToArray();

            var components = s_allComps;

            s_compListPageHandler.ListCount = components.Length;

            //int startIndex = m_sceneListPageHandler.StartIndex;

            int newCount = 0;

            foreach (var itemIndex in s_compListPageHandler)
            {
                newCount++;

                // normalized index starting from 0
                var i = itemIndex - s_compListPageHandler.StartIndex;

                if (itemIndex >= components.Length)
                {
                    if (i > s_lastCompCount || i >= s_compListTexts.Count)
                    {
                        break;
                    }

                    GameObject label = s_compListTexts[i].transform.parent.parent.gameObject;
                    if (label.activeSelf)
                    {
                        label.SetActive(false);
                    }
                }
                else
                {
                    Component comp = components[itemIndex];

                    if (!comp)
                    {
                        continue;
                    }

                    if (i >= s_compShortlist.Count)
                    {
                        s_compShortlist.Add(comp);
                        AddCompListButton();
                    }
                    else
                    {
                        s_compShortlist[i] = comp;
                    }

                    var text = s_compListTexts[i];

                    text.text = UISyntaxHighlight.ParseFullSyntax(ReflectionHelpers.GetActualType(comp), true);

                    var toggle = s_compToggles[i];
#if CPP
                    if (comp.TryCast <Behaviour>() is Behaviour behaviour)
#else
                    if (comp is Behaviour behaviour)
#endif
                    {
                        if (!toggle.gameObject.activeSelf)
                        {
                            toggle.gameObject.SetActive(true);
                        }

                        toggle.isOn = behaviour.enabled;
                    }
                    else
                    {
                        if (toggle.gameObject.activeSelf)
                        {
                            toggle.gameObject.SetActive(false);
                        }
                    }

                    var label = text.transform.parent.parent.gameObject;
                    if (!label.activeSelf)
                    {
                        label.SetActive(true);
                    }
                }
            }

            s_lastCompCount = newCount;
        }
Пример #11
0
        // Updating result list content

        private void RefreshResultList()
        {
            m_resultListPageHandler.ListCount = m_results.Length;

            int newCount = 0;

            foreach (var itemIndex in m_resultListPageHandler)
            {
                newCount++;

                // normalized index starting from 0
                var i = itemIndex - m_resultListPageHandler.StartIndex;

                if (itemIndex >= m_results.Length)
                {
                    if (i > m_lastCount || i >= m_resultListTexts.Count)
                    {
                        break;
                    }

                    GameObject label = m_resultListTexts[i].transform.parent.parent.gameObject;
                    if (label.activeSelf)
                    {
                        label.SetActive(false);
                    }
                }
                else
                {
                    var obj      = m_results[itemIndex];
                    var unityObj = obj as UnityEngine.Object;

                    if (obj == null || (unityObj != null && !unityObj))
                    {
                        continue;
                    }

                    if (i >= m_resultShortList.Count)
                    {
                        m_resultShortList.Add(obj);
                        AddResultButton();
                    }
                    else
                    {
                        m_resultShortList[i] = obj;
                    }

                    var text = m_resultListTexts[i];

                    if (m_context != SearchContext.StaticClass)
                    {
                        var name = UISyntaxHighlight.ParseFullSyntax(obj.GetActualType(), true);

                        if (unityObj && m_context != SearchContext.Singleton)
                        {
                            if (unityObj && !string.IsNullOrEmpty(unityObj.name))
                            {
                                name += $": {unityObj.name}";
                            }
                            else
                            {
                                name += ": <i><color=grey>untitled</color></i>";
                            }
                        }

                        text.text = name;
                    }
                    else
                    {
                        var type = obj as Type;
                        text.text = UISyntaxHighlight.ParseFullSyntax(type, true);
                    }

                    var label = text.transform.parent.parent.gameObject;
                    if (!label.activeSelf)
                    {
                        label.SetActive(true);
                    }
                }
            }

            m_lastCount = newCount;
        }