Unity3D题目,Unity中利用GUI输出九九乘法表

网上看到的这题,下面贴出源代码

 

using UnityEngine;
using System.Collections;

public class c99 : MonoBehaviour//C#脚本名:c99
{

void OnGUI()
{
#region
const float offsetX = -30;
const float offsetY = -10;
const float width = 80;
const float height = 30;
Rect position;
string formula;

for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
position = new Rect(j * width + offsetX, i * height + offsetY, width, height);
formula = string.Format("{0} x {1} = {2}", j, i, i*j);
GUI.Label(position, formula);

// Debug.Log(formula);

} }

#endregion
}
}

Unity3D题目,Unity中利用GUI输出九九乘法表_第1张图片

 
  

转载于:https://www.cnblogs.com/zhibolife/p/unity3d99.html

你可能感兴趣的:(Unity3D题目,Unity中利用GUI输出九九乘法表)