Commit Graph

2832 Commits

Author SHA1 Message Date
vis2k
ae48cf5c80 perf: kcp2k V1.6 - unreliable channel & improvements 2021-01-10 19:28:50 +08:00
MrGadget1024
8f4856c715 fix: fixed Chat example scene for 2018.4 2021-01-09 20:00:13 -05:00
MrGadget1024
e52dfeb07a Applied Mirror Icon to MiddlewareTransport 2021-01-07 12:12:21 -05:00
vis2k
b85dea57df fix: kcp2k updated to V1.5. bigger send/recv window size defaults because Mirror sends a lot of data. fixes a bug where some projects would encounter ever growing latencies because kcp didn't process/send data fast enough, causing slowly growing send/recv buffers. also shows MaxSend/RecvRate in debug gui now. 2021-01-08 00:00:10 +08:00
MrGadget1024
f10f6f913a doc: Updated ReadMe 2021-01-07 09:34:33 -05:00
MrGadget1024
ca94fca82f fixed NetworkIdentityTest
- removed unused var
2021-01-07 09:22:24 -05:00
MrGadget1024
b85557b8ea Fixed NetworkWriterTest
- Removed unnecessary using
- Removed unused vars
- made netId a uint
2021-01-07 09:20:02 -05:00
Coburn
9393686f16
fix: NetworkWriterTest.cs failing due to Blittable removal (#2530)
This commit compliments dd4d344542, and makes all tests in NetworkWriterTest.cs pass with flying colours. Gold star!
2021-01-05 00:44:38 +08:00
MrGadget1024
0a01edfbd5 fix: Fixed tests for OnStopClient
OnNetworkDestroy was renamed to OnStopClient in May 2020
2021-01-03 21:14:05 -05:00
MrGadget1024
ec972ca46a Removed MonoBehaviour inheritance in Spawners 2021-01-03 13:02:09 -05:00
Coburn
dd4d344542
Revert "perf: NetworkWriter/Reader Write/ReadBlittable<T> for 4-6x performance improvement! (#2441)" (#2526)
This reverts commit 1947f061ad and applies some patches to bring it back up to date without the DOTSNET feature.
2021-01-03 20:52:34 +08:00
James Frowen
eb6b7e73b9
fix: adding newline before StackTrace
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.
2020-12-31 01:58:20 +00:00
James Frowen
d22db33086
Moving FindPath to editor scripts (#2512)
* moving FindPath to editor scripts

this allows this function to be used by other scripts

* Update Assets/Mirror/Editor/EditorHelper.cs

* removing extra using
2020-12-25 16:49:14 +08:00
James Frowen
1cf5930d51
feat: Adding default folder as argument for ScriptableObjectUtility (#2513)
This allows ScriptableObjectUtility to be used for other folders not just Asset/Mirror
2020-12-24 15:29:36 +08:00
MrGadget
41480ac42f
fix: DisallowMultipleComponent on all transports (#2507)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-12-20 10:28:58 +08:00
MrGadget1024
8ad332a64d fixed typo in comment 2020-12-19 14:58:08 -05:00
vis2k
c72fd39f19 NetworkReader.ReadNetworkBehaviour: don't log warning if netId is not in spawned. This is common if we have a [SyncVar] NetworkBeaviour that walks out of proximity range. 2020-12-19 21:39:24 +08:00
vis2k
c7b2d1d1d3 use more obvious syntax 2020-12-19 21:38:39 +08:00
vis2k
4e30409db5 NetworkReader.ReadNetworkIdentity: don't log warning if netId is not in spawned. This is common if we have a [SyncVar] NetworkIdentity that walks out of proximity range. 2020-12-19 21:37:43 +08:00
Paul Pacheco
45a494aded
fix: prevent allocation of massive array (#2465)
* 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>
2020-12-17 12:12:26 +08:00
MrGadget
f2e78da58c
fix: Changed all fields in examples from [SerializeField] internal to public per Vis request. (#2502)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-12-17 12:06:04 +08:00
MrGadget1024
2aa4c84ae5 Added meta file 2020-12-16 23:00:09 -05:00
James Frowen
50a214613f
fix(weaver): Weaver finds correct log methods for unity 2020.2 (#2497)
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
2020-12-17 11:43:37 +08:00
Antoine Place
613851ff3c
Added an example featuring multiple match on a single server using the Match Checker component. (#2499)
Co-authored-by: Antoine Place <antoine.place@youkado.com>
2020-12-17 11:42:06 +08:00
MrGadget1024
8fcb7719e2 fix: Updated Basic example to work in Unity 2018.4 2020-12-16 15:05:58 -05:00
MrGadget
58aeb622ba
Make IDisposable classes sealed (#2495)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-12-14 11:12:03 +08:00
James Frowen
e7e36d0558 feat(SimpleWebTransport): adding option to allow for tls outside of the transport 2020-12-12 14:53:23 +00:00
MrGadget1024
2f24d9aa2b fix: Added OnStopServer to NetworkMatchChecker 2020-12-10 14:50:49 -05:00
MrGadget1024
36814e6abb fix: Removed debug logging from NeworkSceneChecker
They were added for testing OnStop Server and forgot to take them out.
2020-12-10 14:49:41 -05:00
MrGadget1024
484b80f0bb fix: Added OnStopServer to NetworkSceneChecker 2020-12-10 14:44:25 -05:00
Tiago Martines
6f8a289384
Disable KCP console logging when debugLog flag is off (#2488)
* Disable KCP console logging when debugLog flag is off

* Update KcpTransport.cs

* Update KcpTransport.cs

Co-authored-by: Tiago Martines <tiago.martines@wildlifestudios.com>
Co-authored-by: vis2k <info@noobtuts.com>
2020-12-09 14:29:38 +08:00
James Frowen
c3e2a26378
feat: allow types that inherit from Networkbehaviour to be used in syncvar's (#2471)
* 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
2020-12-09 10:53:26 +08:00
James Frowen
99f7e9112d
perf(NetworkTransform): removing allocations from Command (#2491)
`byte[] payload` will cause a new array to be created when parameters are read, using `ArraySegment<byte>` avoids this.
2020-12-08 16:01:39 +08:00
MrGadget1024
53694e3be3 fix: NetworkRoomManager.ReadyStatusChanged made public 2020-12-06 18:36:00 -05:00
James Frowen
2b91a3049b
Sorting usings (#2487)
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`
2020-12-05 10:51:02 +08:00
James Frowen
a51ee1fa3b
fix: stopping values being reset before OnDestory is called (#2485)
* 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
2020-12-03 15:50:52 +00:00
James Frowen
4acf0d69e0
feat: Allow Networkbehaviours to be sent in rpc (#2478)
* 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
2020-12-02 09:40:38 +08:00
James Frowen
798a4cab33
breaking: Unity LLAPI transport meets the recycle bin. (#2484) 2020-12-02 01:35:53 +00:00
James Frowen
adabbdc552
using TypeReference with comparer instead of string (#2481)
* 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
2020-12-01 00:32:10 +00:00
James Frowen
05f6690484
weaver: moving IsNetworkIdentityField to extensions (#2476)
* weaver: moving IsNetworkIdentityField to extensions

* making extension use TypeReference
2020-11-29 21:51:19 -06:00
James Frowen
3bc58a851a
weaver: making GenerateWriter return MethodReference (#2479) 2020-11-30 03:05:57 +00:00
James Frowen
f9baa3f9da
making IsDerivedFrom use TypeReference (#2475) 2020-11-29 20:02:46 -06:00
MrGadget1024
58d6db72ad fix: NetworkRoomManager and NetworkRoomPlayer public fields
Made fields public again for inheritance.
2020-11-29 01:52:26 -05:00
MrGadget1024
b3e7aa9d95 fix: NetworkBehaviour throwing error in logger
```
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)
```
2020-11-28 23:03:36 -05:00
MrGadget1024
bcd1c6fbab renamed rb to non-abbreviated name 2020-11-28 22:53:57 -05:00
MrGadget1024
930d0cbbfd Tanks Example Improvements
- made fields private with SerializeField
2020-11-28 19:55:11 -05:00
MrGadget1024
8efd45c0d2 Room Example Improvements
- made fields private / internal with SerializeField
- CapsuleCollider is always on
2020-11-28 19:51:01 -05:00
MrGadget1024
12231c3be7 Pong Example Improvements
- made fields private with SerializeField
2020-11-28 19:26:20 -05:00
MrGadget1024
6823fb9d2e Multiple Additive Scenes Example Improvements
- made fields private / internal with SerializeField
- simplified Spawner to use prefab directly from MultiSceneNetManager
2020-11-28 19:12:57 -05:00
MrGadget1024
982b268b87 Additive Scenes Example Improvements
- Player Collider is always on
- made fields private with SerializeField
2020-11-28 18:53:14 -05:00
MrGadget1024
d6cfd2eadf perf: Improvements to RigidbodyPhysics Example
- 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
2020-11-28 18:14:13 -05:00
MrGadget1024
d0ee88150f Removed AsmDef from RigidBodyPhysics example 2020-11-28 18:03:13 -05:00
MrGadget1024
c6f0554bd8 Removed Obsolete from TelepathyTransport 2020-11-28 17:30:33 -05:00
MrGadget1024
090b83e583 Chat Example: made field private with SerializeField 2020-11-28 17:29:38 -05:00
MrGadget1024
f735ad2f6b Chat Example: made field private with SerializeField 2020-11-28 15:45:02 -05:00
MrGadget1024
1339ab7065 fix: Fixed broken reference in Chat example scene 2020-11-28 15:44:27 -05:00
MrGadget1024
6027b8056d Basic Example: Made fields internal with SerializeField 2020-11-28 15:43:02 -05:00
MrGadget1024
0856bc008a perf: Applied Channels.DefaultUnreliable to Experimental Network Transform 2020-11-28 10:20:24 -05:00
MrGadget1024
1616f57db0 perf: Added Compress / Decompress Quaternion to Experimental Network Transform 2020-11-28 10:16:01 -05:00
vis2k
fde07decfc
perf: NetworkTransform compresses rotation from 16 to 4 bytes. (#2469)
1024 entities => 4KB instead of 16KB
2020-11-28 12:12:17 +08:00
vis2k
3d5c942d85 fix: kcp2k V1.4. fixes a bug where KcpConnection message processing can now be stopped immediately when transport was disabled after scene change message; MirrorTransport uses turbo mode by default now 2020-11-27 18:28:10 +08:00
vis2k
cca5c12f4d remove unused import 2020-11-27 17:34:09 +08:00
vis2k
5e4a86e3aa perf: Kcp: use 'turbo mode' configuration in all examples(https://github.com/skywind3000/kcp/blob/master/README.en.md#protocol-configuration) 2020-11-27 17:09:59 +08:00
vis2k
cbcace8dfe
fix: NetworkScenePostProcess now stops editor for invalid sceneIds (#2468)
Better than launching with sceneId errors, which never works.
2020-11-27 15:55:49 +08:00
vis2k
b96d0d2284
fix: NetworkScenePostProcess gives proper error message if currently in prefab edit mode. (#2467)
Previously it would give 'a scene needs to be resaved', which is confusing.
2020-11-27 15:54:25 +08:00
vis2k
4ea25feee7 Syntax 2020-11-27 12:53:02 +08:00
MrGadget1024
01d5358145 Rephrased comment 2020-11-26 19:57:56 -05:00
MrGadget1024
ee24eae3f6 feat: NetworkServer.maxConnections is now public
Fixes #2448
2020-11-25 22:52:48 -05:00
MrGadget
fa9aa67cc6
feat: Updated Basic Example (#2461)
* 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>
2020-11-25 22:39:31 -05:00
James Frowen
b14fa87f1a
docs: adding explanation for Compression for ScaleToUInt parameters 2020-11-25 23:41:48 +00:00
vis2k
31c3c2f924 Telepathy: Common.ReadMessageBlocking: log warning instead of logging OverflowException if size header is negative 2020-11-25 21:51:43 +08:00
James Frowen
ff6ced11aa
docs: fixing cref (#2463) 2020-11-24 21:25:54 +00:00
MrGadget1024
fb8c3c4736 fix: broken links to documentation 2020-11-23 10:59:11 -05:00
MrGadget1024
e0fb14feea Changed oldColor to underscore in hook in RandomColor 2020-11-22 21:49:01 -05:00
James Frowen
c84b317a7b
Calling Register from RegisterWriteFunc and adding comments (#2451)
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
2020-11-23 10:35:16 +08:00
James Frowen
800a3d934b
docs(NetworkWriter): doc comments for WriteBlittable (with benchmark) (#2459)
* docs(NetworkWriter): doc comments for WriteBlittable

* Update Assets/Mirror/Runtime/NetworkWriter.cs
2020-11-23 10:32:19 +08:00
James Frowen
96a03a3d59
docs(NetworkReader): doc comments (#2460)
* 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
2020-11-23 10:31:50 +08:00
MrGadget
3a5da1d256
feat: Add OnStopServer / OnStopClient methods to Network Authenticator (#2447)
* feat: Add OnStopServer / OnStopClient methods to Network Authenticator

* Added calls to Network Manager

* Added OnStopServer / OnStopClient overrides to Authenticators

Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-11-22 10:44:56 +08:00
James Frowen
301e791d9d
fix(weaver): Warning for multiple write/read functions for the same type (#2453)
* 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
2020-11-22 10:42:53 +08:00
James Frowen
fd9a7b0561
docs(NetworkWriter): doc comments (#2455)
* style for writer<T>

* adding doc comments to function that miss it
2020-11-22 10:40:06 +08:00
James Frowen
c8e4333d4e
docs(Transport): adding rules to remarks on transport (#2450)
* adding rules to remarks on transport

* adding default channel rule
2020-11-21 17:10:09 +00:00
James Frowen
2bd6675d19
Checking buffer length is atleast 2 (#2433)
* 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
2020-11-21 11:41:35 +08:00
vis2k
995fd06a77 ignore warning in tests 2020-11-20 23:50:36 +08:00
James Frowen
d3d3113f7b
perf(transport): BREAKING: callbacks instead of unityevent for transports (#2417)
* 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>
2020-11-20 23:47:56 +08:00
MrGadget1024
347a376dad fix: Fixed PlayerScore Display in MultipleAdditiveScenes Example 2020-11-19 23:58:14 -05:00
MrGadget1024
72ae5cb7a7 fix: Fixed issues in MultipleAdditiveScenes example
- Fixed NRE when no host player in PlayerScore
- Fixed player collisions by making the collider always on
2020-11-19 22:24:16 -05:00
MrGadget1024
43cea98ef9 Fixed typos 2020-11-18 11:28:01 -05:00
vis2k
1947f061ad
perf: NetworkWriter/Reader Write/ReadBlittable<T> for 4-6x performance improvement! (#2441)
* Mirror asmdef: allow unsafe

* perf: NetworkWriter.WriteBlittable<T> for 4-6x performance improvement

* perf: NetworkReader.ReadBlittable<T>

* Remove unused conversion structs

* Add sizeof(T) vs Marshal.SizeOf<T> comments

* Add 'BlittableOnThisPlatform' test to be sure
2020-11-18 10:46:45 +08:00
James Frowen
cebc578abb
moving transport handler code to functions (#2444)
this matches Networkclient
2020-11-17 14:46:37 +00:00
James Frowen
72fa903125
Refactor add transport handlers 2 (#2443)
* moving add/remove methods next to each other

* renaming methods for clarity
2020-11-17 08:37:55 -06:00
James Frowen
c95f7d4da9
moving add/remove methods next to each other (#2442) 2020-11-17 08:36:21 -06:00
James Frowen
793d3478fc perf: Increase write performance (https://github.com/MirrorNetworking/SimpleWebTransport/pull/25)
* adding options to increase performance of send loop

adding config to Transport

* removing extra comments

* changing default value of sleep to false
2020-11-17 14:25:18 +00:00
vis2k
1ca61547ea Performance Tests: create big enough writer to measure without runtime resizes 2020-11-17 20:59:40 +08:00
vis2k
968c2e86ec Syntax 2020-11-17 20:48:05 +08:00
vis2k
54e680f61c Performance Tests: simplify WriteInt so it truly only measures WriteInt 2020-11-17 20:47:49 +08:00
vis2k
eaf1df2dc1 better 2020-11-17 20:46:37 +08:00
vis2k
f577864877 Performance Tests: add WriteQuaternion to test a more complex type 2020-11-17 20:46:37 +08:00
James Frowen
7bb312bdb8
adding try/catch to handler so server doesn't crash from user exceptions (#2435)
* 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>
2020-11-17 15:51:29 +08:00
vis2k
2a5af1af20 kcp2k V1.3 2020-11-17 15:41:37 +08:00
James Frowen
54869c9ba2
finding handler inside TransportReceive so we dont need to check true/false (#2439) 2020-11-16 16:09:32 +00:00