Hi I have probably a simple question but I wondering what the best way to do it.
I am currently working on a game where you place a object where you raycast to the plane. After the object is placed, I got a reference to the planes that were created. How should I turn them off so they aren’t seen? Also if I do like simple renderer and collider component off, does it affect them meaning, do they stay in that state until the session is complete?
It only disables the existing ARPlanes’ GameObjects; new planes will continue to be detected. If you want to disable plane detection, disable the ARPlaneManager.
You say ‘planes will continue to be detected’ I’m confused dose the first line of code in this function() not disable enable the ARPlaneManager stopping plane detection ?
public void TogglePlaneDetection()
{
m_ARPlaneManager.enabled = !m_ARPlaneManager.enabled;
string planeDetectionMessage = "";
if (m_ARPlaneManager.enabled)
{
planeDetectionMessage = "Disable Plane Detection and Hide Existing";
SetAllPlanesActive(true);
}
else
{
planeDetectionMessage = "Enable Plane Detection and Show Existing";
SetAllPlanesActive(false);
}
if (togglePlaneDetectionText != null)
togglePlaneDetectionText.text = planeDetectionMessage;
}
Correct, disabling the ARPlaneManager will disable plane detection. I meant that deactivating the existing ARPlanes will not stop plane detection, i.e., what SetTrackablesActive does.
When you don’t want to detect planes. For example, if you have already detected a plane and placed whatever content you need, you can disable the plane detection - assuming you don’t need to place more content.
Good thing you guys mentioned turning off the detections. Once I placed in models, and detection was running, it would cause memory issues and crash. Turning off detection helped.
Hi!
I have just this problem, when i place my model (preloaded and not instantiated) cause lag and freeze for a moment…
I’ve tried everything, any suggestions? @tdmowrer
Thanks a lot!
EDIT: When i restart the Scene with an AsyncOperation, the model place without issue. I mean, only have this issue when its the first time of the “run”… I dont know why…
unnanego: Are you sure? This is what tdmowrer wrote above:
Correct, disabling the ARPlaneManager will disable plane detection. And setting an entire GO to inactive should disable all its scripts, what’s left?
As I understand, the tracking data is not stored in the GameObjects themselves, they are just a representation of the planes in the scene. My guess would be, the ARPlaneManager has the tracking data.
After giving it some thought, I think the solution is even more simple. The anchorpoints are only important if the environment changes, so your object gets repositioned to the point where foundation puts the plane after obtaining more information. Once you stop tracking, the Unity world does not change anymore and we should be fine either way.