Home > other >  The unity of the c # script, how to multiple object attribute assignment?
The unity of the c # script, how to multiple object attribute assignment?

Time:09-20

The game scene have 12 statues, depending on the player's behavior 1, 2, 3... 12, only visible with the corresponding behavior that a statue,
Need to Update method under each frame detection,
I try to use c # script if statements, each situation to 11 other statues rendering visible attribute assignment, too multifarious,
Once to multiple objects of the same attribute assignment easy way?

CodePudding user response:

With inheritance, you put the public properties when the parent class, and then to the parent class members not change the value?

CodePudding user response:

Because you're one of the 12 and distinguish from the other, then to judge IF it is used, you put twelve statue to manage in an array, then cycle comparison, the same is a process, not the same that 11 statues with cyclic assignment, don't you assign them one by one,

CodePudding user response:

If demand is players every time is a kind of behavior, can set CurrentBehavior and OldBehavior, every time the switching behavior, OldBehavior corresponding to the statue of the invisible, CurrentBehavior corresponding to the statue of the visible, remember to set the CurrentBehavior and OldBehavior behavior at the same time,
  • Related