i have a problem with my INetworkSerializable
i want to pass network varible of basickly a transform and i did it lke that
public class ShotBase : NetworkBehaviour, IDamager
{
public struct NetworkTransformROT_SCL_POS : INetworkSerializable
{
public Vector3 Position;
public Quaternion Rotation;
public Vector3 Scale;
public void FromTransform(Transform transform)
{
Position = transform.position;
Rotation = transform.rotation;
Scale = transform.localScale;
}
public void ApplyToTransform(Transform transform)
{
transform.position = Position;
transform.rotation = Rotation;
transform.localScale = Scale;
}
public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref Position);
/ serializer.SerializeValue(ref Rotation);
serializer.SerializeValue(ref Scale);
}
}
public NetworkVariable<NetworkTransformROT_SCL_POS> PositioningEmitter = new NetworkVariable<NetworkTransformROT_SCL_POS>(default,
NetworkVariableReadPermission.Owner, NetworkVariableWritePermission.Server);
public virtual void Start()
{
FireCommanded_net = false;
//NOT IMPLEMENTED
//Use InitialSet as default Start/Constructor unless external dependency requires Start()
print("start " + transform.localScale + this.name);
Debug.Log(“22”);
PositioningEmitter = new NetworkVariable<NetworkTransformROT_SCL_POS>();
PositioningEmitter.Value.FromTransform(this.transform);
Debug.Log(“11”);
}
…
and later on stuff like that:
PositioningEmitter = new NetworkVariable<NetworkTransformROT_SCL_POS>();
PositioningEmitter.Value.FromTransform(this.transform);
the game is running but its not working right and i cant oper shotlaser scripts or any other scripts in the inspector like there is an error -
in the console on edit mode i see this:
ArgumentException: Invalid generic arguments
Parameter name: typeArguments
System.Reflection.RuntimeMethodInfo.MakeGenericMethod (System.Type[ ] methodInstantiation) (at <0de99929796b4095b47389e59e446fbd>:0)
Unity.Netcode.Editor.NetworkBehaviourEditor.RenderNetworkVariable (System.Int32 index) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Editor/NetworkBehaviourEditor.cs:85)
Unity.Netcode.Editor.NetworkBehaviourEditor.OnInspectorGUI () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Editor/NetworkBehaviourEditor.cs:236)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.b__0 () (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
not sure why and how to dix it - basicly i just wanted to have the transorm(pos scale and rotaion of an emitter to be synced)
thx!

