mirrornetworking / mirror Goto Github PK
View Code? Open in Web Editor NEW#1 Open Source Unity Networking Library
Home Page: https://mirror-networking.com
License: MIT License
#1 Open Source Unity Networking Library
Home Page: https://mirror-networking.com
License: MIT License
Consider the following file:
using System;
using UnityEngine;
using Mirror;
public class GameServerConnectionToMasterBehaviour : MonoBehaviour
{
public bool AutoStartServer = true;
public string AutoStartMasterIP = "10.1.10.65";
public int AutoStartMasterPort = 7777;
private NetworkClient Client;
private void Awake()
{
if (AutoStartServer)
{
DontDestroyOnLoad(gameObject);
Client = new NetworkClient();
Client.hostPort = 7778;
RegisterClientMessages();
Client.Connect(AutoStartMasterIP, AutoStartMasterPort);
}
}
private void RegisterClientMessages()
{
Client.RegisterHandler(MsgType.Connect, OnClientConnectInternal);
Client.RegisterHandler(MsgType.Disconnect, OnClientDisconnectInternal);
Client.RegisterHandler(MsgType.NotReady, OnClientNotReadyMessageInternal);
Client.RegisterHandler(MsgType.Error, OnClientErrorInternal);
Client.RegisterHandler(MsgType.Scene, OnClientSceneInternal);
}
private void OnClientSceneInternal(NetworkMessage netMsg)
{
throw new NotImplementedException();
}
private void OnClientErrorInternal(NetworkMessage netMsg)
{
throw new NotImplementedException();
}
private void OnClientNotReadyMessageInternal(NetworkMessage netMsg)
{
throw new NotImplementedException();
}
private void OnClientDisconnectInternal(NetworkMessage netMsg)
{
throw new NotImplementedException();
}
private void OnClientConnectInternal(NetworkMessage netMsg)
{
throw new NotImplementedException();
}
}
This file is pretty similar to the basics of the NetworkManager, yet it throws an error on Client.Connect(). The following error occurs whether or not there is a NetworkManager in the scene:
NullReferenceException: Object reference not set to an instance of an object
Any ideas? The Master Server in this case does not throw any errors or output any messages (it is using a NetworkManager).
Desktop:
Project: https://noobtuts.com/_projects/Mirror/bugs/bug_synclist_inheritance.zip
Reproduce:
happens because HLAPI's 'SyncListMessage' is applied to the first synclist with that hash.
this is deeply convoluted in hlapi. probably need to come up with a better solution for synclists first.
Describe the bug
You can't Send a message from within the ClientConnected callback (MsgType.Connect) as it will return the error "NetworkClient Send when not connected to a server". But it does work if you wait a bit (Probably next frame).
Expected behavior
You should be able to send a message when you get the "I'm connected callback"
Desktop (please complete the following information):
Unity 2017.4
Hello!
First, thank you for this project because it gives me hope! I was unhappy to hear that Unity was no longer taking care of UNET...
Unfortunately, I'm boring you with a bug report.
It seems to have a problem with the NetworkManager when I try to extend these features. Indeed, when I use a script that inherits from the NetworkManager and I try to fill it with a GameObject with a NetworkIdentity, the component does not seem to be recognized (it works on another project that does not use Mirror).
Thank you in advance for your work! :)
Best regards.
NB: I use Mirror 517 & Unity 2018.2.14f1
Describe the bug
Shutting down the server does not destroy all player objects
Repro project
https://drive.google.com/open?id=1Kf0QOjPN9ljDOm7nQVJPA8f2zx72h7My
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect the player object to be destroyed in the editor.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Describe the bug
You'd think that when you place a NetworkIdentity script on a object on the scene, for example a cube that a AssetID is generated and assigned to the object so it can identify itself over the network, right? Well, apparently it's broken somehow in the latest versions of Mirror. See for yourself, this was a Cube that was created by the "Create -> Cube" menu option and I slapped a NetworkIdentity component on it to replicate this behaviour. AssetID should NOT be zeroed out.
In my network stress test project which makes simple capsules on an AI navmesh to emulate some network load you can see that this bug also causes OnObjSpawn errors.
Repro project
Downloadable from my OneDrive: Removed since it's obsolete (new project in thread below)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
AssetIDs should be properly assigned per GameObject (not zeroed out) and not cause the OnObjSpawn error to occur when trying to spawn them in a network test environment.
Screenshots
See bug description.
Desktop (please complete the following information):
Additional context
Have not tested with it in Unity 2018.x.
In the Migrations Guide, no instruction was given about where are these NetworkIdentity
Component, I only found it's in the Runtim.dll
and Runtime-Editor.dll
by watching the video.
So there comes the question, Which one to use? or more generally speaking, if the Editor version is attached to a game object in unity editor, will it automatically linked to Runtime version when build? what's the different between these two dlls?
Describe the bug
Using the incremental compiler in unity 2018.2 causes this error
Repro project
Just import mirror into any project and install the incremental compiler. Once done create a network behaviour and the error will be thrown on compile.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Weave to complete correctly and allow for continued development.
Desktop (please complete the following information):
open networkreader, change InvalidDataExceptions to IndexOutOfRangeException
rebuild
repeat
it works
wtf
we might need to report this to unity..
When inheriting from NetworkManager (e.g. MyNetworkManager : NetworkManager), the base network manager's Awake function is not called, which is suppose to call private InitializeSingleton and public InitializeTransport.
Steps to reproduce the behaviour:
Expected behavior
Network transport and singleton should initialise. "Thank you for using Mirror" message should be logged.
Using Release: mirror-397
I solved this myself for the time being by calling base.awake via reflection in my own awake.
I suppose it's something you don't want to support anymore but i didn't see any mention of it in the migration doc.
Support more than one transport at a time. For example websocket + TCP
Describe the bug
In SyncList callbacks (including SyncListInt, SyncListSTRUCT, etc. etc.), if the SyncListOperation is OP_ADD, then the value passed to the callback corresponds to the first value in the list, not the item that was just added to the list.
Repro project
https://www.dropbox.com/s/zlkel1maw7c8zny/Mirror%20SyncList%20Operation%20OP_ADD%20Bug%20Repro.zip?dl=0
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
This bug first appeared in early October, or thereabouts, around the time that changes were made to the way SyncList bundling is handled. Prior to that time, the bug did not occur.
Describe the bug
Selecting a GameObject with NetworkTransform causes null ref errors to pop up.
NetworkTransformPreview is accessing null properties of NetworkTransform (m_RigidBody2D, m_RigidBody3D) inside OnPreviewGUI method.
To Reproduce
Quick and dirty fix with dnspy
I'm storing references to all components inside GetNetworkInformation method, in OnPreviewGUI these are get by m_ReferenceTargetIndex and null checked.
From here: https://github.com/vis2k/Mirror/wiki
The Bandwidth and Increased synvar limit links both don't work.
New features
Clock Synchronization
Bandwidth
Increased synvar limit <- This has a typo, i assume from the link it should be synchvar.
Provide a mechanism to synchronize data only with the owner of the object.
This would typically apply to quests, inventory, and other properties that other players don't see. It can significantly reduce the amount of messages sent near NPC when people are trading and crafting.
Add an encrypted transport such as TLS 1.3.
Describe the bug
Having the following setup in the player prefab:
Will cause only the top (first) component of the same type to execute the command on the server when the client does the RPC.
Repro project
repro.zip
1- Run one editor instance in server mode.
2- Run one editor instance in client mode.
3- Press editor button in the second instance of the component.
Expected behavior
The same instance should receive the command and the bool should switch, not the first one of the game object.
Additional context
UNET behaves the same way. If this is expected behaviour would a fixed implementation be merged into mirror?
Describe the bug
I am getting this error in my server log:
NullReferenceException: Object reference not set to an instance of an object at Mirror.NetworkManager+<>c.<get_numPlayers>b__66_0 (Mirror.NetworkConnection conn) [0x00000] in <filename unknown>:0 at System.Linq.Enumerable.Count[NetworkConnection] (IEnumerable
1 source, System.Func`2 selector) [0x00000] in :0
at Mirror.NetworkManager.get_numPlayers () [0x00000] in :0
at NetworkManagerMMO.WorldStats () [0x00000] in :0
`
Just gathering my findings here.
The bug:
Player.cs has [SyncVar] GameObject pet;
Pet.cs has [SyncVar] GameObject owner;
In other words: circular references.
Now this player+pet are spawned at another client, here is what happens:
so instead of Player knowing Pet and Pet knowing Player, only Pet knows Player because it was spawned after Player. Player was spawned before Pet, so it doesn't know Pet.
What weaver does right now:
for every [SyncVar] GameObject player;
it creates:
uint ___playerNetId;
public GameObject Networkplayer
{
get
{
return this.player;
}
[param: In] set
{
this.SetSyncVarGameObject(value, ref this.player, 8388608UL, ref this.____playerNetId);
}
}
The get just returns the original variable. The set sets calls SetSyncVarGameObject which sets dirty and then sets the original variable.
3. replaces all player = ...
(writes) in code with NetworkPlayer = ...
.
4. In PreStartClient() assigns Networkplayer = ClientScene.FindLocalObject(__playerNetId)
Solution 1
What it should do is to also replace all ... = player
(reads) with ... = Networkplayer
and in Networkplayer
get return ClientScene.FindLocalObject(___playerNetId)
In other words: for every [SyncVar] GameObject test
variable it should wrap get/set around the __testNetId
field. The netId is just an int, it doesn't matter when we receive it. The 'get' will simply return objects[netId] which is null if not spawned yet, or != null if spawned yet.
Solution 2
Spawn everything first. Then assign. Perhaps it's already meant to do that but it doesn't for some reason. The NetworkPlayer field is assigned in 'PreStartClient()' after all.
Describe the bug
Unable to use two NetworkClients in Mirror. Works in UNet
Repro project
https://github.com/uweenukr/MultipleNetworkClientTest
To Reproduce
Steps to reproduce the behavior:
Note: Can switch between UNet and Mirror by changing the 'using' in the 3 NetworkManager scripts and rebuilding.
Expected behavior
Message Handling similar to UNet that would allow the use of both NetworkClients
Screenshots
https://imgur.com/a/6WXisQI
Desktop (please complete the following information):
Using my full project I get this Behaviour:
Login and Client without 2nd NetworkClient = Works
Login and Client both with 2nd NetworkClient = Broke
Login Off Client On = Broke
Login On Client Off = Broke
The Client sent the LoginMsg. The server handled it properly. But when it went to reply it sent to the MasterServer.
During this test the LoginServer was set to start the 2nd NetworkClient after the NetworkManager.
This next test I set it to start the 2nd NetworkClient before the NetworkManager. Same result.
The LoginMsg is handled on the LoginServer but its reply is sent to the MasterServer.
So i fix my last problem but now i have problem with p2p
public override bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error)
{
EP2PSend eP2PSendType = EP2PSend.k_EP2PSendReliable;
var hostTopology = NetworkServer.active ? NetworkServer.hostTopology : NetworkManager.singleton.client.hostTopology;
QosType qos = hostTopology.DefaultConfig.Channels[channelId].QOS;
if (qos == QosType.Unreliable || qos == QosType.UnreliableFragmented || qos == QosType.UnreliableSequenced)
{
eP2PSendType = EP2PSend.k_EP2PSendUnreliableNoDelay;
}
if (SteamNetworking.SendP2PPacket(remoteSteamId, bytes, (uint)numBytes, eP2PSendType))
{
error = (byte)NetworkError.Ok;
return true;
}
else
{
P2PSessionState_t state;
if (SteamNetworking.GetP2PSessionState(remoteSteamId, out state))
{
if (state.m_eP2PSessionError == (byte)EP2PSessionError.k_EP2PSessionErrorTimeout)
{
error = (byte)NetworkError.Timeout;
}
else
{
error = (byte)NetworkError.WrongHost;
}
}
else
{
error = (byte)NetworkError.WrongConnection;
}
return false;
}
}
}
and that was really good, now i don't have functions like numBytes or QosType and dunno how to fix this. Could you help me? Thanks!
When i put all files on the unity editor and created server is all working but when client want join i've got error 'OnObjSpawn netId: 2 has invalid asset Id' why?
Is your feature request related to a problem? Please describe.
To make it easier to migrate existing projects from UNET to Mirror, it is necessary for existing prefabs, that their UNET components (NetworkIdentity, NetworkTransform, etc...) are replaced. As there are often a lot of different settings, it would be nice, if all properties would keep their values.
Describe the solution you'd like
Please have a look at the attached editor script for easier replacement of the UNET components.
Describe alternatives you've considered
Additional context
using System.IO;
using UnityEditor;
using UnityEngine;
using UnetNetworkIdentity = UnityEngine.Networking.NetworkIdentity;
using UnetNetworkTransform = UnityEngine.Networking.NetworkTransform;
using MirrorNetworkIdentity = Mirror.NetworkIdentity;
using MirrorNetworkTransform = Mirror.NetworkTransform;
using System;
using System.Reflection;
public class UnetToMirrorEditor : EditorWindow {
[MenuItem("Window/Mirror/Replace UNET components")]
private static void ReplaceComponents() {
FindAndReplaceUnetComponents();
}
private static void FindAndReplaceUnetComponents() {
int gameObjectCount = 0, netIdComponentsCount = 0, netTransformComponentCount = 0, fileCounter = 0;
string[] files = Directory.GetFiles(Application.dataPath, "*.prefab", SearchOption.AllDirectories);
gameObjectCount = files.Length;
foreach (string file in files) {
fileCounter++;
EditorUtility.DisplayProgressBar("Mirror Migration Progress", string.Format("{0} of {1} files scanned...", fileCounter, files.Length), fileCounter / files.Length);
string relativepath = "Assets" + file.Substring(Application.dataPath.Length);
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(relativepath);
// replace UNET components with their mirror counterpart
netTransformComponentCount = ReplaceNetworkComponent<UnetNetworkTransform, MirrorNetworkTransform>(prefab);
// always replace NetworkIdentity as last element, due to dependencies
netIdComponentsCount = ReplaceNetworkComponent<UnetNetworkIdentity, MirrorNetworkIdentity>(prefab);
}
EditorUtility.ClearProgressBar();
Debug.Log(string.Format("Searched {0} GameObjects, found {1} UNET NetworkIdentity, {2} NetworkTransform components and replaced them with Mirror components.", gameObjectCount, netIdComponentsCount, netTransformComponentCount));
}
private static int ReplaceNetworkComponent<TSource, TDestination>(GameObject prefab)
where TSource : Component
where TDestination : Component {
int netTransformComponentCount = 0;
TSource unetNetworkComponent = prefab.GetComponent<TSource>();
if (unetNetworkComponent != null) {
netTransformComponentCount++;
// check for mirror component
TDestination mirrorNetworkComponent = prefab.AddComponent<TDestination>();
if (mirrorNetworkComponent == null) {
mirrorNetworkComponent = prefab.GetComponent<TDestination>();
}
// copy values
CopyProperties(unetNetworkComponent, mirrorNetworkComponent);
// destroy UNET component
DestroyImmediate(unetNetworkComponent, true);
}
return netTransformComponentCount;
}
// source: https://stackoverflow.com/questions/930433/apply-properties-values-from-one-object-to-another-of-the-same-type-automaticall
private static void CopyProperties(object source, object destination) {
// If any this null throw an exception
if (source == null || destination == null)
throw new Exception("Source or/and Destination Objects are null");
// Getting the Types of the objects
Type typeDest = destination.GetType();
Type typeSrc = source.GetType();
// Iterate the Properties of the source instance and
// populate them from their desination counterparts
PropertyInfo[] srcProps = typeSrc.GetProperties();
foreach (PropertyInfo srcProp in srcProps) {
if (!srcProp.CanRead) {
continue;
}
PropertyInfo targetProperty = typeDest.GetProperty(srcProp.Name,
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance);
if (targetProperty == null) {
continue;
}
if (!targetProperty.CanWrite) {
continue;
}
if (targetProperty.GetSetMethod(true) != null && targetProperty.GetSetMethod(true).IsPrivate) {
continue;
}
if ((targetProperty.GetSetMethod().Attributes & MethodAttributes.Static) != 0) {
continue;
}
if (!targetProperty.PropertyType.IsAssignableFrom(srcProp.PropertyType)) {
continue;
}
// Passed all tests, lets set the value
targetProperty.SetValue(destination, srcProp.GetValue(source, null), null);
}
}
}
Mirror should have a way to send messages in an unreliable channel.
This helps when doing voice or movement.
Description
When using the UnityEngine.UI namespace the Weaver gets confused and an error is shown in the unity log:
UNetWeaver error: Exception :Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x000ff] in C:\buildslave\cecil\build\Mono.Cecil\BaseAssemblyResolver.cs:169 at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in C:\buildslave\cecil\build\Mono.Cecil\BaseAssemblyResolver.cs:115 at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x0001d] in C:\buildslave\cecil\build\Mono.Cecil\DefaultAssemblyResolver.cs:35 at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in C:\buildslave\cecil\build\Mono.Cecil\MetadataResolver.cs:101 at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in C:\buildslave\cecil\build\Mono.Cecil\ModuleDefinition.cs:754 at Mono.Cecil.TypeReference.Resolve () [0x0000f] in C:\buildslave\cecil\build\Mono.Cecil\TypeReference.cs:280 at Mirror.Weaver.NetworkBehaviourProcessor.ProcessSyncVars () [0x00000] in <filename unknown>:0 at Mirror.Weaver.NetworkBehaviourProcessor.Process () [0x00000] in <filename unknown>:0 at Mirror.Weaver.Weaver.ProcessNetworkBehaviourType (Mono.Cecil.TypeDefinition td) [0x00000] in <filename unknown>:0 at Mirror.Weaver.Weaver.CheckNetworkBehaviour (Mono.Cecil.TypeDefinition td) [0x00000] in <filename unknown>:0 at Mirror.Weaver.Weaver.Weave (System.String assName, IEnumerable1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x00000] in <filename unknown>:0 UnityEngine.Debug:LogError(Object) Mirror.Weaver.Log:Error(String) Mirror.Weaver.Weaver:WeaveAssemblies(IEnumerable1, IEnumerable1, IAssemblyResolver, String, String, String) Mirror.Weaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action1, Action1) Mirror.Weaver.<>c:<.cctor>b__0_0(String, CompilerMessage[]) UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)
Repro project
https://github.com/divieirasilva/mirror-weaver-repro-project
To Reproduce
Steps to reproduce the behavior:
1 - Build the Offline Scene (when this scene starts, it will connect automatically)
2 - Open the Server Scene on Unity and just click Play
3 - When the client connects on server you will see a "Called the wrong OnServerAddPlayer" error log on Unity.
Need the ability to specify an additional channel to support Voip in game chat.
Describe the bug
When a client completely shuts off their internet, other users experience a complete drop in server response. The server produces no error logs and in the case that the client reconnects in a timely manner, everything resumes back to normal. This shutting off of the internet is not equivalent to force closing the game, where that still acts like a clean break from the server.
Desktop (please complete the following information):
Hi there,
We have an idea on how to improve Mirror by removing the need to build assemblies externally.
The main benefit we get from not building them outside of Unity, is being able to step through the code at runtime, setting break points, etc.
Also, adapting the code would be naturally easier and quicker that way.
To achieve this, we imported the source into our Unity project, and wrote .asmdef files to let Unity build the assemblies for us.
This works perfectly fine with Weaver and Cecil as well.
Is that something you'd be interested in integrating?
If so, we'd be ready to start a pull request to get this into the repo.
Cheers,
Andi
Is your feature request related to a problem? Please describe.
The attributes are inconsistently named, hard to learn and awkward to use.
[Command]
- requires Cmd
prefix[ClientRpc]
- requires Rpc
prefix[TargetRpc]
- requires Target
prefix(Beginning to see a pattern? I'm not.)
Describe the solution you'd like
[Command]
to [Cmd]
.[ClientRpc]
to [Rpc]
.[TargetRpc]
. Simply use [Rpc]
with a NetworkConnection
parameter. (NetworkConnection
parameters are already disallowed outside of [TargetRpc]
methods.)Now the required name prefix matches the attribute.
Additional context
This change would require additional steps during migration, but can easily be done using a simple search-and-replace, or even automated in a migration tool.
Describe the bug
NetworkScene.cs calls non-existing method in NetworkIdentity in line 54
Repro project
unnecessary because it happens at compile time
To Reproduce
Steps to reproduce the behavior:
download the latest branch 2018 and put it into a new project
Expected behavior
no compiler error
Describe the bug
The hook function of a syncvar it's not called.
To Reproduce
Easy, create some syncvar.
Example:
[SyncVar(hook="OnHealthChange")] public float health;
,then the function
private void OnHealthChange(float theAmount) { health = theAmount; healthBar.SetValue (theAmount); }
final, change the health var value in server side and the OnHealthChange function never is called.
I get a warning "ClientScene::InternalAddPlayer: playerControllerId higher than expected: 0" when NetworkManager has set Auto Create Player to false and you then spawn a player on the server.
Although its only a warning there is a simple fix in NetworkManager.cs :
public override void OnClientConnect(NetworkConnection conn)
{
if (!clientLoadedScene)
{
// Ready/AddPlayer is usually triggered by a scene load completing. if no scene was loaded, then Ready/AddPlayer it here instead.
if (autoCreatePlayer)
{
ClientScene.Ready(conn);
ClientScene.AddPlayer(0);
}
else
{
ClientScene.localPlayers.Add(new Mirror.PlayerController());
ClientScene.Ready(conn);
}
}
}
public override void OnClientSceneChanged(NetworkConnection conn)
{
if (autoCreatePlayer)
{
// always become ready.
ClientScene.Ready(conn);
// vis2k: replaced all this weird code with something more simple
// add player if all existing ones are null (or if list is empty, then .All returns true)
if (ClientScene.localPlayers.All(pc => pc.gameObject == null))
{
ClientScene.AddPlayer(0);
}
}
else
{
ClientScene.localPlayers.Add(new Mirror.PlayerController());
ClientScene.Ready(conn);
}
}
Describe the bug
When spawning objects into the scene when connected, sometimes you can get a message that says "AddObserver: Already added observer to (gameobject). Maybe the function was called twice. Or perhaps the connection layer assigned the same ID twice ....." or something along those lines. We need to investigate why that's happening and stop emitting that warning unless people are actually deliberately trying to mess things up.
To Reproduce
Most of the time it's triggered when the player prefab is spawned by AddPlayerForConnection I believe. Can also be triggered if you use Auto Create Player option in the Network Manager.
Expected behavior
We should make sure that when objects are spawned that AddObserver functions are called once, and not multiple times.
I will investigate this further and see if there's any leads I can bring up.
Describe the bug
When i try to start a server or quit my application i have this kind of error :
Mirror.NetworkServer.InternalListen (System.String ipAddress, System.Int32 serverPort, System.Int32 maxConnections) (at <91ed777b83ab48fba45ddff3b3dfe8ed>:0)
Or
Mirror.NetworkManager.OnApplicationQuit () (at <91ed777b83ab48fba45ddff3b3dfe8ed>:0)
I had a previous version of mirror from early september working.
I upgraded the files to the last one and now i have this error.
In these two functions there is Transport.layer called i suppose it isn't set properly.
Expected behavior
No error.
Desktop (please complete the following information):
Maybe it's my fault, for upgrading i just closed the project and replaced the mirror files in the folder, like that i didn't lost any prefab with mirror component on it.
Describe the bug
Starting a project/building it or entering playmode drops warning when using the Roslyn incremental compiler (v0.0.42) in Unity 2018.2.14f (same with 2018.1+). Even with this warning all the functionality of Mirror seems to be fine
Unable to delete file Library/ScriptAssemblies/Assembly-CSharp.pdb: Sharing violation on path Library/ScriptAssemblies/Assembly-CSharp.pdb UnityEngine.Debug:LogWarning(Object) Mirror.Weaver.Weaver:Weave(String, IEnumerable
1, IAssemblyResolver, String, String, String)
Mirror.Weaver.Weaver:WeaveAssemblies(IEnumerable1, IEnumerable
1, IAssemblyResolver, String, String, String)
Mirror.Weaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action1, Action
1)
Mirror.Weaver.<>c:<.cctor>b__0_0(String, CompilerMessage[])
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)`
To Reproduce
Just put Mirror into an empty project with the Roslyn Incremental compiler enabled (2018.1+/0.0.42)
Installation instructions for the compiler: https://goo.gl/6FmREG (first post)
Expected behavior
The warning not to appear
Desktop:
Is your feature request related to a problem? Please describe.
From the migration guide:
Every networked prefab and scene object needs to be adjusted. They will be using NetworkIdentity from Unet, and you need to replace that componenent with NetworkIdentity from Mirror. You may be using other network components, such as NetworkAnimator or NetworkTransform. All components from Unet should be replaced with their corresponding component from Mirror.
This is a difficult and error-prone process that could easily be automated with a search-and-replace script. I migrated my project with the search-and-replace function in VSCode and it worked really well.
Describe the solution you'd like
Create a program/script that goes through all prefab/scene files replaces all instances of the UnityEngine.Networking.NetworkIdentity
script GUID with the Mirror.NetworkIdentity
GUID. This can also be applied to other Mirror components, as well as certain required code changes:
using UnityEngine.Networking;
-> using Mirror;
[Command(channel.*)])
-> [Command]
SyncListStruct
-> SyncListSTRUCT
Additional context
Obviously, users should be prompted to backup their project before migration.
One easy way to implement this would be as a PowerShell script:
# replace UnityEngine.Networking namespace usings
Get-ChildItem -recurse '*.cs' | ForEach {(Get-Content $_ | ForEach { $_ -replace '^[ \t]*using UnityEngine\.Networking;', 'using Mirror;' }) | Set-Content $_}
# remove command channels
Get-ChildItem -recurse '*.cs' | ForEach {(Get-Content $_ | ForEach { $_ -replace '^([ \t]*)\[Command\(channel.*\)\]', '$1[Command]' }) | Set-Content $_}
# ...
Currently, websockets is provided by LLAPI.
Since LLAPI is on it's death bed and it generally sucks, we need a LLAPI free websocket implementation.
We can use a websocket-sharp based implementation for the server and jslib for the the clients, as seen in this plugin:
https://assetstore.unity.com/packages/essentials/tutorial-projects/simple-web-sockets-for-unity-webgl-38367
Hi, thanks for this project! Mirror is awesome but we do need relay servers for our project so we are implementing a Transportlayer for the Photon Realtime API and came around an issue concerning the shutdown of a host.
After shutting down the server and reconnecting/rehosting, Mirror thinks that the old clients are still connected.
When calling NetworkServer.Shutdown
Mirror calls ServerStop and we generate disconnect messages for every client still connected, but immediately stops polling these messages.
Those messages aren't getting polled cause s_ServerHostId
is set to -1.
Starting the as host again NetworkServer.connections
still includes old client connections.
What is the right way to tell mirror that there are no more clients connected?
Thanks in advance!
Greets, Andi
I just noticed a bug in Mirrors code when reading it.. ill do a bug report. Its Very minor and not really having an effect but it could in future and its a 1 line correction.
Its simply NetworkServer.cs @ line ~ 113 / 118 "Initialize();"is called twice in a row if s_DontListen is false.. which is usually.
I would imagine remove the 1st one on line 113. Its not currently major as inside Initialize(); there is a check to make sure its not run again.. but no never a need to call it twice and ... oh it does nothing of note in Initialize but still shoudln't be called twice.
internal static bool InternalListen(string ipAddress, int serverPort, int maxConnections)
{
Initialize();
// only start server if we want to listen
if (!s_DontListen)
{
Initialize();
See #149
Describe the bug
When child scenes are loaded additive, objects with network identities don't appear in client or server.
Repro project
https://www.dropbox.com/s/orq17qrsug7hjsi/Test%20Mirror.zip?dl=0
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Child scene networked objects should be visible.
Desktop (please complete the following information):
Additional context
No warnings or errors in console or output_log.txt but debug msgs are logged as expected.
In the _Prefabs folder, find Cubes, Cylinders, and Spheres prefabs.
Remove the Network Identity components from Cylinders, and Spheres to see what it should look like.
The Cubes in ZoneC are not networked objects and they work correctly when ZoneC is entered / exited.
If you do a build, make sure to include MainScene and SceneA, SceneB, and SceneC.
Find MrGadget in Discord if you need more info.
Describe the bug
HLAPI may fail to synchronize existing clients when a new client joins and an existing object is sent to him.
This is very hard to reproduce in real life, however I managed to reproduce it by doing data change inside "OnRebuildObservers" which happens to execute at the right time. In theory, if a new client connect between 2 synchronizations this can happen.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
All 3 instances should have the same values
Desktop (please complete the following information):
Additional context
The root cause is: when a client connects, a spawn message will be sent for that client for any existing object. This will clear the dirty bits of existing objects. Any other client that was observing them will not be updated because the object will be considered clean.
The fix is not trivial at all. It is fixed in synctoowner because there is a fundamentally different way of handling dirty bits.
Hy,
when I try to build a project for UWP, there are always 3 errors showing up, after the build finished successfully. I'll just attach text files containing the error messages, to keep this post readable. Nevertheless the build succeeded and I'm also able to deploy to Hololens, but these errors are confusing and maybe they'll cause errors in future development.
Is there something I'm missing or doing wrong?
Best regards :)
OS: Windows 10 x64
Unity: 2018.1.6f1, BuildTarget UWP
HLAPI Community Edition: 2018.1
ReferenceRewriterFoundSomeErrors.txt
ReferenceRewriterErrorMethodSystem.Void.txt
ReferenceRewriterErrorMethodSystem.UInt64.txt
Currently I do not know which version of Mirror I am getting from github or the Asset Store. I would like to add the version number to my Insight addon.
create ScriptableObject class with data of own type
use as parameter in [Command] function
editor crashes upon recompile
see repro project
reproduced on 2018.3.0b3 and 2018.3.0b6
Currently we cannot send message larger than 65Kb
This is a problem that we inherited from UNET.
This limit is too small in some cases, such as sending images. We need to lift this limit to allow much larger message sizes.
Describe the bug
I'm trying to migrate from unet to Mirror and i'm having a couple errors where I'm not sure how to fix them. (Unity 2018.2.6f1)
Mirror doesn't appear to provide:
Granted using 2018.2.6f1 I thought i could still try and see what happens, I hope this helps.
@paulpach can't remember if you talked about this before or not. what do you think about this?
Describe the bug
Mirror is not compatible with .NET Backend on UWP because of missing APIs.
See documentation here : Missing .NET APIs in Unity and UWP
To Reproduce
Steps to reproduce the behavior:
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.