mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Simplify validation
This commit is contained in:
parent
c590b89836
commit
95972329af
@ -240,17 +240,13 @@ void SerializeModeTransform(NetworkWriter writer)
|
||||
|
||||
void VerifySerializeComponentExists()
|
||||
{
|
||||
bool throwError = false;
|
||||
Type componentMissing = null;
|
||||
|
||||
switch (transformSyncMode)
|
||||
{
|
||||
case TransformSyncMode.SyncCharacterController:
|
||||
m_CharacterController = m_CharacterController ?? GetComponent<CharacterController>();
|
||||
if (!m_CharacterController)
|
||||
{
|
||||
throwError = true;
|
||||
componentMissing = typeof(CharacterController);
|
||||
throw new InvalidOperationException(string.Format("transformSyncMode set to {0} but no CharacterController component was found, did you call NetworkServer.Spawn on a prefab?", transformSyncMode));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -258,8 +254,7 @@ void VerifySerializeComponentExists()
|
||||
m_RigidBody2D = m_RigidBody2D ?? GetComponent<Rigidbody2D>();
|
||||
if (!m_RigidBody2D)
|
||||
{
|
||||
throwError = true;
|
||||
componentMissing = typeof(Rigidbody2D);
|
||||
throw new InvalidOperationException(string.Format("transformSyncMode set to {0} but no Rigidbody2D component was found, did you call NetworkServer.Spawn on a prefab?", transformSyncMode));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -267,16 +262,10 @@ void VerifySerializeComponentExists()
|
||||
m_RigidBody3D = m_RigidBody3D ?? GetComponent<Rigidbody>();
|
||||
if (!m_RigidBody3D)
|
||||
{
|
||||
throwError = true;
|
||||
componentMissing = typeof(Rigidbody);
|
||||
throw new InvalidOperationException(string.Format("transformSyncMode set to {0} but no Rigidbody component was found, did you call NetworkServer.Spawn on a prefab?", transformSyncMode));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (throwError && componentMissing != null)
|
||||
{
|
||||
throw new InvalidOperationException(string.Format("transformSyncMode set to {0} but no {1} component was found, did you call NetworkServer.Spawn on a prefab?", transformSyncMode, componentMissing.Name));
|
||||
}
|
||||
}
|
||||
|
||||
void SerializeMode3D(NetworkWriter writer)
|
||||
|
Loading…
Reference in New Issue
Block a user