Example #1
0
    void AddTag(ReTag tag)
    {
        _property.InsertArrayElementAtIndex(_property.arraySize);

        var subProp = _property.GetArrayElementAtIndex(_property.arraySize - 1);

        subProp.objectReferenceValue = tag;
    }
Example #2
0
    void AddDropdown(Rect buttonRect, ReorderableList list)
    {
        var tagsDropdown = new GenericMenu();

        for (int i = 0; i < tags.Count; i++)
        {
            var tag = tags[i];
            tagsDropdown.AddItem(new GUIContent(tagMenuPaths[i]), false, () => toAdd = tag);
        }

        tagsDropdown.ShowAsContext();
    }
Example #3
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        property.serializedObject.Update();
        if (!tagsSetup)
        {
            SetupTags();
        }

        Rect labelRect = new Rect(position.position,
                                  new Vector2(position.width * 0.5f, EditorGUIUtility.singleLineHeight));

        Rect toggleRect = new Rect(labelRect);

        toggleRect.position += new Vector2(position.width * 0.5f, EditorGUIUtility.singleLineHeight);

        Rect listRect = new Rect(position);

        listRect.height   -= EditorGUIUtility.singleLineHeight * 2f;
        listRect.position += new Vector2(0f, EditorGUIUtility.singleLineHeight * 1f);

        EditorGUI.LabelField(labelRect, label);
        _list.DoList(listRect);
        EditorGUI.PropertyField(toggleRect, property.FindPropertyRelative(nameof(ReMultiTag.RequireAll)));

        HandleDragAndDrop();

        if (toRemove != -1)
        {
            _property.DeleteArrayElementAtIndex(toRemove);
            _property.DeleteArrayElementAtIndex(toRemove);
            toRemove = -1;
        }

        if (toAdd != null)
        {
            AddTag(toAdd);
            toAdd = null;
        }

        property.serializedObject.ApplyModifiedProperties();
    }
Example #4
0
 public bool RemoveTag(ReTag tag) => cachedTags.Remove(tag.GetTag);
Example #5
0
 public bool SetTag(ReTag tag) => cachedTags.Add(tag.GetTag);
Example #6
0
 public bool HasTag(ReTag tag) => cachedTags.Contains(tag.GetTag);
Example #7
0
 public static bool SetTag(this GameObject target, ReTag tag)
 {
     return(target.SetTag(tag.GetTag));
 }
Example #8
0
 public static bool HasTag(this MonoBehaviour target, ReTag tag)
 {
     return(target.HasTag(tag.GetTag));
 }