コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Mathf.Clamp、Mathf.Max、Mathf.Min を拡張メソッドで呼び出せるようにするパッケージ「UniClampExtensionMethods」を GitHub に公開しました

リポジトリ

使用例

using Kogane;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void Awake()
    {
        int i = 25;

        Debug.Log( i.Clamp( 0, 100 ) );
        Debug.Log( i.Max( 100 ) );
        Debug.Log( i.Min( 0 ) );

        float f = 25f;

        Debug.Log( f.Clamp01() );
        Debug.Log( f.Clamp( 0, 100 ) );
        Debug.Log( f.Max( 100 ) );
        Debug.Log( f.Min( 0 ) );
    }
}