void AddTag(ReTag tag) { _property.InsertArrayElementAtIndex(_property.arraySize); var subProp = _property.GetArrayElementAtIndex(_property.arraySize - 1); subProp.objectReferenceValue = tag; }
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(); }
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(); }
public bool RemoveTag(ReTag tag) => cachedTags.Remove(tag.GetTag);
public bool SetTag(ReTag tag) => cachedTags.Add(tag.GetTag);
public bool HasTag(ReTag tag) => cachedTags.Contains(tag.GetTag);
public static bool SetTag(this GameObject target, ReTag tag) { return(target.SetTag(tag.GetTag)); }
public static bool HasTag(this MonoBehaviour target, ReTag tag) { return(target.HasTag(tag.GetTag)); }