/// <summary> /// Function used to query for found objects present in the real world. /// </summary> /// <param name="parameters">The parameters to use for this query.</param> /// <param name="callback">The function to call when the query is done.</param> public static MLResult QueryFoundObjects(MLFoundObjects.QueryResultsDelegate callback) { if (MLFoundObjects.IsStarted) { if (IsQuerying) { return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "A previous query is still in progress.")); } callback += queryCallback; result = MLFoundObjects.GetObjects(callback); IsQuerying = result.IsOk; if (!result.IsOk) { callback = null; Debug.LogErrorFormat("Error: MLFoundObjectsStarterKit.QueryFoundObjects failed. Reason: {0}", result); } } else { Debug.LogError("Error: MLFoundObjectsStarterKit.QueryFoundObjects failed because MLFoundObjects was not started."); result = MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLFoundObjects was not started"); } return(result); }
/// <summary> /// Starts up MLFoundObjects. /// </summary> public static MLResult Start() { #if PLATFORM_LUMIN result = MLPrivilegesStarterKit.Start(); if (!result.IsOk) { Debug.LogErrorFormat("Error: MLFoundObjectsStarterKit failed when calling MLPrivilegesStarterKit.Start. Reason: {0}", result); return(result); } result = MLPrivilegesStarterKit.RequestPrivileges(MLPrivileges.Id.ObjectData); if (result.Result != MLResult.Code.PrivilegeGranted) { Debug.LogErrorFormat("Error: MLFoundObjectsStarterKit failed requesting privileges. Reason: {0}", result); return(result); } MLPrivilegesStarterKit.Stop(); result = MLFoundObjects.Start(); if (!result.IsOk) { Debug.LogErrorFormat("Error: MLFoundObjectsStarterKit failed starting MLFoundObjects. Reason: {0}", result); } return(result); #endif }
/// <summary> /// Stops MLFoundObjects if it has been started. /// </summary> public static void Stop() { if (MLFoundObjects.IsStarted) { MLFoundObjects.Stop(); } }
/// <summary> /// Starts up MLFoundObjects. /// </summary> public static MLResult Start() { result = MLFoundObjects.Start(); if (!result.IsOk) { Debug.LogErrorFormat("Error: MLFoundObjectsStarterKit failed starting MLFoundObjects. Reason: {0}", result); } return(result); }
/// <summary> /// Requests a new query if one is not currently active. /// </summary> /// <returns>Will return true if the request was successful.</returns> public bool QueryFoundObjects() { #if PLATFORM_LUMIN if (MLFoundObjects.IsStarted) { MLFoundObjects.GetObjects(HandleOnFoundObject); return(true); } #endif return(false); }