forked from MerlinVR/UdonSharp
-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Please refer to following syntax inside OnPreSerialization(), it is syntactically (and logically) correct in C# (since it was just casting the underly primitive type), I was expect the first and second also works in U#, but it didn't, only the third workaround works.
using UnityEngine;
using UdonSharp;
using VRC.SDKBase;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class Enum2ByteTest : UdonSharpBehaviour
{
[SerializeField] TestEnum someEnum = TestEnum.Two;
[UdonSynced] byte syncdEnumAsByte;
public override void Interact()
{
if (!Networking.IsOwner(gameObject)) Networking.SetOwner(Networking.LocalPlayer, gameObject);
RequestSerialization();
}
public override void OnPreSerialization()
{
// This will cause serialization failed warning and fail to synchronize
syncdEnumAsByte = (byte)someEnum;
// This also fails
syncdEnumAsByte = (byte)(int)someEnum;
// This works
int intEnum = (int)someEnum;
syncdEnumAsByte = (byte)intEnum;
}
}
public enum TestEnum
{
Zero,
One,
Two,
Three,
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working