-
-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: weaver syncLists now checks for SerializeItem in base class (#1768)
* tests for override in base class * fixing overrides in base class * moving check up so that typedef cant be null for the check
- Loading branch information
1 parent
54fa1b1
commit 1af5b4e
Showing
6 changed files
with
113 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Assets/Mirror/Tests/Editor/Weaver/WeaverSyncListTests~/SyncListInheritanceWithOverrides.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Mirror; | ||
using UnityEngine; | ||
|
||
namespace MirrorTest | ||
{ | ||
class SyncListInheritanceWithOverrides : NetworkBehaviour | ||
{ | ||
readonly SomeExtraList superSyncListString = new SomeExtraList(); | ||
} | ||
|
||
// Type that cant have custom writer | ||
public class MyBehaviourWithValue : NetworkBehaviour | ||
{ | ||
public Vector3 target; | ||
} | ||
|
||
public class SomeBaseList : SyncList<MyBehaviourWithValue> | ||
{ | ||
protected override void SerializeItem(NetworkWriter writer, MyBehaviourWithValue item) | ||
{ | ||
writer.WriteUInt32(item.netId); | ||
writer.WriteVector3(item.target); | ||
} | ||
protected override MyBehaviourWithValue DeserializeItem(NetworkReader reader) | ||
{ | ||
NetworkIdentity item = NetworkIdentity.spawned[reader.ReadUInt32()]; | ||
MyBehaviourWithValue behaviour = item.GetComponent<MyBehaviourWithValue>(); | ||
|
||
behaviour.target = reader.ReadVector3(); | ||
|
||
return behaviour; | ||
} | ||
} | ||
|
||
// Sync List type is MyBehaviourWithValue | ||
// MyBehaviourWithValue is an invalid type, so requires custom writers | ||
// Custom writers exist in base class so SomeExtraList should work without errors | ||
public class SomeExtraList : SomeBaseList | ||
{ | ||
// do extra stuff here | ||
} | ||
} |