From 5e207ddae7060db3ba68f4b9a8a379b4f6c5a009 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 28 Jan 2024 00:21:38 +0100 Subject: [PATCH] fix: no camera no flood --- Assets/2DAssets/404.png | 3 + Assets/2DAssets/404.png.meta | 166 ++++++++++++++++++++++++++++++++ Assets/Scenes/PhoneView.unity | 3 +- Assets/Scripts/CameraManager.cs | 13 ++- Assets/Scripts/GameManager.cs | 16 +-- 5 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 Assets/2DAssets/404.png create mode 100644 Assets/2DAssets/404.png.meta diff --git a/Assets/2DAssets/404.png b/Assets/2DAssets/404.png new file mode 100644 index 0000000..bc8ffd0 --- /dev/null +++ b/Assets/2DAssets/404.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508a222c7dc67e9d419f08799d448347b16a25bee849047848b35c1868bd2d35 +size 114714 diff --git a/Assets/2DAssets/404.png.meta b/Assets/2DAssets/404.png.meta new file mode 100644 index 0000000..3dd979e --- /dev/null +++ b/Assets/2DAssets/404.png.meta @@ -0,0 +1,166 @@ +fileFormatVersion: 2 +guid: 9ff1e55f8bf477a569e826492485e011 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/PhoneView.unity b/Assets/Scenes/PhoneView.unity index 35da6ac..dc3902d 100644 --- a/Assets/Scenes/PhoneView.unity +++ b/Assets/Scenes/PhoneView.unity @@ -924,7 +924,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3} m_Name: m_EditorClassIdentifier: - PicturePlayer: {fileID: 1316036595} Canvas: {fileID: 1202782726} --- !u!1 &436596783 GameObject: @@ -3865,7 +3864,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Texture: {fileID: 0} + m_Texture: {fileID: 2800000, guid: 9ff1e55f8bf477a569e826492485e011, type: 3} m_UVRect: serializedVersion: 2 x: 0 diff --git a/Assets/Scripts/CameraManager.cs b/Assets/Scripts/CameraManager.cs index 3034fc8..32f4568 100644 --- a/Assets/Scripts/CameraManager.cs +++ b/Assets/Scripts/CameraManager.cs @@ -31,8 +31,11 @@ void Start() // Update is called once per frame void Update() { - photoBox.texture = GetPhoto(); - Resources.UnloadUnusedAssets(); + if (wTexture) + { + photoBox.texture = GetPhoto(); + Resources.UnloadUnusedAssets(); + } } public void WebcamResume() @@ -115,11 +118,13 @@ Texture2D CropTexture(WebCamTexture originalTexture) public Texture2D GetPhoto() { - if (photo) { + if (photo) + { return photo; } - if (!wTexture) { + if (!wTexture) + { return null; } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index c04453e..a1ab969 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -54,12 +54,13 @@ private void Start() HomeConnection.SetActive(true); submitNewPlayer.interactable = false; } + private void OnApplicationQuit() { myOnlineRoom.Child("players").Child(currentPlayer.id).RemoveValueAsync().ContinueWithOnMainThread(task => { Debug.Log($"delete player {currentPlayer.name}"); - if(myOnlineRoom!= null) + if (myOnlineRoom != null) { myOnlineRoom.ValueChanged -= OnRoomUpdate; } @@ -276,7 +277,8 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) { Debug.LogException(ex); } - if(myRoom == null) { + if (myRoom == null) + { return; } switch (myRoom.currentState) @@ -289,7 +291,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) } case (int)GameState.Explanation: { - + break; } case (int)GameState.MakeProposition: @@ -321,12 +323,12 @@ private void CheckIfIAmTheFirst(List players) if (players.Count > 1) { - IOrderedEnumerable sortedList = players.OrderBy(x=>x.creationDate); + IOrderedEnumerable sortedList = players.OrderBy(x => x.creationDate); - if(sortedList.Last().id == currentPlayer.id) + if (sortedList.Last().id == currentPlayer.id) { isFirst = true; - } + } } if (isFirst) @@ -334,7 +336,7 @@ private void CheckIfIAmTheFirst(List players) submitStartGame.SetActive(true); } } - public void sendCurrentState(GameState state,Action callback_oncCurrentStateSent) + public void sendCurrentState(GameState state, Action callback_oncCurrentStateSent) { myOnlineRoom.Child("currentState").SetValueAsync((int)state).ContinueWithOnMainThread(task => {