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
}
}


posted @ 2013-09-03 23:32  zhibolife  阅读(1338)  评论(0编辑  收藏  举报