Skip to content

sha-255/ChanceEditor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChanceEditor

Makes it easier to manage the randomness in the inspector

Percantage Attribute

Displays the percentages in the inspector.

  [Percantage]
  [SerializeField] private float _chance;

Percentages in the inspector

PercentagesExtension

ToPercentages()

[float value].ToPercentages()
Parameter Type Description
value float A value from 0 to 1 is required.

ToProbability()

[int value].ToProbability()
Parameter Type Description
value int A value from 0 to 100 is required.

Chance Wrapper

Wraps a serializable value in a wrapper with a manageable chance.

[SerializeField] private List<ChanceWrapper<GameObject>> _chanceObjects;

public void TrySetActive()
    => _chanceObjects.ForEach(wrapper
        => wrapper.Value.SetActive(wrapper.Calculate()));
Generic Type Description
T The original value.

wrapper inspector