当前位置:网站首页>Unity text superscript square representation +text judge whether the text is empty
Unity text superscript square representation +text judge whether the text is empty
2022-07-04 07:48:00 【Little sun works hard every day】
Code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class textTest : MonoBehaviour
{
public Text text;
public Text aText;
public Text bText;
public Text cText;
public Text dText;
private string valueOfAText;
private string valueOfBText;
private string valueOfCText;
private string valueOfDText;
private double aValue=0;
private double bValue =0;
private double cValue =0;
private double dValue =0;
private double resultValue=0;
// Start is called before the first frame update
void Start()
{
text.text = "D(1)=189.65+69.01A-4.91B+19.99C+5.22D-3.08AB+20.62AC+1.57AD+3.75BC+2.67BD-1.57CD-36.32A" + "\u00B2" + "+0.25B" + "\u00B2" + "-15.8C" + "\u00B2" + "-24.38D" + "\u00B2";
}
public bool JudgeValue()
{
// Determines if the input value is null
valueOfAText = aText.GetComponent<Text>().text.ToString();
valueOfBText = bText.GetComponent<Text>().text.ToString();
valueOfCText = cText.GetComponent<Text>().text.ToString();
valueOfDText = dText.GetComponent<Text>().text.ToString();
if (IsSpace(valueOfAText))
{
Debug.Log("A Edit is empty ");
}
else if (!valueOfAText.Equals(""))
{
Debug.Log("A Edit is not empty ");
}
if (IsSpace(valueOfBText))
{
Debug.Log("B Edit is empty ");
}
else if (!valueOfBText.Equals(""))
{
Debug.Log("B Edit is not empty ");
}
if (IsSpace(valueOfCText))
{
Debug.Log("C Edit is empty ");
}
else if (!valueOfCText.Equals(""))
{
Debug.Log("C Edit is not empty ");
}
if (IsSpace(valueOfDText))
{
Debug.Log("D Edit is empty ");
}
else if (!valueOfDText.Equals(""))
{
Debug.Log("D Edit is not empty ");
}
if(!IsSpace(valueOfAText)&& !IsSpace(valueOfBText) && !IsSpace(valueOfCText) && !IsSpace(valueOfDText))
{
return true;
}else
{
return false;
}
}
public void clickComputeBtn()
{
// Judge whether the value is empty
if(JudgeValue())
{ // Calculation
ComputeValue();
}
}
public void ComputeValue()
{
aValue = Convert.ToSingle(aText.text.ToString());
bValue = Convert.ToSingle(bText.text.ToString());
cValue = Convert.ToSingle(cText.text.ToString());
dValue = Convert.ToSingle(dText.text.ToString());
if (double.TryParse(aText.text.ToString(), out aValue))
{
aValue = Double.Parse(aText.text.ToString());
}
if (double.TryParse(bText.text.ToString(), out bValue))
{
bValue = Double.Parse(bText.text.ToString());
}
if (double.TryParse(cText.text.ToString(), out cValue))
{
cValue = Double.Parse(cText.text.ToString());
}
if (double.TryParse(dText.text.ToString(), out dValue))
{
dValue = Double.Parse(dText.text.ToString());
}
resultValue = 189.65 + 69.01 * aValue - 4.91 * bValue + 19.99 * cValue + 5.22 * dValue
- 3.08 * aValue * bValue + 20.62 * aValue * cValue + 1.57 * aValue * dValue
+ 3.75 * bValue * cValue + 2.67 * bValue * dValue - 1.57 * cValue * dValue
- 36.32 * aValue * aValue + 0.25 * bValue * bValue - 15.8 * cValue * cValue - 24.38 * dValue * dValue;
Debug.Log(aValue);
Debug.Log(bValue);
Debug.Log(cValue);
Debug.Log(dValue);
Debug.Log(resultValue);
}
// Detect spaces
private bool IsSpace(string textValue)
{
if (textValue.Trim().Length == 0)// Remove the spaces at the beginning and end of the string
{
return true;
}
return false;
}
}
Demo picture
边栏推荐
- BibTex中参考文献种类
- zabbix监控系统自定义监控内容
- Jianmu continuous integration platform v2.2.2 release
- Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
- ZABBIX monitoring system custom monitoring content
- JVM -- class loading process and runtime data area
- 如何用MOS管来实现电源防反接电路
- window上用.bat文件启动项目
- 线性代数1.1
- How to write a summary of the work to promote the implementation of OKR?
猜你喜欢
System architecture design of circle of friends
zabbix监控系统邮件报警配置
How to use MOS tube to realize the anti reverse connection circuit of power supply
zabbix監控系統自定義監控內容
Tri des fonctions de traitement de texte dans MySQL, recherche rapide préférée
1. Qt入门
【Go基础】2 - Go基本语句
Zephyr learning notes 1, threads
L2-013 red alarm (C language) and relevant knowledge of parallel search
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
随机推荐
Rhcsa the next day
Unity 从Inspector界面打开资源管理器选择并记录文件路径
时序数据库 InfluxDB 2.2 初探
Zephyr 学习笔记1,threads
I was pressed for the draft, so let's talk about how long links can be as efficient as short links in the development of mobile terminals
Do you know about autorl in intensive learning? A summary of articles written by more than ten scholars including Oxford University and Google
L1-024 the day after tomorrow (5 points)
Activiti常见操作数据表关系
Life planning (flag)
真空介电常数和真空磁导率究竟是由什么决定的?为何会存在这两个物理量?
socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
Leetcode 146. LRU 缓存
OKR vs. KPI 一次搞清楚这两大概念!
MYCAT middleware installation and use
Types of references in BibTex
JVM中堆概念
How does dataframe calculate the average value of each row as another column
Scanf read in data type symbol table
[gurobi] establishment of simple model
[Gurobi] 简单模型的建立