diff --git a/Assets/AirConsole/examples/AirConsole.Examples.asmdef b/Assets/AirConsole/examples/AirConsole.Examples.asmdef index 765e0e00..48fa51e6 100644 --- a/Assets/AirConsole/examples/AirConsole.Examples.asmdef +++ b/Assets/AirConsole/examples/AirConsole.Examples.asmdef @@ -1,24 +1,24 @@ { - "name": "AirConsole.Examples", - "rootNamespace": "NDream.AirConsole.Examples", - "references": [ - "AirConsole.Runtime" - ], - "includePlatforms": [ - "Android", - "Editor", - "WebGL" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "Newtonsoft.Json.dll" - ], - "autoReferenced": true, - "defineConstraints": [ - "UNITY_2022_3_OR_NEWER" - ], - "versionDefines": [], - "noEngineReferences": false + "name": "AirConsole.Examples", + "rootNamespace": "NDream.AirConsole.Examples", + "references": [ + "AirConsole.Runtime" + ], + "includePlatforms": [ + "Android", + "Editor", + "WebGL" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "Newtonsoft.Json.dll" + ], + "autoReferenced": true, + "defineConstraints": [ + "UNITY_2022_3_OR_NEWER" + ], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Assets/AirConsole/examples/basic/ExampleBasicLogic.cs b/Assets/AirConsole/examples/basic/ExampleBasicLogic.cs index 452166d3..f1768726 100644 --- a/Assets/AirConsole/examples/basic/ExampleBasicLogic.cs +++ b/Assets/AirConsole/examples/basic/ExampleBasicLogic.cs @@ -39,11 +39,12 @@ private void Awake() { private void OnReady(string code) { AirConsoleLogger.Log(() => "OnReady: " + code); + //Log to on-screen Console logWindow.text = "ExampleBasic: AirConsole is ready! \n \n"; Time.timeScale = 1.0f; - + //Mark Buttons as Interactable as soon as AirConsole is ready Button[] allButtons = (Button[])FindObjectsOfType(typeof(Button)); foreach (Button button in allButtons) { @@ -53,7 +54,8 @@ private void OnReady(string code) { private void OnMessage(int from, JToken data) { //Log to on-screen Console - logWindow.text = logWindow.text.Insert(0, "Incoming message from device: " + from + ": " + data.ToString() + " \n \n"); + logWindow.text = logWindow.text.Insert(0, + "Incoming message from device: " + from + ": " + data.ToString() + " \n \n"); // Rotate the AirConsole Logo to the right if ((string)data == "left") { @@ -92,7 +94,8 @@ private void OnDisconnect(int device_id) { private void OnDeviceStateChange(int device_id, JToken data) { //Log to on-screen Console - logWindow.text = logWindow.text.Insert(0, "Device State Change on device: " + device_id + ", data: " + data + "\n \n"); + logWindow.text = logWindow.text.Insert(0, + "Device State Change on device: " + device_id + ", data: " + data + "\n \n"); } private void OnCustomDeviceStateChange(int device_id, JToken custom_data) { @@ -124,6 +127,7 @@ private void OnGameEnd() { private void OnHighScores(JToken highscores) { //Log to on-screen Console logWindow.text = logWindow.text.Insert(0, "On High Scores " + highscores + " \n \n"); + //logWindow.text = logWindow.text.Insert (0, "Converted Highscores: " + HighScoreHelper.ConvertHighScoresToTables(highscores).ToString() + " \n \n"); } @@ -197,7 +201,8 @@ public void DisplayNicknameOfFirstController() { string nicknameOfFirstController = AirConsole.instance.GetNickname(idOfFirstController); //Log to on-screen Console - logWindow.text = logWindow.text.Insert(0, "The first controller's nickname is: " + nicknameOfFirstController + "\n \n"); + logWindow.text = logWindow.text.Insert(0, + "The first controller's nickname is: " + nicknameOfFirstController + "\n \n"); } private IEnumerator DisplayUrlPicture(string uri) { @@ -227,7 +232,8 @@ public void DisplayProfilePictureOfFirstController() { string urlOfProfilePic = AirConsole.instance.GetProfilePicture(idOfFirstController, 512); //Log url to on-screen Console - logWindow.text = logWindow.text.Insert(0, "URL of Profile Picture of first Controller: " + urlOfProfilePic + "\n \n"); + logWindow.text = logWindow.text.Insert(0, + "URL of Profile Picture of first Controller: " + urlOfProfilePic + "\n \n"); StartCoroutine(DisplayUrlPicture(urlOfProfilePic)); } @@ -246,7 +252,11 @@ public void DisplayAllCustomDataOfFirstController() { // go through all properties foreach (JProperty prop in ((JObject)data).Properties()) { logWindow.text = logWindow.text.Insert(0, - "Custom Data on first Controller - Key: " + prop.Name + " / Value:" + prop.Value + "\n \n"); + "Custom Data on first Controller - Key: " + + prop.Name + + " / Value:" + + prop.Value + + "\n \n"); } } else { //If there's only one property, log it to on-screen Console @@ -310,7 +320,8 @@ public void DisplayNumberOfConnectedControllers() { //This does not count devices that have been connected and then left, //only devices that are still active int numberOfActiveControllers = AirConsole.instance.GetControllerDeviceIds().Count; - logWindow.text = logWindow.text.Insert(0, "Number of Active Controllers: " + numberOfActiveControllers + "\n \n"); + logWindow.text + = logWindow.text.Insert(0, "Number of Active Controllers: " + numberOfActiveControllers + "\n \n"); } public void SetActivePlayers() { @@ -333,7 +344,8 @@ public void DisplayDeviceIDOfPlayerOne() { if (device_id != -1) { logWindow.text = logWindow.text.Insert(0, "Player #1 has device ID: " + device_id + " \n \n"); } else { - logWindow.text = logWindow.text.Insert(0, "There is no active player # 1 - Set Active Players first!\n \n"); + logWindow.text + = logWindow.text.Insert(0, "There is no active player # 1 - Set Active Players first!\n \n"); } } @@ -371,6 +383,7 @@ public void NavigateToPong() { public void ShowAd() { //Display an Advertisement AirConsole.instance.ShowAd(); + //Log to on-screen Console logWindow.text = logWindow.text.Insert(0, "Called ShowAd" + "\n \n"); } @@ -470,4 +483,4 @@ private void OnDestroy() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/game-states/GameStatesExampleLogic.cs b/Assets/AirConsole/examples/game-states/GameStatesExampleLogic.cs index ac32c481..6ad7434b 100644 --- a/Assets/AirConsole/examples/game-states/GameStatesExampleLogic.cs +++ b/Assets/AirConsole/examples/game-states/GameStatesExampleLogic.cs @@ -28,7 +28,9 @@ private static class ControllerEvents { public const string ResumeGame = "resume-game"; } - private readonly string[] colorNames = new string[] { "red", "blue", "green", "yellow", "orange", "purple", "pink" }; + private readonly string[] colorNames = new string[] + { "red", "blue", "green", "yellow", "orange", "purple", "pink" }; + private int colorIndex; // This field should overwrite any game state @@ -158,6 +160,7 @@ public void AssignPlayerColors() { // updates get delayed because of rate limiting the more devices are connected, the more this becomes a problem AirConsole.instance.SetCustomDeviceStateProperty("playerColors", UpdatePlayerColorData(AirConsole.instance.GetCustomDeviceState(0), i, colorNames[colorIndex])); + // The controller listens for the onCustomDeviceStateChanged event. // See the controller-game-states.html file for how this is handled there. @@ -171,6 +174,7 @@ public void AssignPlayerColors() { private void SetGameState(string state) { gameStateText.text = state; + // Set a custom device state property to inform all connected devices // of the current game state AirConsole.instance.SetCustomDeviceStateProperty("state", state); @@ -199,10 +203,13 @@ private static JToken UpdatePlayerColorData(JToken oldGameState, int deviceId, s } // Logging and returning the updated playerColorData - Debug.Log("AssignPlayerColor for device " + deviceId + " returning new playerColorData: " + playerColorData); + Debug.Log("AssignPlayerColor for device " + + deviceId + + " returning new playerColorData: " + + playerColorData); return playerColorData; } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/platformer/PlatformerExampleLogic.cs b/Assets/AirConsole/examples/platformer/PlatformerExampleLogic.cs index a97b48b5..22a902b1 100644 --- a/Assets/AirConsole/examples/platformer/PlatformerExampleLogic.cs +++ b/Assets/AirConsole/examples/platformer/PlatformerExampleLogic.cs @@ -57,4 +57,4 @@ private void OnDestroy() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/platformer/Player_Platformer.cs b/Assets/AirConsole/examples/platformer/Player_Platformer.cs index 0a467b43..a7dee034 100644 --- a/Assets/AirConsole/examples/platformer/Player_Platformer.cs +++ b/Assets/AirConsole/examples/platformer/Player_Platformer.cs @@ -68,4 +68,4 @@ private void OnTriggerExit(Collider trigger) { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/pong/ExamplePongLogic.cs b/Assets/AirConsole/examples/pong/ExamplePongLogic.cs index d77c35e7..e9c78dd4 100644 --- a/Assets/AirConsole/examples/pong/ExamplePongLogic.cs +++ b/Assets/AirConsole/examples/pong/ExamplePongLogic.cs @@ -48,6 +48,7 @@ private void OnConnect(int device_id) { private void OnDisconnect(int device_id) { int player = AirConsole.instance.ConvertDeviceIdToPlayerNumber(device_id); if (player >= 0) + // Player that was in the game left the game. // Setting active players to length 0 { @@ -82,6 +83,7 @@ private void OnMessage(int device_id, JToken data) { private void OnPause() { Time.timeScale = 0; + // If we were playing any sounds we must mute them when the game gets paused AudioListener.pause = true; } @@ -96,6 +98,7 @@ private void OnResume() { /// private void OnAdShow() { Time.timeScale = 0; + // If we were playing any sounds we must mute them when an ad is shown AudioListener.pause = true; } @@ -137,7 +140,8 @@ private void CheckTwoPlayers() { /// /// private void Vibrate(int player) { - AirConsole.instance.Message(AirConsole.instance.ConvertPlayerNumberToDeviceId(player), new { vibrate = 1000 }); + AirConsole.instance.Message(AirConsole.instance.ConvertPlayerNumberToDeviceId(player), + new { vibrate = 1000 }); } /// @@ -224,4 +228,4 @@ private void OnDestroy() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/pong/Racket.cs b/Assets/AirConsole/examples/pong/Racket.cs index ff5cc0d8..12511885 100644 --- a/Assets/AirConsole/examples/pong/Racket.cs +++ b/Assets/AirConsole/examples/pong/Racket.cs @@ -2,17 +2,15 @@ namespace NDream.AirConsole.Examples { public class Racket : MonoBehaviour { - public ExamplePongLogic logic; // Use this for initialization - void Start() { } - - void OnCollisionEnter2D(Collision2D col) { + private void Start() { } + private void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.GetComponent() != null) { - - float hitPos = (col.transform.position.y - transform.position.y) / (GetComponent().bounds.size.y / 2); + float hitPos = (col.transform.position.y - transform.position.y) + / (GetComponent().bounds.size.y / 2); float hitDir = 1f; if (col.relativeVelocity.x > 0) { @@ -21,7 +19,6 @@ void OnCollisionEnter2D(Collision2D col) { Vector2 dir = new Vector2(hitDir, hitPos).normalized; col.gameObject.GetComponent().velocity = dir * logic.ballSpeed; - } } } diff --git a/Assets/AirConsole/examples/safe-area/FullscreenSafeAreaHandler.cs b/Assets/AirConsole/examples/safe-area/FullscreenSafeAreaHandler.cs index ab0142bd..fe70afbf 100644 --- a/Assets/AirConsole/examples/safe-area/FullscreenSafeAreaHandler.cs +++ b/Assets/AirConsole/examples/safe-area/FullscreenSafeAreaHandler.cs @@ -8,7 +8,8 @@ namespace NDream.AirConsole.Examples { /// [RequireComponent(typeof(Camera))] public class FullscreenSafeAreaHandler : MonoBehaviour { - [Tooltip("Reference to the camera that should be adjusted to the safe area. Will use the attached camera if not assigned.")] + [Tooltip( + "Reference to the camera that should be adjusted to the safe area. Will use the attached camera if not assigned.")] [SerializeField] private Camera targetCamera; @@ -61,4 +62,4 @@ private void OnDisable() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/safe-area/SplitScreenSafeAreaHandler.cs b/Assets/AirConsole/examples/safe-area/SplitScreenSafeAreaHandler.cs index 6b9d98c1..6b94fac7 100644 --- a/Assets/AirConsole/examples/safe-area/SplitScreenSafeAreaHandler.cs +++ b/Assets/AirConsole/examples/safe-area/SplitScreenSafeAreaHandler.cs @@ -75,7 +75,6 @@ private void HandleSafeAreaChanged(Rect newSafeArea) { } #region Split Screen Configuration Methods - /// /// Sets up two player cameras in a horizontal split (side by side) /// @@ -234,7 +233,6 @@ private void SetupFourPlayers(Rect safeArea) { ); playerCameras[3].pixelRect = bottomRightRect; } - #endregion private void OnEnable() { @@ -251,4 +249,4 @@ private void OnDisable() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/safe-area/UISafeAreaHandler.cs b/Assets/AirConsole/examples/safe-area/UISafeAreaHandler.cs index 4223da2c..e84dd4d7 100644 --- a/Assets/AirConsole/examples/safe-area/UISafeAreaHandler.cs +++ b/Assets/AirConsole/examples/safe-area/UISafeAreaHandler.cs @@ -108,8 +108,7 @@ private void AdjustCanvasScaler(Rect safeArea) { if (Mathf.Approximately(canvasScaler.matchWidthOrHeight, 1)) { newReferenceResolution.x = originalReferenceResolution.y * safeAreaAspect; - } else if (canvasScaler.matchWidthOrHeight == 0) - { + } else if (canvasScaler.matchWidthOrHeight == 0) { newReferenceResolution.y = originalReferenceResolution.x / safeAreaAspect; } else { float matchValue = canvasScaler.matchWidthOrHeight; @@ -145,4 +144,4 @@ private void OnDisable() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/swipe/Player_Swipe.cs b/Assets/AirConsole/examples/swipe/Player_Swipe.cs index 80dee1d2..e68d0b13 100644 --- a/Assets/AirConsole/examples/swipe/Player_Swipe.cs +++ b/Assets/AirConsole/examples/swipe/Player_Swipe.cs @@ -1,5 +1,4 @@ - -namespace NDream.AirConsole.Examples { +namespace NDream.AirConsole.Examples { using System.Collections; using UnityEngine; using Newtonsoft.Json.Linq; @@ -31,7 +30,8 @@ private void OnMessage(int from, JToken message) { //we convert the x and y values we received to float values and make a new direction vector to pass to our movement function movementCoroutine = - StartCoroutine(MoveSphere(new Vector3((float)message["vector"]["x"], -(float)message["vector"]["y"], 0))); + StartCoroutine(MoveSphere(new Vector3((float)message["vector"]["x"], + -(float)message["vector"]["y"], 0))); } } } @@ -56,4 +56,4 @@ private void OnDestroy() { } #endif } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/examples/translations/TranslationExampleLogic.cs b/Assets/AirConsole/examples/translations/TranslationExampleLogic.cs index 6d55ad9f..94406f32 100644 --- a/Assets/AirConsole/examples/translations/TranslationExampleLogic.cs +++ b/Assets/AirConsole/examples/translations/TranslationExampleLogic.cs @@ -31,8 +31,9 @@ private void InitializeTranslations() { //in this case, we are translating a greeting message that includes the master controller's nickname //'welcome_nickname' has an English language value of "Welcome %nickname%, glad you're here!" translationExample.text = AirConsole.instance.GetTranslation("welcome_nickname", - new Dictionary - { { "nickname", AirConsole.instance.GetNickname(AirConsole.instance.GetMasterControllerDeviceId()) } }); + new Dictionary { + { "nickname", AirConsole.instance.GetNickname(AirConsole.instance.GetMasterControllerDeviceId()) } + }); /* Note: to really understand how translations work, we recommend creating your own project in the AirConsole Developer Console. * in this example, we show how to retrieve translations, but you will not be able to view or edit translatable phrases for the @@ -48,4 +49,4 @@ private void OnDestroy() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/AssemblyInfo.cs b/Assets/AirConsole/scripts/Editor/AssemblyInfo.cs index b6d22ff9..8e8d5759 100644 --- a/Assets/AirConsole/scripts/Editor/AssemblyInfo.cs +++ b/Assets/AirConsole/scripts/Editor/AssemblyInfo.cs @@ -4,4 +4,4 @@ namespace NDream.AirConsole.Editor { public class AssemblyInfo { } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs index a3ed9e67..3167aca3 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs @@ -6,7 +6,8 @@ namespace NDream.AirConsole.Editor { using System.Linq; internal abstract class AndroidGradleProcessor { - private const string PROGUARD_CLASSMEMBERS = "-keepclasseswithmembers class com.airconsole.unityandroidlibrary.** {*;}"; + private const string PROGUARD_CLASSMEMBERS + = "-keepclasseswithmembers class com.airconsole.unityandroidlibrary.** {*;}"; internal static void Execute(string basePath) { UpdateMainGradleProperties(Path.GetFullPath(Path.Combine(basePath, "..")), "gradle.properties"); @@ -28,7 +29,10 @@ private static void UpdateProGuard(string basePath, string proguardUnityTxt) { private static void UpdateMainGradleTemplate(string basePath, string gradleTemplateName) { string gradleTemplatePath = Path.Combine(basePath, gradleTemplateName); - string[] initialLines = File.ReadAllText(gradleTemplatePath).Replace("\r\n", "\n").Replace("\r", "\n").Split(new[] { '\n' }); + string[] initialLines = File.ReadAllText(gradleTemplatePath) + .Replace("\r\n", "\n") + .Replace("\r", "\n") + .Split(new[] { '\n' }); List lines = new(); bool inDependencies = false; @@ -73,7 +77,8 @@ private static void UpdateMainGradleProperties(string basePath, string gradlePro AirConsoleLogger.LogDevelopment(() => $"Gradle templates updated from {initialLines} to {lines} for {gradlePropertiesPath}"); } else { - AirConsoleLogger.LogDevelopment(() => $"Gradle properties were {initialLines}, no update for {gradlePropertiesPath}"); + AirConsoleLogger.LogDevelopment(() => + $"Gradle properties were {initialLines}, no update for {gradlePropertiesPath}"); } } @@ -85,4 +90,4 @@ private static void AddImplementationLineIfNotPresent(string[] lines, string lin } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifest.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifest.cs index 765b46ae..bfab389d 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifest.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifest.cs @@ -23,4 +23,4 @@ internal void SetAttribute(XmlAttribute Attribute) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifestProcessor.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifestProcessor.cs index 8a213978..a47cc6ca 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifestProcessor.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidManifestProcessor.cs @@ -8,14 +8,14 @@ namespace NDream.AirConsole.Editor { public abstract class AndroidManifestProcessor { - private static void CreateDefaultUnityManifest(string targetPath) { if (string.IsNullOrEmpty(targetPath)) { throw new ArgumentException(targetPath); } string unityManifestPath = - Path.Combine(Path.GetDirectoryName(EditorApplication.applicationPath), "PlaybackEngines", "AndroidPlayer", "Apk", + Path.Combine(Path.GetDirectoryName(EditorApplication.applicationPath), "PlaybackEngines", + "AndroidPlayer", "Apk", "UnityManifest.xml"); string directoryName = Path.GetDirectoryName(targetPath); if (!string.IsNullOrEmpty(directoryName)) { @@ -40,7 +40,8 @@ internal static void Execute(string projectPath) { } private static void SetCustomManifestActive(bool active) { - SerializedObject playerSettings = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); + SerializedObject playerSettings + = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); SerializedProperty filterTouchesProperty = playerSettings.FindProperty("useCustomMainManifest"); filterTouchesProperty.boolValue = active; @@ -50,7 +51,8 @@ private static void SetCustomManifestActive(bool active) { } private static bool GetCustomManifestActive() { - SerializedObject playerSettings = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); + SerializedObject playerSettings + = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); SerializedProperty filterTouchesProperty = playerSettings.FindProperty("useCustomMainManifest"); return filterTouchesProperty.boolValue; @@ -104,7 +106,8 @@ internal AndroidManifestTransformer(string path) { manifestElement = manifest.SelectSingleNode("/manifest") as XmlElement; applicationElement = manifest.SelectSingleNode("/manifest/application") as XmlElement; namespaceManager = CreateNamespaceManager(manifest); - activityElement = manifest.SelectSingleNode("/manifest/application/activity[contains(@android:name, 'UnityPlayerActivity')]", + activityElement = manifest.SelectSingleNode( + "/manifest/application/activity[contains(@android:name, 'UnityPlayerActivity')]", namespaceManager) as XmlElement; gameActivityElement = manifest.SelectSingleNode( "/manifest/application/activity[contains(@android:name, 'UnityPlayerGameActivity')]", @@ -149,28 +152,36 @@ internal void PreTransform() { } private static void UpdateManifestAttributes(AndroidManifest manifest, XmlElement manifestElement) { - SetAttributeIfMissing(manifest, manifestElement, "android", "installLocation", "auto", manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, manifestElement, "android", "installLocation", "auto", + manifest.AndroidXmlNamespace); RemoveAttributeIfPresent(manifestElement, "android", "package"); } private static void AddSupportsScreens(AndroidManifest manifest, XmlElement manifestElement) { XmlElement supportsScreens = GetOrCreateElement(manifest, manifestElement, "supports-screens"); - SetAttributeIfMissing(manifest, supportsScreens, "android", "smallScreens", "true", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, supportsScreens, "android", "normalScreens", "true", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, supportsScreens, "android", "largeScreens", "true", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, supportsScreens, "android", "xlargeScreens", "true", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, supportsScreens, "android", "anyDensity", "true", manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, supportsScreens, "android", "smallScreens", "true", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, supportsScreens, "android", "normalScreens", "true", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, supportsScreens, "android", "largeScreens", "true", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, supportsScreens, "android", "xlargeScreens", "true", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, supportsScreens, "android", "anyDensity", "true", + manifest.AndroidXmlNamespace); } private static void AddQueries(AndroidManifest manifest, XmlElement manifestElement) { XmlElement queries = GetOrCreateElement(manifest, manifestElement, "queries"); XmlElement intent = GetOrCreateElement(manifest, queries, "intent"); XmlElement action = GetOrCreateElement(manifest, intent, "action"); - SetAttributeIfMissing(manifest, action, "android", "name", "android.intent.action.MAIN", manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, action, "android", "name", "android.intent.action.MAIN", + manifest.AndroidXmlNamespace); XmlElement data = GetOrCreateElement(manifest, intent, "data"); - SetAttributeIfMissing(manifest, data, "android", "mimeType", AirConsoleAndroidMimeType, manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, data, "android", "mimeType", AirConsoleAndroidMimeType, + manifest.AndroidXmlNamespace); } private static void UpdateApplicationAttributes(XmlElement applicationElement) { @@ -191,21 +202,27 @@ private static void RemoveInternalAttributesIfNeeded(XmlElement applicationEleme } } - private static void UpdateActivityAttributes(AndroidManifest manifest, XmlElement activityElement, string themeAttribute) { + private static void UpdateActivityAttributes(AndroidManifest manifest, XmlElement activityElement, + string themeAttribute) { if (activityElement == null) { return; } - SetAttributeIfMissing(manifest, activityElement, "android", "screenOrientation", "landscape", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, activityElement, "android", "launchMode", "singleTask", manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, activityElement, "android", "screenOrientation", "landscape", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, activityElement, "android", "launchMode", "singleTask", + manifest.AndroidXmlNamespace); SetAttributeIfMissing(manifest, activityElement, "android", "configChanges", "mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, activityElement, "android", "hardwareAccelerated", "true", manifest.AndroidXmlNamespace); - SetAttributeIfMissing(manifest, activityElement, "android", "theme", themeAttribute, manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, activityElement, "android", "hardwareAccelerated", "true", + manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, activityElement, "android", "theme", themeAttribute, + manifest.AndroidXmlNamespace); } - private static void ActivityAddAirConsoleIntentFilter(AndroidManifest manifest, XmlNamespaceManager namespaceManager, + private static void ActivityAddAirConsoleIntentFilter(AndroidManifest manifest, + XmlNamespaceManager namespaceManager, XmlElement activityElement) { XmlElement existingIntentFilter = activityElement.SelectSingleNode( "intent-filter[category/@android:name='android.intent.category.LAUNCHER']", @@ -215,7 +232,8 @@ private static void ActivityAddAirConsoleIntentFilter(AndroidManifest manifest, XmlElement leanbackCategory = GetOrCreateElement(manifest, existingIntentFilter, "category", node => GetAttributeValue(node, "android", "name", manifest.AndroidXmlNamespace) == "android.intent.category.LEANBACK_LAUNCHER"); - SetAttributeIfMissing(manifest, leanbackCategory, "android", "name", "android.intent.category.LEANBACK_LAUNCHER", + SetAttributeIfMissing(manifest, leanbackCategory, "android", "name", + "android.intent.category.LEANBACK_LAUNCHER", manifest.AndroidXmlNamespace); } @@ -247,17 +265,20 @@ private static void AddUsesFeatureAndPermissions(AndroidManifest manifest, XmlEl AddUsesPermission(manifest, manifestElement, "android.permission.INTERNET"); } - private static void AddUsesFeature(AndroidManifest manifest, XmlElement manifestElement, string name, string required = null) { + private static void AddUsesFeature(AndroidManifest manifest, XmlElement manifestElement, string name, + string required = null) { XmlElement usesFeature = GetOrCreateElement(manifest, manifestElement, "uses-feature", node => GetAttributeValue(node, "android", "name", manifest.AndroidXmlNamespace) == name); SetAttributeIfMissing(manifest, usesFeature, "android", "name", name, manifest.AndroidXmlNamespace); if (required != null) { - SetAttributeIfMissing(manifest, usesFeature, "android", "required", required, manifest.AndroidXmlNamespace); + SetAttributeIfMissing(manifest, usesFeature, "android", "required", required, + manifest.AndroidXmlNamespace); } } - private static void RemoveUsesFeature(AndroidManifest manifest, XmlNamespaceManager namespaceManager, string name) { + private static void RemoveUsesFeature(AndroidManifest manifest, XmlNamespaceManager namespaceManager, + string name) { XmlElement usesFeatureElement = manifest.SelectSingleNode($"//uses-feature[@android:name='{name}']", namespaceManager) as XmlElement; usesFeatureElement?.ParentNode.RemoveChild(usesFeatureElement); @@ -291,7 +312,8 @@ private static XmlElement GetOrCreateElement(AndroidManifest manifest, XmlElemen return newElement; } - private static void SetAttributeIfMissing(AndroidManifest manifest, XmlElement element, string prefix, string name, string value, + private static void SetAttributeIfMissing(AndroidManifest manifest, XmlElement element, string prefix, + string name, string value, string xmlNamespace) { if (element.GetAttribute(name, xmlNamespace) == string.Empty) { XmlAttribute attr = manifest.GenerateAttribute(prefix, name, value, xmlNamespace); @@ -306,12 +328,12 @@ private static void RemoveAttributeIfPresent(XmlElement element, string prefix, } } - private static string GetAttributeValue(XmlElement element, string prefix, string name, string xmlNamespace) { - return element.GetAttribute(name, xmlNamespace); - } + private static string GetAttributeValue(XmlElement element, string prefix, string name, string xmlNamespace) => + element.GetAttribute(name, xmlNamespace); private static bool IsNormalActivityActive() { - SerializedObject playerSettings = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); + SerializedObject playerSettings + = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); SerializedProperty filterTouchesProperty = playerSettings.FindProperty("androidApplicationEntry"); AndroidApplicationEntry entry = (AndroidApplicationEntry)filterTouchesProperty.intValue; return (entry & AndroidApplicationEntry.Activity) == AndroidApplicationEntry.Activity; @@ -324,4 +346,4 @@ private enum AndroidApplicationEntry { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidProjectProcessor.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidProjectProcessor.cs index 540fd326..b41fa429 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidProjectProcessor.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidProjectProcessor.cs @@ -13,4 +13,4 @@ public void OnPostGenerateGradleAndroidProject(string projectPath) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidXMLDocument.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidXMLDocument.cs index f5e8d223..b8327679 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidXMLDocument.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidXMLDocument.cs @@ -26,9 +26,7 @@ internal AndroidXmlDocument(string path) { /// Saves the XML document at the current documentPath. /// /// Returns the path at which the document was saved. - internal string Save() { - return SaveAs(documentPath); - } + internal string Save() => SaveAs(documentPath); private string SaveAs(string path) { using (XmlTextWriter writer = new(path, new UTF8Encoding(false))) { @@ -40,4 +38,4 @@ private string SaveAs(string path) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/PostBuildProcess.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/PostBuildProcess.cs index 32901d8a..acac58e1 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/PostBuildProcess.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/PostBuildProcess.cs @@ -19,16 +19,18 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj // Save last port path EditorPrefs.SetString("airconsolePortPath", pathToBuiltProject); - } } private static void ValidateApiUsage() { string webGLTemplateDirectory = PreBuildProcessing.GetWebGLTemplateDirectory(); if (!VerifyAPIUsage(Path.Combine(webGLTemplateDirectory, "index.html"), Settings.RequiredMinimumVersion) + // || !VerifyAPIUsage(pathToBuiltProject + "/screen.html", Settings.RequiredMinimumVersion) - || !VerifyAPIUsage(Path.Combine(webGLTemplateDirectory, "controller.html"), Settings.RequiredMinimumVersion)) { - AirConsoleLogger.LogError(() => "Outdated AirConsole API detected. Please check the previous logs to address the problem."); + || !VerifyAPIUsage(Path.Combine(webGLTemplateDirectory, "controller.html"), + Settings.RequiredMinimumVersion)) { + AirConsoleLogger.LogError(() => + "Outdated AirConsole API detected. Please check the previous logs to address the problem."); throw new UnityException("Build failed. Outdated AirConsole API detected"); } } @@ -38,7 +40,8 @@ private static bool VerifyAPIUsage(string pathToHtml, Version requiredApiVersion string reference = File.ReadAllText(pathToHtml); Regex regex = new(@"airconsole-(\d+)\.(\d+)\.(\d+)\.js", RegexOptions.IgnoreCase); Match match = regex.Match(reference); - string apiVersion = $"airconsole-{requiredApiVersion.Major}.{requiredApiVersion.Minor}.{requiredApiVersion.Build}.js"; + string apiVersion + = $"airconsole-{requiredApiVersion.Major}.{requiredApiVersion.Minor}.{requiredApiVersion.Build}.js"; if (match.Success && !reference.Contains("airconsole-latest.js")) { int major = int.Parse(match.Groups[1].Value); int minor = int.Parse(match.Groups[2].Value); @@ -48,13 +51,13 @@ private static bool VerifyAPIUsage(string pathToHtml, Version requiredApiVersion if (referencedVersion >= requiredApiVersion) { AirConsoleLogger.LogDevelopment(() => $"Valid API reference {match.Groups[0]} found."); } else { - AirConsoleLogger.LogError( - () => $"airconsole-{major}.{minor}.{revision}.js found. This is outdated, please update to {apiVersion}"); + AirConsoleLogger.LogError(() => + $"airconsole-{major}.{minor}.{revision}.js found. This is outdated, please update to {apiVersion}"); return false; } } else if (reference.Contains("airconsole-latest.js")) { - AirConsoleLogger.LogError( - () => $"{pathToHtml} uses airconsole-latest.js. Please fix it to use {apiVersion}"); + AirConsoleLogger.LogError(() => + $"{pathToHtml} uses airconsole-latest.js. Please fix it to use {apiVersion}"); return false; } @@ -63,4 +66,4 @@ private static bool VerifyAPIUsage(string pathToHtml, Version requiredApiVersion } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/BuildAutomation/PreBuildProcessing.cs b/Assets/AirConsole/scripts/Editor/BuildAutomation/PreBuildProcessing.cs index edaab636..da154662 100644 --- a/Assets/AirConsole/scripts/Editor/BuildAutomation/PreBuildProcessing.cs +++ b/Assets/AirConsole/scripts/Editor/BuildAutomation/PreBuildProcessing.cs @@ -9,7 +9,9 @@ namespace NDream.AirConsole.Editor { using UnityEngine; public class PreBuildProcessing : IPreprocessBuildWithReport { - public int callbackOrder => 1; + public int callbackOrder { + get => 1; + } public void OnPreprocessBuild(BuildReport report) { if (report.summary.platform == BuildTarget.WebGL) { @@ -32,7 +34,8 @@ private static void CheckWebGLSetup() { throw new BuildFailedException("Controller missing in WebGL template location."); } - if (!Directory.GetFiles(templatePath).Any(filename => filename.EndsWith("airconsole-unity-plugin.js"))) { + if (!Directory.GetFiles(templatePath) + .Any(filename => filename.EndsWith("airconsole-unity-plugin.js"))) { EditorUtility.DisplayDialog("Error", "airconsole-unity-plugin missing. Please set up your airconsole plugin again", "Cancel"); diff --git a/Assets/AirConsole/scripts/Editor/Extentions.cs b/Assets/AirConsole/scripts/Editor/Extentions.cs index 7c1f7131..e89899ff 100644 --- a/Assets/AirConsole/scripts/Editor/Extentions.cs +++ b/Assets/AirConsole/scripts/Editor/Extentions.cs @@ -24,7 +24,8 @@ private static void CreateAirConsoleObject() { GameObject _tmp = new("AirConsole"); _tmp.AddComponent(); } else { - EditorUtility.DisplayDialog("Already exists", "AirConsole object already exists in the current scene", "ok"); + EditorUtility.DisplayDialog("Already exists", "AirConsole object already exists in the current scene", + "ok"); EditorGUIUtility.PingObject(airConsole.GetInstanceID()); } } @@ -95,7 +96,10 @@ public static void OpenBrowser(AirConsole controller, string startUpPath) { // add port info if starting the unity editor version if (startUpPath.Contains(Settings.WEBTEMPLATE_PATH)) { - url += "?unity-editor-websocket-port=" + Settings.webSocketPort + "&unity-plugin-version=" + Settings.VERSION; + url += "?unity-editor-websocket-port=" + + Settings.webSocketPort + + "&unity-plugin-version=" + + Settings.VERSION; } Application.OpenURL(url); @@ -104,7 +108,8 @@ public static void OpenBrowser(AirConsole controller, string startUpPath) { "{action:\"onReady\", code:\"0\", devices:[], server_time_offset: 0, device_id: 0, location: \"\" }"); } } else { - EditorUtility.DisplayDialog("AirConsole", "Please link a controller file to the AirConsole object.", "ok"); + EditorUtility.DisplayDialog("AirConsole", "Please link a controller file to the AirConsole object.", + "ok"); Debug.Break(); } } @@ -128,4 +133,4 @@ public static string GetLocalAddress() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/Inspector.cs b/Assets/AirConsole/scripts/Editor/Inspector.cs index 8ce7e054..eed35753 100644 --- a/Assets/AirConsole/scripts/Editor/Inspector.cs +++ b/Assets/AirConsole/scripts/Editor/Inspector.cs @@ -27,7 +27,9 @@ public class Inspector : UnityEditor.Editor { private const string ANDROID_NATIVE_GAME_SIZING_INACTIVE = "var AIRCONSOLE_ANDROID_NATIVE_GAMESIZING = false;"; private const string AIRCONSOLE_RUNTIME_SETTINGS_ASSET_FILE = AirconsoleRuntimeSettings.ResourceName + ".asset"; - private static string SettingsPath => Application.dataPath + Settings.WEBTEMPLATE_PATH + "/airconsole-settings.js"; + private static string SettingsPath { + get => Application.dataPath + Settings.WEBTEMPLATE_PATH + "/airconsole-settings.js"; + } [InitializeOnLoadMethod] private static void Migration() { @@ -100,9 +102,10 @@ private void DrawSettingsToggles() { DrawToggle(new GUIContent("Native Game Sizing", "Enables SafeArea support with fullscreen webview overlay"), ref nativeGameSizingSupportedValue); if (!nativeGameSizingSupportedValue) { - AndroidOnlyHelpBox("Android for Automotive requires you to enable this and to implement the OnSafeAreaChanged " - + "event handler provided by the AirConsole instance, enabling you to only render your game content" - + " in relevant area", MessageType.Warning); + AndroidOnlyHelpBox( + "Android for Automotive requires you to enable this and to implement the OnSafeAreaChanged " + + "event handler provided by the AirConsole instance, enabling you to only render your game content" + + " in relevant area", MessageType.Warning); } } @@ -124,7 +127,8 @@ private void DrawToggle(GUIContent content, ref bool value) { private void ValidateAndroidGameVersion() { string androidGameVersion = serializedObject.FindProperty("androidGameVersion").stringValue; - if (string.IsNullOrEmpty(androidGameVersion) || !Regex.IsMatch(androidGameVersion, @"^\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}$")) { + if (string.IsNullOrEmpty(androidGameVersion) + || !Regex.IsMatch(androidGameVersion, @"^\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}$")) { EditorGUILayout.HelpBox("Please enter a valid Game Version for Android", MessageType.Error); } } @@ -132,7 +136,8 @@ private void ValidateAndroidGameVersion() { private void ShowAdditionalProperties() { EditorGUILayout.PropertyField(serializedObject.FindProperty("androidGameVersion")); EditorGUILayout.PropertyField(serializedObject.FindProperty("androidUIResizeMode")); - if (serializedObject.FindProperty("androidUIResizeMode").enumValueIndex > (int)AndroidUIResizeMode.ResizeCamera + if (serializedObject.FindProperty("androidUIResizeMode").enumValueIndex + > (int)AndroidUIResizeMode.ResizeCamera && nativeGameSizingSupportedValue) { AndroidOnlyHelpBox("Android with native game sizing requires SafeAreas.\n" + "In this mode, AirConsole no longer supports UI Reference Resolution Scaling.", @@ -151,6 +156,7 @@ private void ShowAdditionalProperties() { private void ShowButtons() { EditorGUILayout.BeginHorizontal(styleBlack); + // check if a port was exported if (File.Exists(EditorPrefs.GetString("airconsolePortPath") + "/screen.html")) { if (GUILayout.Button("Open Exported Port", GUILayout.MaxWidth(130))) { @@ -225,11 +231,13 @@ private static void MigrateVersion250(string originalPath, string newPath) { } if (!File.Exists(newPath)) { - AirConsoleLogger.LogWarning(() => "Update settings file to new version, renaming from translation.js to game-settings.js"); + AirConsoleLogger.LogWarning(() => + "Update settings file to new version, renaming from translation.js to game-settings.js"); File.Move(originalPath, newPath); File.AppendAllText(newPath, $"\n{INACTIVE_PLAYERS_SILENCED_INACTIVE}"); } else { - AirConsoleLogger.LogError(() => $"game-settings.js found [{newPath}]. Deleting prior translation.js [{originalPath}]."); + AirConsoleLogger.LogError(() => + $"game-settings.js found [{newPath}]. Deleting prior translation.js [{originalPath}]."); File.Delete(originalPath); } } @@ -297,7 +305,8 @@ private static string GetResourcesFolderRelativeToAirConsole(bool ensureFolderEx string parentFolder = Path.GetDirectoryName(resourcesFolder)?.Replace("\\", "/"); string folderName = Path.GetFileName(resourcesFolder); if (string.IsNullOrEmpty(parentFolder) || string.IsNullOrEmpty(folderName)) { - AirConsoleLogger.LogError(() => $"Failed to resolve Resources folder relative to {airConsoleDirectory}"); + AirConsoleLogger.LogError(() => + $"Failed to resolve Resources folder relative to {airConsoleDirectory}"); return null; } diff --git a/Assets/AirConsole/scripts/Editor/PlayMode.cs b/Assets/AirConsole/scripts/Editor/PlayMode.cs index 9c223b33..98d5369a 100644 --- a/Assets/AirConsole/scripts/Editor/PlayMode.cs +++ b/Assets/AirConsole/scripts/Editor/PlayMode.cs @@ -92,4 +92,4 @@ private static void OnUnityPlayModeChanged(PlayModeStateChange playModeState) { _currentState = changedState; } } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/scripts/Editor/PluginDevelopment/BuildHelper.cs b/Assets/AirConsole/scripts/Editor/PluginDevelopment/BuildHelper.cs index 6b61306a..03095c20 100644 --- a/Assets/AirConsole/scripts/Editor/PluginDevelopment/BuildHelper.cs +++ b/Assets/AirConsole/scripts/Editor/PluginDevelopment/BuildHelper.cs @@ -14,7 +14,9 @@ public static class BuildHelper { private const string BasePath = "TestBuilds"; private const string KEY_INTERNAL_BUILD = "AIRCONSOLE.IS_INTERNAL_BUILD"; - public static bool IsInternalBuild => EditorPrefs.GetBool(KEY_INTERNAL_BUILD, false); + public static bool IsInternalBuild { + get => EditorPrefs.GetBool(KEY_INTERNAL_BUILD, false); + } public static void BuildWeb() { ProjectConfigurationCheck.CheckSettings(BuildTarget.WebGL); diff --git a/Assets/AirConsole/scripts/Editor/PluginDevelopment/DevelopmentTools.cs b/Assets/AirConsole/scripts/Editor/PluginDevelopment/DevelopmentTools.cs index 162100ce..57156b47 100644 --- a/Assets/AirConsole/scripts/Editor/PluginDevelopment/DevelopmentTools.cs +++ b/Assets/AirConsole/scripts/Editor/PluginDevelopment/DevelopmentTools.cs @@ -1,5 +1,4 @@ #if !DISABLE_AIRCONSOLE && AIRCONSOLE_DEVELOPMENT - namespace NDream.AirConsole.Editor { using UnityEngine; using UnityEditor; diff --git a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectConfigurationCheck.cs b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectConfigurationCheck.cs index 1fbd30e4..af1944e4 100644 --- a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectConfigurationCheck.cs +++ b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectConfigurationCheck.cs @@ -1,4 +1,3 @@ - #if !DISABLE_AIRCONSOLE namespace NDream.AirConsole.Editor { using System.Text; @@ -12,7 +11,7 @@ namespace NDream.AirConsole.Editor { using UnityEditor.Build.Reporting; using UnityEngine; using UnityEngine.Rendering; - + internal abstract class EditorNotificationService { /// /// Displays an error dialog and logs an error message, optionally providing instructions to disable AirConsole. @@ -23,7 +22,8 @@ internal abstract class EditorNotificationService { /// /// The title of the error dialog. Defaults to "Unsupported". /// Always thrown with the provided error message. - internal static void InvokeError(string message, bool addAirConsoleDisable = false, string title = "Unsupported") { + internal static void InvokeError(string message, bool addAirConsoleDisable = false, + string title = "Unsupported") { EditorUtility.DisplayDialog(title, message, "I understand"); if (addAirConsoleDisable) { message += @@ -42,7 +42,8 @@ private static void CheckUnityVersions() { return; } - EditorNotificationService.InvokeError($"AirConsole {Settings.VERSION} requires Unity 2022.3 or newer!", true); + EditorNotificationService.InvokeError($"AirConsole {Settings.VERSION} requires Unity 2022.3 or newer!", + true); } public static bool IsSupportedUnityVersion() => Settings.IsUnity2022OrHigher(); @@ -61,14 +62,16 @@ private static void CheckPlatform() { } else if (IsPlatformSupported(BuildTarget.Android)) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android); } else { - EditorNotificationService.InvokeError($"AirConsole {Settings.VERSION} requires the WebGL or Android module to be present!", + EditorNotificationService.InvokeError( + $"AirConsole {Settings.VERSION} requires the WebGL or Android module to be present!", true); } } private static bool IsPlatformSupported(BuildTarget buildTarget) { Type moduleManager = Type.GetType("UnityEditor.Modules.ModuleManager,UnityEditor.dll"); - MethodInfo IsPlatformSupportLoadedByBuildTarget = moduleManager.GetMethod("IsPlatformSupportLoadedByBuildTarget", + MethodInfo IsPlatformSupportLoadedByBuildTarget = moduleManager.GetMethod( + "IsPlatformSupportLoadedByBuildTarget", BindingFlags.Static | BindingFlags.NonPublic); if (IsPlatformSupportLoadedByBuildTarget != null) { @@ -106,14 +109,15 @@ internal static void CheckSettings(BuildTarget platform) { throw new BuildFailedException($"AirConsole Plugin does not support platform {platform}"); } - AirConsoleLogger.Log(() => $"AirConsole Plugin configuration checks for {platform} completed successfully."); + AirConsoleLogger.Log(() => + $"AirConsole Plugin configuration checks for {platform} completed successfully."); } [InitializeOnLoadMethod] private static void EnsureSharedPlayerSettings() { Inspector airconsoleInspector = Editor.CreateInstance(); airconsoleInspector.UpdateAirConsoleConstructorSettings(); - + PlayerSettings.resetResolutionOnWindowResize = true; PlayerSettings.SplashScreen.showUnityLogo = false; @@ -128,7 +132,8 @@ private static void EnsureSharedPlayerSettings() { } if (!UnityVersionCheck.IsSupportedUnityVersion()) { - string message = $"AirConsole {Settings.VERSION} requires Unity 2022.3 or newer. You are using {Application.unityVersion}."; + string message + = $"AirConsole {Settings.VERSION} requires Unity 2022.3 or newer. You are using {Application.unityVersion}."; AirConsoleLogger.LogError(() => message); throw new BuildFailedException(message); } @@ -155,7 +160,8 @@ private static void EnsureWebGLPlayerSettings() { PlayerSettings.SetScriptingBackend(BuildTargetGroup.WebGL, ScriptingImplementation.IL2CPP); PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm; - PlayerSettings.WebGL.nameFilesAsHashes = false; // We upload into timestamp based folders. This is not necessary. + PlayerSettings.WebGL.nameFilesAsHashes + = false; // We upload into timestamp based folders. This is not necessary. if (PlayerSettings.WebGL.dataCaching) { AirConsoleLogger.LogWarning(() => @@ -189,8 +195,10 @@ private static void EnsureWebGLPlayerSettings() { } if (!IsDesirableTextureCompressionFormat(BuildTargetGroup.WebGL)) { - AirConsoleLogger.LogError(() => "AirConsole requires 'ASTC' or 'ETC2' as the texture compression format."); - throw new BuildFailedException("Please update the WebGL build or player settings to build for AirConsole WebGL."); + AirConsoleLogger.LogError(() => + "AirConsole requires 'ASTC' or 'ETC2' as the texture compression format."); + throw new BuildFailedException( + "Please update the WebGL build or player settings to build for AirConsole WebGL."); } } @@ -207,7 +215,8 @@ private static void VerifyWebGLTemplate() { $"Unity version \"{Application.unityVersion}\" needs the AirConsole WebGL template \"{expectedTemplateName}\" to work.\nPlease change the WebGL template in your Project Settings under Player (WebGL platform tab) > Resolution and Presentation > WebGL Template."; AirConsoleLogger.LogError(() => incompatibleTemplateMessage); - if (EditorUtility.DisplayDialog("Incompatible WebGL Template", incompatibleTemplateMessage, "Open Player Settings", + if (EditorUtility.DisplayDialog("Incompatible WebGL Template", incompatibleTemplateMessage, + "Open Player Settings", "Cancel")) { // In Unity 6 this needs to be done with a delay call, otherwise it breaks the window layout when Project Settings are docked already. EditorApplication.delayCall = () => SettingsService.OpenProjectSettings("Project/Player"); @@ -220,7 +229,8 @@ private static void EnsureAndroidPlayerSettings() { PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7; PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP); if (PlayerSettings.muteOtherAudioSources) { - AirConsoleLogger.Log(() => "AirConsole requires 'mute other audio sources' to be disabled for automotive compatibility"); + AirConsoleLogger.Log(() => + "AirConsole requires 'mute other audio sources' to be disabled for automotive compatibility"); PlayerSettings.muteOtherAudioSources = false; } @@ -232,8 +242,10 @@ private static void EnsureAndroidPlayerSettings() { } if (!IsDesirableTextureCompressionFormat(BuildTargetGroup.Android)) { - AirConsoleLogger.LogError(() => "AirConsole requires 'ASTC' or 'ETC2' as the texture compression format."); - throw new BuildFailedException("Please update the Android Build or Player settings to build for AirConsole WebGL"); + AirConsoleLogger.LogError(() => + "AirConsole requires 'ASTC' or 'ETC2' as the texture compression format."); + throw new BuildFailedException( + "Please update the Android Build or Player settings to build for AirConsole WebGL"); } UpdateAndroidPlayerSettingsInProperties(); @@ -255,7 +267,8 @@ private static void EnsureAndroidPlayerSettings() { Mathf.Clamp(version.Minor, 0, version.Minor), Mathf.Clamp(version.Build, 0, version.Build)); PlayerSettings.bundleVersion - = new Version(version.Major, version.Minor, version.Build, PlayerSettings.Android.bundleVersionCode).ToString(); + = new Version(version.Major, version.Minor, version.Build, PlayerSettings.Android.bundleVersionCode) + .ToString(); #pragma warning restore 0162 // Unreachable code detected } @@ -265,8 +278,9 @@ private static void EnsureAndroidPlatformSettings() { // To ensure Google Play compatibility, we require a target SDK of 35 or higher. const int requiredAndroidTargetSdk = 35; if ((int)PlayerSettings.Android.targetSdkVersion < requiredAndroidTargetSdk) { - AirConsoleLogger.LogError(() => $"AirConsole requires 'Target SDK Version' of {requiredAndroidTargetSdk} or higher.\n" - + "We are updating the Android settings now."); + AirConsoleLogger.LogError(() => + $"AirConsole requires 'Target SDK Version' of {requiredAndroidTargetSdk} or higher.\n" + + "We are updating the Android settings now."); } PlayerSettings.Android.targetSdkVersion = (AndroidSdkVersions)requiredAndroidTargetSdk; @@ -315,11 +329,11 @@ private static void MaintainChallengingAndroidFeatures() { // When the layout corrects, the webview does not resize. PlayerSettings.Android.startInFullscreen = true; } - } private static void UpdateAndroidPlayerSettingsInProperties() { - SerializedObject playerSettings = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); + SerializedObject playerSettings + = new(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]); SerializedProperty filterTouchesProperty = playerSettings.FindProperty("AndroidFilterTouchesWhenObscured"); filterTouchesProperty.boolValue = false; @@ -372,7 +386,8 @@ private static void EnsureAndroidRenderSettings() { GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.Android); if (graphicsAPIs.First() != GraphicsDeviceType.Vulkan) { - AirConsoleLogger.LogWarning(() => "AirConsole requires either 'Auto Graphics API' or Vulkan to be the first API."); + AirConsoleLogger.LogWarning(() => + "AirConsole requires either 'Auto Graphics API' or Vulkan to be the first API."); } } @@ -387,12 +402,14 @@ private static int SecondsSinceStartOf2025() { private static void ValidateApiUsage() { string webGLTemplateDirectory = PreBuildProcessing.GetWebGLTemplateDirectory(); AirConsoleLogger.Log(() => $"Validating API Usage in {webGLTemplateDirectory}"); - if (!VerifyReferencedAirConsoleApiVersion(Path.Combine(webGLTemplateDirectory, "index.html"), Settings.RequiredMinimumVersion) + if (!VerifyReferencedAirConsoleApiVersion(Path.Combine(webGLTemplateDirectory, "index.html"), + Settings.RequiredMinimumVersion) // || !VerifyAPIUsage(pathToBuiltProject + "/screen.html", Settings.RequiredMinimumVersion) || !VerifyReferencedAirConsoleApiVersion(Path.Combine(webGLTemplateDirectory, "controller.html"), Settings.RequiredMinimumVersion)) { - AirConsoleLogger.LogError(() => "Outdated AirConsole API detected. Please check the previous logs to address the problem."); + AirConsoleLogger.LogError(() => + "Outdated AirConsole API detected. Please check the previous logs to address the problem."); throw new BuildFailedException( "Build failed. Outdated AirConsole API detected. Please see Error Logs for more information."); } @@ -407,19 +424,22 @@ private static bool VerifyReferencedAirConsoleApiVersion(string pathToHtml, Vers // Check if the reference to airconsole-Major.Minor.Patch.js is at least as big as requiredMinimumVersion. // Ensure that the reference is not 'airconsole-latest.js'. string fileContent = File.ReadAllText(pathToHtml); - string apiVersion = $"airconsole-{requiredApiVersion.Major}.{requiredApiVersion.Minor}.{requiredApiVersion.Build}.js"; + string apiVersion + = $"airconsole-{requiredApiVersion.Major}.{requiredApiVersion.Minor}.{requiredApiVersion.Build}.js"; // If airconsole-latest usage is detected, we need to inform the game developer to use the specified version. // We do not want Unity games to use latest due to prior implicit assumptions and requirements that might not be met anymore. Regex regexAirconsoleLatest = new(@"(? $"{pathToHtml} uses airconsole-latest.js. Please fix it to use airconsole-{apiVersion}.js"); + AirConsoleLogger.LogError(() => + $"{pathToHtml} uses airconsole-latest.js. Please fix it to use airconsole-{apiVersion}.js"); return false; } - Regex regexAirconsoleApiVersion = new(@"(?]*src\s*=\s*[""'].*airconsole-(\d+)\.(\d+)\.(\d+)\.js[""'][^>]*>", + Regex regexAirconsoleApiVersion = new( + @"(?]*src\s*=\s*[""'].*airconsole-(\d+)\.(\d+)\.(\d+)\.js[""'][^>]*>", RegexOptions.IgnoreCase); // Regex regexAirconsoleApiVersion = new(@"(? $"{version.Major}.{version.Minor}.{version.Build}f{version.Revision}"; + private static string StringFromVersion(Version version) => + $"{version.Major}.{version.Minor}.{version.Build}f{version.Revision}"; private static string GetUnityVersion() { #if UNITY_INCLUDE_TESTS diff --git a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferenceManager.cs b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferenceManager.cs index 6bca0a49..054cb0c6 100644 --- a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferenceManager.cs +++ b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferenceManager.cs @@ -6,7 +6,9 @@ namespace NDream.AirConsole.Editor { internal abstract class ProjectPreferenceManager { - private static string PreferencePath => Path.GetFullPath(Path.Combine(Application.dataPath, "AirConsole", "airconsole.prefs")); + private static string PreferencePath { + get => Path.GetFullPath(Path.Combine(Application.dataPath, "AirConsole", "airconsole.prefs")); + } /// /// Loads the Project Preferences. @@ -19,7 +21,8 @@ internal static ProjectPreferences LoadPreferences() { return newPreferences; } - ProjectPreferences result = JsonConvert.DeserializeObject(File.ReadAllText(PreferencePath)); + ProjectPreferences result + = JsonConvert.DeserializeObject(File.ReadAllText(PreferencePath)); return result; } @@ -37,4 +40,4 @@ internal static void SavePreferences(ProjectPreferences preferences) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferences.cs b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferences.cs index e81002f0..fb018c9a 100644 --- a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferences.cs +++ b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectPreferences.cs @@ -14,4 +14,4 @@ internal string PluginVersion { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectUpgradeEditor.cs b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectUpgradeEditor.cs index 503596a8..f9467bf0 100644 --- a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectUpgradeEditor.cs +++ b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/ProjectUpgradeEditor.cs @@ -37,7 +37,8 @@ private static void HandleVersionUpgrade(PluginVersionUpdateState state) { break; default: - AirConsoleLogger.LogDevelopment(() => "Default Plugin Upgrade path hit. If this is expected, ignore this message"); + AirConsoleLogger.LogDevelopment(() => + "Default Plugin Upgrade path hit. If this is expected, ignore this message"); break; } @@ -105,9 +106,7 @@ internal static int CalculatePluginVersion(string versionString) { return result; } - internal static PluginVersionUpdateState GetPluginVersionUpdateState() { - return new PluginVersionUpdateState(GetLastKnownPluginVersion()); - } + internal static PluginVersionUpdateState GetPluginVersionUpdateState() => new(GetLastKnownPluginVersion()); internal static void RecordPluginVersionUpdate(string newVersionString) { ProjectPreferences preferences = ProjectPreferenceManager.LoadPreferences(); @@ -135,7 +134,8 @@ internal class PluginVersionUpdateState { public PluginVersionUpdateState(string previousPluginVersion) { PreviousPluginVersion = GetUpgradeVersionComponent(previousPluginVersion); int previousVersion = PluginVersionTracker.CalculatePluginVersion(PreviousPluginVersion); - int currentVersion = PluginVersionTracker.CalculatePluginVersion(GetUpgradeVersionComponent(Settings.VERSION)); + int currentVersion + = PluginVersionTracker.CalculatePluginVersion(GetUpgradeVersionComponent(Settings.VERSION)); RequiresUpdate = currentVersion > previousVersion; } @@ -154,4 +154,4 @@ private static string GetUpgradeVersionComponent(string version) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/SemVerCheck.cs b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/SemVerCheck.cs index 7fa1b0a3..86bdd2f3 100644 --- a/Assets/AirConsole/scripts/Editor/ProjectMaintenance/SemVerCheck.cs +++ b/Assets/AirConsole/scripts/Editor/ProjectMaintenance/SemVerCheck.cs @@ -3,7 +3,7 @@ namespace NDream.AirConsole.Editor { using System; using System.Text.RegularExpressions; using UnityEditor.Build; - + internal abstract class SemVerCheck { /// /// Validates that Unity matches a required minimum version. diff --git a/Assets/AirConsole/scripts/Editor/SafeAreaTester.cs b/Assets/AirConsole/scripts/Editor/SafeAreaTester.cs index f89fda81..3227249d 100644 --- a/Assets/AirConsole/scripts/Editor/SafeAreaTester.cs +++ b/Assets/AirConsole/scripts/Editor/SafeAreaTester.cs @@ -149,4 +149,4 @@ private void OnSet16By9Clicked() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Editor/SettingWindow.cs b/Assets/AirConsole/scripts/Editor/SettingWindow.cs index 3f4649f2..908677a0 100644 --- a/Assets/AirConsole/scripts/Editor/SettingWindow.cs +++ b/Assets/AirConsole/scripts/Editor/SettingWindow.cs @@ -43,10 +43,12 @@ private void OnGUI() { GUILayout.Label("AirConsole Settings", EditorStyles.boldLabel); - Settings.webSocketPort = EditorGUILayout.IntField("Websocket Port", Settings.webSocketPort, GUILayout.MaxWidth(200)); + Settings.webSocketPort + = EditorGUILayout.IntField("Websocket Port", Settings.webSocketPort, GUILayout.MaxWidth(200)); EditorPrefs.SetInt("webSocketPort", Settings.webSocketPort); - Settings.webServerPort = EditorGUILayout.IntField("Webserver Port", Settings.webServerPort, GUILayout.MaxWidth(200)); + Settings.webServerPort + = EditorGUILayout.IntField("Webserver Port", Settings.webServerPort, GUILayout.MaxWidth(200)); EditorPrefs.SetInt("webServerPort", Settings.webServerPort); EditorGUILayout.LabelField("Webserver is running", Extentions.webserver.IsRunning().ToString()); diff --git a/Assets/AirConsole/scripts/Editor/WebListener.cs b/Assets/AirConsole/scripts/Editor/WebListener.cs index 735105e4..65a8262e 100644 --- a/Assets/AirConsole/scripts/Editor/WebListener.cs +++ b/Assets/AirConsole/scripts/Editor/WebListener.cs @@ -79,6 +79,7 @@ public void ProcessRequest(object listenerContext) { if (startUpPath.Contains(Settings.WEBTEMPLATE_PATH)) { // remove query parameters rawUrl = rawUrl.Split('?')[0]; + // translate screen.html to index.html rawUrl = rawUrl.Replace("screen.html", "index.html"); } diff --git a/Assets/AirConsole/scripts/Runtime/AirConsoleLogger.cs b/Assets/AirConsole/scripts/Runtime/AirConsoleLogger.cs index 4e33da76..206bc8c1 100644 --- a/Assets/AirConsole/scripts/Runtime/AirConsoleLogger.cs +++ b/Assets/AirConsole/scripts/Runtime/AirConsoleLogger.cs @@ -36,7 +36,8 @@ internal static void LogDevelopment(Func messageFunction) { internal static void LogEditor(string message) => Debug.Log($"AC UNITY EDITOR: {message}"); [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool IsDebugLoggingEnabled() => Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Log); + private static bool IsDebugLoggingEnabled() => + Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Log); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Log(Func messageFunction) { @@ -53,7 +54,8 @@ public static void Log(Func messageFunction, Object context) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool IsWarningLoggingEnabled() => Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Warning); + private static bool IsWarningLoggingEnabled() => + Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Warning); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogWarning(Func messageFunction) { @@ -70,7 +72,8 @@ public static void LogWarning(Func messageFunction, Object context) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool IsErrorLoggingEnabled() => Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Error); + private static bool IsErrorLoggingEnabled() => + Debug.unityLogger != null && Debug.unityLogger.IsLogTypeAllowed(LogType.Error); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogError(Func messageFunction) { diff --git a/Assets/AirConsole/scripts/Runtime/AirconsoleRuntimeSettings.cs b/Assets/AirConsole/scripts/Runtime/AirconsoleRuntimeSettings.cs index 566e6edf..9d8f7ea4 100644 --- a/Assets/AirConsole/scripts/Runtime/AirconsoleRuntimeSettings.cs +++ b/Assets/AirConsole/scripts/Runtime/AirconsoleRuntimeSettings.cs @@ -10,7 +10,9 @@ public sealed class AirconsoleRuntimeSettings : ScriptableObject { [SerializeField] private bool nativeGameSizingSupported = true; - public bool NativeGameSizingSupported => nativeGameSizingSupported; + public bool NativeGameSizingSupported { + get => nativeGameSizingSupported; + } #if UNITY_EDITOR public void SetNativeGameSizingSupported(bool value) { diff --git a/Assets/AirConsole/scripts/Runtime/AssemblyInfo.cs b/Assets/AirConsole/scripts/Runtime/AssemblyInfo.cs index 44c3a4ba..a4e0f72b 100644 --- a/Assets/AirConsole/scripts/Runtime/AssemblyInfo.cs +++ b/Assets/AirConsole/scripts/Runtime/AssemblyInfo.cs @@ -7,4 +7,4 @@ namespace NDream.AirConsole { public class AssemblyInfo { } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/scripts/Runtime/DebugLevel.cs b/Assets/AirConsole/scripts/Runtime/DebugLevel.cs index e0bc9f5b..c3c28dca 100644 --- a/Assets/AirConsole/scripts/Runtime/DebugLevel.cs +++ b/Assets/AirConsole/scripts/Runtime/DebugLevel.cs @@ -7,4 +7,4 @@ public class DebugLevel { public bool warning = true; public bool error = true; } -} \ No newline at end of file +} diff --git a/Assets/AirConsole/scripts/Runtime/Plugin/Android/AndroidUnityUtils.cs b/Assets/AirConsole/scripts/Runtime/Plugin/Android/AndroidUnityUtils.cs index 1bfcf6d8..ae3007a4 100644 --- a/Assets/AirConsole/scripts/Runtime/Plugin/Android/AndroidUnityUtils.cs +++ b/Assets/AirConsole/scripts/Runtime/Plugin/Android/AndroidUnityUtils.cs @@ -23,21 +23,18 @@ public static bool GetIntentExtraBool(string key, bool defaultValue) { #if !UNITY_ANDROID || UNITY_EDITOR return defaultValue; #endif - try - { - using (AndroidJavaClass unityPlayer = new("com.unity3d.player.UnityPlayer")) - { + try { + using (AndroidJavaClass unityPlayer = new("com.unity3d.player.UnityPlayer")) { AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity"); - AndroidJavaObject intent = currentActivity.Call("getIntent"); + AndroidJavaObject intent = currentActivity.Call("getIntent"); return intent.Call("getBooleanExtra", key, defaultValue); } - } - catch (System.Exception e) - { + } catch (System.Exception e) { AirConsoleLogger.LogWarning(() => "Error getting intent extra: " + e); return defaultValue; } } } + // ReSharper enable RedundantUsingDirective -} \ No newline at end of file +} diff --git a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityAndroidObjectProvider.cs b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityAndroidObjectProvider.cs index 9f284f7e..e627b1b6 100644 --- a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityAndroidObjectProvider.cs +++ b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityAndroidObjectProvider.cs @@ -25,7 +25,7 @@ internal static AndroidJavaObject GetUnityActivity() { if (!AirConsole.IsAndroidRuntime) { throw new UnityException("UnityAndroidObjectProvider is only supported on Unity Android builds."); } - + #if UNITY_6000_0_OR_NEWER return UnityEngine.Android.AndroidApplication.currentActivity; #endif @@ -63,4 +63,4 @@ internal static AndroidJavaObject GetInstanceOfClass(string className, params ob } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginExecutionCallback.cs b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginExecutionCallback.cs index fb954b5c..01665eb7 100644 --- a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginExecutionCallback.cs +++ b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginExecutionCallback.cs @@ -19,9 +19,10 @@ public void onExecute() { _executionCallback.Invoke(); } else { - AirConsoleLogger.LogDevelopment(() => "UnityPluginExecutionCallback execution callback is not assigned."); + AirConsoleLogger.LogDevelopment(() => + "UnityPluginExecutionCallback execution callback is not assigned."); } } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginStringCallback.cs b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginStringCallback.cs index 2d7535d4..54bab54e 100644 --- a/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginStringCallback.cs +++ b/Assets/AirConsole/scripts/Runtime/Plugin/Android/UnityPluginStringCallback.cs @@ -30,6 +30,7 @@ public void onSuccess(string message) { AirConsoleLogger.LogDevelopment(() => $"UnityPluginStringCallback received message[{i}]: {message.Substring(i, endValue - i)}"); } + // AirConsoleLogger.LogDevelopment($"UnityPluginStringCallback received message[{message.Length}]: {message}"); _successCallback.Invoke(message); } else { @@ -52,4 +53,4 @@ public void onFailure(string error) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/AndroidRuntimeConfigurator.cs b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/AndroidRuntimeConfigurator.cs index 17a00c0d..b5f0ebaa 100644 --- a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/AndroidRuntimeConfigurator.cs +++ b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/AndroidRuntimeConfigurator.cs @@ -23,11 +23,12 @@ private void ApplyRequiredSettings() { // To ensure consistent behavior and layout on cars where custom safe areas can be in use, // we ensure to run in fullscreen for it to be treated correctly. // In the optimal case we could use _pluginManager.IsAutomotiveDevice() to decide more granularly. - Screen.fullScreen = true; + Screen.fullScreen = true; + // Car OEMs can modify some of the standard android behavior so we want to make sure to be vSync aligned. QualitySettings.vSyncCount = 0; Application.targetFrameRate = Mathf.CeilToInt((float)Screen.currentResolution.refreshRateRatio.value); } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/EditorRuntimeConfigurator.cs b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/EditorRuntimeConfigurator.cs index 9e650422..ebbe6e57 100644 --- a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/EditorRuntimeConfigurator.cs +++ b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/EditorRuntimeConfigurator.cs @@ -18,4 +18,4 @@ private void ApplyRequiredSettings() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/IRuntimeConfigurator.cs b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/IRuntimeConfigurator.cs index 9b501dfe..f78441b7 100644 --- a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/IRuntimeConfigurator.cs +++ b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/IRuntimeConfigurator.cs @@ -7,4 +7,4 @@ public interface IRuntimeConfigurator { void RefreshConfiguration(); } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/WebGLRuntimeConfigurator.cs b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/WebGLRuntimeConfigurator.cs index a9b661da..dcb1a21a 100644 --- a/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/WebGLRuntimeConfigurator.cs +++ b/Assets/AirConsole/scripts/Runtime/RuntimeConfiguration/WebGLRuntimeConfigurator.cs @@ -24,4 +24,4 @@ private void ApplyRequiredSettings() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/Settings.cs b/Assets/AirConsole/scripts/Runtime/Settings.cs index 49985164..9ca3f8a5 100644 --- a/Assets/AirConsole/scripts/Runtime/Settings.cs +++ b/Assets/AirConsole/scripts/Runtime/Settings.cs @@ -36,4 +36,4 @@ static Settings() { public static bool IsUnity2022OrHigher() => int.Parse(Application.unityVersion.Split('.')[0]) >= 2022; } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/WebViewManager.cs b/Assets/AirConsole/scripts/Runtime/WebViewManager.cs index 7f97a1f8..f1393246 100644 --- a/Assets/AirConsole/scripts/Runtime/WebViewManager.cs +++ b/Assets/AirConsole/scripts/Runtime/WebViewManager.cs @@ -7,7 +7,7 @@ namespace NDream.AirConsole { public class WebViewManager { private readonly WebViewObject _webViewObject; private readonly int _defaultScreenHeight; - + private WebViewState _currentState; private bool _isSafeAreaActive; private int _webViewHeight; @@ -41,7 +41,8 @@ internal void ActivateSafeArea() { } internal void RequestStateTransition(WebViewState newState) { - AirConsoleLogger.LogDevelopment(() => $"WebViewManager.RequestStateTransition: {_currentState} => {newState}"); + AirConsoleLogger.LogDevelopment(() => + $"WebViewManager.RequestStateTransition: {_currentState} => {newState}"); // When the SafeArea has been activated, we do not allow any other state transitions anymore. // The only thing allowed after this is for the safe area itself to change. @@ -86,4 +87,4 @@ private static void LogMargins(int left, int top, int right, int bottom) { } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Runtime/WebsocketListener.cs b/Assets/AirConsole/scripts/Runtime/WebsocketListener.cs index 093bc53a..c470649d 100644 --- a/Assets/AirConsole/scripts/Runtime/WebsocketListener.cs +++ b/Assets/AirConsole/scripts/Runtime/WebsocketListener.cs @@ -7,7 +7,7 @@ namespace NDream.AirConsole { using WebSocketSharp.Server; using Newtonsoft.Json; using Newtonsoft.Json.Linq; - + public class WebsocketListener : WebSocketBehavior { public event Action onReady; public event Action onClose; @@ -188,7 +188,8 @@ public void ProcessMessage(string data) { public void Message(JObject data) { switch (Application.platform) { case RuntimePlatform.WebGLPlayer: - Application.ExternalCall("window.app.processUnityData", data.ToString()); //TODO: External Call is obsolete? + Application.ExternalCall("window.app.processUnityData", + data.ToString()); //TODO: External Call is obsolete? break; case RuntimePlatform.Android: { if (AirConsole.IsAndroidOrEditor) { @@ -205,4 +206,4 @@ public void Message(JObject data) { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Tests/EditMode/AirConsoleTests.cs b/Assets/AirConsole/scripts/Tests/EditMode/AirConsoleTests.cs index 63d87b4c..8de884aa 100644 --- a/Assets/AirConsole/scripts/Tests/EditMode/AirConsoleTests.cs +++ b/Assets/AirConsole/scripts/Tests/EditMode/AirConsoleTests.cs @@ -43,7 +43,8 @@ public IEnumerator SetSafeArea_WithValidMessage_SafeAreaChangedIsInvoked() { action = "onSetSafeArea", safeArea = JObject.FromObject(new { left = 0.2f, top = 0.1f, width = 0.6f, height = 0.8f }) }); - Rect expectedRect = new(0.2f * Screen.width, (1 - 0.1f - 0.8f) * Screen.height, 0.6f * Screen.width, 0.8f * Screen.height); + Rect expectedRect = new(0.2f * Screen.width, (1 - 0.1f - 0.8f) * Screen.height, 0.6f * Screen.width, + 0.8f * Screen.height); target = new GameObject("Target").AddComponent(); target.OnSafeAreaChanged += rect => { RectTestHelper.AreRectsEqual(expectedRect, rect, "onSafeAreaChanged rect matches expectation"); @@ -73,7 +74,9 @@ public IEnumerator SetSafeArea_WithInvalidMessage_ExceptionIsRaised() { try { target.SetSafeArea(expectedMessage); } catch (UnityException e) { - Assert.AreEqual($"OnSetSafeArea called without safeArea property in the message: {expectedMessage.ToString()}", e.Message); + Assert.AreEqual( + $"OnSetSafeArea called without safeArea property in the message: {expectedMessage.ToString()}", + e.Message); } yield return null; @@ -82,7 +85,9 @@ public IEnumerator SetSafeArea_WithInvalidMessage_ExceptionIsRaised() { public class AirConsoleTestRunner : AirConsole, IMonoBehaviourTest { private int frameCount; - public bool IsTestFinished => frameCount > 10; + public bool IsTestFinished { + get => frameCount > 10; + } private void Awake() { androidGameVersion = "1"; @@ -109,4 +114,4 @@ internal void Initialize() { } } } -#endif \ No newline at end of file +#endif diff --git a/Assets/AirConsole/scripts/Tests/Editor/ProjectDependencyCheckTests.cs b/Assets/AirConsole/scripts/Tests/Editor/ProjectDependencyCheckTests.cs index 5e064f84..873af14c 100644 --- a/Assets/AirConsole/scripts/Tests/Editor/ProjectDependencyCheckTests.cs +++ b/Assets/AirConsole/scripts/Tests/Editor/ProjectDependencyCheckTests.cs @@ -4,7 +4,7 @@ namespace NDream.AirConsole.Editor.Tests { using UnityEditor.Build; using UnityEngine; using UnityEngine.TestTools; - + public class ProjectDependencyCheckTests { [TearDown] public void TearDown() { @@ -39,7 +39,8 @@ public void ValidateUnityVersion_PassesExpectedRequiredVersion(string unityVersi [TestCase("6000.1.16f1", "6000.1.17f1")] [TestCase("6000.2.5f1", "6000.2.6f2")] public void ValidateUnityVersion_WhenBelowMinimum_LogsWarning(string unityVersion, string expectedRequired) { - string expectedMessage = $"For security (CVE-2025-59489), AirConsole requires at least Unity {expectedRequired}"; + string expectedMessage + = $"For security (CVE-2025-59489), AirConsole requires at least Unity {expectedRequired}"; ProjectDependencyCheck.UnityVersionProvider = () => unityVersion; @@ -72,7 +73,9 @@ public void ValidateUnityVersion_WhenBelowMinimumAndErrorRequested_InvokesErrorH ProjectDependencyCheck.InvokeErrorOrLogOverride = (message, title, shallError) => { handlerInvoked = true; Assert.That(shallError, Is.True); - Assert.That(message, Is.EqualTo($"For security (CVE-2025-59489), AirConsole requires at least Unity {expectedRequired}")); + Assert.That(message, + Is.EqualTo( + $"For security (CVE-2025-59489), AirConsole requires at least Unity {expectedRequired}")); Assert.That(title, Is.EqualTo($"Insecure version {unityVersion}")); }; diff --git a/CHANGELOG.md b/CHANGELOG.md index 063b34fd..d0ecff21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This includes security related updates like requiring fixed Unity versions and i - **Android Target SDK:** Increased to 35 to meet Google Play requirements per Nov 1, 2025. - **Unity Minimum Versions:** The Unity minimum versions have been updated to match `CVE-2025-59489` fix versions. +- **Code Style**: Examples and scripts have been aligned on style. ### Added