티스토리 뷰

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();
        }
    }

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함