DINO-Unity icon indicating copy to clipboard operation
DINO-Unity copied to clipboard

Scene changing issue when using Hl2Dino

Open nmitrak opened this issue 9 months ago • 2 comments

Hi First of all congratulations on developing this application. I am using the HL2Dino dll in a MRTK application but there is an issue when i try to load another scene of my application that doesn't use the HL2dino plugin. When i try to debug the operation i am getting the error from the Microsoft Visual Studio "Unhandled exception at 0x00007FF86A4431A8 (HL2DinoPlugin.dll) in _SolarSystem.exe: 0xC0000005: Access violation reading location 0x0000000000000000." I am using the MRTK Scene Transition manager and everything is operating smoothly until the moment i load the scene which is using the HL2Dino plugin. After loading this scene , none other scene is loaded, application crashes and i am getting the above unhandled exception. Any idea how this could be handled? Thank you very much in advance

nmitrak avatar Mar 07 '25 22:03 nmitrak

Hi, unfortunately I haven't used multi scene setups much, especially on the HL2. Is there a minimal example/setup you can share of how the Scene Transition manager is used in your app?

Can't promise I'll be able to solve the issue as I'm not too experienced with this!

hiqb217 avatar Mar 15 '25 10:03 hiqb217

First of all thank you very much for your response. I am using the MRTK Scene Transition manager to change scenes in Hololens 2. The fist scene i use doesn't incorporate HL2Dino and all scene changes occur without any problem. The problem occurs when the scene that uses HL2Dino is loaded. This HL2Dino scene works perfectly (thank you very much for that) but when i try to change to another scene from this point on, the application crashes. I think , as read from the debug messages, when scene changes HL2 tries to allocate a register that is not accessible i think and everything crashes. Maybe the dll continues to harvest data that cannot be handled? Below there is an example for the code i use for the scene transitions


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.SceneSystem;
using Microsoft.MixedReality.Toolkit.Extensions.SceneTransitions;
using System.Runtime.InteropServices;
using System;
using System.Threading.Tasks;

public class SceneTransition : MonoBehaviour
{
	
		
	public async void TransitionToScene(string SceneName)
	{
		ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
		IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
		
		
		// Fades out
		// Loads scene using Unity's scene manager
		// Fades back in
		string activeScene;
		activeScene=SceneManager.GetActiveScene().name;
		sceneSystem.UnloadContent(activeScene);
		await transition.DoSceneTransition(
			() => LoadScene(SceneName)
		);
	}

	private async Task LoadScene(string sceneName)
	{
		AsyncOperation asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
		while (!asyncOp.isDone)
		{
			await Task.Yield();
		}
	}
	

nmitrak avatar Mar 17 '25 15:03 nmitrak