Example #1
0
        public void UsingsTest()
        {
            RexUsingsHandler.Save("Lol");
            Assert.IsTrue(RexUsingsHandler.Usings.Contains("Lol"));

            RexUsingsHandler.Remove("Lol");
            Assert.IsEmpty(RexUsingsHandler.Usings);
        }
        /// <summary>
        /// Displays the selection screen for Namespaces.
        /// </summary>
        private void DisplayScope()
        {
            showUsings = RexUIUtils.Toggle(showUsings, _texts["scope_header"]);

            if (showUsings)
            {
                EditorGUILayout.BeginVertical(slimBox);
                {
                    var useWidth = 25;
                    EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    EditorGUILayout.LabelField(_texts["scope_use"], GUILayout.Width(useWidth));
                    EditorGUILayout.LabelField(_texts["scope_namespace"], GUILayout.ExpandWidth(false));
                    EditorGUILayout.EndHorizontal();

                    usingScroll = EditorGUILayout.BeginScrollView(usingScroll, GUILayout.Height(1), GUILayout.MaxHeight(150));
                    {
                        var depth = 0;
                        foreach (var n in RexCompileEngine.Instance.NamespaceInfos)
                        {
                            if (n.Depth > depth)
                            {
                                continue;
                            }
                            if (n.Depth < depth)
                            {
                                depth = n.Depth;
                            }

                            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
                            {
                                for (int i = 0; i < n.Depth; i++)
                                {
                                    GUILayout.Space(25f);
                                }

                                var prev = n.Selected;
                                n.Selected = GUILayout.Toggle(n.Selected, "", GUILayout.Width(useWidth));

                                if (prev != n.Selected)
                                {
                                    if (prev)
                                    {
                                        RexUsingsHandler.Remove(n.Name);
                                    }
                                    else
                                    {
                                        RexUsingsHandler.Save(n.Name);
                                    }
                                }

                                if (n.HasSubNamespaces)
                                {
                                    EditorGUILayout.LabelField(n.Name);
                                }
                                else if (n.DisplaySubNamespaces = EditorGUILayout.Foldout(n.DisplaySubNamespaces, n.Name))
                                {
                                    depth = n.Depth + 1;
                                }
                                //EditorGUILayout.LabelField(n.Assembly.Location);
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
        }