91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 19KB
    文件類型: .cs
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-11
  • 語言: C#
  • 標簽: Unity3D??C#??

資源簡介

此腳本用unity3D實現了簡單2D計算器,實現計算器的加減乘除等功能,博客地址https://blog.csdn.net/qq874455953

資源截圖

代碼片段和文件信息

using?UnityEngine;
using?System.Text.Regularexpressions;
using?System.Collections.Generic;
using?System;
using?System.Linq;

public?class?NewBehaviourscript?:?MonoBehaviour
{

????public?static?bool?IsNumeric(string?value)
????{
????????return?Regex.IsMatch(value?@“^[+-]?\d*[.]?\d*$“);
????}
????


???

//用來顯示結果
public?string?result?=?““;
????//第一個操作數
????public?static?string?str1?=?““;
????//第二個操作數
????public?static?bool?haveDot?=?false;

????public?static?bool?isCaclutate?=?false;


????void?OnGUI()
????{
????????
????????//對數字進行處理
????????if?(GUI.Button(new?Rect(100?100?100?60)?“CE“))
????????{
????????????result?=?““;
????????????str1?=?““;
????????????haveDot?=?false;
????????}
????????if?(GUI.Button(new?Rect(210?100?100?60)?“ד)?&&?str1.Substring(str1.Length?-?1?1)?!=?“-“?&&?str1.Substring(str1.Length?-?1?1)?!=?“+“?&&?str1.Substring(str1.Length?-?1?1)?!=?“.“)
????????{
????????????if?(IsNumeric(str1.Substring(str1.Length?-?1?1)))
????????????{
????????????????Debug.Log(str1.Substring(str1.Length?-?1?1));
????????????????str1?+=?“*“;
????????????????haveDot?=?false;
????????????????isCaclutate?=?false;
????????????}
????????????result?=?str1;
????????}
????????if?(GUI.Button(new?Rect(320?100?100?60)?“÷“)?&&?str1.Substring(str1.Length?-?1?1)?!=?“-“?&&?str1.Substring(str1.Length?-?1?1)?!=?“+“?&&?str1.Substring(str1.Length?-?1?1)?!=?“.“)
????????{
????????????if?(IsNumeric(str1.Substring(str1.Length?-?1?1)))
????????????{
????????????????str1?+=?“/“;
????????????????haveDot?=?false;
????????????????isCaclutate?=?false;
????????????}
????????????result?=?str1;
????????}
????????if?(GUI.Button(new?Rect(430?100?100?60)?“←“))
????????{
????????????if?(isCaclutate?==?true)
????????????{
????????????????str1?=?““;
????????????????isCaclutate?=?false;
????????????}?else?if?(result.Length?!=?0)
????????????{

????????????????str1?=?str1.Substring(0?str1.Length?-?1);
????????????????
????????????}
????????????result?=?str1;


????????}
????????if?(GUI.Button(new?Rect(100?170?100?60)?“1“))
????????{
????????????if?(isCaclutate?==?true)
????????????{
????????????????str1?=?““;
????????????????isCaclutate?=?false;
????????????????haveDot?=?false;
????????????}
????????????str1?+=?“1“;
????????????result?=?str1;
????????}
????????if?(GUI.Button(new?Rect(210?170?100?60)?“2“))
????????{
????????????if?(isCaclutate?==?true)
????????????{
????????????????str1?=?““;
????????????????isCaclutate?=?false;
????????????????haveDot?=?false;
????????????}
????????????str1?+=?“2“;
????????????result?=?str1;
????????}
????????if?(GUI.Button(new?Rect(320?170?100?60)?“3“))
????????{
????????????if?(isCaclutate?==?true)
????????????{
????????????????str1?=?““;
????????????????isCaclutate?=?false;
????????????????haveDot?=?false;
????????????}
????????????str1?+=?“3“;
????????????result?=?str1;
????????}
????????if?(GUI.Button(new

評論

共有 條評論