nomnomab / unity-project-patcher

GNU General Public License v3.0
4 stars 3 forks source link

Compilation errors on Unity 2020.3 #3

Open Badhamknibbs opened 1 month ago

Badhamknibbs commented 1 month ago

Trying to add the project patcher to a Unity 2020.3.16f1 project results in multiple compilation errors (183 initially without changes). I tried resolving most them, though some of the issues seem fundamental:

The majority were resolved by doing explicit new, e.g. if (colorAttribute.UseRGB) return new(colorAttribute.R / 255f, colorAttribute.G / 255f, colorAttribute.B / 255f, alpha); -> if (colorAttribute.UseRGB) return new Color(colorAttribute.R / 255f, colorAttribute.G / 255f, colorAttribute.B / 255f, alpha);

and replacing is not null with the classic-style null check, e.g. if (closest.x.original is not null) -> if (closest.x.original != null)

However I couldn't figure out these issues:

nomnomab commented 1 month ago

Ah right, prior versions don't have that stuff. Do you have a PR with the changes you did by chance? In the middle of a crunch week at work, so I'll see when I can integrate fixes for them myself if not!

Regarding the last two changes:

Badhamknibbs commented 1 month ago

I was working on the copy downloaded via the package manager so I'll work on a git downloaded version with the changes proper (I found there's a bunch of other misc errors the compiler didn't immediately pick up, e.g. TryAdd() for Dicts isn't a thing along with various other new C# functions)

Badhamknibbs commented 1 month ago

I've started working on a fork ( https://github.com/Badhamknibbs/unity-project-patcher-2020.3 ), though I'm stuck on some stuff (there's seemingly no equivalent to the relative path function?)

nomnomab commented 1 month ago

Relative path function? Got an example? And anything else you are stuck on, you can throw into a list and I can help find replacements.

Badhamknibbs commented 1 month ago

The Path.GetRelativePath function doesn't exist according to Unity 2020.3, and the alternative, PathCoreLib, says it doesn't exist either. I'll get back to you with any other issues when I've got some time on the weekend.

nomnomab commented 1 month ago

This additional util was for the older versions so maybe the flag is wrong here as well 🤔 But it's meant to be the compatibility layer for situations like this haha https://github.com/nomnomab/unity-project-patcher/blob/master/Editor/Utility/PathNetCore.cs

Badhamknibbs commented 1 month ago

Ah, didn't realize it was a custom module. I've fixed up more of the compilation errors but there's still some I'm stuck on like I can't access the PathNetCore module from the Libs folder which also use Path.GetRelativePath. I'm also iffy on how some of the array accessors work since I'm not familiar with them; I'm replacing var projectRoot = Application.dataPath[..^assetLength]; with var projectRoot = Application.dataPath.Substring(0, Application.dataPath.Length - assetLength); Which I'm not sure is correct as the documentation about ..^ is confusing.

nomnomab commented 1 month ago

Yeah that looks correct. [..^5] is basically 0 to length - 5.

Not really sure what you mean by:

I can't access the PathNetCore module from the Libs folder which also use Path.GetRelativePath

PathNetCore is wrapped in the #if !UNITY_2020_3_OR_NEWER conditional, that's what I was referring to before (with it being possibly incorrect for your version). That file also only uses its own GetRelativePath, the normal Path one isn't in there (since that's what it is replacing).

Let me know if I am misunderstanding!

Badhamknibbs commented 1 month ago

I got GetRelativePath working for the cs files under the Editor folder, however Path.GetRelativePath is also used in cs files under the Libs folder which can't access PathNetCore.

Path.IsPathFullyQualified(filePath) is also used which doesn't exist.

Badhamknibbs commented 1 month ago

I've gotten everything sorted out, but the EditorAttributes library causes compiler errors on 2020.3 and thus can't be included, so I can't really pull this back into main. Do you know if there'd be any way to exclude the folder for specific Unity versions?

nomnomab commented 1 month ago

Could try upping the conditional tag on its .asmdef (since they are both UNITY_2020_3_OR_NEWER)

https://github.com/nomnomab/unity-project-patcher/blob/master/Libs/EditorAttributes/Runtime/Scripts/EditorAttributes.asmdef

and

https://github.com/nomnomab/unity-project-patcher/blob/master/Libs/EditorAttributes/Editor/Scripts/EditorAttributes.Editor.asmdef