public override void ButtonDown() { GameSession session = GameSession.Instance; if (session.isNetworkGame) { if (!processing) { if (PausableMonoBehaviour.isPaused) { session.RequestResume(); } else { session.RequestPause(); } } } else { if (!processing) { if (!PausableMonoBehaviour.isPaused) { ScreenDebugger.addText("Paws"); PausableMonoBehaviour.Pause(); } else { ScreenDebugger.addText("Un-paws"); PausableMonoBehaviour.Resume(); } } } }
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> /// 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"); } } }
/// <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)); } }
public void OnControllerDisconnected(byte controllerID) { if (IsCorrectHand(controllerID)) { ScreenDebugger.Print($"Controller {NativeHandID} disconnected"); OnDestroy(); } }
void ButtonDown() { if (!PausableMonoBehaviour.isPaused && GameSession.Instance.isDefender) { ScreenDebugger.addText("teh-rain"); GameSession.Instance.refreshSelected(); } }
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 static void addText(string line) { ScreenDebugger screen = ScreenDebugger.Instance; if (screen) { screen.guiText.text = line + "\n" + screen.guiText.text; } }
public static void clearText() { ScreenDebugger screen = ScreenDebugger.Instance; if (screen) { screen.guiText.text = ""; } }
// Optional public methods to turn on public void ActivateScreenDebugger() { if (screenDebugger == null) { screenDebugger = gameObject.AddComponent(typeof(ScreenDebugger)) as ScreenDebugger; } isScreenDebuggerActivated = true; this.Log(SCREEN_DEBUGGER_STARTED); }
public void LateUpdate() { if (!IsConnected && MLInput.IsStarted && NativeHandID != null && connector?.IsControllerValid((byte)MLInput.GetControllerIndexFromHand(NativeHandID.Value)) == true) { ScreenDebugger.Print($"New controller connected"); GetController(); } }
public override void ButtonDown() { ScreenDebugger.addText("De-wete"); Tower tower = ((Tower)GameSession.Instance.selectedObject); GameSession.Instance.selectedObject.Deselect(); tower.Sell(); UIBlockLower.Instance.guiTexture.texture = PrefabManager.UIBlockLowerDefault; UITowerSelectedCard.Instance.hide(); UITowerUpgradeCard.Instance.hide(); }
void panTouch() { if (Input.touchCount == 1) { if (Input.GetTouch(0).phase == TouchPhase.Moved) { Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition; if (touchDeltaPosition.magnitude > minPanMagnitude) { transform.Translate(-touchDeltaPosition.x * touchDragSpeed, 0, -touchDeltaPosition.y * touchDragSpeed); Vector3 pos = transform.position; transform.position = new Vector3(Mathf.Clamp(pos.x, cameraMinX, cameraMaxX), cameraY, Mathf.Clamp(pos.z, cameraMinZ, cameraMaxZ)); } } } else if (Input.touchCount == 2) { if (Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved) { ScreenDebugger.addText("Zooming"); curDist = Input.GetTouch(0).position - Input.GetTouch(1).position; //current distance between finger touches prevDist = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) - (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition)); //difference in previous locations using delta positions touchDelta = curDist.magnitude - prevDist.magnitude; speedTouch0 = Input.GetTouch(0).deltaPosition.magnitude / Input.GetTouch(0).deltaTime; speedTouch1 = Input.GetTouch(1).deltaPosition.magnitude / Input.GetTouch(1).deltaTime; if (speedTouch0 > minPinchSpeed && speedTouch1 > minPinchSpeed) { float fov = Camera.main.fieldOfView; if (touchDelta + varianceInDistances <= 1) { //zooming out ScreenDebugger.addText("Zooming out"); fov -= touchDelta * pinchZoomOutSpeed; } else if (touchDelta + varianceInDistances > 1) { //zooming in fov -= touchDelta * pinchZoomInSpeed; ScreenDebugger.addText("Zooming in"); } else { return; } fov = Mathf.Clamp(fov, minFov, maxFov); Camera.main.fieldOfView = fov; } } } }
/// <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 handleButtonDown() { ScreenDebugger.addText("ey-lee-an"); GameSession session = GameSession.Instance; if (!session.isDefender) { if (session.selectedObject != null && session.selectedObject != this) { session.selectedObject.Deselect(); } Select(); } else { ScreenDebugger.addText("Deselecting"); session.refreshSelected(); } }
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()}"); } }
/// <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"); }