Forum Discussion
moshangmusic
7 years agoExplorer
Render Texture with OVR Overlay causes Invalid Cast Exception
I'm attempting to display my UI as a render texture using OVR Overlay. Whenever I assign a render texture in the OVR Overlay script and run, I get the following error "InvalidCastException: Specified cast is not valid.
Normal textures assigned to the script render fine in HMD. Are there any specific settings that the render texture needs to conform to?
This is in Unity 2018.4.2f1.
OVROverlay.LatchLayerTextures () (at Assets/Oculus/VR/Scripts/OVROverlay.cs:453)
OVROverlay.LateUpdate () (at Assets/Oculus/VR/Scripts/OVROverlay.cs:903)"Normal textures assigned to the script render fine in HMD. Are there any specific settings that the render texture needs to conform to?
This is in Unity 2018.4.2f1.
3 Replies
Replies have been turned off for this discussion
- bmoodyP3ProtegeI have also had this issue. Were you able to find out why this happens?
- ForwardXP_JimExplorerAlso happens in 2019.1.2f1.Basically, when run in the editor, the OVROverlay.cs code tries to check the texture type and tries to convert a UnityEngine.NativeFormatImporter returned by UnityEditor.TextureImporter.GetAtPath to a UnityEditor.TextureImporter, which is apparently a bad cast.My solution has been to comment out the code in OVROverlay.cs. I don't like modifying the SDK code, but there's so many warnings during a compile that I've resigned myself to it. I don't think Oculus tests the SDK samples when they release the SDK.
- ForwardXP_JimExplorerYou can fix this by changing line 459 from:
var importer = (UnityEditor.TextureImporter)UnityEditor.TextureImporter.GetAtPath(assetPath);To:var importer = UnityEditor.TextureImporter.GetAtPath(assetPath) as UnityEditor.TextureImporter;
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago
- 10 months ago
- 3 years ago
- 9 months ago
- 5 years ago