protected override void PrintDebugReport() { base.PrintDebugReport(); if (illumination == null) { if (analyzer == null) { ScreenDebugger.Print("No illumination manager or image analyzer"); } else { if (!analyzer.Running) { ScreenDebugger.Print("Image analyzer is not running"); } ScreenDebugger.Print("Image analyzer image format is {0}", VuforiaImageAnalyzer.ImageFormat); } } else { if (illumination.AmbientIntensity == null) { ScreenDebugger.Print("Illumination manager doesn't have an estimate"); } } }
/// <summary> /// Prints a report to the screen that reveals the internal state of the component. /// </summary> private void PrintDebugReport() { if (torques == null) { ScreenDebugger.Print("Torque sampling hasn't started yet."); } else { ScreenDebugger.PrintFormat("Torqued {3} = |{0}| >{1}< {2}", torques.Mean.Label(UnitOfMeasure.Degrees, 3), torques.StandardDeviation.Label(UnitOfMeasure.Degrees), TorqueK, HasTorqued); } if (accelerations == null) { ScreenDebugger.Print("Acceleration sampling hasn't started yet."); } else { ScreenDebugger.PrintFormat("Acceled {3} = |{0}| >{1}< {2}", accelerations.Mean.Label(UnitOfMeasure.Degrees, 3), accelerations.StandardDeviation.Label(UnitOfMeasure.Degrees), ForceK, HasAccelerated); ScreenDebugger.PrintFormat("F{0} L{1} m{2} M{3} _|_{4} |{5}| >{6}< {7}", accelerations.Mean, accelerations.StandardDeviation, ForceK); } ScreenDebugger.PrintFormat("Acceled {0} || Torqued {1} = Shaken {2}", HasAccelerated, HasTorqued, HasShaken); }
/// <summary> /// Prints a report showing the internal state of the component. /// </summary> private void PrintDebugReport() { ScreenDebugger.PrintFormat(" {0}", currentTime.ToLocalTime().FixTime()); if (location == null) { ScreenDebugger.Print(" No location service"); } else if (!location.HasCoord) { ScreenDebugger.Print(" No location yet"); } if (compass == null) { ScreenDebugger.Print(" No compass service"); } else if (!compass.HasHeading) { ScreenDebugger.Print(" No compass heading yet"); } if (CanCalculateCurrentLocalPosition) { ScreenDebugger.PrintFormat(" Azimuth {0}, Altitude {1}", orientation.AzimuthDegrees.Label(UnitOfMeasure.Degrees, 3), orientation.AltitudeDegrees.Label(UnitOfMeasure.Degrees, 3)); } }
/// <summary> /// attempts to setup the right image format, retrieve images from Vuforia, and pass them on /// for processing. /// </summary> protected override void Loop() { if (ImageFormat != lastFormat) { while (ImageFormat != null && !CameraDevice.Instance.SetFrameFormat(ImageFormat.Value, true)) { attemptFormats.Dequeue(); } lastFormat = ImageFormat; pixelGetter = null; if (ImageFormat != null && PixelConverters.ContainsKey(ImageFormat.Value)) { pixelGetter = PixelConverters[ImageFormat.Value]; } } if (ImageFormat != null) { try { var image = CameraDevice.Instance.GetCameraImage(ImageFormat.Value); if (image != null) { imageAnalyzer(image, pixelGetter); } } catch (Exception exp) { ScreenDebugger.Print(exp, "VuforiaImageAnalyzer"); } } }
public void OnControllerDisconnected(byte controllerID) { if (IsCorrectHand(controllerID)) { ScreenDebugger.Print($"Controller {NativeHandID} disconnected"); OnDestroy(); } }
public void OnControllerConnected(byte controllerID) { if (IsCorrectHand(controllerID)) { ScreenDebugger.Print($"Controller {NativeHandID} connected"); GetController(); } }
/// <summary> /// If <see cref="DebugReport"/> is set to true, prints a report that displays the status of /// the component and the values it is using for the light estimation. /// </summary> protected virtual void PrintDebugReport() { if (UseFakeIntensity) { ScreenDebugger.Print("Using fake light estimate"); } ScreenDebugger.PrintFormat(" Raw: int {0:0.000} col {1}", IntensityEstimate, ColorEstimate); }
public void LateUpdate() { if (!IsConnected && MLInput.IsStarted && NativeHandID != null && connector?.IsControllerValid((byte)MLInput.GetControllerIndexFromHand(NativeHandID.Value)) == true) { ScreenDebugger.Print($"New controller connected"); GetController(); } }
/// <summary> /// If <see cref="IndoorLightEstimate.DebugReport"/> is true, prints a report that displays /// the status of the component. /// </summary> private void PrintDebugReport() { if (weather == null) { ScreenDebugger.Print(" no weather service"); } if (sunPosition == null) { ScreenDebugger.Print(" no sun position"); } }
/// <summary> /// Updates the tracking state of the target when Unity's OnTrackableStateChange event is fired. /// </summary> /// <param name="previousStatus">Previous status.</param> /// <param name="newStatus"> New status.</param> public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (DebugReport) { ScreenDebugger.Print("[{0}] {1} => {2}", trackable.TrackableName, previousStatus, newStatus); } Extended = trackable.CurrentStatus == TrackableBehaviour.Status.EXTENDED_TRACKED; Found = trackable.CurrentStatus == TrackableBehaviour.Status.DETECTED || trackable.CurrentStatus == TrackableBehaviour.Status.TRACKED || Extended; }
private void OnError(CancellationErrorCode errorCode, string errorMessage) { ScreenDebugger.Print($"Recognition error: [{errorCode}] {errorMessage}"); IsUnrecoverable = errorCode == CancellationErrorCode.AuthenticationFailure || errorCode == CancellationErrorCode.BadRequest || errorCode == CancellationErrorCode.ConnectionFailure || errorCode == CancellationErrorCode.Forbidden || errorCode == CancellationErrorCode.RuntimeError || errorCode == CancellationErrorCode.ServiceUnavailable; TearDown(); OnRecognitionError(); }
/// <summary> /// If <see cref="DebugReport"/> is set to true, prints a report on the status of tracking. /// </summary> private void PrintDebugReport() { if (DebugReport) { if (trackable == null) { ScreenDebugger.Print($"[{name}] No trackable object!"); } else { var msg = Extended ? "extended" : Found ? "FOUND" : ""; ScreenDebugger.Print($"[{name}] {trackable.TrackableName} -> {msg}"); } } }
/// <summary> /// When <see cref="DebugReport"/> is set to true, the <see cref="Update"/> function calls /// this function at its end. /// </summary> private void PrintDebugReport() { try { if (!CanSeeHorizon) { ScreenDebugger.Print("Can't see the horizon"); } if (IsUpsideDown) { ScreenDebugger.Print("Device is upside down"); } if (!HasHeading) { ScreenDebugger.Print("No heading available yet"); } if (camT == null) { ScreenDebugger.Print(" Please set the MainCamera tag on a camera in the scene"); } else if (UseFakeHeading) { ScreenDebugger.Print(" Using a static heading"); } else if (!UnityInput.compass.enabled) { ScreenDebugger.Print(" Compass not available"); } else { var deltaHeading = CompassHeading - CameraHeading; var sampleProgress = samples.Count / (float)averagingIterations; ScreenDebugger.Print($" Raw Magnetometer {CompassHeading.Label(UnitOfMeasure.Degrees, 4)}"); ScreenDebugger.Print($" Camera Angle {CameraHeading.Label(UnitOfMeasure.Degrees, 4)}"); ScreenDebugger.Print($" Delta {deltaHeading.Label(UnitOfMeasure.Degrees, 4)}"); ScreenDebugger.Print($" To North {toNorthHeading.Label(UnitOfMeasure.Degrees, 4)}"); ScreenDebugger.Print($" North {toNorthHeading.Label(UnitOfMeasure.Degrees, 4)} ({samples.Count}/{averagingIterations}: {sampleProgress.Label(UnitOfMeasure.Proportion)}, σ = {samples.StandardDeviation})"); } } catch (Exception exp) { ScreenDebugger.PrintException(exp, "CompassRose"); } }
public override void Update() { if (cameraCtrl.ControlMode == CameraControl.Mode.Auto) { if (Find.Any(out UnifiedInputModule input)) { #if UNITY_WSA if (input.TouchRequested && Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { cameraCtrl.playerMode = CameraControl.Mode.Touch; } else if (input.MouseRequested && Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily != "Windows.Mobile") { cameraCtrl.playerMode = CameraControl.Mode.MouseLocked; } #else if (input.TouchRequested && Application.isMobilePlatform) { cameraCtrl.playerMode = CameraControl.Mode.Touch; } else if (input.MouseRequested && UnityInput.mousePresent) { cameraCtrl.playerMode = CameraControl.Mode.MouseLocked; } #endif else { cameraCtrl.playerMode = CameraControl.Mode.None; } ScreenDebugger.Print($"Mode is {cameraCtrl.playerMode.ToString()}"); } } else if (cameraCtrl.ControlMode == CameraControl.Mode.MagicWindow) { UnityInput.gyro.enabled = true; UnityInput.compensateSensors = true; } base.Update(); }
/// <summary> /// Check to see if the average frame delta time (minus outliers) has dropped below 30FPS. /// </summary> public void Update() { if (collectStats) { frameStats.Add(1 / Time.unscaledDeltaTime); if (frameStats.IsSaturated && IsBad) { if (QualityLevel > 0) { --QualityLevel; } ScreenDebugger.Print(QualityName); frameStats.Clear(); } } }
protected void ProcessText(string text, bool isComplete) { if (!string.IsNullOrEmpty(text)) { var resultText = new string(text .ToLowerInvariant() .Where(IsWordChar) .ToArray()); if (!string.IsNullOrEmpty(resultText)) { var maxSimilarity = 0f; Keywordable receiver = null; string match = null; foreach (var keywordable in keywordables) { foreach (var keyword in keywordable.keywords) { var similarity = keyword.Similarity(resultText); if (similarity > maxSimilarity) { match = keyword; maxSimilarity = similarity; receiver = keywordable; } } } ScreenDebugger.Print($"{text} => {resultText} = {match} ({Units.Converter.Label(maxSimilarity, Units.UnitOfMeasure.Proportion, Units.UnitOfMeasure.Percent)})"); if (isComplete && maxSimilarity < minimumCompleteSimilarity || !isComplete && maxSimilarity < minimumIncompleteSimilarity) { receiver = null; } lock (syncRoot) { resultReceiver = receiver; } } } }
/// <summary> /// Prints the internal state of the GPS tracking. /// </summary> private void PrintDebugReport() { if (UseFakeCoord) { ScreenDebugger.Print(" Using fake location"); } else if (!UnityInput.location.isEnabledByUser) { ScreenDebugger.Print(" User has disabled location services"); } else if (UnityInput.location.status == LocationServiceStatus.Stopped) { ScreenDebugger.Print(" Starting location services"); } else if (UnityInput.location.status == LocationServiceStatus.Initializing) { ScreenDebugger.Print(" Initializing location services"); } else if (UnityInput.location.status == LocationServiceStatus.Failed) { ScreenDebugger.Print(" Unable to determine device location"); } if (!HasCoord) { ScreenDebugger.Print(" Waiting for location lock"); } else { if (!UseFakeCoord) { var ts = lastLocation.timestamp.UnixTimestampToDateTime(); var sinceUpdate = EditableDateTime.Now - ts; ScreenDebugger.PrintFormat(" At [{0:mm\\:ss\\.fff}]: accuracy [+-{1}], altitude {2}", sinceUpdate, lastLocation.horizontalAccuracy.Label(UnitOfMeasure.Meters, 3), lastLocation.altitude.Label(UnitOfMeasure.Meters, 3)); } ScreenDebugger.PrintFormat(" Coordinate: {0}", HasCoord ? Coord.ToDMS(5) : "N/A"); } }
/// <summary> /// If <see cref="DebugReport"/> is set to true, prints a report that displays the status of /// the component and the values it is using for the light estimation. /// </summary> /// <param name="ambientIntensity"> Ambient intensity.</param> /// <param name="ambientColor"> Ambient color.</param> /// <param name="directionalIntensity">Directional intensity.</param> /// <param name="directionalColor"> Directional color.</param> /// <param name="shadowStrength"> Shadow strength.</param> private void PrintDebugReport(float ambientIntensity, Color ambientColor, float directionalIntensity, Color directionalColor, float shadowStrength) { if (measurement == null) { ScreenDebugger.Print(" no light measurement"); } ScreenDebugger.Print($" Sun Position: <{SunRotation.x.Label(UnitOfMeasure.Degrees, 4)}, {SunRotation.y.Label(UnitOfMeasure.Degrees, 4)}, {SunRotation.z.Label(UnitOfMeasure.Degrees, 4)}>"); ScreenDebugger.PrintFormat(" Ambient: int {0:0.000} col {1}", ambientIntensity, ambientColor); ScreenDebugger.PrintFormat(" Directional: int {0:0.000} col {1}", directionalIntensity, directionalColor); ScreenDebugger.PrintFormat(" Shadow strength: {0:0.000}", shadowStrength); if (sun == null) { ScreenDebugger.Print(" no directional light"); } else { ScreenDebugger.Print($" sun orientation: {sun.transform.eulerAngles}"); } }
protected override void Start() { base.Start(); targetsByName = targets.ToDictionary(target => target.image.imageName); dataSetsByName = targets.Select(target => target.imagesSet) .Distinct() .ToDictionary(set => set.resourceGroupName); ScreenDebugger.Print($"Found {targets.Count} targets: {string.Join(", ", targetsByName.Keys.ToArray())}"); ScreenDebugger.Print($"Found {dataSetsByName.Count} data sets: {string.Join(", ", dataSetsByName.Keys.ToArray())}"); UnityARSessionNativeInterface.ARImageAnchorAddedEvent += UnityARSessionNativeInterface_ARImageAnchorAddedEvent; UnityARSessionNativeInterface.ARImageAnchorUpdatedEvent += UnityARSessionNativeInterface_ARImageAnchorUpdatedEvent; UnityARSessionNativeInterface.ARImageAnchorRemovedEvent += UnityARSessionNativeInterface_ARImageAnchorRemovedEvent; if (dataSetsByName.Count == 1) { StartTrackerWithDataSetForTarget(dataSetsByName.Keys.First(), null); } }
/// <summary> /// Finds a target object by name and updates its state. /// </summary> /// <param name="label"> A label to aid in debugging.</param> /// <param name="anchorData">Anchor data.</param> /// <param name="act"> The action to perform once the target is found.</param> private void WithTarget(string label, ARImageAnchor anchorData, Action <TrackableFoundEventHandler> act) { var tracking = Tracking ? "tracking" : "not tracking"; ScreenDebugger.Print($"{label} {anchorData.referenceImageName} [{tracking}]"); if (Tracking) { var targetName = anchorData.referenceImageName; if (targetsByName.ContainsKey(targetName)) { var target = targetsByName[targetName]; act?.Invoke(target); target.transform.position = UnityARMatrixOps.GetPosition(anchorData.transform); target.transform.rotation = UnityARMatrixOps.GetRotation(anchorData.transform); } else { ScreenDebugger.Print($"Couldn't find {targetName}"); ScreenDebugger.Print($"Names we recognize: {string.Join(", ", targetsByName.Keys.ToArray())}"); } } }
/// <summary> /// If <see cref="DebugReport"/> is set to true, prints a report that displays the status of /// the component and the values it is using for the light estimation. /// </summary> private void PrintDebugReport() { if (FakeWeather) { ScreenDebugger.Print(" Using fake weather report"); } else if (weatherService == null) { ScreenDebugger.Print(" No weather service"); } if (currentWeather == null) { ScreenDebugger.Print(" No weather report"); } else if (currentWeather.ErrorMessage != null) { ScreenDebugger.Print($" ERROR: {currentWeather.ErrorMessage}"); } else { ScreenDebugger.Print($" City: {currentWeather.City}, {currentWeather.Country}:"); ScreenDebugger.Print($" Report time: {currentWeather.ReportTime.FixTime()}"); ScreenDebugger.Print($" Current time: {EditableDateTime.Now.FixTime()}"); ScreenDebugger.Print($" Time since report: {EditableDateTime.Now - currentWeather.ReportTime}"); ScreenDebugger.Print($" Conditions: {currentWeather.Conditions}"); ScreenDebugger.Print($" Cloud coverage: {currentWeather.CloudCover.Label(UnitOfMeasure.Proportion)}"); ScreenDebugger.Print($" Temperature: {currentWeather.Temperature.Label(UnitOfMeasure.Celsius)}"); ScreenDebugger.Print($" Humidity: {currentWeather.Humidity.Label(UnitOfMeasure.Proportion)}"); ScreenDebugger.Print($" Pressure: {currentWeather.AtmosphericPressure.Label(UnitOfMeasure.Hectopascals)}"); ScreenDebugger.Print($" Visibility: {currentWeather.AtmosphericVisibility.Label(UnitOfMeasure.Meters)}"); ScreenDebugger.Print($" Wind Direction {WindDirection.Label(UnitOfMeasure.Degrees)}"); ScreenDebugger.Print($" Wind Speed {WindSpeed.Label(UnitOfMeasure.MetersPerSecond)}"); ScreenDebugger.Print($" Sunrise: {currentWeather.SunriseTime?.FixTime()}"); ScreenDebugger.Print($" Sunset: {currentWeather.SunsetTime?.FixTime()}"); } }
private IEnumerator SwitchToSceneCoroutine(string subSceneName, bool skipFadeOut, bool skipLoadingScreen, bool unloadOtherScenes, bool fromView, IProgress prog) { var scenePath = GetScenePathFromName(subSceneName); if (scenePath == null) { ScreenDebugger.Print($"Couldn't find scene: {subSceneName}"); } else { if (unloadOtherScenes) { yield return(ExitAllSubScenesExcept(GetOpenSubScenes(scenePath), scenePath)); } var showFader = !skipFadeOut && fader != null && fader.CanEnter; if (showFader && fromView) { showFader &= !IsSceneLoaded(scenePath); if (!showFader) { var scene = SceneManager.GetSceneByPath(scenePath); var subScenes = scene.FindAll <SubSceneController>(); foreach (var subScene in subScenes) { showFader |= subScene.IsExited || !subScene.isActiveAndEnabled; } } } if (showFader) { Resources.UnloadUnusedAssets(); yield return(fader.EnterAsync().AsCoroutine()); if (input != null) { input.paused = true; } if (loadingBar != null && !skipLoadingScreen) { loadingBar.Activate(); prog.Report(0, subSceneName); } } if (unloadOtherScenes) { foreach (var subScene in GetOpenSubScenes(scenePath)) { if (subScene.unloadSceneOnExit) { var scene = subScene.gameObject.scene; yield return(SceneManager.UnloadSceneAsync(scene).AsCoroutine()); } } } yield return(LoadScenePathCoroutine(scenePath, prog)); for (var i = 1; i < SceneManager.sceneCount; ++i) { var scene = SceneManager.GetSceneAt(i); #if UNITY_MODULES_UI var canvases = scene.FindAll <Canvas>((c) => c.renderMode == RenderMode.WorldSpace && (c.worldCamera == null || c.worldCamera != DisplayManager.MainCamera)); foreach (var canvas in canvases) { canvas.worldCamera = DisplayManager.EventCamera; } #endif #if UNITY_MODULES_AUDIO var audioSources = scene.FindAll <AudioSource>((a) => a.spatialize); foreach (var audioSource in audioSources) { if (audioSource.spatialize) { interaction.Spatialize(audioSource); } else { interaction.SetDefaultMixerGroup(audioSource); } } #endif } if (loadingBar != null) { var end = DateTime.Now.AddSeconds(1); while (DateTime.Now < end || loadingBar.Progress >= 1) { yield return(null); } loadingBar.Deactivate(); } if (splash != null) { splash.Deactivate(); } if (fader != null && fader.CanExit) { if (input != null) { input.paused = false; } if (skipLoadingScreen) { fader.SkipExit(); } else { yield return(fader.ExitAsync().AsCoroutine()); } } } }
/// <summary> /// If <see cref="DebugReport"/> is set to true, prints a report on the status of tracking. /// </summary> protected override void PrintDebugReport() { ScreenDebugger.Print(tracker == null ? "No tracker" : "Has tracker"); ScreenDebugger.Print(usingPET ? "Using PET" : "Not using PET"); }
/// <summary> /// Initializes tracking of a set of targets. /// </summary> /// <param name="dataSetName">Data set name.</param> public void StartTrackerWithDataSet(string dataSetName) { ScreenDebugger.Print($"Activating data set: {dataSetName}"); StartTrackerWithDataSetForTarget(dataSetName, null); }