vrchat-community / UdonSharp

A compiler for compiling C# to Udon assembly
https://udonsharp.docs.vrchat.com
MIT License
461 stars 50 forks source link

UdonSharp

UdonSharp is a compiler that translates C# to Udon assembly, so you can create interactive VRChat worlds by writing C# code.

You can find the full docs at https://udonsharp.docs.vrchat.com.

:warning: IMPORTANT! :warning:

The old 0.x version of UdonSharp which used to be delivered as a .unitypackage is deprecated and no longer supported. You can use the Creator Companion to migrate your projects to this new version and keep it updated moving forward.

Requirements

Getting Started

If you're comfortable using GitHub, follow the directions in the UdonSharp Template repo to quickly make your own ready-to-use repository. Otherwise, you can download the VRChat Creator Companion, and then choose Projects > New > UdonSharp to create a new ready-to-use Unity Project.

Use Unity 2019.4.31.f1 to open the project. Press "OK" on the dialog that offers to download the required VRChat packages.

image

Loading the Example World

Find the "VRChat SDK" item in the menu bar at the top of the Unity Editor window, press it to open, then choose "Samples > UdonExampleScene".

samples-udonexample-scene

Once the scene opens, choose "File > Save As..." and give the scene a new name.

Then modify the scene however you'd like - you learn about all the examples in the UdonExampleScene or learn about Getting Started with Udon.

Making your own Scripts

  1. Make a new object in your scene
  2. Add an Udon Behaviour component to your object
  3. Below the "New Program" button click the dropdown and select "Udon C# Program Asset"
  4. Now click the New Program button, this will create a new UdonSharp program asset for you
  5. Click the Create Script button and choose a save destination and name for the script.
  6. This will create a template script that's ready for you to start working on, open the script in your editor of choice and start programming.

    Instead of creating assets from an UdonBehaviour you can also do the following:

  7. Right-click in your project asset explorer
  8. Navigate to Create > U# script
  9. Click U# script, this will open a create file dialog
  10. Choose a name for your script and click Save
  11. This will create a .cs script file and an UdonSharp program asset that's set up for the script in the same directory

Test Your World

When you're ready to try out your World, find and choose the menu item "VRChat SDK > Show Control Panel".

Publish Your World

When you're ready to publish your World so you can use it regularly:

Return to VRChat - open the "Worlds" menu, then scroll down to the section named "Mine". Choose your world from the list and press "Go" to check it out!

Visual Studio Code Integration

You can follow this video guide to get Intellisense for C# within your Unity project in Visual Stido Code (VS Code), inlcuding libraries such as UdonSharp.

Credits

Discord