Search Unity

Question Use custom Smart String formatter without ()

Discussion in 'Localization Tools' started by silkmoon18, Jan 21, 2024.

  1. silkmoon18

    silkmoon18

    Joined:
    Dec 13, 2020
    Posts:
    25
  2. namo352

    namo352

    Joined:
    Dec 13, 2023
    Posts:
    18
    i think this example can help to you:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public static class ByteExtensions
    4. {
    5.     public static string FormatAsByte(this byte value)
    6.     {
    7.         return value.ToString("byte");
    8.     }
    9. }
    10.  
     
  3. silkmoon18

    silkmoon18

    Joined:
    Dec 13, 2020
    Posts:
    25
    Actually I meant the usage in smart string, like "The file size is {0:byte()}", is there a way to call the formatter without parenthesis "The file size is {0:byte}"