this avoids the first line of the stacktrace being on the same line as the Exception. this is better because the Exception line could be line and it is easy to miss the first stack trace line.
* moving FindPath to editor scripts
this allows this function to be used by other scripts
* Update Assets/Mirror/Editor/EditorHelper.cs
* removing extra using
* fix: prevent allocation of massive array
A poison message could contain an invalid length causing us to allocate massive arrays
* throw exception instead
* Update Assets/Mirror/Runtime/NetworkReader.cs
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
* test for ReadArray
* swapping order of equation so that length doesnt overflow
* adding test case
* adding more tests for array length
* swapping order
* fixing expected message
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
Unity has added new private LogWarning methods in 2020.2 which causes weaver to find the wrong method. Checking the parameters as we as the name will find the correct method.
fixes: https://github.com/vis2k/Mirror/issues/2366
* adding MakeGeneric method
* adding tests for NB syncvar+hook
* adding functions to NetworkBehaviour
* getting references to new functions
* fixing NB read so it always reads same number of bytes as write
* adding backing field and serialize for Nb Syncvar
* extra test
* adding ignore to transform test
* fixing test
Seems like this has come up a few times so here is a commit to sort this out.
We shouldn't have to worry about the order of the using, we should just let plugins automatically sort them. They are sorted into alphabetical order expect for system becase we have `dotnet_sort_system_directives_first = true` enabled in `.editorconfig`
* fix: stopping values being reset before OnDestory is called
* matches server side logic
* if an object is being fully destroyed it doesn't need its values to be reset
* adding read/write functions
* adding method to get WriteNetworkBehaviour
* adding methods to weavertypes
* adding method to get ReadNetworkBehaviour
* weaver test for NetworkBehaviour in RPC
* renaming var
* writing tests to make sure read/write works
* registering functions
* changing function and adding comment
* checking any writer is set
* adding Description to test
* collection test
* fixing call
* removing errors, networkbehaviour as read/write
* adding test to use the reader that weaver generates
* fixing import
* simplifying test
* removing null from spawned
* improving throw
* adding code coverage
* applying code suggestions
* Using TypeReference with IEqualityComparer instead of string to keep reference to type
* using targetType to initialize write/read functions
* test to make sure write function is set
```
UnityException: ToString is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'GamePlay' on game object 'GamePlay'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.Object.ToString () (at <a979f18d51af41179d12b797e8c5be14>:0)
UnityEngine.Logger.GetString (System.Object message) (at <a979f18d51af41179d12b797e8c5be14>:0)
UnityEngine.Logger.LogError (System.String tag, System.Object message) (at <a979f18d51af41179d12b797e8c5be14>:0)
Mirror.NetworkBehaviour.InitSyncObject (Mirror.SyncObject syncObject) (at Assets/System/3rdParty/Mirror/Runtime/NetworkBehaviour.cs:168)
myGame.GamePlay..ctor () (at Assets/System/GamePlay.cs:18)
```
- consolidate nested if
- set kinematic by default on scene objects
- set kinematic false on server in AddForce::Start
- added field for Rigidbody component reference via inspector
- eliminated calling GetComponent every frame
- set SyncInverval to zero on both NetworkTransforms and NetworkRigidbody
* Changed oldColor to underscore in hook in RandomColor
* WIP
* feat: Updated Basic Example
- PlayerUI is now separated from player object
- PlayerUI is event driven from the Player object
- PlayerUI is locally instantiated, instead of networked
- added border to players panel
* fixed code smells
* moved playersList to BasicNetManager
* fixed compile error and improved layout
* fixed tooltips
Co-authored-by: MrGadget1024 <chris@clevertech.net>
Having near identical lines in these functions is confusing at first glace. Having RegisterWriteFunc call Register makes it more clear exactly what is going on
* formatting
* moving comment about buffer next to buffer
* moving comment to doc comment
* doc comment position
* doc comments for Length
* doc comments for ReadBlittable
* doc comments for ReadBytes
* doc comments for ReadBytesSegment
* doc comments for ToString
* doc comments for NetworkReaderExtensions
* comments for ReadString
* exception comments for read bytes/segement
* fixing comment
* fix(weaver): Warning for multiple write/read functions for the same type
Adding warning message when trying to register a write or read function for a type that is already in dictionary. Previously weaver would be silent about this making it hard to know when an extension method overrides another one.
* test for warnings
* checking buffer length is atleast 2
disconnect if invalid message
* using const instead of magic number
Adding test to make sure that writing id is the same size as IdSize
* adding comment
* renaming to HeaderSize
* delegate and callbacks instead of unityevent
* using callbacks in Mirror
* Using new callbacks instead of events
* moving methods next to each other in NetworkClient
* moving add/remove to methods in NetworkServer
* replacing uses of events within transports and tests
* fixing tests
* fixing more tests
* replacing delegates with actions
* adding comments to show what action variable's are
* removing extra function created in rebase
* renaming callbacks
* adding reset methods so that actions arn't null
* fixing rename
* breaking defines
* Update Assets/Mirror/Runtime/Transport/KCP/MirrorTransport/KcpTransport.cs
* Update KcpTransport.cs
* Update Transport.cs
* removing ResetHandlers methods
transports can now call events after stop is called
Co-authored-by: vis2k <info@noobtuts.com>
* adding try/catch to hanlder
user code can throw errors.
* Update Assets/Mirror/Runtime/MessagePacker.cs
* Update Assets/Mirror/Runtime/MessagePacker.cs
* test for command that throws
* disconnecting client after Exception in message handler
Co-authored-by: vis2k <info@noobtuts.com>
Generating readers and writers for structs in other assemblies
could sometimes cause a
```
System.ArgumentException: Member 'xxx' is declared in another module and needs to be imported
```
This in particular affected unity mathematics.
fixes#2406
* Round trip time bool and tooltip.
I've added this RTT boolean and a tooltip, might clear up some confusion for future users.
Many believe ping is time to server, and rtt is ping pong.
* Round trip time bool and tooltip.
I've added this RTT boolean and a tooltip, might clear up some confusion for future users.
Many believe ping is time to server, and rtt is ping pong.
* Round trip time bool and tooltip.
I've added this RTT boolean and a tooltip, might clear up some confusion for future users.
Many believe ping is time to server, and rtt is ping pong.
* Round trip time bool and tooltip.
I've added this RTT boolean and a tooltip, might clear up some confusion for future users.
Many believe ping is time to server, and rtt is ping pong.
Changed the default 100ms to 10ms
Double checked with Vis in Discord "tooltip is meant to say 10ms."
Already seen one screenshot of a Discord user that set this from 10 to 100, due to the typo, believing 100 was meant to be default and not 10.
* NetworkWriter consistency: Write(U)Ints moved to static extension methods for consistency with all the other writer functions like WriteUInt16.
This makes life easier because weaver looks for all Write(U)Int functions in the same place. Otherwise packed writes can't be removed in a later PR without breaking weaver (which is also evidence for being bad design before)
* NetworkReader consistency: removed redundant Read(U)Ints
* breaking: Obsolete Read/WritePacked functions and use the regular ones everywhere. We are not bandwidth limited but CPU limited, so this is good. Those were overly complex and worst of all they cause non deterministic packet sizes. a player packet might spawn fine in editor, but 1 month into production it might very well hit the 1200 MTU limit if health is suddenly >241 or the Vector2Int position is somewhere else. This was insanity.
* NetworkWriter consistency: Write(U)Ints moved to static extension methods for consistency with all the other writer functions like WriteUInt16.
This makes life easier because weaver looks for all Write(U)Int functions in the same place. Otherwise packed writes can't be removed in a later PR without breaking weaver (which is also evidence for being bad design before)
* NetworkReader consistency: removed redundant Read(U)Ints
* Return and log warning on start already started client or server
* Apply suggestions from code review, Always check for client and server active state
Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
* Update Assets/Mirror/Runtime/NetworkManager.cs
* Update Assets/Mirror/Runtime/NetworkManager.cs
* Update Assets/Mirror/Runtime/NetworkManager.cs
* Update Assets/Mirror/Runtime/NetworkManager.cs
* Update Assets/Mirror/Runtime/NetworkManager.cs
* Update Assets/Mirror/Runtime/NetworkManager.cs
Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
Co-authored-by: vis2k <info@noobtuts.com>
* adding kcp2k asmdef
marked with allowUnsafeCode
* adding reference to new kcp2k asmdef, and unmarking allowUnsafeCode
* adding public gettings for list/queue count
* Update Assets/Mirror/Runtime/Transport/KCP/MirrorTransport/KcpTransport.cs
Co-authored-by: vis2k <info@noobtuts.com>