Object instance missing after going from inactive to active(HTC Utility)
Hello Community!
I've created a Player Controller and a Pawn "Possess" and "Unpossess" system, but it seems that If I set an object inactive at the start then active when I want to possess the object, References seem to disappear(Mostly the HTC Utility Vivepointer instances to be exact).
NullReferenceException: Object reference not set to an instance of an object
Teleportable.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/ThirdParty/HTC.UnityPlugin/ViveInputUtility/Examples/4.Teleport/Scripts/Teleportable.cs:19)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
HTC.UnityPlugin.Pointer3D.Pointer3DInputModule:ProcessPress(Pointer3DEventData) (at Assets/ThirdParty/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs:322)
HTC.UnityPlugin.Pointer3D.Pointer3DInputModule:ProcessRaycast() (at Assets/ThirdParty/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs:227)
HTC.UnityPlugin.Pointer3D.Pointer3DInputModule:UpdateModule() (at Assets/ThirdParty/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs:66)
UnityEngine.EventSystems.EventSystem:Update()
That's the error I'm getting in particular when I try to select to Teleport. Everything else seems to work great, just the HTC Utility seems to lose object references once deactivated.
Any Idea what's going on here?
Teleportable.cs (in the HTC Utility plug-in)
public void OnPointerClick(PointerEventData eventData)
{
var viveEventData = eventData as VivePointerEventData;
POINTS AT THIS LINE =============> if (viveEventData != null && viveEventData.viveButton == ControllerButton.Pad &&
/**CUSTOM CODE**/PC.bTeleportMode/****************/)
{
var headVector = Vector3.ProjectOnPlane(pivot.position - target.position, target.up);
var targetPos = viveEventData.pointerCurrentRaycast.worldPosition - headVector;
if (fadeDuration <= 0)
{
target.position = targetPos;
}
else
{
if (teleportCoroutine == null)
{
teleportCoroutine = StartCoroutine(StartTeleport(targetPos, fadeDuration));
}
}
}
}
Comment