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
Describe the bug in detail:
I'm coming into this problem where when I call VRCObjectSync.Respawn() on a VRCObjectSync component, even though the component exists on the gameobject, it gives me the error "Object reference not set to an instance of an object"
Provide steps/code to reproduce the bug:
- Call
Respawn()on any VRCObjectSync component that exists on a gameobject. - Save the script and wait for the script to compile.
- Go into play mode in Unity.
- Trigger the behavior that calls
Respawn() - Script breaks and both the UdonBehavior and UdonSharp throws an error.
Expected behavior:
The expected result is for the VRCObjectSync component to be recognized and the object to respawn.
Additional Information:
Here is the full stacktrace of the UdonBehavior error:
[UdonBehaviour] An exception occurred during Udon execution, this UdonBehaviour will be halted.
VRC.Udon.VM.UdonVMException: The VM encountered an error!
Exception Message:
An exception occurred during EXTERN to 'VRCSDK3ComponentsVRCObjectSync.__Respawn__SystemVoid'.
Parameter Addresses: 0x00000041
Object reference not set to an instance of an object
----------------------
Program Counter was at: 2084
----------------------
Stack Dump:
0: 0x0000000A
----------------------
Heap Dump:
0x00000000: -8846834194911805839
0x00000001: WhitelistedToggle
0x00000002: 1960
0x00000003: Whitelist (VRC.Udon.UdonBehaviour)
0x00000004: UnityEngine.GameObject[]
0x00000005: UnityEngine.GameObject[]
0x00000006: UnityEngine.Canvas[]
0x00000007: True
0x00000008: False
0x00000009: True
0x0000000A: 4294967295
0x0000000B: __0_player__param
0x0000000C: __0_IsOnWhitelist
0x0000000D: __0___0_IsOnWhitelist__ret
0x0000000E: Mic Toggle (UnityEngine.Transform)
0x0000000F: UnityEngine.Collider
0x00000010: UnityEngine.MeshRenderer
0x00000011: 0
0x00000012: 1
0x00000013: Mic Toggle (UnityEngine.GameObject)
0x00000014: 768
0x00000015: True
0x00000016: 716
0x00000017: False
0x00000018: False
0x00000019: True
0x0000001A: Mic Toggle (VRC.Udon.UdonBehaviour)
0x0000001B: DelayedRespawn
0x0000001C: Update
0x0000001D: 1960
0x0000001E: Microphone (VRC.SDK3.Components.VRCObjectSync)
0x0000001F: Microphone (UnityEngine.Transform)
0x00000020: null
0x00000021: VRC.SDK3.Components.VRCObjectSync
0x00000022: True
0x00000023: VRC.SDKBase.VRCPlayerApi
0x00000024: True
0x00000025: True
0x00000026: Mic Toggle (UnityEngine.SphereCollider)
0x00000027: 0
0x00000028: False
0x00000029: Microphone (UnityEngine.GameObject)
0x0000002A: null
0x0000002B: 0
0x0000002C: 0
0x0000002D: False
0x0000002E: null
0x0000002F: VRC.SDKBase.VRCPlayerApi
0x00000030: True
0x00000031: VRC.SDKBase.VRCPlayerApi
0x00000032: 1
0x00000033: True
0x00000034: 0
0x00000035: False
0x00000036: True
0x00000037: True
0x00000038: True
0x00000039: 1
0x0000003A: Microphone (UnityEngine.GameObject)
0x0000003B: 0
0x0000003C: null
0x0000003D: 1
0x0000003E: 0
0x0000003F: True
0x00000040: Microphone (UnityEngine.GameObject)
0x00000041: Microphone (VRC.SDK3.Components.VRCObjectSync)
0x00000042: Microphone (UnityEngine.Transform)
0x00000043: Microphone (VRC.SDK3.Components.VRCObjectSync)
0x00000044: null
0x00000045: False
0x00000046: Microphone (VRC.SDK3.Components.VRCObjectSync)
0x00000047: VRCSDKBaseNetworking.__get_LocalPlayer__VRCSDKBaseVRCPlayerApi
0x00000048: VRCUdonCommonInterfacesIUdonEventReceiver.__SetProgramVariable__SystemString_SystemObject__SystemVoid
0x00000049: VRCUdonCommonInterfacesIUdonEventReceiver.__SendCustomEvent__SystemString__SystemVoid
0x0000004A: VRCUdonCommonInterfacesIUdonEventReceiver.__GetProgramVariable__SystemString__SystemObject
0x0000004B: UnityEngineComponent.__GetComponent__T
0x0000004C: UnityEngineCollider.__set_enabled__SystemBoolean__SystemVoid
0x0000004D: UnityEngineRenderer.__set_enabled__SystemBoolean__SystemVoid
0x0000004E: SystemArray.__get_Length__SystemInt32
0x0000004F: SystemInt32.__op_Inequality__SystemInt32_SystemInt32__SystemBoolean
0x00000050: SystemInt32.__op_LessThan__SystemInt32_SystemInt32__SystemBoolean
0x00000051: SystemObjectArray.__Get__SystemInt32__SystemObject
0x00000052: UnityEngineCanvas.__set_enabled__SystemBoolean__SystemVoid
0x00000053: SystemInt32.__op_Addition__SystemInt32_SystemInt32__SystemInt32
0x00000054: UnityEngineGameObject.__get_activeInHierarchy__SystemBoolean
0x00000055: VRCSDKBaseNetworking.__SetOwner__VRCSDKBaseVRCPlayerApi_UnityEngineGameObject__SystemVoid
0x00000056: SystemBoolean.__op_UnaryNegation__SystemBoolean__SystemBoolean
0x00000057: VRCSDKBaseNetworking.__GetOwner__UnityEngineGameObject__VRCSDKBaseVRCPlayerApi
0x00000058: UnityEngineGameObject.__SetActive__SystemBoolean__SystemVoid
0x00000059: SystemBoolean.__op_Equality__SystemBoolean_SystemBoolean__SystemBoolean
0x0000005A: VRCSDKBaseNetworking.__IsOwner__UnityEngineGameObject__SystemBoolean
0x0000005B: VRCUdonCommonInterfacesIUdonEventReceiver.__SendCustomEventDelayedFrames__SystemString_SystemInt32_VRCUdonCommonEnumsEventTiming__SystemVoid
0x0000005C: UnityEngineGameObject.__get_transform__UnityEngineTransform
0x0000005D: UnityEngineObject.__op_Equality__UnityEngineObject_UnityEngineObject__SystemBoolean
0x0000005E: VRCSDK3ComponentsVRCObjectSync.__Respawn__SystemVoid
0x0000005F: UnityEngineComponent.__GetComponent__SystemType__UnityEngineComponent
----------------------
Inner Exception:
---> VRC.Udon.VM.UdonVMException: An exception occurred during EXTERN to 'VRCSDK3ComponentsVRCObjectSync.__Respawn__SystemVoid'.
Parameter Addresses: 0x00000041
---> System.NullReferenceException: Object reference not set to an instance of an object
at VRC.SDK3.ClientSim.ClientSimObjectSyncHelper.RespawnObject (VRC.SDK3.Components.VRCObjectSync sync) [0x00000] in .\Packages\com.vrchat.worlds\Integrations\ClientSim\Runtime\Helpers\ClientSimObjectSyncHelper.cs:18
at VRC.SDK3.Components.VRCObjectSync.Respawn () [0x00009] in <6ff4ff48394b436282bb70dc0ff277c2>:0
at VRC.Udon.Wrapper.Modules.ExternVRCSDK3ComponentsVRCObjectSync.__Respawn__SystemVoid (VRC.Udon.Common.Interfaces.IUdonHeap heap, System.Span`1[T] parameterAddresses) [0x0001d] in <b001fa9908f1453c979dae8b67f4c4f7>:0
at VRC.Udon.VM.UdonVM.Interpret () [0x00273] in <62e4a0d35446446b8fa1f8e5755bcfaa>:0
--- End of inner exception stack trace ---
at VRC.Udon.VM.UdonVM.Interpret () [0x0033c] in <62e4a0d35446446b8fa1f8e5755bcfaa>:0
--- End of inner exception stack trace ---
at VRC.Udon.VM.UdonVM.Interpret () [0x00436] in <62e4a0d35446446b8fa1f8e5755bcfaa>:0
at VRC.Udon.UdonBehaviour.RunProgram (System.UInt32 entryPoint) [0x00063] in .\Packages\com.vrchat.worlds\Runtime\Udon\UdonBehaviour.cs:1098
UnityEngine.Debug:LogError (object,UnityEngine.Object)
VRC.Core.Logger:LogError (string,string,UnityEngine.Object)
VRC.Udon.UdonBehaviour:RunProgram (uint) (at ./Packages/com.vrchat.worlds/Runtime/Udon/UdonBehaviour.cs:1112)
VRC.Udon.UdonBehaviour:RunProgram (string) (at ./Packages/com.vrchat.worlds/Runtime/Udon/UdonBehaviour.cs:1072)
VRC.Udon.UdonBehaviour:SendCustomEvent (string) (at ./Packages/com.vrchat.worlds/Runtime/Udon/UdonBehaviour.cs:1743)
VRC.Udon.ClientBindings.UdonEventScheduler:ProcessFrameEvents (VRC.Udon.Common.Enums.EventTiming)
VRC.Udon.ClientBindings.UdonEventScheduler:RunScheduledEvents (VRC.Udon.Common.Enums.EventTiming)
VRC.Udon.UdonManager:Update () (at ./Packages/com.vrchat.worlds/Runtime/Udon/UdonManager.cs:376)
This is the UdonSharp error:
[UdonSharp] Assets/Assets/Scripts/Events/Whitelist/WhitelistedToggle.cs(94,27): Udon runtime exception detected!
An exception occurred during EXTERN to 'VRCSDK3ComponentsVRCObjectSync.__Respawn__SystemVoid'.
Parameter Addresses: 0x00000041
Object reference not set to an instance of an object
And this is my code:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.SDK3.Components;
using VRC.Udon;
public class WhitelistedToggle : UdonSharpBehaviour
{
[Tooltip("Set this to the game object that contains the Whitelist script.")]
public Whitelist whitelist;
// private VRCPlayerApi localPlayer;
[Tooltip("Add the objects that you want to toggle on and off.")]
public GameObject[] objectsToToggle;
[Tooltip("Add any of the toggled object's children that have udon behaviors.")]
public GameObject[] childObjects;
[Tooltip("A list of canvases to hide for unwhitelisted people.")]
public Canvas[] hiddenCanvases;
[Tooltip("If this option is enabled, the object will be respawned whenever it is toggled on.")]
public bool respawnOnEnable;
[Tooltip("If this option is enabled, this object will not be rendered for people who are not whitelisted.")]
public bool hideMeshIfNotWhitelisted;
[UdonSynced, FieldChangeCallback(nameof(ToggledOn))]
private bool _toggledOn;
void Start()
{
}
void OnEnable() {
bool onWhitelist = whitelist.IsOnWhitelist(Networking.LocalPlayer);
this.GetComponent<Collider>().enabled = onWhitelist;
if (hideMeshIfNotWhitelisted) {
this.GetComponent<MeshRenderer>().enabled = onWhitelist;
}
if (hiddenCanvases.Length != 0) {
foreach (Canvas canvas in hiddenCanvases) {
canvas.enabled = onWhitelist;
}
}
_toggledOn = objectsToToggle[0].activeInHierarchy;
}
public override void Interact() {
// localPlayer = Networking.LocalPlayer;
Networking.SetOwner(Networking.LocalPlayer, this.gameObject);
ToggledOn = !ToggledOn;
}
public bool ToggledOn
{
set
{
_toggledOn = value;
VRCPlayerApi owner = Networking.GetOwner(this.gameObject);
if (objectsToToggle.Length != 0) {
foreach (GameObject toggleObj in objectsToToggle) {
toggleObj.SetActive(value);
Networking.SetOwner(owner, toggleObj);
}
}
if (childObjects.Length != 0) {
// Debug.Log(childObjects.Length);
foreach (GameObject thisObj in childObjects) {
Networking.SetOwner(owner, thisObj);
}
}
if (respawnOnEnable && value == true && objectsToToggle.Length != 0 && Networking.IsOwner(this.gameObject)) {
foreach (GameObject toggleObj2 in objectsToToggle) {
VRCObjectSync sync = toggleObj2.GetComponent<VRCObjectSync>();
if (sync == null) {
continue;
}
sync.Respawn();
}
}
}
get => _toggledOn;
}
}The error gets called during sync.Respawn();
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working