示例#1
0
        public override void OnInspectorGUI()
        {
            var group = (ISelectionGroup)target;
            var scope = group.Scope;
            var query = group.Query;

            base.OnInspectorGUI();
            if (group.Query != query)
            {
                SelectionGroupManager.ExecuteQuery(group);
            }
            if (group.Scope != scope)
            {
                SelectionGroupManager.ChangeGroupScope(group, group.Scope);
            }
        }
        void ShowGroupContextMenu(Rect rect, string groupName, ISelectionGroup group)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Select All"), false, () =>
            {
                Selection.objects = activeSelectionGroup.Members.ToArray();
                UpdateActiveSelection();
            });
            menu.AddSeparator(string.Empty);
            menu.AddItem(new GUIContent("Clear Group"), false, () =>
            {
                group.Clear();
            });
            menu.AddItem(new GUIContent("Configure Group"), false, () => SelectionGroupConfigurationDialog.Open(group, this));
            if (!string.IsNullOrEmpty(group.Query))
            {
                menu.AddItem(new GUIContent("Update Query Results"), false, () => SelectionGroupManager.ExecuteQuery(group));
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Update Query Results"), false);
            }
            if (group.Scope == SelectionGroupDataLocation.Editor)
            {
                menu.AddItem(new GUIContent("Move to Scene"), false, () =>
                {
                    SelectionGroupManager.ChangeGroupScope(group, SelectionGroupDataLocation.Scene);
                });
            }
            else
            {
                menu.AddItem(new GUIContent("Move to Editor"), false, () =>
                {
                    SelectionGroupManager.ChangeGroupScope(group, SelectionGroupDataLocation.Editor);
                });
            }

            menu.AddItem(new GUIContent("Delete Group"), false, () =>
            {
                SelectionGroupManager.Delete(group);
            });
            menu.DropDown(rect);
        }