Skip to content

Releases: RimuruDev/Unity-PercentDrawer

v1.1.0

31 Aug 20:29
390d399
Compare
Choose a tag to compare

⭐Percentage Property Drawer for Unity⭐

Made With Unity License Last Commit Repo Size Downloads Last Release GitHub stars GitHub user stars

This solution includes a custom attribute PercentageAttribute and a property drawer PercentDrawer that work together
to provide a convenient way of displaying float values as percentages in the Unity Editor.

image
image

Option 1: Install via Unity Package Manager

  1. Open Unity and go to Window > Package Manager.
  2. Click the + button in the top left corner.
  3. Select Add package from git URL....
  4. Enter the following URL: https://github.com/RimuruDev/Unity-PercentDrawer.git
  5. Click Add to install the package.

Option 2: Install from Releases

  1. Go to the Releases page in this repository.
  2. Download the latest .unitypackage file.
  3. In Unity, go to Assets > Import Package > Custom Package....
  4. Select the downloaded .unitypackage file and import it into your project.

Option 3: Install from copy-past

  1. Create a folder named Editor within your project's Assets directory if it does not already exist. Unity requires
    that all editor scripts be located in a folder named Editor.
  2. Create a folder named Attributes within your Assets directory to store custom attributes.
  3. Place the PercentageAttribute.cs file inside the Attributes folder.
  4. Place the PercentDrawer.cs file inside the Editor folder.

Your folder structure should look like this:

Assets/
│
├── Editor/
│ └── PercentDrawer.cs
│
└── Attributes/
└── PercentageAttribute.cs

Usage

To use the PercentageAttribute, you first need to define it in a script file:

// PercentageAttribute.cs
using UnityEngine;

public class PercentageAttribute : PropertyAttribute {}

Then, apply the [Percentage] attribute to any float field in your MonoBehaviour or ScriptableObject classes:

// SomeScript.cs
using UnityEngine;

public class SomeScript : MonoBehaviour
{
    [Percentage]
    public float dropChance;
}

When you select a GameObject with this script attached in the Unity Editor, you'll see the dropChance field displayed as
a slider with a percentage value next to it.

Customizing the Drawer

If you wish to customize the behavior of the PercentDrawer, you can edit the PercentDrawer.cs file within
the Editor folder. Comments in the code provide guidance on what each part does and how to adjust the layout.

Support

For support, questions, or contributions, please open an issue on the repository's issue tracker.

Contributing
Contributions to improve the PercentageAttribute and PercentDrawer are welcome. Please follow the standard pull
request process to submit improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Made by RimuruDev

Full Changelog: v1.0.0.0...v1.1.0

v1.0.0.0

18 Feb 10:16
085b2ee
Compare
Choose a tag to compare