Click or drag to resize

ARRaycast_Example Class

A demo showcasing how to use two types of raycasts in AR. A standard physics raycast can be used normally in AR as long as it is provided with the touch position. A Pose ASL raycast receives the Pose of any object the raycast hits. This demo allows AR users to raycast on objects within an AR space, as well as allowing a secondary PC user to spectate and select ASL objects. At least one AR user must be present when using this demo, as the PC user cannot create/view AR planes and thus cannot create spheres. Additionally, for simplicity, the PC user cannot move or rotate, however, these values can be changed if running within the Unity editor. Users switch between two modes, Select mode or Create mode. In Create mode, AR users can create spheres (ASL objects) on scanned AR planes. In Select mode, AR users can select AR planes as well as spheres, and PC users can select created spheres. Information is displayed to the user via text and informs the user of the object they have hit, or if the raycast hit the UI, or did not hit any object. Video Example: https://drive.google.com/file/d/1-tFcISyVAa5TGP3zB6ys4ay6Tqq7fy_n/view?usp=sharing
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          SimpleDemosARRaycast_Example

Namespace:  SimpleDemos
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
public class ARRaycast_Example : MonoBehaviour

The ARRaycast_Example type exposes the following members.

Constructors
  NameDescription
Public methodARRaycast_Example
Initializes a new instance of the ARRaycast_Example class
Top
Properties
  NameDescription
Private propertyStatic memberIsPC
Determines if user is on PC
Top
Methods
  NameDescription
Private methodDeselectObject
Deselects the currently selected object
Private methodSelectObject
Selects the given object
Public methodStatic memberSpawnSphere
The create object call back for the normal spheres - used to inform the user the sphere was created and to scale it down so it matches the size of the other objects
Private methodStatic memberSpawnWorldOrigin
Spawns the world origin cloud anchor after the world origin object visualizer has been created (blue cube)
Private methodStart
Called on start up - creates the world origin at the origin. For simplicity, this demo creates the origin at the exact location the AR user starts at, which may cause issues if the AR user starts in one location and then moves to another area and begins creating objects - the objects may be far from the PC user in this case. For a better representation of accurate world origin creation, check out the ARWorldOrigin demo.
Private methodUpdate
Update function - gets touch and selects or creates objects
Top
Fields
  NameDescription
Public fieldm_DisplayInformation
Text that displays scene information to the user
Public fieldm_ModeDropDown
Determines which mode the example is in: Select or Create
Public fieldm_PCCamera
Camera for the PC User
Private fieldm_SelectedObject
GameObject that is currently selected
Private fieldm_TouchPosition
Vector2 position of last touch
Top
See Also