It’s just a small problem, but there’s probably a really simple explanation/fix. Every time I restart my project, I get the same compile errors, so I make the same two changes to the XRInteractionManager.cs script. I make these two functions public so one of my other scripts can access them:
public void SelectEnter(XRBaseInteractor interactor, XRBaseInteractable interactable)
{
// If Exclusive Selection, is this the only interactor trying to interact?
if (interactor.requireSelectExclusive)
{
for (int i = 0; i < m_Interactors.Count; i++)
{
if (m_Interactors[i] != interactor
&& m_Interactors[i].selectTarget == interactable)
{
return;
}
}
}
else
{
for (int i = 0; i < m_Interactors.Count; i++)
{
if (m_Interactors[i].selectTarget == interactable)
SelectExit(m_Interactors[i], interactable);
}
}
interactor.OnSelectEnter(interactable);
interactable.OnSelectEnter(interactor);
}
public void SelectExit(XRBaseInteractor interactor, XRBaseInteractable interactable)
{
interactor.OnSelectExit(interactable);
interactable.OnSelectExit(interactor);
}
What’s causing this script to reset? Is it something I can prevent? Such a small thing, but as you can understand, quite an annoyance!
Until the Unity team updates XR (hopefully soon? :)) and removes all the unnecessarily private/internal methods, you need to use c# reflection to access them.
This happens in your classes, not Unity’s, so it’ll continue working across all updates.
Even better: use a static class extension, and you can effectively make the private method public, without touching Unity’s source.
You can also copy the package to a new location in your project or file system to avoid the overwriting.
We use a cache on your machine to download XR.Interaction.Toolkit. This cache is occasionally updated, and will assume it’s using an unmodified version of the package. This update will wipe over your changes.
In order to break that overwriting link, you can copy the root package folder (in this case named XR.Interaction.Toolkit), and paste it into the [Root Project Folder]/Packages folder. This will cause that version to be included in your project, and that version won’t suffer from overwrites. You can also paste that package elsewhere on your file system and use the Package Manager UI’s Add From File option if you have multiple projects that need the same change.
Then if you need to update the package to a newer version, you will need to update the cached version, then do a local merge between that and your local package.