修改数字格式化

This commit is contained in:
yangjing 2022-02-16 18:53:13 +08:00
parent a24d4e314d
commit 68a38bbef6
2 changed files with 6 additions and 6 deletions

View File

@ -13,28 +13,28 @@ public partial class Const
public static string GetLevelIconBig(int pLevelID) public static string GetLevelIconBig(int pLevelID)
{ {
return string.Format("Image/LevelIcon_Big/{0}", (pLevelID + 1).ToString().PadLeft(3, '0')); return string.Format("Image/LevelIcon_Big/{0}", (pLevelID + 1).ToString("D3"));
} }
public static string GetLevelIconSmall(int pLevelID) public static string GetLevelIconSmall(int pLevelID)
{ {
return string.Format("Image/LevelIcon_Small/{0}", (pLevelID + 1).ToString().PadLeft(3, '0')); return string.Format("Image/LevelIcon_Small/{0}", (pLevelID + 1).ToString("D3"));
} }
public static string GetLevelLogo(int pLevelID) public static string GetLevelLogo(int pLevelID)
{ {
return string.Format("Image/LevelLogo/{0}", (pLevelID + 1).ToString().PadLeft(3, '0')); return string.Format("Image/LevelLogo/{0}", (pLevelID + 1).ToString("D3"));
} }
public static string GetSoundPic(int pLevelID, int pSoundIndex) public static string GetSoundPic(int pLevelID, int pSoundIndex)
{ {
string tLevelIDStr = (pLevelID + 1).ToString().PadLeft(3, '0'); string tLevelIDStr = (pLevelID + 1).ToString("D3");
return string.Format("Image/SoundPic/{0}/{1}", tLevelIDStr, tLevelIDStr + "_" + (pSoundIndex + 1).ToString()); return string.Format("Image/SoundPic/{0}/{1}", tLevelIDStr, tLevelIDStr + "_" + (pSoundIndex + 1).ToString());
} }
public static string GetSound(int pLevelID, int pSoundIndex) public static string GetSound(int pLevelID, int pSoundIndex)
{ {
string tLevelIDStr = (pLevelID + 1).ToString().PadLeft(3, '0'); string tLevelIDStr = (pLevelID + 1).ToString("D3");
return string.Format("Audio/GameSound/{0}/{1}", tLevelIDStr, tLevelIDStr + "_" + (pSoundIndex + 1).ToString()); return string.Format("Audio/GameSound/{0}/{1}", tLevelIDStr, tLevelIDStr + "_" + (pSoundIndex + 1).ToString());
} }

View File

@ -12,7 +12,7 @@ public class ImageNum : MonoBehaviour
public void SetNum(int pNum) public void SetNum(int pNum)
{ {
pNum = pNum % 1000; pNum = pNum % 1000;
string tNumStr = pNum.ToString().PadLeft(3, '0'); string tNumStr = pNum.ToString("D3");
mImgHundreds.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[0].ToString())); mImgHundreds.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[0].ToString()));
mImgTens.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[1].ToString())); mImgTens.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[1].ToString()));