Creating Objects for Varwin in Unity

Video Guides

Here you will find the video guides showing how to create objects for the Varwin RMS platform.

Creating a Button


Creating a Light Bulb


Creating a Screen


Creating objects

  1. Create or import a game object and save it as a prefab.
  2. Select the prefab in its folder.
  3. Open VARWIN SDK -> Create -> Object
../_images/image85.png
  1. Select an object, name it. Add tags for fast search. Fill in the info about the object’s author.
  2. Click Create. You’ll be asked to wait several moments.
../_images/image120.png
  1. Your object has been created. It consists of: a. object prefab, b. .asmdef file (for object code compilation), c. object class stored in a unique namespace. Should the need arise to add more classes, they will have to be stored in the same directory and the same namespace.
../_images/image94.png
  1. SimpleButton class has been created for the object. It inherits VarwinObject. This is the main object class, which connects the object with the platform.
using UnityEngine;
using Varwin.Public;
namespace Varwin.Types.Cube_68bc9ae493d843aab141939fcd529513
{
    [Locale(SystemLanguage.English,"Cube")]
    [Locale(SystemLanguage.Russian,"Cube")]
    public class Cube : VarwinObject
    {
        void Start()
        {
        }

        void Update()
        {
        }
    }
}
  1. Everything is ready for writing object code.

Example

The object has a method “ChangeState” in its main class. The method changes bool variable IsPressed.

public void ChangeState()
       {
           isPressed = !isPressed;
           _animator.SetBool("Pressed", isPressed);

To connect this method with the action of pulling the trigger on a controller (“Use”): select method “ChangeState” in Interactable Object Behavior.

../_images/image38.png

You will have to create a function for Blockly, write an attribute for it (in this case, Checker) and name it.

[Checker("buttonState")]
[Locale(SystemLanguage.English, "button pressed")]
public bool ButtonPressedChecker()
{
   return isPressed;
}

Should this object have several methods, Blockly will group them within one block within this name.

  • E.g., if we create another state of the button, “is released”,
[Checker("pressed")]
   [Locale(SystemLanguage.English, "is released")]
   public bool IsReleased()
   {
       return !IsPressed;
   }
  • Blockly will group these methods this way:
../_images/image144.png

Everything is ready for object building. Click Build.

../_images/image154.png

When the object is ready, the folder containing it will open. Now you can upload the object into the Varwin library.

../_images/image57.png

The object appears in the library.

../_images/image1110.png

Now you can place the object into a scene in VR. Click Save. Now the object appears in the scene. Open Blockly. You’ll see logic blocks that have been created for the object.

../_images/image165.png ../_images/image215.png

Working with attributes

Ways of working with attributes are described here: Working with attributes

Objects, scene templates versioning

Create new versions of existing objects and scene templates.

Objects, scene templates versioning: instruction