public static ForUUID ( string uuid ) : |
||
uuid | string | UUID to find. |
리턴 |
/// <summary> /// Inits the emulation for a given area description UUID and set of Tango Application settings. /// </summary> /// <param name="uuid">UUID of the Area Description that /// TangoApplication.Startup() was called with.</param> /// <param name="haveAreaDescriptionPermissions">If set to <c>true</c>, assume area description /// permissions have been requested and 'granted'.</param> /// <param name="learningMode">If set to <c>true</c>, service is in learning mode.</param> /// <param name="artificialOffset">Artificial offset fom Start of Service to Area Description.</param> public static void InitEmulationForUUID(string uuid, bool haveAreaDescriptionPermissions, bool learningMode, Vector3 artificialOffset) { m_usingEmulatedDescriptionFrames = false; m_currentUUID = uuid; if (haveAreaDescriptionPermissions) { if (!string.IsNullOrEmpty(uuid)) { if (AreaDescription.ForUUID(uuid).GetMetadata() != null) { m_usingEmulatedDescriptionFrames = true; } else { m_currentUUID = string.Empty; Debug.LogError("Requested Area Description UUID does not exist."); } } else if (learningMode) { m_usingEmulatedDescriptionFrames = true; } } m_emulationAreaOffset = artificialOffset; }
/// <summary> /// Raise a Tango Area Description event if there is new data. /// </summary> internal static void SendIfAvailable() { if (!m_isCallbackSet) { return; } if (m_onTangoAreaDescriptionExported != null && m_onTangoAreaDescriptionImported != null) { lock (m_lockObject) { if (m_isImportFinished) { m_onTangoAreaDescriptionImported(m_isSuccessful, AreaDescription.ForUUID(m_eventString)); m_isImportFinished = false; m_eventString = string.Empty; } if (m_isExportFinished) { m_onTangoAreaDescriptionExported(m_isSuccessful); m_isExportFinished = false; } } } }
/// <summary> /// Saves the current area description, returning the area description saved. /// /// You can only save an area description while connected to the Tango Service and if you have enabled Area /// Learning mode. If you loaded an ADF before connecting, then calling this method appends any new learned /// areas to that ADF and returns the same UUID. If you did not load an ADF, this method creates a new ADF and /// a new UUID for that ADF. /// </summary> /// <returns> /// AreaDescription instance for the newly saved area description if saved successfully, <c>null</c> otherwise. /// /// See logcat for details of why the saved failed. /// </returns> public static AreaDescription SaveCurrent() { byte[] rawUUID = new byte[Common.UUID_LENGTH]; if (AreaDescriptionAPI.TangoService_saveAreaDescription(rawUUID) != Common.ErrorType.TANGO_SUCCESS) { Debug.Log("Could not save area description.\n" + Environment.StackTrace); return(null); } string uuid = Encoding.UTF8.GetString(rawUUID); return(AreaDescription.ForUUID(uuid)); }
/// <summary> /// Raise a Tango Area Description event if there is new data. /// </summary> internal void SendEventIfAvailable() { if (OnTangoAreaDescriptionExported != null && OnTangoAreaDescriptionImported != null) { lock (m_lockObject) { if (m_isImportFinished) { OnTangoAreaDescriptionImported(m_isSuccessful, AreaDescription.ForUUID(m_eventString)); m_isImportFinished = false; m_eventString = string.Empty; } if (m_isExportFinished) { OnTangoAreaDescriptionExported(m_isSuccessful); m_isExportFinished = false; } } } }
/// <summary> /// Saves the current area description, returning the area description saved. /// /// You can only save an area description while connected to the Tango Service and if you have enabled Area /// Learning mode. If you loaded an area description before connecting, then calling this method appends any /// new learned areas to that area description and returns an area description with the same UUID. If you did /// not load an area description, this method creates a new area description and a new UUID for that area /// description. /// </summary> /// <returns> /// AreaDescription instance for the newly saved area description if saved successfully, <c>null</c> otherwise. /// /// See logcat for details of why a saved failed. /// </returns> public static AreaDescription SaveCurrent() { #if UNITY_EDITOR if (!EmulatedAreaDescriptionHelper.m_usingEmulatedDescriptionFrames) { Debug.LogError("Error in Area Description save emulation:\nNo current emulated area description."); return(null); } // If we don't have an existing UUID, this is a 'new' Area Description, so we'll have to create it. if (string.IsNullOrEmpty(EmulatedAreaDescriptionHelper.m_currentUUID)) { // Just use a .net GUID for the UUID. string uuid = Guid.NewGuid().ToString(); EmulatedAreaDescriptionHelper.m_currentUUID = uuid; try { Directory.CreateDirectory(EMULATED_ADF_SAVE_PATH); using (StreamWriter streamWriter = new StreamWriter(File.Open(EMULATED_ADF_SAVE_PATH + uuid + EMULATED_ADF_EXTENSION, FileMode.Create))) { Metadata metadata = new Metadata(); metadata.m_name = "Unnamed"; metadata.m_dateTime = DateTime.Now; metadata.m_transformationPosition = new double[3]; metadata.m_transformationRotation = new double[] { 0, 0, 0, 1 }; metadataXmlSerializer.Serialize(streamWriter, metadata); } } catch (IOException ioException) { Debug.LogError("IO error in Area Description save/load emulation:\n" + ioException.Message); return(null); } return(AreaDescription.ForUUID(uuid)); } else { // Since we don't actually save any description of the area in emulation, // if we're using an existing UUID, we don't have to do anything but return it. return(AreaDescription.ForUUID(EmulatedAreaDescriptionHelper.m_currentUUID)); } #else byte[] rawUUID = new byte[Common.UUID_LENGTH]; if (AreaDescriptionAPI.TangoService_saveAreaDescription(rawUUID) != Common.ErrorType.TANGO_SUCCESS) { Debug.Log("Could not save area description.\n" + Environment.StackTrace); return(null); } // Don't want to include the null terminator in the C# string. string uuid = Encoding.UTF8.GetString(rawUUID, 0, Common.UUID_LENGTH - 1); return(AreaDescription.ForUUID(uuid)); #endif }