Skip to content

Commit

Permalink
exception when using invalid sync type
Browse files Browse the repository at this point in the history
  • Loading branch information
Xytabich committed Sep 27, 2021
1 parent ebb81b0 commit 417d1b4
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Assets/Katsudon/Builder/Common/FieldsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reflection;
using Katsudon.Builder.Helpers;
using Katsudon.Info;
using VRC.Udon;

namespace Katsudon.Builder
{
Expand All @@ -20,7 +21,32 @@ public FieldsCollection(AsmTypeInfo typeInfo)
DeferredValueVariable variable;
if(info.syncMode != SyncMode.NotSynced)
{
variable = new SyncableVariable(info.name, info.field.FieldType, (info.flags & AsmFieldInfo.Flags.Export) != 0, info.syncMode);
SyncMode mode;
switch(info.syncMode)
{
case SyncMode.Linear:
if(!UdonNetworkTypes.CanSyncLinear(info.field.FieldType))
{
throw new Exception(string.Format("Field `{0}:{1}` doesn't support {2} synchronization", info.field.DeclaringType, info.field, info.syncMode));
}
mode = SyncMode.Linear;
break;
case SyncMode.Smooth:
if(!UdonNetworkTypes.CanSyncSmooth(info.field.FieldType))
{
throw new Exception(string.Format("Field `{0}:{1}` doesn't support {2} synchronization", info.field.DeclaringType, info.field, info.syncMode));
}
mode = SyncMode.Smooth;
break;
default:
if(!UdonNetworkTypes.CanSync(info.field.FieldType))
{
throw new Exception(string.Format("Field `{0}:{1}` cannot be synchronized by Udon", info.field.DeclaringType, info.field));
}
mode = SyncMode.None;
break;
}
variable = new SyncableVariable(info.name, info.field.FieldType, (info.flags & AsmFieldInfo.Flags.Export) != 0, mode);
}
else
{
Expand Down

0 comments on commit 417d1b4

Please sign in to comment.