- Reworked CameraTimedSwitcher to be able to execute callback functions.

- Cameras are thus much more reliable and less likely to desync in round 2.
This commit is contained in:
2025-12-23 05:03:14 -05:00
parent 2281fae54e
commit 27abad7657
7 changed files with 900 additions and 250 deletions
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 5
Data: 8
- Name:
Entry: 7
Data:
@@ -210,12 +210,229 @@ MonoBehaviour:
- Name: _fieldAttributes
Entry: 7
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 14|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 15|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: _LoopPoint
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _LoopPoint
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
- 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: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 20|UnityEngine.TooltipAttribute, UnityEngine.CoreModule
- Name: tooltip
Entry: 1
Data: Loop to this point in the camera sequence. Default is index 0 (the beginning)
- 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: _FirstLoopCallbackObject
- Name: $v
Entry: 7
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FirstLoopCallbackObject
- 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: 4
- 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: 3
- 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:
- Name:
Entry: 7
Data: 26|UnityEngine.TooltipAttribute, UnityEngine.CoreModule
- Name: tooltip
Entry: 1
Data: Set this to call a function on an UdonSharpBehaviour instead of looping
the camera sequence
- 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: _FirstLoopCallbackFunction
- Name: $v
Entry: 7
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FirstLoopCallbackFunction
- Name: <UserType>k__BackingField
Entry: 7
Data: 28|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String, mscorlib
- 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: 14|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 30|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -239,13 +456,13 @@ MonoBehaviour:
Data: _Active
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Active
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
Data: 32|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -254,7 +471,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -269,19 +486,19 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 18|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 34|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 19|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 35|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -305,22 +522,16 @@ MonoBehaviour:
Data: _NextCameraIndex
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _NextCameraIndex
- Name: <UserType>k__BackingField
Entry: 7
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
Entry: 9
Data: 17
- Name: <SystemType>k__BackingField
Entry: 9
Data: 21
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -335,7 +546,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -10,10 +10,16 @@ using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class CameraTimedSwitcher : UdonSharpBehaviour
{
[SerializeField] private CameraControllerBase _CameraController;
[SerializeField] private string[] _SwitchFunctions;
[SerializeField] private float _TimeBetweenCuts = 5.0f;
[SerializeField] private CameraControllerBase _CameraController;
[SerializeField] private string[] _SwitchFunctions;
[Space]
[SerializeField] private float _TimeBetweenCuts = 5.0f;
[SerializeField, Tooltip("Loop to this point in the camera sequence. Default is index 0 (the beginning)")]
private int _LoopPoint = 0;
[Space]
[SerializeField, Tooltip("Set this to call a function on an UdonSharpBehaviour instead of looping the camera sequence")]
private UdonSharpBehaviour _FirstLoopCallbackObject = null;
[SerializeField] private string _FirstLoopCallbackFunction = "";
[UdonSynced, FieldChangeCallback(nameof(Activate))] private bool _Active = false;
@@ -26,6 +32,19 @@ public class CameraTimedSwitcher : UdonSharpBehaviour
{
_CameraController.SendCustomEvent(_SwitchFunctions[_NextCameraIndex]);
_NextCameraIndex = (_NextCameraIndex + 1) % _SwitchFunctions.Length;
if (_NextCameraIndex == 0)
{
if (_FirstLoopCallbackObject != null)
{
Activate = false;
_FirstLoopCallbackObject.SendCustomEvent(_FirstLoopCallbackFunction);
return;
}
else
{
_NextCameraIndex = _LoopPoint;
}
}
SendCustomEventDelayedSeconds(nameof(SwitchToNextCamera), _TimeBetweenCuts);
}