First of all, congratulations on our upcoming game "Dragon Ring"! http://www.9game.cn/longjie/
Steal a half-free, share a little thing. is the function that prints the log. In the development of output log is necessary, in C # in the output of a number of different types of parameters, the need for connectors to accumulate output, it is inconvenient. One simple way is to encapsulate a printed function yourself,
Let it support indeterminate parameters and different types of output. This will not strongly use the string for splicing output. Maybe you don't understand the need, okay, nonsense say, on the code.
Public Static voidLog (paramssystem.object[] message) { stringstr =""; if(Message = =NULL|| Message. Length = =0) {str="NULL"; } Else { for(inti =0; I < message. Length; i++) {str+=Message[i]; }} Debug.Log (str); }
OK, now look at the use of this function: If this class is called unitl, it needs to be printed directly Util.Log ("Hello World");
Seemingly not much difference, but can also play: Util.Log (1,4,0.5,-1); , Util.Log ("test", true,56);
OK, little tricks, nothing big on the technology. The params is used to receive indeterminate parameters, and object receives any type, so a simple encapsulated output function is done
C # tips for printing logs