I'm getting some really odd behaviour in both Visual Studio Code and Unity, and I'm not sure where the issue is coming from, or how to fix.
I'm able to successfully import Mirror Components to Game Objects (i.e Default Network Manager), and am able to use Mirror successfully (can spawn in Player Objects, and they move over the network)
I'm getting issues when it comes to adding Public Overrides for Mirror in a custom Network Manager script.
This is my code in my custom Network Manager Script (yes, this is the whole script)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class RTSNetworkManager : NetworkManager
{
public override void onServerAddPlayer(NetworkConnection conn)
{
base.onServerAddPlayer(conn);
}
}
After typing this in, I get the following Compiler Error in the Unity Console:
Assets\Scripts\Networking\RTSNetworkManager.cs(8,26): error CS0115: 'RTSNetworkManager.onServerAddPlayer(NetworkConnection)': no suitable method found to override
When I remove the onServerAddPlayer
function from this script, the script compiles successfully.
I'm going through a tutorial (GameDev.tv, intermediate C# Coding & Networking), and was working on another project in the same tutorial which also used Mirror, and this same script seemed to work perfectly fine
Additionally, it seems that Visual Studio Code (or one of the extensions installed) is not working properly either. When replacing the default MonoBehaviour
with NetworkManager
in the C# script, this should throw an error in VSCode which prompts me to add using Mirror;
- this doesn't appear at all.
In general, when I start typing and the Predictive box comes up, this still only shows MonoBehaviour
content, and nothing from NetworkManager
What's really odd is that I don't get error CS0115 in the previous project, however that project is now also affected by the VSCode glitches, which leads me to believe they are either Separate issues, or VSCode is the true culprit here
I also looked at this article here, but I suspect this is a different issue as Mirror is able to be used outside of VSCode
These are my troubleshooting steps:
- Unity Error
- Restarted Unity Editor
- Restarted PC
- Copied
NetworkManager
script from earlier section - Removed all
.csproj
files - Removed
.sln
files - Removed
.vscode
folder - Reimported Mirror
- Removed project from PC and re-cloned from GitHub
- Created new project from scratch
- VSCode Error
- Uninstalled relevant extensions (In bold below)
- Reinstalled VSCode
- Specs
- Unity Version: 2020.3.26f1
- I have also attempted on 2021.3.3f1
- VSCode Version: 1.67.2
- Installed VSCode Extensions:
- C# for Visual Studio Code
- Debugger for Unity
- GitLens
- PHP Intelephense
- Unity Code Snippets
- Unity Version: 2020.3.26f1
Any advice would be greatly appreciated - this is doing my head in!
EDIT 1 The error with Unity not recognising the Mirror has been solved (Thanks Retired Ninja!) - The VSCode Intellisense issue remains, which confirms that they are not related