View on Asset Store (opens in new tab)
Package details
- Latest version
- 1.0
- Last updated
- First released
- Unity version
- 2022.3.19 or later
- Package size
- 9 KB
- Files
- 6
- Favorites
- 3
- Views in the past week
- 4
Price tracking
- Last checked
- Tracked since
- Lowest recorded
- Free on
Keywords
ShowOnly Attribute
Make fields in the Unity Inspector visible but not editable — perfect for debugging and monitoring values without accidentally changing them.
Affiliate link · Purchases support this site
Price history
Last 6 months
USDAsset preview
1 / 3
ShowOnly Attribute screenshot 1
About this asset
The ShowOnly Attribute is a simple and lightweight Unity tool designed to make specific fields visible in the Inspector while preventing accidental edits. By adding this attribute to any field, developers can ensure that the value is displayed for easy monitoring but remains protected from modification. It’s a great way to improve debugging clarity while keeping values safe.
From the publisher's Asset Store listing.
Technical details
Technical Details for Unity Asset Store
Name: ShowOnly Attribute
Version: 1.0
Author: T0M1
Overview
The ShowOnly Attribute is a simple Unity tool that allows you to display serialized fields in the Inspector as read-only, making it perfect for debugging or monitoring purposes without risking accidental changes.
Namespace Integration
The script uses the T0M1.ShowOnlyTool namespace, ensuring that your custom attributes and tools are well-contained, preventing any potential naming conflicts in your projects.
Features
- Attribute-Based Read-Only Fields:[ShowOnly] Attribute: Displays fields in the Inspector, visible but not editable.
[SerializeField] Attribute: Ensures private fields are visible in the Inspector while keeping data encapsulation intact.
Example Usage
An example MonoBehaviour script (ShowOnlyExample) is included to demonstrate:
- Read-Only Player Stats: Fields like currentScore and speed are set as read-only to track these values without allowing modification in the Inspector.
- Runtime Changes: The script increments currentScore and adjusts speed during runtime based on user inputs (e.g., Space key, Up/Down arrows), showcasing the ShowOnly attribute in action.
Compatibility
- Line Endings: All line endings are consistent (Unix-style), ensuring compatibility across different environments and preventing line-ending related issues in Unity.
Usage Example in the Inspector
- Attach the ShowOnlyExample script to any GameObject.
- Monitor the currentScore and speed values as they update during gameplay. These fields will be read-only in the Inspector, allowing safe debugging.
Benefits
- Enhanced Debugging: Observe important values in real-time without the risk of editing.
- Simplicity: Easy to implement by simply adding [ShowOnly] above the desired fields.
- Namespace Encapsulation: Prevents naming conflicts with other tools in your project.
Compatibility
| Unity version | Built-in | URP | HDRP | Custom |
|---|---|---|---|---|
| 2022.3.19f1 | Compatible | Compatible | Compatible | Compatible |
As listed on the Asset Store.