求问以下c#脚本怎么写

JohnnyHu112 2020-07-30 10:21:49
Create a new C# script called HelloWorld that every frame increments an int variable by 1 in the Update() method and prints it to the console using Debug.Log(), starting with 0.
• Attach this to script Empty2 and press the Play button to see the output in the Console window.
创建一个名为HelloWorld的新C#脚本,该脚本在Update()方法中每帧将一个int变量加1,然后使用Debug.Log()从0开始将其打印到控制台。
•将其附加到脚本Empty2,然后按“播放”按钮 在控制台窗口中查看输出。
...全文
64498 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
int index = 0; index++; debug.log(index)
示申○言舌 2020-07-31
  • 打赏
  • 举报
回复

public class HelloWorld : MonoBehaviour
{
      private int theVariable = 0;

      private void Update()
      {
            Debug.log( theVariable ++ );
      }
}

2,535

社区成员

发帖
与我相关
我的任务
社区描述
Unity3D相关内容讨论专区
游戏unity 技术论坛(原bbs)
社区管理员
  • Unity3D
  • 芝麻粒儿
  • 「已注销」
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

Unity3D社区公告:

  1. 社区致力于解决各种Unity3D相关的“疑难杂症”。
  2. 社区不允许发布与Unity3D或相关技术无关内容。
  3. 社区版主邀请各位一道为打造优秀社区不懈努力。

试试用AI创作助手写篇文章吧