VixCore Inspector Attributes¶
Namespace: VixCore.Inspector
These attributes are small editor helpers for MonoBehaviours and ScriptableObjects.
Button¶
Draws a button in the inspector that calls a parameterless method.
using UnityEngine;
using VixCore.Inspector;
public class DoorTester : MonoBehaviour
{
[Button("Open Door")]
private void OpenDoor()
{
Debug.Log("Opening door");
}
}
The method must be parameterless and non-generic. Instance and static methods are supported.
Visibility modes:
ButtonVisibility.AlwaysButtonVisibility.EditorOnlyButtonVisibility.PlayModeOnly
[Button("Respawn", ButtonVisibility.PlayModeOnly)]
private void Respawn()
{
}
InspectorButtonAttribute still exists for old code, but it is obsolete. Use ButtonAttribute for new code.
Required¶
Shows an error when a field is null or empty.
[Required("Player transform is required.")]
[SerializeField] private Transform player;
Options:
AllowEmptyStringAllowEmptyCollection
ShowIf¶
Shows a field only when a bool field, property, or parameterless method returns true.
[SerializeField] private bool useCustomSpeed;
[ShowIf(nameof(useCustomSpeed))]
[SerializeField] private float customSpeed = 5f;
Use invert: true to show the field when the condition is false.
[ShowIf(nameof(useCustomSpeed), invert: true)]
[SerializeField] private float defaultSpeed = 3f;
ShowInEditMode and ShowInPlayMode¶
Shows a field only in the matching Unity mode.
[ShowInEditMode]
[SerializeField] private string editorOnlyNote;
[ShowInPlayMode]
[SerializeField] private float runtimeHealth;
InspectorReadOnly¶
Shows a field but prevents editing.
[InspectorReadOnly]
[SerializeField] private string generatedId;
Read-only modes:
ReadOnlyMode.AlwaysReadOnlyMode.EditorOnlyReadOnlyMode.PlayModeOnly
ProgressBar¶
Draws a progress bar for a float field. The expected value range is 0 to 1.
[ProgressBar]
[SerializeField] private float healthPercent = 1f;
InlineEditor¶
Draws an inline inspector for an assigned object reference.
[InlineEditor]
[SerializeField] private ScriptableObject settings;
The optional constructor argument controls the default foldout state.
[InlineEditor(defaultExpanded: false)]
[SerializeField] private ScriptableObject settings;
InlineEditor only works on object reference fields. The inline inspector is hidden when the reference is missing or mixed across multiple selected objects.
PathPicker¶
Draws a string field with a file or folder picker button.
[PathPicker]
[SerializeField] private string inputFile;
Modes:
PathPickerMode.OpenFilePathPickerMode.SaveFilePathPickerMode.Folder
[PathPicker(PathPickerMode.OpenFile, title: "Select Config", extension: "json", relativeToProject: true)]
[SerializeField] private string configPath;
[PathPicker(PathPickerMode.SaveFile, title: "Save Report", extension: "zip", defaultName: "report")]
[SerializeField] private string reportPath;
By default, selected paths are stored as absolute paths. Set relativeToProject: true to store paths inside the project folder relative to the project root.
FolderPicker¶
Shortcut for PathPickerMode.Folder.
[FolderPicker]
[SerializeField] private string outputFolder;
[FolderPicker(relativeToProject: true)]
[SerializeField] private string projectFolder;
Password¶
Draws a string field as a masked password field.
[Password]
[SerializeField] private string apiKey;
The value is still serialized as a normal string. This is for inspector display only, not secure secret storage.