Reworking the choice cards to use VRCObjectSync. This is too hard. :c

This commit is contained in:
2026-05-20 01:01:06 -04:00
parent b234da3820
commit 4f58eedcda
10 changed files with 1981 additions and 991 deletions
+285 -18
View File
@@ -20,7 +20,7 @@ MonoBehaviour:
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 4
hasInteractEvent: 1
hasInteractEvent: 0
scriptID: -4699376671505787403
serializationData:
SerializedFormat: 2
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 5
Data: 9
- Name:
Entry: 7
Data:
@@ -150,12 +150,219 @@ MonoBehaviour:
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 10|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 11|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _Pickup
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Pickup
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCPickup, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 15|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 16|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _ObjectSync
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ObjectSync
- Name: <UserType>k__BackingField
Entry: 7
Data: 18|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCObjectSync, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 18
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 20|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: CardInteractObject
- Name: $v
Entry: 7
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: CardInteractObject
- Name: <UserType>k__BackingField
Entry: 7
Data: 22|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UdonSharp.UdonSharpBehaviour, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 24|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 25|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -179,13 +386,13 @@ MonoBehaviour:
Data: _Mesh
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Mesh
- Name: <UserType>k__BackingField
Entry: 7
Data: 12|System.RuntimeType, mscorlib
Data: 27|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.MeshRenderer, UnityEngine.CoreModule
@@ -194,7 +401,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 12
Data: 27
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -209,13 +416,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 14|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 29|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -239,13 +446,13 @@ MonoBehaviour:
Data: _SpawnPosition
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _SpawnPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
Data: 31|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform, UnityEngine.CoreModule
@@ -254,7 +461,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
Data: 31
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -269,13 +476,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 18|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 33|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -299,16 +506,16 @@ MonoBehaviour:
Data: _HeldPosition
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _HeldPosition
- Name: <UserType>k__BackingField
Entry: 9
Data: 16
Data: 31
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
Data: 31
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -323,13 +530,73 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 21|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 36|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _AnchorMode
- Name: $v
Entry: 7
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _AnchorMode
- Name: <UserType>k__BackingField
Entry: 7
Data: 38|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: CardAnchorMode, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 40|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
+87 -19
View File
@@ -1,34 +1,76 @@
using UdonSharp;
using UnityEngine;
using VRC.SDK3.UdonNetworkCalling;
using VRC.Udon.Common.Interfaces;
using VRC.SDK3.Components;
using VRC.SDKBase;
using VRC.Udon.Common;
public enum CardAnchorMode
{
None,
AtSpawn,
InHeldPosition
}
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class ChoiceCard : UdonSharpBehaviour
{
[UdonSynced] public int ChoiceNumber = 0;
[Space]
[SerializeField] private ChoiceCardGroup CardGroup = null;
[Space]
[SerializeField] private VRCPickup _Pickup;
[SerializeField] private VRCObjectSync _ObjectSync;
[Space]
[SerializeField] private UdonSharpBehaviour CardInteractObject;
[SerializeField] private MeshRenderer _Mesh;
[SerializeField] private Transform _SpawnPosition;
[SerializeField] private Transform _HeldPosition;
[UdonSynced] private CardAnchorMode _AnchorMode = CardAnchorMode.None;
public override void OnPickup()
public override void OnOwnershipTransferred(VRCPlayerApi Player)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)CardGroup, NetworkEventTarget.All, "ChoiceCardPickedUp", ChoiceNumber);
if (Utilities.IsValid(_Pickup))
{
Networking.SetOwner(Player, _Pickup.gameObject);
}
base.OnOwnershipTransferred(Player);
}
public override void Interact()
public override void OnDeserialization(DeserializationResult Result)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)CardGroup, NetworkEventTarget.All, "ChoiceCardInteract", ChoiceNumber);
_SetPosition_Synced();
base.OnDeserialization(Result);
}
public void SetCardGroup(ChoiceCardGroup ParentCardGroup)
public void ChoiceCardPickedUp()
{
CardGroup = ParentCardGroup;
CardGroup.ChoiceCardPickedUp(ChoiceNumber);
_ObjectSync.enabled = true;
}
public void ChoiceCardInteract()
{
CardGroup.ChoiceCardInteract(ChoiceNumber);
_ObjectSync.enabled = false;
}
public new void DisableInteractive(bool Disable)
{
CardInteractObject.DisableInteractive = Networking.IsOwner(gameObject) ? Disable : true;
}
public void SetPickupable(bool Pickupable)
{
_Pickup.pickupable = Networking.IsOwner(gameObject) ? Pickupable : false;
}
public void SetColourMaterial(Material Colour)
@@ -36,21 +78,47 @@ public class ChoiceCard : UdonSharpBehaviour
_Mesh.sharedMaterial = Colour;
}
[NetworkCallable]
public void SetToHeldPosition()
{
transform.SetParent(_HeldPosition, false);
transform.localPosition = Vector3.zero;
transform.localEulerAngles = Vector3.zero;
InteractionText = "Reveal";
_Pickup.Drop();
_ObjectSync.enabled = false;
_Pickup.InteractionText = "Reveal";
_AnchorMode = CardAnchorMode.InHeldPosition;
_SetPosition_Synced();
RequestSerialization();
}
[NetworkCallable]
public void ResetPosition()
{
transform.SetParent(_SpawnPosition, false);
transform.localPosition = Vector3.zero;
transform.localEulerAngles = Vector3.zero;
InteractionText = "Choose";
_Pickup.Drop();
_Pickup.InteractionText = "Choose";
_AnchorMode = CardAnchorMode.AtSpawn;
_SetPosition_Synced();
RequestSerialization();
}
private void _SetPosition_Synced()
{
_ObjectSync.enabled = false;
switch (_AnchorMode)
{
case CardAnchorMode.None:
case CardAnchorMode.AtSpawn:
_Pickup.transform.SetParent(_SpawnPosition, false);
_Pickup.transform.localPosition = Vector3.zero;
_Pickup.transform.localRotation = Quaternion.identity;
break;
case CardAnchorMode.InHeldPosition:
_Pickup.transform.SetParent(_HeldPosition, false);
_Pickup.transform.localPosition = Vector3.zero;
_Pickup.transform.localRotation = Quaternion.identity;
break;
}
}
}
+382 -52
View File
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 7
Data: 13
- Name:
Entry: 7
Data:
@@ -116,31 +116,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ChoiceCards
Data: _ChoiceCardEnabler
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChoiceCards
Data: _ChoiceCardEnabler
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: ChoiceCard[], Assembly-CSharp
Data: UnityEngine.GameObject, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 9|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -155,13 +149,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 10|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 11|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -182,25 +176,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ChoiceCardText
Data: _ChoiceCards
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChoiceCardText
Data: _ChoiceCards
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TMPro.TextMeshProUGUI[], Unity.TextMeshPro
Data: ChoiceCard[], Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -242,19 +242,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ChoiceCardColourOptions
Data: _ChoiceCardText
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChoiceCardColourOptions
Data: _ChoiceCardText
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Material[], UnityEngine.CoreModule
Data: TMPro.TextMeshProUGUI[], Unity.TextMeshPro
- Name:
Entry: 8
Data:
@@ -302,19 +302,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _PCCardHeldPosition
Data: _ChoiceCardColourOptions
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _PCCardHeldPosition
Data: _ChoiceCardColourOptions
- Name: <UserType>k__BackingField
Entry: 7
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject, UnityEngine.CoreModule
Data: UnityEngine.Material[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -362,25 +362,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _PCCardAnimator
Data: _PCCardHeldPosition
- Name: $v
Entry: 7
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _PCCardAnimator
Data: _PCCardHeldPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 25|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 25
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -395,13 +389,355 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 27|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 26|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _PCCardAnimator
- Name: $v
Entry: 7
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _PCCardAnimator
- Name: <UserType>k__BackingField
Entry: 7
Data: 28|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 28
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 30|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _Enabled
- Name: $v
Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Enabled
- Name: <UserType>k__BackingField
Entry: 7
Data: 32|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 34|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _Colour
- Name: $v
Entry: 7
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Colour
- Name: <UserType>k__BackingField
Entry: 7
Data: 36|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 36
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 38|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _ChoiceTextVisibleForAllPlayers
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChoiceTextVisibleForAllPlayers
- Name: <UserType>k__BackingField
Entry: 9
Data: 32
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 40|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 41|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _ChoiceLocked
- Name: $v
Entry: 7
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChoiceLocked
- Name: <UserType>k__BackingField
Entry: 9
Data: 32
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 43|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 44|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _TurnForward
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _TurnForward
- Name: <UserType>k__BackingField
Entry: 9
Data: 32
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 46|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 47|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -425,22 +761,16 @@ MonoBehaviour:
Data: _SelectedChoice
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _SelectedChoice
- Name: <UserType>k__BackingField
Entry: 7
Data: 29|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
Entry: 9
Data: 36
- Name: <SystemType>k__BackingField
Entry: 9
Data: 29
Data: 36
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -455,13 +785,13 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 49|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 31|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 50|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
+139 -59
View File
@@ -2,43 +2,79 @@
using TMPro;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDK3.UdonNetworkCalling;
using VRC.SDKBase;
using VRC.Udon.Common.Interfaces;
using VRC.Udon.Common;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class ChoiceCardGroup : UdonSharpBehaviour
{
[SerializeField] private PlayerPodium _Podium;
[SerializeField] private GameObject _ChoiceCardEnabler;
[SerializeField] private ChoiceCard[] _ChoiceCards;
[SerializeField] private TextMeshProUGUI[] _ChoiceCardText;
[SerializeField] private Material[] _ChoiceCardColourOptions;
[SerializeField] private GameObject _PCCardHeldPosition;
[SerializeField] private Animator _PCCardAnimator;
[UdonSynced] private bool _Enabled = false;
[UdonSynced] private int _Colour = -1;
[UdonSynced] private bool _ChoiceTextVisibleForAllPlayers = false;
[UdonSynced] private bool _DisableInteractive = false;
[UdonSynced] private bool _SetPickupable = true;
[UdonSynced] private bool _ChoiceLocked = false;
[UdonSynced] private bool _TurnForward = false;
[UdonSynced] private int _SelectedChoice = -1;
void Start()
public override void OnDeserialization(DeserializationResult Result)
{
for (int i = 0; i < _ChoiceCards.Length; i++)
{
ChoiceCard Card = _ChoiceCards[i];
_SetEnabled_Synced();
_DisableInteractive_Synced();
_SetPickupable_Synced();
_SetColourChoice_Synced();
_MakeChoiceTextVisible_Synced();
_TurnForward_Synced();
Card.SetCardGroup(this);
}
base.OnDeserialization(Result);
}
[NetworkCallable]
public override void OnOwnershipTransferred(VRCPlayerApi Player)
{
foreach (ChoiceCard Card in _ChoiceCards)
{
Networking.SetOwner(Player, Card.gameObject);
}
base.OnOwnershipTransferred(Player);
}
public void SetEnabled(bool Enable, int ColourChoice)
{
_Enabled = Enable;
_SetEnabled_Synced();
ResetCards(ColourChoice, false);
MakeChoiceTextVisible(false, false);
RequestSerialization();
}
private void _SetEnabled_Synced()
{
_ChoiceCardEnabler.gameObject.SetActive(_Enabled);
}
public void ChoiceCardPickedUp(int ChoiceNumber)
{
_SelectedChoice = ChoiceNumber;
RequestSerialization();
}
[NetworkCallable]
public void ChoiceCardInteract(int ChoiceNumber)
{
if (_SelectedChoice == ChoiceNumber)
@@ -49,22 +85,16 @@ public class ChoiceCardGroup : UdonSharpBehaviour
_SelectedChoice = ChoiceNumber;
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
Debug.Assert(Player != null);
for (int i = 0; i < _ChoiceCards.Length; i++)
foreach (ChoiceCard Card in _ChoiceCards)
{
ChoiceCard Card = _ChoiceCards[i];
_PCCardAnimator.SetBool("Turn Forward", false);
Card.DisableInteractive = false;
Card.DisableInteractive(false);
if (Card.ChoiceNumber == _SelectedChoice)
{
if (!Player.IsUserInVR())
if (!Networking.LocalPlayer.IsUserInVR())
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)Card, NetworkEventTarget.All, "SetToHeldPosition");
Card.DisableInteractive = true;
Card.SetToHeldPosition();
Card.DisableInteractive(true);
}
}
else
@@ -72,27 +102,29 @@ public class ChoiceCardGroup : UdonSharpBehaviour
Card.ResetPosition();
}
}
RequestSerialization();
}
private void _TurnForward_Synced()
{
_PCCardAnimator.SetBool("Turn Forward", _TurnForward);
}
private void RevealChoice()
{
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
if (Player != null && !Player.IsUserInVR())
if (!Networking.LocalPlayer.IsUserInVR())
{
for (int i = 0; i < _ChoiceCards.Length; i++)
foreach (ChoiceCard Card in _ChoiceCards)
{
ChoiceCard Card = _ChoiceCards[i];
if (Card.ChoiceNumber == _SelectedChoice)
{
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.Drop();
}
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)Card, NetworkEventTarget.All, "SetToHeldPosition");
_PCCardAnimator.SetBool("Turn Forward", true);
Card.DisableInteractive = true;
Card.SetToHeldPosition();
_TurnForward = true;
_TurnForward_Synced();
Card.DisableInteractive(true);
RequestSerialization();
}
else
{
@@ -118,37 +150,54 @@ public class ChoiceCardGroup : UdonSharpBehaviour
}
}
[NetworkCallable]
public void MakeChoiceTextVisible()
public void MakeChoiceTextVisible(bool VisibleForAllPlayers = false, bool RequestSerialisation = true)
{
for (int i = 0; i < _ChoiceCards.Length && i < _ChoiceCardText.Length; i++)
_ChoiceTextVisibleForAllPlayers = VisibleForAllPlayers;
_MakeChoiceTextVisible_Synced(true);
if (RequestSerialisation)
{
_ChoiceCardText[i].gameObject.SetActive(true);
RequestSerialization();
}
}
private void _MakeChoiceTextVisible_Synced(bool VisibleLocally = false)
{
for (int i = 0; i < _ChoiceCardText.Length; i++)
{
_ChoiceCardText[i].gameObject.SetActive(VisibleLocally || _ChoiceTextVisibleForAllPlayers);
}
}
public void LockInChoice()
{
for (int i = 0; i < _ChoiceCards.Length; i++)
_ChoiceLocked = true;
_LockInChoice_Synced();
RequestSerialization();
}
private void _LockInChoice_Synced()
{
if (_ChoiceLocked)
{
ChoiceCard Card = _ChoiceCards[i];
if (Card.ChoiceNumber == _SelectedChoice) { Card.DisableInteractive = false; continue; }
Card.DisableInteractive = true;
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null) { Pickup.pickupable = false; }
foreach (ChoiceCard Card in _ChoiceCards)
{
if (Card.ChoiceNumber == _SelectedChoice) { Card.DisableInteractive(false); continue; }
_DisableInteractive = true;
_DisableInteractive_Synced();
_SetPickupable = false;
_SetPickupable_Synced();
}
}
}
public void ResetCards(int Colour = 0)
public void ResetCards(int Colour = 0, bool RequestSerialisation = true)
{
_SelectedChoice = -1;
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
Debug.Assert(Player != null);
bool IsInVR = Networking.LocalPlayer.IsUserInVR();
bool IsInVR = Player.IsUserInVR();
for (int i = 0; i < _ChoiceCards.Length; i++)
for (int i = 0; i < _ChoiceCards.Length && i < _ChoiceCardText.Length; i++)
{
ChoiceCard Card = _ChoiceCards[i];
@@ -156,18 +205,49 @@ public class ChoiceCardGroup : UdonSharpBehaviour
_ChoiceCardText[i].text = "";
_ChoiceCardText[i].gameObject.SetActive(false);
Card.SetColourMaterial(_ChoiceCardColourOptions[Colour]);
_Colour = Colour;
_SetColourChoice_Synced();
Card.DisableInteractive = IsInVR;
_DisableInteractive = IsInVR;
_DisableInteractive_Synced();
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.pickupable = IsInVR;
}
_SetPickupable = IsInVR;
_SetPickupable_Synced();
}
_PCCardAnimator.SetBool("Turn Forward", false);
_TurnForward = false;
_TurnForward_Synced();
_ChoiceLocked = false;
_LockInChoice_Synced();
if (RequestSerialisation)
{
RequestSerialization();
}
}
private void _SetColourChoice_Synced()
{
foreach (ChoiceCard Card in _ChoiceCards)
{
Card.SetColourMaterial(_ChoiceCardColourOptions[(_Colour >= 0 && _Colour < _ChoiceCardColourOptions.Length) ? _Colour : 0]);
}
}
private void _DisableInteractive_Synced()
{
foreach (ChoiceCard Card in _ChoiceCards)
{
Card.DisableInteractive(_DisableInteractive);
}
}
private void _SetPickupable_Synced()
{
foreach (ChoiceCard Card in _ChoiceCards)
{
Card.SetPickupable(_SetPickupable);
}
}
public int GetColourOptionsCount()
+2 -4
View File
@@ -185,9 +185,7 @@ public class PlayerPodium : UdonSharpBehaviour
[NetworkCallable]
public void EnableChoiceCards(bool Enable, int ColourChoice)
{
_ChoiceCards.gameObject.SetActive(Enable);
_ChoiceCards.ResetCards(ColourChoice);
_ChoiceCards.SendCustomNetworkEvent(NetworkEventTarget.Owner, "MakeChoiceTextVisible");
_ChoiceCards.SetEnabled(Enable, ColourChoice);
}
[NetworkCallable]
@@ -200,7 +198,7 @@ public class PlayerPodium : UdonSharpBehaviour
public void LockInChoice()
{
_ChoiceCards.LockInChoice();
_ChoiceCards.SendCustomNetworkEvent(NetworkEventTarget.All, "MakeChoiceTextVisible");
_ChoiceCards.MakeChoiceTextVisible(true);
}
public bool VerifyMultipleChoiceResponse(int CorrectResponse)