NetPrints Unity Tutorial
This is an example of how to use NetPrints inside Unity3D for visual programming. It replicates part of the roll-a-ball tutorial where we make a ball roll with user input. For further information on how the example works please visit the link. The completed project is contained in this repository.
- Create a new project within your unity project. Create a plane for the floor and a sphere. Add a
Rigidbodyto the sphere. The exact path does not matter. Unity will automatically find the generated scripts.
- Click assemblies in the main menu. Remove all existing items and add Unity’s .NET libraries (
System.Core.dll) which can be found in
<UnityDirectory>/Editor/Data/Mono/lib/mono/unity/as well as
- Unity can use either our generated .NET binary or C# source code. The source code has the advantage that we can debug our generated code. Furthermore there are some bugs in Unity with generated .NET binaries and MonoBehaviour inheritance. Set the output mode to
SourceCodewhich will output only the source code. Then press
New Classwhich will add a new empty class to our project. You can open it by clicking on it. In the class settings it is possible to change the class name, its namespace and some other interesting properties. Set the base class to
- Add the
Start()methods. Also create the
System.Single, which is the same as
float). Mark the
speedattribute as public by clicking on it and checking the
Publiccheckbox on the right side of the editor.
- Implement the
- Implement the
- Press compile. This will generate a source code file with the name
<Namespace.Class>.cs. Since Unity only recognizes classes with the same name as its filename, the generated file will need to have the namespace part removed. The script can now be dragged onto our sphere like any other C# script. The sphere should now move when we press WASD.