示例#1
0
        /// <summary>
        /// Adds the items to opening view menu.
        /// </summary>
        /// <param name="menu">
        /// [in,out] The menu. </param>
        /// <param name="inspector"> The inspector for which the menu is opening. </param>
        /// <param name="addScriptFieldItem"> Should we add item for script field visibility? </param>
        public static void AddFieldVisibilityItems(ref Menu menu, IInspector inspector, bool addScriptFieldItem)
        {
            menu.AddSeparatorIfNotRedundant();

            var settings = inspector.Preferences;

            if (addScriptFieldItem)
            {
                menu.Add("Script Field/Hide", () => { settings.drawScriptReferenceFields = false; inspector.ForceRebuildDrawers(); }, !settings.drawScriptReferenceFields);
                menu.Add("Script Field/Show", () => { settings.drawScriptReferenceFields = true; inspector.ForceRebuildDrawers(); }, settings.drawScriptReferenceFields);
            }

            menu.Add("Field Visibility/Serialized Only", "Only display fields that Unity can serialize by default. Attributes such as EditorBrowsable can still be used to expose any fields individually.", ShowFieldsSerializedOnly, inspector, settings.showFields == FieldVisibility.SerializedOnly);
            menu.Add("Field Visibility/All Public", "Display all public fields even if Unity can't serialize them by default. Attributes such as HideInInspector can still be used to hide any fields individually.", ShowFieldsAllPublic, inspector, settings.showFields == FieldVisibility.AllPublic);
            menu.Add("Field Visibility/All Except Hidden", "Display all public and private fields by default. Attributes such as HideInInspector can still be used to hide any fields individually.", ShowFieldsAllExceptHidden, inspector, settings.showFields == FieldVisibility.AllExceptHidden);

            menu.Add("Property Visibility/Attribute-Exposed Only", "Only show properties explicitly exposed with Attributes like EditorBrowsable, Browsable(true), SerializeField or ShowInInspector", ShowPropertiesAttributeExposedOnly, inspector, settings.showProperties == PropertyVisibility.AttributeExposedOnly);
            menu.Add("Property Visibility/Auto-Generated Public", "All public auto-generated properties will also be shown, unless explicitly hidden with Attributes like HideInInspector or NonSerialized. All other properties can also explicitly be marked to be shown with Attributes like EditorBrowsable, Browsable(true), SerializeField or ShowInInspector.", ShowPropertiesPublicAutoGenerated, inspector, settings.showProperties == PropertyVisibility.PublicAutoGenerated);
            menu.Add("Property Visibility/All Public", "All public properties will be shown by default, unless explicitly hidden with Attributes like HideInInspector or NonSerialized.", ShowPropertiesAllPublic, inspector, settings.showProperties == PropertyVisibility.AllPublic);

            menu.Add("Method Visibility/Attribute-Exposed Only", "Only show methods explicitly exposed with Attributes like EditorBrowsable, Browsable(true), SerializeField or ShowInInspector", ShowMethodsAttributeExposedOnly, inspector, settings.showMethods == MethodVisibility.AttributeExposedOnly);
            menu.Add("Method Visibility/Context Menu", "All methods that have the ContextMenu attribute will also be shown, unless explicitly hidden with Attributes like HideInInspector. All other methods can also explicitly be marked to be shown with Attributes like EditorBrowsable, Browsable(true), or ShowInInspector.", ShowMethodsContextMenu, inspector, settings.showMethods == MethodVisibility.ContextMenu);
            menu.Add("Method Visibility/All Public", "All public methods will be shown by default, unless explicitly hidden with Attributes like HideInInspector.", ShowMethodsAllPublic, inspector, settings.showMethods == MethodVisibility.AllPublic);
        }