diff --git a/README.md b/README.md index add07f8..ca9d88c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ How it works: 3. **Project File Adjustment**: Finally, `UnityPackage` modifies the `.csproj` file to reflect the C# version specified in the `csc.rsp`. This alerts your IDE to the correct language version to use, ensuring it can provide you with all the relevant language features. +Platform Support: +-------- +1. Editor OS support: Mac / Linux / Windows. +2. Target OS support: Mac / Windows / Linux / iOS / Android / WebGL. +3. IDE support: Rider / VSCode / Visual Studio. + Supported AssemblyDefinition locations: -------- 1. Project - everything that is located in `Assets/` folder of your project. @@ -20,55 +26,55 @@ Supported AssemblyDefinition locations: 3. Local Packages - everything that is located anywhere on your pc with specified path with `file:` prefix in manifest. > [!WARNING] +> Patch will modify the Editor installation, so all the projects that are using it will be affected (default for unity C# version will be used for compilation, but from newer (patched) dotnet sdk) +> > **DON'T** put `.asmdef` with its `csc.rsp` at the root of the project (`Assets/`). > Unity in that case will apply the specified C# version to everything, that may cause compile errors (e.g. `field` keyword is used as a name in some third party library). > Place it in any subfolder (usually Scripts, but doesn't matter, just not at the root) - - -> [!NOTE] -> OS support: Mac / Linux / Windows. -> You can backup your editor just in case, but should be fine. -> -> Patch will modify the Editor installation, so all the projects that are using it will be affected (default for unity C# version will be used for compilation, but from newer (patched) dotnet sdk) -> -> Tested on target platforms: Mac / Windows / Linux / iOS / Android / WebGL -> -> Tested in IDEs: > -> `Rider 2025.1` with integration package `com.unity.ide.rider@3.0.36` -> -> `VSCode 1.99.3` with integration package `com.unity.ide.visualstudio@2.0.23` -> -> `Visual Studio Community 2022 17.13.6` with integration package `com.unity.ide.visualstudio@2.0.23` +> Opening the editor in `safe mode` will not apply the patch, so you may see a lot of errors in IDE only. It will be applied when you will exit the safe mode, so when all compile errors from editor console are fixed. How to Install: --------------- -1. Add the package via git url ``https://github.com/kandreyc/unity-csharp-patch.git#v1.5.0`` +1. Add the package via git url ``https://github.com/kandreyc/unity-csharp-patch.git#v1.6.0`` or download latest package from [releases](https://github.com/kandreyc/unity-csharp-patch/releases) 2. Ensure Unity Editor is closed. 3. Ensure latest dotnet sdk is installed. [Download Page](https://dotnet.microsoft.com/en-us/download) 4. Open terminal at folder ``EditorPatch~`` inside the added package. 5. Patch the editor (administrative privileges are required): + +Mac / Linux: ``` $ dotnet UnityEditorPatch.dll apply --editor '/Applications/Unity/Hub/Editor/2022.3.21f1' --allow-prerelease ``` -where ``--editor`` - path to the unity editor - -where ``--allow-prerelease`` - (optional) allows to use prerelease dotnet sdk +Windows: +``` +$ dotnet UnityEditorPatch.dll apply --editor "C:/Program Files/Unity/Hub/Editor/2022.3.21f1" --allow-prerelease +``` +    where: +- ``--editor`` - path to the unity editor +- ``--allow-prerelease`` - (optional) allows to use prerelease dotnet sdk In case if you want to revert the patch: + +Mac / Linux: ``` $ dotnet UnityEditorPatch.dll revert --editor '/Applications/Unity/Hub/Editor/2022.3.21f1' ``` -where ``--editor`` - path to the unity editor +Windows: +``` +$ dotnet UnityEditorPatch.dll revert --editor "C:/Program Files/Unity/Hub/Editor/2022.3.21f1" +``` + +    where: +- ``--editor`` - path to the unity editor 6. Open the Unity Editor with your project and create a `csc.rsp` file alongside desired `.asmdef` with the following content: ``` --langVersion:13 +-langVersion:14 -nullable:enable ``` -where: - +    where: - ``langVersion`` (optional) - C# version you want to be used for this ``.asmdef``. Values are ``10``, ``11``, ``12``, ``13``, ``14`` - ``nullable`` (optional) - allows to use nullables like ``string?`` without defining ``#nullable enable/disable`` in each file where it used. Values are ``enable``, ``disable`` diff --git a/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/AssetPostProcessor.cs b/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/AssetPostProcessor.cs index 87fe939..46fa945 100644 --- a/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/AssetPostProcessor.cs +++ b/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/AssetPostProcessor.cs @@ -19,6 +19,18 @@ private static void OnPostprocessAllAssets(string[] imported, string[] deleted, AssetDatabase.Refresh(); } + [InitializeOnLoadMethod] + public static void TriggerRefreshOnSafeModeExit() + { + const string isPatched = "__is_csproj_patched"; + + if (!SessionState.GetBool(isPatched, false)) + { + SessionState.SetBool(isPatched, true); + SolutionUtility.RegenerateProjects(); + } + } + private static bool IsCsc(string asset) { return Path.GetFileName(asset) is "csc.rsp"; diff --git a/UnityCSharpPatch/Packages/manifest.json b/UnityCSharpPatch/Packages/manifest.json index 1dd08ec..9b00e27 100644 --- a/UnityCSharpPatch/Packages/manifest.json +++ b/UnityCSharpPatch/Packages/manifest.json @@ -2,7 +2,7 @@ "dependencies": { "com.test.local-outer-package": "file:../AnotherPackages/com.test.local-outer-package", "com.unity.feature.development": "1.0.1", - "com.unity.ide.rider": "3.0.34", + "com.unity.ide.rider": "3.0.36", "com.unity.ugui": "1.0.0", "com.unity.modules.androidjni": "1.0.0" } diff --git a/UnityCSharpPatch/Packages/packages-lock.json b/UnityCSharpPatch/Packages/packages-lock.json index 85432f4..7bb7398 100644 --- a/UnityCSharpPatch/Packages/packages-lock.json +++ b/UnityCSharpPatch/Packages/packages-lock.json @@ -38,16 +38,16 @@ "source": "builtin", "dependencies": { "com.unity.ide.visualstudio": "2.0.22", - "com.unity.ide.rider": "3.0.31", + "com.unity.ide.rider": "3.0.36", "com.unity.ide.vscode": "1.2.5", "com.unity.editorcoroutines": "1.0.0", - "com.unity.performance.profile-analyzer": "1.2.2", + "com.unity.performance.profile-analyzer": "1.2.3", "com.unity.test-framework": "1.1.33", "com.unity.testtools.codecoverage": "1.2.6" } }, "com.unity.ide.rider": { - "version": "3.0.34", + "version": "3.0.36", "depth": 0, "source": "registry", "dependencies": { @@ -72,14 +72,14 @@ "url": "https://packages.unity.com" }, "com.unity.performance.profile-analyzer": { - "version": "1.2.2", + "version": "1.2.3", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.settings-manager": { - "version": "2.0.1", + "version": "2.1.0", "depth": 2, "source": "registry", "dependencies": {}, diff --git a/UnityCSharpPatch/ProjectSettings/ProjectVersion.txt b/UnityCSharpPatch/ProjectSettings/ProjectVersion.txt index 8fb87e6..b852362 100644 --- a/UnityCSharpPatch/ProjectSettings/ProjectVersion.txt +++ b/UnityCSharpPatch/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.50f1 -m_EditorVersionWithRevision: 2022.3.50f1 (c3db7f8bf9b1) +m_EditorVersion: 2022.3.62f2 +m_EditorVersionWithRevision: 2022.3.62f2 (7670c08855a9) diff --git a/UnityEditorPatch/UnityEditorPatch.csproj b/UnityEditorPatch/UnityEditorPatch.csproj index a52a2be..faee703 100644 --- a/UnityEditorPatch/UnityEditorPatch.csproj +++ b/UnityEditorPatch/UnityEditorPatch.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable None false