Пример #1
0
    private void DrawTagSelection(Constraint constraint, TagTarget target)
    {
        EditorGUILayout.BeginHorizontal();
        constraint.RawTags = EditorGUILayout.TextField("Containing tag(s)", constraint.RawTags);
        if (GUILayout.Button(constraint.TagMethod.ToString(), GUILayout.Width(32)))
        {
            constraint.ToggleTagMethod();
        }
        GUI.SetNextControlName("PlusButton");
        if (GUILayout.Button("+", GUILayout.Width(20)))
        {
            GUI.FocusControl("PlusButton");
            List <string> userTags    = new List <string>();
            string[]      allUserTags = ChunkTags.GlobalUserTags(target);
            //Filtering all tags that are already used
            allUserTags.ToList()
            .Where(s => !constraint.ParsedTags.Contains(s)).ToList()
            .ForEach(s => userTags.Add(s));

            TagContextMenu(userTags, constraint);
            //selectedTag = EditorGUILayout.GetControlRect(selectedTag, userTags);
            //constraint.RawTags += ";" + userTags[selectedTag];
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.LabelField(" ", "(Separated by semicolons)");
    }
Пример #2
0
    //Returns a list of all user defined tags without duplicates
    public static string[] GlobalUserTags(TagTarget _target)
    {
        string            path           = _target == TagTarget.CHUNK ? GlobalPaths.RelativeChunkPath : GlobalPaths.RelativeHallwayPath;
        List <string>     globalUserTags = new List <string> ();
        List <GameObject> chunks         = Resources.LoadAll <GameObject> (path).ToList();
        List <ChunkTags>  chunkTags      = new List <ChunkTags> ();

        chunks.Where(c => c.GetComponentInChildren <ChunkTags> () != null)
        .ToList()
        .ForEach(c => chunkTags.Add(c.GetComponentInChildren <ChunkTags> ()));

        chunkTags.SelectMany(ct => ct.userGenerated)
        .Where(t => !globalUserTags.Contains(t.Name))
        .ToList()
        .ForEach(t => globalUserTags.Add(t.Name));

        return(globalUserTags.ToArray());
    }