0

i am coding in C# with Unity3D and have a basic question. The following code snippet appears in the Loop of an Object "Monster"

if (monster == ENEMY.DEAD)
    isHidden = true;
    hideMe();

Somewhere in the code, i am setting the status of monster, which would in this case execute the written three lines of code all the time.

1) Is the Compiler of Unity clever enough to see, that there is no status change?

2) Or is this a bad way of changing Statuses?

ps: hideMe() is a function which checks if isHidden is set to true, to then disable all objects relevant for this object

4

1 に答える 1

2

1) いいえ。 2) はい。他のオブジェクトに何かをしないでください。イベントを送信し、それに応じて他の MonoBehaviour を反応させます。コードを切り離します。

于 2013-10-02T14:31:34.177 に答える