A comprehensive collection of custom attributes to enhance Unity Inspector functionality and improve workflow. These attributes provide advanced customization options for displaying and managing properties in the Unity Editor.
- Rich set of inspector customization attributes
- Serializable dictionary implementation
- Save/Load system for game objects
- Advanced property decorators
- Method buttons and dropdowns
- Component and GameObject references
- Conditional display attributes
- Open the Package Manager in Unity (Window > Package Manager)
- Click the "+" button in the top-left corner
- Choose "Add package from git URL..."
- Enter:
https://github.com/Jahn-Star-Games/JSG-Attributes.git
Or simply copy the contents of this repository into your Unity project's Packages folder.
- Using
using JahnStarGames.Attributes;
A serializable dictionary implementation for Unity that allows you to store key-value pairs that persist in the Unity Inspector.
[SerializeField] private HeySerializableDictionary<string, int> myDictionary;
Make ScriptableObject fields expandable in the inspector.
[HeyExpandable]
[SerializeField] private ItemData itemData;
Save and load system for game objects using JSON serialization. Mark fields to be saved and loaded.
[HeySave("playerData")]
private PlayerStats stats;
// Save data
HeySave.Save("playerData");
// Load all saved data
HeySave.LoadAll();
Note: This feature is experimental and in development.
Conditionally show fields based on other property values.
[SerializeField] private bool showAdvanced;
[HeyShowIf("showAdvanced", true)]
[SerializeField] private float advancedValue;
Make fields read-only in the inspector while keeping them serialized.
[HeyReadonly("Current Health")]
[SerializeField] private float health;
Create buttons in the inspector that call specified methods.
[HeyMethodButton("Reset Stats", "Reset")]
private void ResetStats() {
// Reset logic here
}
Display help messages in the inspector with different message types and conditions.
[HeyHelpBox("Please assign a manager.", HeyHelpBoxAttribute.BoxType.Error, nameof(manager), conditionValue: null)]
[HeyObjectField(required: true, minimizeWhenNull: true)]
[SerializeField] private ManagerMono manager;
Enhanced object field with additional features like required flag and null state visualization.
[HeyObjectField(required: true, minimizeWhenNull: true)]
[SerializeField] private GameObject requiredObject;
Custom serialization for fields with support for foldouts.
[HeySerializeField("mainStats.health", "mainStats.mana")]
[SerializeField] private PlayerStats playerStats;
Customize field labels with colors and styling.
[HeyLabel("Player Speed", LabelColor.Blue, fieldBox: true)]
[SerializeField] private float moveSpeed;
Reference GameObjects by name with drag-and-drop support.
[HeyGameObjectName("Main Camera")]
[SerializeField] private string cameraObjectName;
Dropdown selection for component types.
[HeyComponentDropdown]
[SerializeField] private string selectedComponent;
Create dropdowns for method selection.
[HeyMethodDropdown("targetComponent")]
[SerializeField] private string selectedMethod;
Note: Some features are experimental and in development. Please test thoroughly before using in production.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by Halil Emre Yildiz (2023-2024)
For issues and feature requests, please use the GitHub issue tracker.