yo peoples.
Below a very basic script, attached to a game object in a scene with number of box colliders. Run in the editor the script works correctly, drawing a debug line to the detected colliders, and outputing the number of collisions detected to the console.
When I deploy the same scene to the Hololens, I get an exception.
“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
StackTrace " at UnityEngineProxy.InternalCalls.PInvokeCalls.Physics_CUSTOM_INTERNAL_CALL_OverlapSphereNonAlloc(IntPtr param_0, Single param_1, Int64 param_2, Int32 param_3, Int32 param_4, Int64& outExceptionHandle)\r\n at UnityEngineProxy.InternalCalls.Physics_CUSTOM_INTERNAL_CALL_OverlapSphereNonAlloc(IntPtr position, Single radius, Object results, Int32 layerMask, Int32 queryTriggerInteraction)\r\n at UnityEngine.Physics.INTERNAL_CALL_OverlapSphereNonAlloc(Vector3& position, Single radius, Collider[ ] results, Int32 layerMask, QueryTriggerInteraction queryTriggerInteraction)\r\n at UnityEngine.Physics.OverlapSphereNonAlloc(Vector3 position, Single radius, Collider[ ] results)\r\n at Test.Update()\r\n at Test.$Invoke6Update(Int64 instance, Int64* args)\r\n at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)" string
Any thoughts, suggestions etc would be much appreciated.
cheers
Vinnie
public class Test : MonoBehaviour {
private Collider[] overlapResults = new Collider[10];
public int NumberOfCollisions = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
NumberOfCollisions = Physics.OverlapSphereNonAlloc(transform.position, 10f, overlapResults);
for (int i = 0; i < NumberOfCollisions; i++)
{
Debug.DrawLine(transform.position, overlapResults[i].transform.position, Color.red);
}
Debug.Log("collisions " + this.NumberOfCollisions);
}
}