Closed wirelessdreamer closed 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.
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.
@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.
It doesn't save at all, because android doesn't have write permission to the location it try's to save to.
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();
ViveRoleBindingsHelper.SaveBindingConfigToFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);
ViveRoleBindingsHelper.SaveBindingConfigToFile(VIUSettings.bindingConfigFilePath);
m_dirtySymble.SetActive(false);
}
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.
@wirelessdreamer By editing the same script, but under ReloadConfig function.
ViveRoleBindingsHelper.LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);
ViveRoleBindingsHelper.LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath);
To allow load on start, modify Assets\HTC.UnityPlugin\ViveInputUtility\Scripts\ViveRole\ViveRoleBindingsHelper.cs, Under TryInitializeOnLoad function,
if (LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath))
if (LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath))
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(LoadBindingConfigFromFile(Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath)) {
var appliedCount = ApplyBindingConfigToRoleMap();
Debug.Log("android ViveRoleBindingsHelper: " + appliedCount + " bindings applied from " + Application.persistentDataPath + "/" + VIUSettings.bindingConfigFilePath);
}
if (LoadBindingConfigFromFile(VIUSettings.bindingConfigFilePath)){ var appliedCount = ApplyBindingConfigToRoleMap(); Debug.Log("ViveRoleBindingsHelper: " + appliedCount + " bindings applied from " + VIUSettings.bindingConfigFilePath); }
}
if (!Active && VIUSettings.enableBindingInterfaceSwitch)
{
Initialize();
}
}
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 :)
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.