Start a new topic

Swtiching between Horizontal & Vertical Plane in Instant Tracking without using Scenes

 Hello,


I'm developing an application which determines the Plane Orientation to be Horizontal or Vertical based on some API data it receives on Run time.


My question is how can I change the Plane Orientation without making the Scene change ?


To avoid the Scene change, I've already made two copies of Game objects with required properties set, and these objects are Inactive from beginning of the application. I'm instantiating these game objects based on the API response.


The issue I'm unable to understand is, the app crashes randomly at some point when I try to toggle between them.


Hi, 


Have you tried using the TrackingPlaneOrientation property on the InstantTracker? You can set it when the tracker is in Initialization phase, otherwise it won't be considered. This way you don't need to have multiple copies of the GameObject.


Best regards,

Alexandru

Hi,


I tried what you suggested, but that it didn't work.


I'm sharing with you my sample project, with all the details int it. Please find a README.txt file in the Assets folder. I have mentioned everything about the idea, and the process I tired doing, with all required scenes and scripts.


Note: My Unity Version is 2017.3.0f3

My Target platforms are iOS and Android.


Link: https://we.tl/t-99Xar3OJWb

Hi, 


Thank you for sending the project.

You're right, the TrackingOrientationPlane doesn't work after the InstantTracker started, so it doesn't work during the initialization state. We'll fix this in the 8.1.0 release.

However, you can set the TrackingOrientationPlane to InstantTrackingPlaneOrientation.Custom and then set the TrackingPlaneOrientationAngle to either 0 for horizontal or 90 for vertical. I verified this in your project in the Instant Tracking scene, using the existing "Is Horizontal?" toggle. I added the following method to the InstantTrackingController.cs


    public void OnPlaneOrientationChanged(bool value) {
        if (value) {
            Debug.Log("Horizontal toggle is on, switching to horizontal");
            Tracker.TrackingPlaneOrientation = InstantTrackingPlaneOrientation.Custom;
            Tracker.TrackingPlaneOrientationAngle = 0.0f;
        } else {
            Debug.Log("Horizontal toggle is off, switching to vertical");
            Tracker.TrackingPlaneOrientation = InstantTrackingPlaneOrientation.Custom;
            Tracker.TrackingPlaneOrientationAngle = 90.0f;
        }
    }


Then, in the Inspector of the Toggle, I added OnPlaneOrientationChanged as a callback to the On Value Changed event and tested on the device.

If you have any other issues, or if this workaround doesn't fix your issue, please let me know.


Best regards,

Alexandru

Login or Signup to post a comment