-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: weaver support array of custom types (#1470)
* WIP * Proposed Rearrange * Rearrange Code * Unit test for PR * unit test * unit test * Update TestingScriptableObjectArraySerialization.cs Improving code * Update TestingScriptableObjectArraySerialization.cs * Remove blank lines * remove blank space * Remove leftover log Co-authored-by: MrGadget <chris@clevertech.net> Co-authored-by: Uchiha I_A_H_I <jkaran.sharma101@gmail.com>
- Loading branch information
1 parent
1736bb0
commit d0b0bc9
Showing
4 changed files
with
73 additions
and
14 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
38 changes: 38 additions & 0 deletions
38
Assets/Mirror/Tests/Editor/WeaverTests~/TestingScriptableObjectArraySerialization.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,38 @@ | ||
using Mirror; | ||
using UnityEngine; | ||
|
||
namespace MirrorTest | ||
{ | ||
public static class CustomSerializer | ||
{ | ||
public static void Writedata(this NetworkWriter writer, Data arg) | ||
{ | ||
writer.WriteInt32(arg.Var1); | ||
} | ||
|
||
public static Data Readdata(this NetworkReader reader) | ||
{ | ||
return new Data | ||
{ | ||
Var1 = reader.ReadInt32() | ||
}; | ||
} | ||
} | ||
|
||
public class Data : ScriptableObject | ||
{ | ||
public int Var1; | ||
} | ||
|
||
public class PlayerScript : NetworkBehaviour | ||
{ | ||
[Command] | ||
public void | ||
CmdwriteArraydata( | ||
Data[] arg) //This gonna give error saying-- Mirror.Weaver error: Cannot generate writer for scriptable object Data[]. Use a supported type or provide a custom writer | ||
{ | ||
|
||
//some code | ||
} | ||
} | ||
} |