ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
357 stars 82 forks source link

Controller binding demo doesn't work on quest #162

Closed wirelessdreamer closed 4 years ago

wirelessdreamer commented 4 years ago

the default save location on android trys to save the config file in a place that is not allowed on android. android targets (Wave, Quest) need to save the controller binding config in an appropriate place.

chengnay commented 4 years ago

@wirelessdreamer What should I do to reproduce your issue? I am not sure how to save the controller binding config on Android device.

wirelessdreamer commented 4 years ago

set the target platform to android, build and push to a device. watch the logs in logcat. make sure you have 2 controllers active. assign a role to one of them and when you hit save, you'll see an error in log cat that the default location it try's to save the config to isn't accessable on android.

The solution is to save to https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html for android instead.

chengnay commented 4 years ago

@wirelessdreamer After you save the file, does it load successfully on start? VIU's binding does not support Android, that's why we did not allow developer to check "Load Binding Config on Start". If you tested and it works, I will fix the bug.

wirelessdreamer commented 4 years ago

It doesn't save at all, because android doesn't have write permission to the location it try's to save to.

chengnay commented 4 years ago

It doesn't save at all, because android doesn't have write permission to the location it try's to save to.

I mean using your method, it will save to that persistent data path. Try to modify your cs file, Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/ViveRole/BindingInterface/BindingInterfaceConfigPanelController.cs, public void SaveConfig() { ViveRoleBindingsHelper.LoadBindingConfigFromRoleMap();

if UNITY_ANDROID

ViveRoleBindingsHelper.SaveBindingConfigToFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);

else

ViveRoleBindingsHelper.SaveBindingConfigToFile(VIUSettings.bindingConfigFilePath);

endif

m_dirtySymble.SetActive(false);

}

wirelessdreamer commented 4 years ago

I made the suggested modifications, and no errors are thrown when save is clicked, but the next the the test app gets loaded, the saved bindings don't get loaded either.

chengnay commented 4 years ago

@wirelessdreamer By editing the same script, but under ReloadConfig function.

if UNITY_ANDROID

        ViveRoleBindingsHelper.LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);

else

         ViveRoleBindingsHelper.LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath);

endif

To allow load on start, modify Assets\HTC.UnityPlugin\ViveInputUtility\Scripts\ViveRole\ViveRoleBindingsHelper.cs, Under TryInitializeOnLoad function,

if UNITY_ANDROID

            if (LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath))

else

            if (LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath))

endif

wirelessdreamer commented 4 years ago

with the above changes, the config never gets loaded. the reload buttons works to load the saved config. I tried the below, and a version where i removed the check for autoLoadBindingConfigOnStart, to always run it, and neither of them loaded the config.

I updated TryInitializeOnLoad to this:

    private static void TryInitializeOnLoad()
    {
        if (VIUSettings.autoLoadBindingConfigOnStart)
        {

if UNITY_ANDROID

if(LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath)) {
    var appliedCount = ApplyBindingConfigToRoleMap();                
    Debug.Log("android ViveRoleBindingsHelper: " + appliedCount + " bindings applied from " + Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);
}

else

if (LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath)){ var appliedCount = ApplyBindingConfigToRoleMap(); Debug.Log("ViveRoleBindingsHelper: " + appliedCount + " bindings applied from " + VIUSettings.bindingConfigFilePath); }

endif

        }

        if (!Active && VIUSettings.enableBindingInterfaceSwitch)
        {
            Initialize();
        }
    }
wirelessdreamer commented 4 years ago

Ignore that last one. the push didn't make it onto the device. Your suggested solution resolved all the issues. feel free to close this once they're in trunk :)