Releases: MerlinVR/UdonSharp
UdonSharp 1.2-beta1: Non-Behaviour scripts, Lists, Dictionaries, and more
UdonSharp 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.
Sync mode None support
Make sure you are using the latest VRCSDK
If you are upgrading from Unity 2018, follow the upgrade instructions https://docs.vrchat.com/v2021.3.2/docs/migrating-from-2018-lts-to-2019-lts pay special attention to step 2.5 MAKE A BACKUP OF YOUR PROJECT BEFORE UPGRADING IT TO 2019.4
- 0d6daed: Add support for sync mode none on UdonSharpBehaviours
- #110: Improve default create script location, contributed by @FairlySadPanda
Bug fixes and 2019.4 support
If you are upgrading to Unity 2019.4, make sure you are using the latest VRCSDK and follow the upgrade instructions https://docs.vrchat.com/v2021.3.2/docs/migrating-from-2018-lts-to-2019-lts pay special attention to step 2.5
MAKE A BACKUP OF YOUR PROJECT BEFORE UPGRADING IT TO 2019.4
- #90: Fix issues with using properties on other user scripts, contributed by @ChanyaKushima
- 6e89d85: Fix exceptions in exposure tree causing it to loop endlessly in 2019, reported by @IkaWaAyuMu in #94
- e57c18f: Fix method/property accesses on user properties, reported by @BocuD in #97
- 1535eec, 7ddf44f, 4154023, d9ec5e1: Various attempted fixes for Unity sucking and dropping references to objects
MAKE A BACKUP OF YOUR PROJECT BEFORE UPGRADING IT TO 2019.4
MAKE A BACKUP OF YOUR PROJECT BEFORE UPGRADING IT TO 2019.4
Unity 2019.4 Interface Fix
For use with the 2019.4 open beta. This is compatible with Unity 2018.4 and 2019.4
- a1e1a49: Fix inspector handling that was using the fallback inspector due to Unity changing how custom editors are located in 2019.4
- 308e752: Fix compile errors when using attributes on properties
- #88: Fix usage of
return
in property setters not working, fixed by @ChanyaKushima
Property Support
This release requires the latest VRCSDK
Features
- #85: Support for user defined C# properties on UdonSharpBehaviours implemented by @mika-f
Property syntax with getters and setters is now valid, for example this works now:
float _myFloat = 5f;
public float MyFloatProperty
{
get { return _myFloat; }
set { _myFloat = value; }
}
private void Start()
{
Debug.Log(MyFloatProperty);
}
- #87: Support for Udon's new OnVariableChange events via FieldChangeCallback. This can be used to let properties automatically execute their setter when network sync updates the marked field.
- 98f8c87: NoVariableSync mode will now attempt to match the common variable sync mode between UdonBehaviours on the same GameObject. This means you can now use your non-synced scripts on GameObjects with manually synced scripts.
- d61ba6d: Support for PostLateUpdate event
Fixes
- a9642c0: Fix scene getting dirtied redundantly when using NoVariableSync
- fe79cc5: Fix handling for updating prefab properties in the scene
- 61f725a: Remove collision transfer option from UdonBehaviour inspector and force to off since it is no longer respected by the client.
- 603ae98: Fix
foreach
loops on iterators that are retrieved from expressions while inside recursive methods, reported by GlitchyDev
Add support for DisableInteractive
This version requires the latest VRCSDK
If you are updating from <v0.19.2, you need to delete the Assets/UdonSharp/Plugins
folder before installing this
- 44b47e8: Add support for new DisableInteractive property on UdonBehaviours
Udon Network Update Support
This version requires the latest VRCSDK
If you are updating from <v0.19.2, you need to delete the Assets/UdonSharp/Plugins
folder before installing this
- Add new supported sync types to allowed sync variable types
- Add UI for manual sync vs continuous sync selection to UdonSharpBehaviour inspector
- Add warning and conversion for objects using the now-deprecated position sync option, in favor of using the new VRC Object Sync component instead
- Add
UdonBehaviourSyncMode
attribute to optionally enforce a chosen sync mode and preform additional validation on synced variables - Switch to use new Udon methods to check sync type compatibility (which allows use of the array sync)
- Add handling for calling RequestSerialization() on UdonSharpBehaviours
- Add handling for the OnOwnershipTransferRequest and OnPostSerialization events
- Add handling for the previous owner being passed to OnOwnershipTransferred
- Update sync utility scripts to use reliable sync
- Add build validation for sync mode conflicts
Networking open beta update
This release is only for use with the open beta VRCSDK, if you are using live, use 0.19.8. If you are updating from UdonSharp <v0.19.2, you need to delete the Assets/UdonSharp/Plugins
folder before installing this
- 7507e92: Add support for SerializationResult on OnPostSerialization, note any scripts currently using OnPostSerialization will need to be updated to include the new argument.
Sync beta support
This release is only for use with the open beta VRCSDK, if you are using live, use 0.19.8. If you are updating from UdonSharp <v0.19.2, you need to delete the Assets/UdonSharp/Plugins
folder before installing this
- 6cca77f: Merge master into sync-beta for delayed event support and recent fixes
Work around mono bug on Japanese locale + other minor fixes
- c8e87cf: Changes to U#, Harmony, Unity, and Odin to work around mono/mono#20968 where possible, and add an error to describe the fix for the inevitable time when other libraries I don't have the ability to patch have issues. Thanks for help with the repro @ikuko, @esnya, and Tony_Lewis
- 4ae86a3: Fix implicit type conversion handling in array creation, reported by @ureishi
- 205e3ad: Strip comments and whitespace on exported assembly assets
- ab14976: Fix player name detection on log watcher, and update filter list for VRC logs
- 4042459: Remove warning about debug info not existing since it isn't really an issue most of the time and can be confusing for people
- f2de786: More explicit handling for if program assets don't match serialized program assets
- 2cb4a66: Mark UdonSharpEditorCache as public so it can be queried for debug info, requested by @orels1