Ejemplo n.º 1
0
        /// <summary>
        /// Creates an MLUUID from a System.Guid
        /// </summary>
        /// <param name="guid">A System.Guid</param>
        /// <returns>A native MLUUID</returns>
        public static MagicLeapNativeBindings.MLUUID FromUnity(Guid guid)
        {
            MagicLeapNativeBindings.MLUUID result = new MagicLeapNativeBindings.MLUUID();
            string guidString = guid.ToString("N");

            result.TimeLow               = uint.Parse(guidString.Substring(0, 8), NumberStyles.HexNumber);
            result.TimeMid               = ushort.Parse(guidString.Substring(8, 4), NumberStyles.HexNumber);
            result.TimeHiAndVersion      = ushort.Parse(guidString.Substring(12, 4), NumberStyles.HexNumber);
            result.ClockSeqHiAndReserved = byte.Parse(guidString.Substring(16, 2), NumberStyles.HexNumber);
            result.ClockSeqLow           = byte.Parse(guidString.Substring(18, 2), NumberStyles.HexNumber);
            result.Node0 = byte.Parse(guidString.Substring(20, 2), NumberStyles.HexNumber);
            result.Node1 = byte.Parse(guidString.Substring(22, 2), NumberStyles.HexNumber);
            result.Node2 = byte.Parse(guidString.Substring(24, 2), NumberStyles.HexNumber);
            result.Node3 = byte.Parse(guidString.Substring(26, 2), NumberStyles.HexNumber);
            result.Node4 = byte.Parse(guidString.Substring(28, 2), NumberStyles.HexNumber);
            result.Node5 = byte.Parse(guidString.Substring(30, 2), NumberStyles.HexNumber);

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a System.Guid from an MLUUID
 /// </summary>
 /// <param name="uuid">A native UUID</param>
 /// <returns>A System.Guid</returns>
 public static Guid ToUnity(MagicLeapNativeBindings.MLUUID uuid)
 {
     return(new Guid(uuid.TimeLow, uuid.TimeMid, uuid.TimeHiAndVersion, uuid.ClockSeqHiAndReserved, uuid.ClockSeqLow, uuid.Node0, uuid.Node1, uuid.Node2, uuid.Node3, uuid.Node4, uuid.Node5));
 }