小编Chr*_*ina的帖子

在C#中压缩多个相似的if语句

我想为游戏编写一些紧凑的代码。这是原件。

if (killPosX != 0) // float x position you would like the object to be destroyed at
{
    killX = true;  // automatically makes the value of killX true
}

if (killPosY != 0) // float y position you would like the object to be destroyed at
{
    killY = true;  // automatically makes the value of killY true
}

if (killPosT != 0) // float position in time you would like the object to be destroyed at
{ …
Run Code Online (Sandbox Code Playgroud)

c# if-statement unity-game-engine

0
推荐指数
1
解决办法
73
查看次数

标签 统计

c# ×1

if-statement ×1

unity-game-engine ×1