UdonSharp 1.2-beta1: Non-Behaviour scripts, Lists, Dictionaries, and more
Pre-releaseUdonSharp 1.2 beta 1
Hey all, it's been a while! This release adds support for non-UdonSharpBehaviour scripts to U#. So now stuff like this is valid and supported:
public class MyCoolClass
{
int a;
string b;
public MyCoolClass(int a, string b)
{
this.a = a;
this.b = b;
}
public string GetStr() => $"a: {a}, b: {b}";
}
public MyBehaviour : UdonSharpBehaviour
{
void Start()
{
MyCoolClass myObj = new MyCoolClass(42, "hi");
Debug.Log($"a: {myObj.a}, b: {myObj.b}"); // "a: 42, b: hi"
Debug.Log(myObj.GetStr()); // "a: 42, b: hi"
}
}
This includes support for generic types, along with this support I've also implemented 'fake' versions of List<>
, Dictionary<>
, HashSet<>
, Queue<>
, and Stack<>
. Dictionaries and HashSets handle types with custom .GetHashCode/.Equals as well so long as they are typed on the dictionary key type or hashset value type as the concrete type and not some generic type like object
. You can do things like operator overloading as well. Serialization is handled on user types as well.
This release should be compatible with persistence as all that requires are some stub functions that I've added.
This has some caveats here; struct
types are not handled because Udon doesn't provide a good way to handle them properly without a ton of overhead. Inheritance is not supported on non-behaviour types due to how easily it'd cause Udon programs to bloat in size and not having very nice tradeoffs to address this otherwise. Please report bugs on this github or my discord server and I'll try to address them when I can.
There are some bugs that I still want to address, and some smaller features I'd like to add so I'll probably be updating this a bit over time.
Installation is also super jank due to how VRC has a copy of U# directly in the SDK I want to make it better, but I advise against using this in prefabs you are looking to distribute.
Installation
Make a backup of your project first, if Unity screws up with importing stuff like this, it can screw up badly.
- Close your project
- Make sure your project is backed up
- Go to the
Packages/com.vrchat.worlds/Integrations
folder and delete theUdonSharp
folder and itsUdonSharp.meta
file - Grab the
com.merlin.UdonSharp_1.2.0-b1.zip
file from the files on this page. Do not use any of the other files that github puts there, they are very out of date since this github has not had the changes merged in. - Extract the
com.merlin.UdonSharp
folder in the zip file into thePackages
directory in your project. - Open your project again, and if everything worked your project should work just as you left it and can now use the new features.
Thanks for your support everyone, sorry I couldn't make it work out better.