Visual Studio / (Code)
- Open the Command Palette (
Ctrl-Shift-P
) for Visual Studio Code, or Quick Launcher (Ctrl-q
) for Visual Studio - Search for and select 'Format Document' to automatically format the
.cs
file
- Please read the following guides to understand how the unity client works (Private source)
- If you are not familiar with server, please be familiar with it first
- Unity Basics, 10 min
- Client Basics, 11 min
- Running assistance, 14 min
- All application logic should be inside Assets/Scripts/Apps
- For new applications create a new namespace such as
TOM.Apps.<APP_NAME>
- Create unit tests at Assets/Tests following Testing
- Ensure you have
protoc
installed by typingprotoc --version
in your terminal. If it is not installed, you may follow the instructions here. - Create your proto file in
Assets/Scripts/Protobuf
. For more information on how to structure proto data, please refer here. cd
toAssets/Scripts
and run this command in your terminalprotoc -I=Protobuf --csharp_out=Protobuf Protobuf/proto_name.proto
to generate the builder class. Note that you have to run the command again if you edit the proto file.
- Activate Test Runner by going to (
Window -> General -> Testrunner
) Ref - Ensure these panels are open in your Unity Editor
- Under the Code Coverage panel, check
Enable Code Coverage
under the Settings header
- Unity has 2 kinds of test scripts.
- Play Mode Tests: Run inside the editor's play mode, ideal for testing game logic and functionality that relies on running the game. Use the (
UnityTest
) attribute. - Edit Mode Tests: Run directly in the Unity Editor and not in play mode, useful for testing logic independent of the game running, like validation, data structures and editor extensions. Use the (
Test
) attribute.
- Play Mode Tests: Run inside the editor's play mode, ideal for testing game logic and functionality that relies on running the game. Use the (
- To create an Edit Mode test script, go to (
Assets/Scripts/Tests
), click on the EditMode folder, click the (EditMode
) tab in the test runner and click (Create Test Script in Current folder
) - To create a Play Mode test script, go to (
Assets/Scripts/Tests
), click on the PlayMode folder, click the (PlayMode
) tab in the test runner and click (Create Test Script in Current folder
)
- Under Test Runner, click on either the EditMode or PlayMode tab, click run all or run selected
- When prompted to enter Debug Mode, click yes
- Code coverage report should be automatically generated after running tests. If not, go to the code coverage panel and click (
Generate from Last
) at the bottom right of the panel. - Open the report in the form of an (
index.html
) file in the (CodeCoverage
) folder in the project root folder.
- Create an asmdef file in Assets/Scripts/...
- Look at the reference-related compilation errors (i.e., the not found errors)
- One by one, drag the required references to the created asmdef file (under the section Assembly Definition References). Repeat till the errors are resolved.
- Use those references in test files.