[3.5.0-beta.1] String.Trim, String.TrimStart and String.TrimEnd are not exposed to Udon in the Unity 2022 beta
available in future release
S
SnowOrShine
There seem like pretty harmless functions that we have used in the past to parse a bunch of data!
Log In
This post was marked as
available in future release
Fax
Merged in a post:
System.String.Trim(Char) is not exposed
Synergiance
And I guess all the other red items here.
Let's begin with, any UdonSharp program using a line such as
someString.Trim('a');
would compile in Unity 2019, but will fail to compile in 2022 since the implicit cast to array no longer happens after the System.String.Trim(Char) method was added.There is a workaround in the meantime, which is
someString.Trim(new[]{'a'});
.Hackebein
Duplicate of: https://feedback.vrchat.com/sdk-bug-reports/p/350-beta1-stringtrim-stringtrimstart-and-stringtrimend-are-not-exposed-to-udon-i
(Workaround can be found there)
Fax
tracked
Thank you for reporting the issue! It's related to a new
TrimStart
function in Unity 2022. UdonSharp got confused and compiled the wrong version of that function.As a workaround, can you try using
TrimStart(null)
instead of just TrimStart()
?S
SnowOrShine
Fax: Unfortunately we're using TrimStart(char), passing in various characters which we need to trim up to, and that overload is not accessible either, but thanks for the attempt!
Phasedragon
SnowOrShine: In your case, the workaround would be to change TrimStart('a') to TrimStart(new char[] {'a'})
To elaborate: previously, TrimStart(char) would use the version of TrimStart which took a params array. In 2022, a single-char version of these functions was added so that they wouldn't have to allocate the array, but these functions were not exposed to udon automatically. If you manually create the array and put your char inside, that will force it to use the old params char array version, which is still exposed.
Long term, we'll be sure to get to the bottom of this and expose all the new functions which cause conflicts.
S
SnowOrShine
Phasedragon: Thanks, we'll give that a go =)
S
SnowOrShine
Phasedragon: Yup, works for us! We'll use this for now, thanks for the tip
Jar
I use this a bunch in Audience Anarchy, guess I'll wait to upgrade
aRkker
Noticed the same in 2022, specifically with String.TrimEnd. Udon had no problems with this before migrating to 2022.
Enverex
Yeah, this has just broken some of my scripts and a subtitling system I was using.