diff --git a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs deleted file mode 100644 index 47d4b71..0000000 --- a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs +++ /dev/null @@ -1,322 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System; - -namespace HoloLensWithOpenCVForUnityExample -{ - public struct PoseData { - public Vector3 pos; - public Quaternion rot; - } - - /// - /// AR utils. - /// - public class ARUtils - { - /// - /// Convertes rvec value to rotation transform. - /// - /// Rvec. - /// Rotation. - public static Quaternion ConvertRvecToRot (double[] rvec) - { - Vector3 _rvec = new Vector3((float)rvec[0], (float)rvec[1], (float)rvec[2]); - float theta = _rvec.magnitude; - _rvec.Normalize(); - - // http://stackoverflow.com/questions/12933284/rodrigues-into-eulerangles-and-vice-versa - return Quaternion.AngleAxis(theta * Mathf.Rad2Deg, _rvec); - } - - /// - /// Convertes tvec value to position transform. - /// - /// Tvec. - /// Position. - public static Vector3 ConvertTvecToPos (double[] tvec) - { - return new Vector3((float)tvec[0], (float)tvec[1], (float)tvec[2]); - } - - /// - /// Convertes rvec and tvec value to PoseData. - /// - /// Rvec. - /// Tvec. - /// PoseData. - public static PoseData ConvertRvecTvecToPoseData (double[] rvec, double[] tvec) - { - PoseData data = new PoseData(); - data.pos = ConvertTvecToPos (tvec); - data.rot = ConvertRvecToRot (rvec); - - return data; - } - - /// - /// Creates pose data dictionary. - /// - /// Marker count. - /// ids. - /// Rvecs. - /// Tvecs. - /// PoseData dictionary. - public static Dictionary CreatePoseDataDict (int markerCount, int[] ids, double[] rvecs, double[] tvecs) - { - Dictionary dict = new Dictionary(); - if (markerCount == 0) return dict; - - Vector3 rvec = new Vector3(); - for(int i = 0; i < markerCount; i++) { - PoseData data = new PoseData(); - data.pos.Set((float)tvecs[i * 3], (float)tvecs[i * 3 + 1], (float)tvecs[i * 3 + 2]); - - rvec.Set((float)rvecs[i * 3], (float)rvecs[i * 3 + 1], (float)rvecs[i * 3 + 2]); - float theta = rvec.magnitude; - rvec.Normalize(); - data.rot = Quaternion.AngleAxis(theta * Mathf.Rad2Deg, rvec); - - dict[ids[i]] = data; - } - return dict; - } - - /// - /// Performs a lowpass check on the position and rotation in newPose, comparing them to oldPose. - /// - /// Old PoseData. - /// New PoseData. - /// Positon threshold. - /// Rotation threshold. - public static void LowpassPoseData (ref PoseData oldPose, ref PoseData newPose, float posThreshold, float rotThreshold) - { - posThreshold *= posThreshold; - - float posDiff = (newPose.pos - oldPose.pos).sqrMagnitude; - float rotDiff = Quaternion.Angle(newPose.rot, oldPose.rot); - - if (posDiff < posThreshold) { - newPose.pos = oldPose.pos; - } - - if (rotDiff < rotThreshold) { - newPose.rot = oldPose.rot; - } - } - - /// - /// Performs a lowpass check on the position and rotation of each marker in newDict, comparing them to those in oldDict. - /// - /// Old dictionary. - /// New dictionary. - /// Positon threshold. - /// Rotation threshold. - public static void LowpassPoseDataDict (Dictionary oldDict, Dictionary newDict, float posThreshold, float rotThreshold) - { - posThreshold *= posThreshold; - - List keys = new List(newDict.Keys); - foreach (int key in keys) { - if (!oldDict.ContainsKey(key)) continue; - - PoseData oldPose = oldDict[key]; - PoseData newPose = newDict[key]; - - float posDiff = (newPose.pos - oldPose.pos).sqrMagnitude; - float rotDiff = Quaternion.Angle(newPose.rot, oldPose.rot); - - if (posDiff < posThreshold) { - newPose.pos = oldPose.pos; - } - - if (rotDiff < rotThreshold) { - newPose.rot = oldPose.rot; - } - - newDict[key] = newPose; - } - } - - - /// - /// Extract translation from transform matrix. - /// - /// Transform matrix. This parameter is passed by reference - /// to improve performance; no changes will be made to it. - /// - /// Translation offset. - /// - public static Vector3 ExtractTranslationFromMatrix (ref Matrix4x4 matrix) - { - Vector3 translate; - translate.x = matrix.m03; - translate.y = matrix.m13; - translate.z = matrix.m23; - return translate; - } - - /// - /// Extract rotation quaternion from transform matrix. - /// - /// Transform matrix. This parameter is passed by reference - /// to improve performance; no changes will be made to it. - /// - /// Quaternion representation of rotation transform. - /// - public static Quaternion ExtractRotationFromMatrix (ref Matrix4x4 matrix) - { - Vector3 forward; - forward.x = matrix.m02; - forward.y = matrix.m12; - forward.z = matrix.m22; - - Vector3 upwards; - upwards.x = matrix.m01; - upwards.y = matrix.m11; - upwards.z = matrix.m21; - - return Quaternion.LookRotation (forward, upwards); - } - - /// - /// Extract scale from transform matrix. - /// - /// Transform matrix. This parameter is passed by reference - /// to improve performance; no changes will be made to it. - /// - /// Scale vector. - /// - public static Vector3 ExtractScaleFromMatrix (ref Matrix4x4 matrix) - { - Vector3 scale; - scale.x = new Vector4 (matrix.m00, matrix.m10, matrix.m20, matrix.m30).magnitude; - scale.y = new Vector4 (matrix.m01, matrix.m11, matrix.m21, matrix.m31).magnitude; - scale.z = new Vector4 (matrix.m02, matrix.m12, matrix.m22, matrix.m32).magnitude; - return scale; - } - - /// - /// Extract position, rotation and scale from TRS matrix. - /// - /// Transform matrix. This parameter is passed by reference - /// to improve performance; no changes will be made to it. - /// Output position. - /// Output rotation. - /// Output scale. - public static void DecomposeMatrix (ref Matrix4x4 matrix, out Vector3 localPosition, out Quaternion localRotation, out Vector3 localScale) - { - localPosition = ExtractTranslationFromMatrix (ref matrix); - localRotation = ExtractRotationFromMatrix (ref matrix); - localScale = ExtractScaleFromMatrix (ref matrix); - } - - /// - /// Set transform component from TRS matrix. - /// - /// Transform component. - /// Transform matrix. This parameter is passed by reference - /// to improve performance; no changes will be made to it. - public static void SetTransformFromMatrix (Transform transform, ref Matrix4x4 matrix) - { - transform.localPosition = ExtractTranslationFromMatrix (ref matrix); - transform.localRotation = ExtractRotationFromMatrix (ref matrix); - transform.localScale = ExtractScaleFromMatrix (ref matrix); - } - - /// - /// Calculate projection matrix from camera matrix values. - /// - /// Focal length x. - /// Focal length y. - /// Image center point x.(principal point x) - /// Image center point y.(principal point y) - /// Image width. - /// Image height. - /// The near clipping plane distance. - /// The far clipping plane distance. - /// - /// Projection matrix. - /// - public static Matrix4x4 CalculateProjectionMatrixFromCameraMatrixValues (float fx, float fy, float cx, float cy, float width, float height, float near, float far) - { - Matrix4x4 projectionMatrix = new Matrix4x4 (); - projectionMatrix.m00 = 2.0f * fx / width; - projectionMatrix.m02 = 1.0f - 2.0f * cx / width; - projectionMatrix.m11 = 2.0f * fy / height; - projectionMatrix.m12 = - 1.0f + 2.0f * cy / height; - projectionMatrix.m22 = -(far + near) / (far - near); - projectionMatrix.m23 = -2.0f * far * near / (far - near); - projectionMatrix.m32 = -1.0f; - - return projectionMatrix; - } - - /// - /// Calculate camera matrix values from projection matrix. - /// - /// Projection matrix. - /// Image width. - /// Image height. - /// Vertical field of view. - /// - /// Camera matrix values. (fx = matrx.m00, fy = matrx.m11, cx = matrx.m02, cy = matrx.m12) - /// - public static Matrix4x4 CameraMatrixValuesFromCalculateProjectionMatrix (Matrix4x4 projectionMatrix, float width, float height, float fovV) - { - float fovH = 2.0f * Mathf.Atan (width/height * Mathf.Tan (fovV*Mathf.Deg2Rad / 2.0f)) * Mathf.Rad2Deg; - - Matrix4x4 cameraMatrix = new Matrix4x4 (); - cameraMatrix.m00 = CalculateDistance (width, fovH); - cameraMatrix.m02 = -((projectionMatrix.m02*width - width) / 2); - cameraMatrix.m11 = CalculateDistance (height, fovV); - cameraMatrix.m12 = (projectionMatrix.m12*height + height) / 2; - cameraMatrix.m22 = 1.0f; - - return cameraMatrix; - } - - /// - /// Calculate frustum size. - /// https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html - /// - /// Distance. - /// Field of view. (horizontal or vertical direction) - /// - /// Frustum height. - /// - public static float CalculateFrustumSize (float distance, float fov) - { - return 2.0f * distance * Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); - } - - /// - /// Calculate distance. - /// https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html - /// - /// One side size of a frustum. - /// Field of view. (horizontal or vertical direction) - /// - /// Distance. - /// - public static float CalculateDistance (float frustumSize, float fov) - { - return frustumSize * 0.5f / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); - } - - /// - /// Calculate FOV angle. - /// https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html - /// - /// One side size of a frustum. - /// Distance. - /// - /// FOV angle. - /// - public static float CalculateFOVAngle (float frustumSize, float distance) - { - return 2.0f * Mathf.Atan (frustumSize * 0.5f / distance) * Mathf.Rad2Deg; - } - } -} \ No newline at end of file diff --git a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs.meta b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs.meta deleted file mode 100644 index 01621aa..0000000 --- a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/ARUtils.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6238f3cc444478e408e6a68ee75b7280 -timeCreated: 1472322944 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/CameraParameters.cs b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/CameraParameters.cs index ae8e510..1131547 100644 --- a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/CameraParameters.cs +++ b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/CameraParameters.cs @@ -1,6 +1,5 @@ -using UnityEngine; -using System; -using OpenCVForUnity; +using System; +using OpenCVForUnity.CoreModule; namespace HoloLensWithOpenCVForUnityExample { diff --git a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoCameraCalibrationExample.cs b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoCameraCalibrationExample.cs index e04f8ea..5212c39 100644 --- a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoCameraCalibrationExample.cs +++ b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoCameraCalibrationExample.cs @@ -1,13 +1,20 @@ using UnityEngine; -using System.Collections; -using System.Collections.Generic; using UnityEngine.UI; using System; +using System.Collections; +using System.Collections.Generic; using System.Xml.Serialization; using System.IO; using System.Linq; -using UnityEngine.EventSystems; using HoloToolkit.Unity.InputModule; +using OpenCVForUnity.CoreModule; +using OpenCVForUnity.ArucoModule; +using OpenCVForUnity.UnityUtils.Helper; +using OpenCVForUnity.ImgprocModule; +using OpenCVForUnity.UnityUtils; +using OpenCVForUnity.Calib3dModule; +using OpenCVForUnity.ImgcodecsModule; +using HoloLensWithOpenCVForUnity.UnityUtils.Helper; #if UNITY_2017_2_OR_NEWER using UnityEngine.XR.WSA.Input; @@ -15,7 +22,6 @@ using UnityEngine.VR.WSA.Input; #endif -using OpenCVForUnity; namespace HoloLensWithOpenCVForUnityExample { @@ -203,7 +209,7 @@ public class HoloLensArUcoCameraCalibrationExample : ExampleSceneBase bool isCalibrating = false; // Use this for initialization - IEnumerator Start () + new IEnumerator Start () { camera = FindObjectOfType(); cursor = FindObjectOfType(); @@ -481,7 +487,7 @@ private void DrawFrame (Mat grayMat, Mat bgrMat) double[] distCoeffsArr = new double[(int)distCoeffs.total ()]; distCoeffs.get (0, 0, distCoeffsArr); - int ff = Core.FONT_HERSHEY_SIMPLEX; + int ff = Imgproc.FONT_HERSHEY_SIMPLEX; double fs = 0.4; Scalar c = new Scalar (255, 255, 255, 255); int t = 0; @@ -504,7 +510,7 @@ private void DrawFrame (Mat grayMat, Mat bgrMat) Imgproc.putText (bgrMat, "AVG_REPROJECTION_ERROR: " + repErr, new Point (bgrMat.cols() - 300, 300), ff, fs, c, t, lt, blo); if (frameCount == 0) - Imgproc.putText (bgrMat, "To calibration start, please press the calibration button or do air tap gesture!", new Point (5, bgrMat.rows () - 10), Core.FONT_HERSHEY_SIMPLEX, 0.5, new Scalar (255, 255, 255, 255), 1, Imgproc.LINE_AA, false); + Imgproc.putText (bgrMat, "To calibration start, please press the calibration button or do air tap gesture!", new Point (5, bgrMat.rows () - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, new Scalar (255, 255, 255, 255), 1, Imgproc.LINE_AA, false); } private double CaptureFrame (Mat frameMat) @@ -939,7 +945,7 @@ public void OnChangeCameraButtonClick () { if (isImagesInputMode) return; - webCamTextureToMatHelper.Initialize (null, webCamTextureToMatHelper.requestedWidth, webCamTextureToMatHelper.requestedHeight, !webCamTextureToMatHelper.requestedIsFrontFacing); + webCamTextureToMatHelper.requestedIsFrontFacing = !webCamTextureToMatHelper.IsFrontFacing(); } /// @@ -1081,10 +1087,10 @@ public void OnSaveButtonClick () // save the calibration images. #if UNITY_WEBGL && !UNITY_EDITOR string format = "jpg"; - MatOfInt compressionParams = new MatOfInt(Imgcodecs.CV_IMWRITE_JPEG_QUALITY, 100); + MatOfInt compressionParams = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 100); #else string format = "png"; - MatOfInt compressionParams = new MatOfInt(Imgcodecs.CV_IMWRITE_PNG_COMPRESSION, 0); + MatOfInt compressionParams = new MatOfInt(Imgcodecs.IMWRITE_PNG_COMPRESSION, 0); #endif for (int i = 0; i < allImgs.Count; ++i) { Imgcodecs.imwrite (Path.Combine (saveCalibratonFileDirectoryPath, calibratonDirectoryName + "_" + i.ToString("00") + "." + format), allImgs[i], compressionParams); diff --git a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoExample.cs b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoExample.cs index 071912a..e528f0e 100644 --- a/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoExample.cs +++ b/Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoExample.cs @@ -1,14 +1,19 @@ using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System; -using System.Threading; using UnityEngine.UI; using UnityEngine.EventSystems; +using System; +using System.Collections.Generic; +using System.Threading; using System.IO; using System.Xml.Serialization; - -using OpenCVForUnity; +using HoloToolkit.Unity.InputModule; +using OpenCVForUnity.ArucoModule; +using OpenCVForUnity.CoreModule; +using OpenCVForUnity.UnityUtils.Helper; +using OpenCVForUnity.Calib3dModule; +using OpenCVForUnity.ImgprocModule; +using OpenCVForUnity.UnityUtils; +using HoloLensWithOpenCVForUnity.UnityUtils.Helper; namespace HoloLensWithOpenCVForUnityExample { @@ -248,7 +253,7 @@ protected override void Start () imageOptimizationHelper = gameObject.GetComponent (); webCamTextureToMatHelper = gameObject.GetComponent (); - #if NETFX_CORE && !DISABLE_HOLOLENSCAMSTREAM_API + #if WINDOWS_UWP && !DISABLE_HOLOLENSCAMSTREAM_API webCamTextureToMatHelper.frameMatAcquired += OnFrameMatAcquired; #endif @@ -405,9 +410,9 @@ public void OnWebCamTextureToMatHelperDisposed () { Debug.Log ("OnWebCamTextureToMatHelperDisposed"); - #if !NETFX_CORE || DISABLE_HOLOLENSCAMSTREAM_API - StopThread (); - lock (sync) { + #if !WINDOWS_UWP || DISABLE_HOLOLENSCAMSTREAM_API + StopThread(); + lock (ExecuteOnMainThread) { ExecuteOnMainThread.Clear (); } isDetecting = false; @@ -445,7 +450,7 @@ public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.Err Debug.Log ("OnWebCamTextureToMatHelperErrorOccurred " + errorCode); } - #if NETFX_CORE && !DISABLE_HOLOLENSCAMSTREAM_API + #if WINDOWS_UWP && !DISABLE_HOLOLENSCAMSTREAM_API public void OnFrameMatAcquired (Mat bgraMat, Matrix4x4 projectionMatrix, Matrix4x4 cameraToWorldMatrix) { downScaleFrameMat = imageOptimizationHelper.GetDownScaleMat (bgraMat); @@ -508,8 +513,8 @@ public void OnFrameMatAcquired (Mat bgraMat, Matrix4x4 projectionMatrix, Matrix4 if (applyEstimationPose) { for (int i = 0; i < ids.total (); i++) { - using (Mat rvec = new Mat (rvecs, new OpenCVForUnity.Rect (0, i, 1, 1))) - using (Mat tvec = new Mat (tvecs, new OpenCVForUnity.Rect (0, i, 1, 1))) { + using (Mat rvec = new Mat (rvecs, new OpenCVForUnity.CoreModule.Rect(0, i, 1, 1))) + using (Mat tvec = new Mat (tvecs, new OpenCVForUnity.CoreModule.Rect(0, i, 1, 1))) { // In this example we are processing with RGB color image, so Axis-color correspondences are X: blue, Y: green, Z: red. (Usually X: red, Y: green, Z: blue) Aruco.drawAxis (rgbMat4preview, camMatrix, distCoeffs, rvec, tvec, markerLength * 0.5f); @@ -519,13 +524,12 @@ public void OnFrameMatAcquired (Mat bgraMat, Matrix4x4 projectionMatrix, Matrix4 } } - - UnityEngine.WSA.Application.InvokeOnAppThread(() => { + Enqueue(() => { if (!webCamTextureToMatHelper.IsPlaying ()) return; if (displayCameraPreview && rgbMat4preview != null) { - OpenCVForUnity.Utils.fastMatToTexture2D (rgbMat4preview, texture); + Utils.fastMatToTexture2D (rgbMat4preview, texture); } if (applyEstimationPose) { @@ -546,7 +550,26 @@ public void OnFrameMatAcquired (Mat bgraMat, Matrix4x4 projectionMatrix, Matrix4 rgbMat4preview.Dispose(); } - }, false); + }); + } + + private void Update() + { + lock (ExecuteOnMainThread) + { + while (ExecuteOnMainThread.Count > 0) + { + ExecuteOnMainThread.Dequeue().Invoke(); + } + } + } + + private void Enqueue(Action action) + { + lock (ExecuteOnMainThread) + { + ExecuteOnMainThread.Enqueue(action); + } } #else @@ -554,7 +577,7 @@ public void OnFrameMatAcquired (Mat bgraMat, Matrix4x4 projectionMatrix, Matrix4 // Update is called once per frame void Update () { - lock (sync) { + lock (ExecuteOnMainThread) { while (ExecuteOnMainThread.Count > 0) { ExecuteOnMainThread.Dequeue ().Invoke (); } @@ -574,12 +597,10 @@ void Update () private void StartThread(Action action) { - #if UNITY_METRO && NETFX_CORE + #if WINDOWS_UWP || (!UNITY_WSA_10_0 && (NET_4_6 || NET_STANDARD_2_0)) System.Threading.Tasks.Task.Run(() => action()); - #elif UNITY_METRO - action.BeginInvoke(ar => action.EndInvoke(ar), null); #else - ThreadPool.QueueUserWorkItem (_ => action()); + ThreadPool.QueueUserWorkItem(_ => action()); #endif } @@ -599,7 +620,7 @@ private void ThreadWorker() DetectARUcoMarker (); - lock (sync) { + lock (ExecuteOnMainThread) { if (ExecuteOnMainThread.Count == 0) { ExecuteOnMainThread.Enqueue (() => { OnDetectionDone (); @@ -666,8 +687,8 @@ private void OnDetectionDone() if (applyEstimationPose) { for (int i = 0; i < ids.total (); i++) { - using (Mat rvec = new Mat (rvecs, new OpenCVForUnity.Rect (0, i, 1, 1))) - using (Mat tvec = new Mat (tvecs, new OpenCVForUnity.Rect (0, i, 1, 1))) { + using (Mat rvec = new Mat (rvecs, new OpenCVForUnity.CoreModule.Rect(0, i, 1, 1))) + using (Mat tvec = new Mat (tvecs, new OpenCVForUnity.CoreModule.Rect(0, i, 1, 1))) { // In this example we are processing with RGB color image, so Axis-color correspondences are X: blue, Y: green, Z: red. (Usually X: red, Y: green, Z: blue) Aruco.drawAxis (rgbMat4preview, camMatrix, distCoeffs, rvec, tvec, markerLength * 0.5f); @@ -676,7 +697,7 @@ private void OnDetectionDone() } } - OpenCVForUnity.Utils.fastMatToTexture2D (rgbMat4preview, texture); + Utils.fastMatToTexture2D (rgbMat4preview, texture); } if (applyEstimationPose) { @@ -700,7 +721,7 @@ private void OnDetectionDone() void OnDestroy () { imageOptimizationHelper.Dispose (); - #if NETFX_CORE && !DISABLE_HOLOLENSCAMSTREAM_API + #if WINDOWS_UWP && !DISABLE_HOLOLENSCAMSTREAM_API webCamTextureToMatHelper.frameMatAcquired -= OnFrameMatAcquired; #endif webCamTextureToMatHelper.Dispose (); @@ -792,8 +813,12 @@ public void OnEnableLowPassFilterToggleValueChanged () /// public void OnTapped () { - if (EventSystem.current.IsPointerOverGameObject ()) + // Determine if a Gaze pointer is over a GUI. + if (GazeManager.Instance.HitObject != null && (GazeManager.Instance.HitObject.GetComponent