Zoe for Unity: Help Center
  • Zoe for Unity - Help Center
  • Installation
    • Setting up Unity
    • Installing Zoe
    • XR Settings
    • Basic Scene
  • Getting Started
    • Interaction Rig
      • Create an Interaction Rig
      • Structure & Settings
    • Testing without a headset
    • Navigation modes
  • Adding interactivity
    • Overview
    • Interactive Objects
      • Creating IOs
      • Structure of IOs
      • IO Setup
    • Interactions
      • Interaction Setup
      • Conditions
        • Duration (parameter)
        • Gaze
        • Point and Click
        • Proximity
        • Touch
        • Manipulate
        • Inputs
        • Drop
        • Approach
        • Collision
      • Actions
        • Delay (parameter)
        • Scale
        • Rotate
        • Rotate Around
        • Translate
        • Activate
        • Audio
        • Animation
        • Physics
        • Change Material
    • Drag & Drop system
    • API - Custom Scripts
      • Create your own Condition
      • Create your own Action
  • Multiplayer
    • Installation
    • Photon Setup
    • Scripting Symbols
    • Get Started
    • Avatars
    • Multiplayer Conditions
    • Multiplayer Actions
  • Exporting Your App
    • Exporting your .apk for Quest
    • Sideloading your .apk on Quest
  • Lessons
    • Getting Started
      • Interactive Objects
      • Actions 01
      • Actions 02
      • Conditions 01
      • Conditions 02
  • MX PEN INTEGRATION
    • Installation
    • MX Pen Input Mapping
    • Changing the default MX Ink Visual
  • Swapping the MX Inc Visual In Play Mode
Powered by GitBook
On this page
  1. Adding interactivity
  2. API - Custom Scripts

Create your own Condition

Find the script TemplateCondition in your Project window (under Scripts > Interactions > Conditions) duplicate it and rename the duplicated file with your condition name [YourConditionName]. Once this is done, open the file for editing.

Rename the class name from:

public class TemplateCondition : S_AbstractCondition

to:

public class [YourConditionName] : S_AbstractCondition

IMPORTANT: the name you gave to the file and the name of the class need to be the same.

The whole logic of a condition revolves around calling the Validate function to tell the system your condition has been validated. Outside of the functions you see in the template, you will need to implement your own logic that will call Validate based on some requirements you defined.

You also need to fill up the three functions Setup, Dispose and Reload with logic.

Setup will be called before your condition is actually checked for validation. Use this function to prepare the things required for its validation.

Dispose is basically the opposite of Setup and undoes what was done in setup so that the condition does not accidentally validate again.

Typically the Setup and Dispose are usually called in a loop if your condition is reloaded several times.

Reload can have some custom logic of your choosing, but it is usually solely made for calling Invalidate which simply tells the system the condition is now ready for validation again.

You can then use your custom CONDITION inside any Interaction through the Add Component menu.

Last updated 2 years ago