bbepis / XUnity.AutoTranslator

MIT License
1.85k stars 285 forks source link

Resize does not handle the case when there is an object name in the path containing "/" #553

Open lechefer opened 1 month ago

lechefer commented 1 month ago

The readme says the following https://github.com/bbepis/XUnity.AutoTranslator/blob/d31d141bd90ecb3f6f481b2d0f4750f19ab04d8c/README.md?plain=1#L691-L700

That is, the left side is a path that is formed from a hierarchy of objects and is separated by a delimiter /.

Example from the readme CharacterСustom/CustomControl/CanvasDraw

However, if an object comes across whose name contains a delimiter, then such a case is not processed.

The example is CharacterCustom/Custom / Control/CanvasDraw, where Custom / Control is still the same CustomControl object, and not two Custom and Control objects.

The splitting takes place here. https://github.com/bbepis/XUnity.AutoTranslator/blob/d31d141bd90ecb3f6f481b2d0f4750f19ab04d8c/src/XUnity.AutoTranslator.Plugin.Core/UIResize/UIResizeAttachment.cs#L73

We need to figure out a way to get around this. For example, through escaping or URL encoding (%2F = /)

One of the solutions is the generated ChatGPT

string path = "segment1%2Fsubsegment1/segment2/segment3%2Fsubsegment3";

string[] segments = path.Split('/');

for (int i = 0; i < segments.Length; i++)
{
    segments[i] = Uri.UnescapeDataString(segments[i]);
}
ManlyMarco commented 1 month ago

Using forward slashes in Object names is basically undefined behaviour and a lot of things will break because of it, including parts of Unity itself. It would be very difficult to deal with all the edge cases caused by this if we were to attempt to support this (feel free to make a PR if this is all it takes to make it work in your game though).

Atamg1994 commented 1 month ago

use as a delimiter //. double slash. ..this will solve the problem...

lechefer commented 1 month ago

use as a delimiter //. double slash. ..this will solve the problem...

I tried, it didn't help :)