Example #1
0
        private void OnEnable()
        {
            List <EEInteractableItem.Args> items = new List <EEInteractableItem.Args>();

            for (int i = 0; i < 100; i++)
            {
                int rand = Random.Range(0, 10000);

                items.Add(new EEInteractableItem.Args()
                {
                    ItemLabel = new SLabel()
                    {
                        Id = $"{rand}", ReadableName = $"CoolItem{rand}", ToolTip = $"Amazing tooltip {rand}"
                    },
                    ButtonLabels = new SLabel[]
                    {
                        new SLabel()
                        {
                            Id = "on", ReadableName = $"On", ToolTip = $"Button ooon"
                        },
                        new SLabel()
                        {
                            Id = "off", ReadableName = $"Off", ToolTip = $"Button oooof"
                        },
                    }
                });
            }

            _list = new EEInteractableList(
                new SLabel()
            {
                Id = "List", ReadableName = "List Example", ToolTip = "This is a list example"
            },
                items.ToArray()
                );

            _list.OnItemInteraction += _list_OnItemInteraction;
        }
Example #2
0
        public void Render_Basic()
        {
            //Render dropdown containing namespaces
            EditorGUILayout.BeginHorizontal();
            _assembliesDropdown.Render_Basic();
            _namespaceDropdown?.Render_Basic();
            EditorGUILayout.EndHorizontal();

            // is assembly changed, render that assemblies namespaces
            if (_assemblyRendering != _assembliesDropdown.Selected.ReadableName)
            {
                // Get the assembly selected
                _assemblySelected = _assembliesDropdown.Selected.Element as Assembly;
                if (_assemblySelected != null && _assemblyMap[_assemblySelected] == null)
                {
                    LoadAssemblyTypes(_assemblySelected, _namespaceLevels, _filter);
                }

                _namespaceDropdown = new EEDropdown(
                    _assemblyMap[_assemblySelected].Namespaces.Select(
                        n => new EEDropdown.SElement()
                {
                    ReadableName = n.Namespace.SeparatorLevelPrune('.', _namespaceLevels)
                }
                        ).ToArray()
                    );

                _assemblyRendering = _assemblySelected.GetName().Name;
            }

            // if the namespace changes, get the new types
            if (_namespaceDropdown != null && _namespaceRendering != _namespaceDropdown.Selected.ReadableName)
            {
                string selectedNamespace = _namespaceDropdown.Selected.ReadableName;
                Type[] types             = _assemblyMap[_assemblySelected].Namespaces.FirstOrDefault(n => n.Namespace == selectedNamespace)?.Types;

                EEInteractableItem.Args[] args = types.Select(
                    t => new EEInteractableItem.Args()
                {
                    ItemLabel = new SLabel()
                    {
                        ReadableName = t.Name, Id = t.Name
                    },
                    ButtonLabels = new SLabel[]
                    {
                        new SLabel {
                            ReadableName = "Select", Id = "select"
                        }
                    }
                }
                    ).OrderBy(a => a.ItemLabel.ReadableName).ToArray();

                _list = new EEInteractableList(new SLabel()
                {
                    ReadableName = "Types"
                }, args);
                _list.OnItemInteraction += OnItemInteraction;

                _namespaceRendering = selectedNamespace;
            }

            _list.Render_Basic(300);
        }