Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High & Low Values for the Progress Bar #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AtaTrkgl
Copy link
Contributor

@AtaTrkgl AtaTrkgl commented Aug 9, 2022

Here is how it looks:

The following code produces the image provided below.
using NaughtyAttributes;
using UnityEngine;

public class ProgressBarTest : MonoBehaviour
{
    [Header("Both Low & High Values are Set")]
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green, 30, EColor.Red)]
    public int health = 10;
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green, 30, EColor.Red)]
    public int health2 = 50;
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green, 30, EColor.Red)]
    public int health3 = 80;
    
    [Header("Only High Values are Set")]
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green)]
    public int health4 = 10;
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green)]
    public int health5 = 50;
    
    [ProgressBar("Health", 100, EColor.Yellow, 75, EColor.Green)]
    public int health6 = 80;
    
    [Header("Non of them are Set")]
    
    [ProgressBar("Health", 100, EColor.Yellow)]
    public int health7 = 10;
    
    [ProgressBar("Health", 100, EColor.Yellow)]
    public int health8 = 50;
    
    [ProgressBar("Health", 100, EColor.Yellow)]
    public int health9 = 80;

    [Header("Dynamics")]
    
    [ProgressBar("Health", 100, EColor.Yellow, nameof(highVal), EColor.Green)]
    public int health10 = 86;
    
    [ProgressBar("Health", 100, EColor.Yellow, nameof(GetHighVal), EColor.Green, nameof(lowVal), EColor.Yellow)]
    public int health11 = 80;
    
    [ProgressBar("Health", 100, EColor.Yellow, nameof(GetHighVal), EColor.Green, nameof(lowVal), EColor.Yellow)]
    public int health12 = 20;
    
    private int highVal = 70;
    private float lowVal = 30;
    private int GetHighVal() => 70;
}

image

- Added High & Low values for progress bar as suggested in dbrizov#226
- Generalized GetMaxValue of ProgressBarPropertyDrawer to work with LowValue & HighValue
- Fixed the extra return statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant