cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] Unity - Oculus rooms - Invitations : ovrID_FromString missing

Manzalab
Honored Guest
Hello,

I'm trying to handle the callback for : SetRoomInviteNotificationCallback
the issue is that it returns a string.

In native, we must use the function : "ovrID_FromString", like this :
const char *roomIDString = ovr_Message_GetString(response);
ovrID roomID;
ovrID_FromString(&roomID, roomIDString));
// we can now try to join the room
But we don't have this ovrID_FromString available anywhere in Unity, so I tried to create it like this in CAPI script :
[DllImport(DLL_NAME, CallingConvention=CallingConvention.Cdecl, EntryPoint= "ovrID_FromString")]
private static extern void ovrID_FromString(IntPtr retval, [MarshalAs(UnmanagedType.LPStr)] string str);
public static ulong IDFromString(string str)
{
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ulong)));
ovrID_FromString(ptr, str);
ulong retval = new ulong();
Marshal.StructureToPtr((object)retval, ptr, false);
Marshal.FreeHGlobal(ptr);
return retval;
}
I think the code doesn't work as expected since I receive a Message with IsError setted to true.

Have you faced the same issue ? Do you have a solution ?

Thanks,
Sylafrs (at Manzalab).





2 REPLIES 2

Manzalab
Honored Guest
When something is missing, comments feels like a troll x)

      /// Indicates that the user has accepted an invitation, for example in Oculus
      /// Home. Use Message.GetString() to extract the ID of the room that the user
      /// has been inivted to as a string. Then call ovrID_FromString() to parse it
      /// into an ovrID.
      ///
      /// Note that you must call Room.Join() if you want to actually join the room.
      Notification_Room_InviteAccepted = 0x6D1071B1,

Meh :tongue:

Manzalab
Honored Guest
[DllImport(DLL_NAME, CallingConvention=CallingConvention.Cdecl, EntryPoint= "ovrID_FromString")]
public static extern bool ovrID_FromString(out ulong retval, [MarshalAs(UnmanagedType.LPStr)] string str);

Works just fine 🙂

Turns out that it simply parses directly into a UInt32 ^^' (tested it earlier, but I had other issues...)

My problem is solved, sorry for this post