From 7f0c6414ef2295dc84fb93c9e340e383a78c28ac Mon Sep 17 00:00:00 2001 From: bozmir Date: Tue, 7 Jan 2025 18:13:03 +0100 Subject: [PATCH] testing if this fixed the auto build --- Assets/Plugins/LockCursor.jslib | 26 ++++++++++++++++++ Assets/Plugins/LockCursor.jslib.meta | 32 +++++++++++++++++++++++ Assets/Plugins/MobileDetection.jslib | 5 ++++ Assets/Plugins/MobileDetection.jslib.meta | 32 +++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 Assets/Plugins/LockCursor.jslib create mode 100644 Assets/Plugins/LockCursor.jslib.meta create mode 100644 Assets/Plugins/MobileDetection.jslib create mode 100644 Assets/Plugins/MobileDetection.jslib.meta diff --git a/Assets/Plugins/LockCursor.jslib b/Assets/Plugins/LockCursor.jslib new file mode 100644 index 000000000..ce4d4808d --- /dev/null +++ b/Assets/Plugins/LockCursor.jslib @@ -0,0 +1,26 @@ +mergeInto(LibraryManager.library, { + AutoCursorLock: function () { + window.OnCursorStateChanged = function OnCursorStateChanged() + { + var unityCanvas = document.getElementById("unity-canvas"); + if (document.pointerLockElement != unityCanvas && document.mozPointerLockElement != unityCanvas) { + unityInstance.SendMessage("CameraModeChanger", "GodViewMode"); + } + } + //Cursor locking for First Person camera mode + if ("onpointerlockchange" in document) { + document.addEventListener('pointerlockchange', window.OnCursorStateChanged, false); + console.log(document.pointerLockElement); + } + else if ("onmozpointerlockchange" in document) { + document.addEventListener('mozpointerlockchange', window.OnCursorStateChanged, false); + console.log(document.mozPointerLockElement); + } + }, + /* + This method locks the cursor for you, since sometimes doing it through Unity just doesn't work + */ + LockCursorInternal: function () { + document.getElementById("unity-canvas").requestPointerLock(); + } +}); \ No newline at end of file diff --git a/Assets/Plugins/LockCursor.jslib.meta b/Assets/Plugins/LockCursor.jslib.meta new file mode 100644 index 000000000..9bd5ddc71 --- /dev/null +++ b/Assets/Plugins/LockCursor.jslib.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: caa441e8e9a78df47ada96d6d4f4bddd +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + WebGL: WebGL + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/MobileDetection.jslib b/Assets/Plugins/MobileDetection.jslib new file mode 100644 index 000000000..a47e14580 --- /dev/null +++ b/Assets/Plugins/MobileDetection.jslib @@ -0,0 +1,5 @@ +mergeInto(LibraryManager.library, { + isMobile: function() { + return /(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/i.test(navigator.userAgent); + } +}); \ No newline at end of file diff --git a/Assets/Plugins/MobileDetection.jslib.meta b/Assets/Plugins/MobileDetection.jslib.meta new file mode 100644 index 000000000..d557273e6 --- /dev/null +++ b/Assets/Plugins/MobileDetection.jslib.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: ac6fe98c0aca0c444b13e488ba6c03b0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + WebGL: WebGL + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: