Esempio n. 1
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);
            });
        }