[C #] add debugging code using some methods

Source: Internet
Author: User

When writing game code, you often need to write more debugging code during the development process. The Code should be commented out or deleted during the game preparation period, the Residual code will also negatively affect the efficiency of game releases. In this way, we need to find an effective way to control such code. Using the C # classification and some methods, you can separate the debugging code into code files, and you only need to block these independent code files during the waiting period, the part called in the original code is automatically ignored by the compiler. After the release process is completed, the block is removed and the code can enter the next development cycle without manual adjustment. For example, in the release code, only the touch input is processed, but the mouse must be replaced during debugging. In this case, you only need to write the code that processes the mouse input to some methods, then, call this method under the main logic for processing input. (PauseButton. cs)

Public partial class PauseButton: TouchableController {void Update (){//... handle touch input CheckMouseInput ();} partial void CheckMouseInput ();} // main class end (PauseButton_Debug.cs) [csharp] view plaincopypublic partial class PauseButton {partial void CheckMouseInput () {//... handle mouse input }}// partial class end

 

In the above Code, you only need to block PauseButton_Debug.cs during the license period. Note: 1. If a namespace exists for a partial classification, make sure that all parts of the class are defined in the same namespace. 2. Some methods can only be private and cannot contain access modifiers. Therefore, some methods can only be defined in the current class.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.