티스토리 뷰
100 ~ 999 : +1
1000~9999 : +10
10000~99999 : +100
....
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using TMPro;
public class test : MonoBehaviour
public int quantity;
public TMP_InputField Text;
double value;
int a;
double result;
/*double pow(double x, double a);*/
private void Start()
{
Text.text = quantity.ToString();
}
public void item()
{
value = int.Parse(Text.text);
a = value.ToString().Length;
}
public void OnClickPlus()
{
item();
if(value < 1000)
{
result = 1;
Text.text = (value + result).ToString();
}
else
{
result = Mathf.Pow(10, a-3);
Text.text = (value + result).ToString();
}
}
public void OnClickMinus()
{
item();
if (value < 1000)
{
result = 1;
Text.text = (value - result).ToString();
}
else
{
result = Mathf.Pow(10, a - 3);
Text.text = (value - result).ToString();
}
}