Search Unity

LEAP MOTION - dynamically changing tracking orientation C#

Discussion in 'AR/VR (XR) Discussion' started by Mungo_, Jul 29, 2018.

  1. Mungo_

    Mungo_

    Joined:
    Jan 28, 2018
    Posts:
    5
    Hi,

    I'm working on a project where hands are tracked from both sides of the device (only one side at a time). I'm having trouble with accessing the config settings to reverse the orientation from a C# script.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Leap.Unity;
    5. using Leap;
    6.  
    7. public class LeapConfigTester : MonoBehaviour {
    8.  
    9.     public LeapServiceProvider leapProvider;
    10.     public Controller leapController;
    11.     public Config leapConfig;
    12.  
    13.     void Start()
    14.     {
    15.         leapController = leapProvider.GetLeapController();
    16.         leapConfig = leapController.Config;
    17.     }
    18.  
    19.     void Update () {
    20.         if (Input.GetKeyDown(KeyCode.Space))
    21.         {
    22.             bool isFlipped = leapConfig.GetBool("image_processing_flipped");
    23.             Debug.Log("Currently flipped: " + isFlipped);
    24.  
    25.             bool setSuccess = leapConfig.SetBool("image_processing_flipped", !isFlipped);
    26.             Debug.Log("Set success: " + setSuccess);
    27.  
    28.             bool saveSuccess = leapConfig.Save();
    29.             Debug.Log("Save success: " + saveSuccess);
    30.  
    31.             bool connectedController = leapController.IsConnected;
    32.             Debug.Log("Controller connected: " + connectedController);
    33.         }
    34.     }
    35. }
    36.  
    This prints to the console:
    Code (csharp):
    1. Currently flipped: True
    2. Set success: True
    3. Save success: False
    4. Controller connected: True
    I'm essentially trying to make the spacebar function like the "Reverse Orientation" button in the Leap Control Panel.
    Any idea why the save method is failing?

    Thanks,
    Mungo
     
    Last edited: Jul 30, 2018