コガネブログ

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

【Unity】TextId 型の拡張メソッド

ソースコード

using TMPro;

namespace Kogane
{
    // ReSharper disable once InconsistentNaming
    public static class TMP_TextTextIdExtensionMethods
    {
        public static void SetText
        (
            this TMP_Text self,
            TextId        textId
        )
        {
            self.text = textId.Value;
        }

        public static void SetText<T>
        (
            this TMP_Text self,
            TextId        textId,
            T             arg1
        )
        {
            self.text = textId.FormatWith( arg1 );
        }

        public static void SetText<T1, T2>
        (
            this TMP_Text self,
            TextId        textId,
            T1            arg1,
            T2            arg2
        )
        {
            self.text = textId.FormatWith( arg1, arg2 );
        }

        public static void SetText<T1, T2, T3>
        (
            this TMP_Text self,
            TextId        textId,
            T1            arg1,
            T2            arg2,
            T3            arg3
        )
        {
            self.text = textId.FormatWith( arg1, arg2, arg3 );
        }

        public static void SetText<T1, T2, T3, T4>
        (
            this TMP_Text self,
            TextId        textId,
            T1            arg1,
            T2            arg2,
            T3            arg3,
            T4            arg4
        )
        {
            self.text = textId.FormatWith( arg1, arg2, arg3, arg4 );
        }
    }
}

リポジトリ