CustomAssets
Askowl Custom Assets
Mutable/Float.cs
1 // Copyright 2018 (C) paul@marrington.net http://www.askowl.net/unity-packages
2 
3 using System;
4 using Askowl;
5 using UnityEngine;
6 
7 namespace CustomAsset.Mutable {
8  /// <a href="http://bit.ly/2QQdUIt">Float CustomAsset contains a float value which can be connected directly to OnValueChange callbacks in UI slider and scrollbar components. Connect it to event listeners to interact with components such as Animation, Text or Unity. Or add listeners to your own classes with Register(this)</a>
9  [CreateAssetMenu(menuName = "Custom Assets/Mutable/Float")] public class Float : OfType<float> {
10  [SerializeField] private Range range = new Range(0, 1);
11 
12  /// <a href="http://bit.ly/2QQdUIt">The smallest value a Float can be set to</a>
13  public float Minimum { get => range.Min; set => range.Min = value; }
14 
15  /// <a href="http://bit.ly/2QQdUIt">The largest value a Float can be set to</a>
16  public float Maximum { get => range.Max; set => range.Max = value; }
17 
18  /// <a href="http://bit.ly/2QQdUIt"><see cref="OfType{T}.Instance{TC}"/></a>
19  public static Float Instance(string name) => Instance<Float>(name);
20 
21  /// <a href="http://bit.ly/2QQdUIt"><see cref="OfType{T}.New"/></a>
22  public new static Float New(string name) => New<Float>(name);
23 
24  /// <a href="http://bit.ly/2QQdUIt"><see cref="OfType{T}.New"/></a>
25  public static Float New() => New<Float>();
26 
27  /// <a href="http://bit.ly/2QQdUIt"><see cref="OfType{T}.Set"/></a> <inheritdoc />
28  public override void Set(float toValue) => base.Set(Math.Min(Math.Max(range.Min, toValue), range.Max));
29  }
30 }
Base class for a custom asset. Provides getters and setters for the contained value and templates for...
override void Set(float toValue)
Float CustomAsset contains a float value which can be connected directly to OnValueChange callbacks i...
Definition: Mutable/Float.cs:9