C# Class NaviConnectionSDK, Navi

This class does most of the heavy-lifting for connecting the PC to the smart device. This class can only have one Instance running for a given game and can be accessed via the Instance variable. The Instance variable allows you access all public methods and variables. The smart device sends data on two connections: one that sends pose data and another that sends RPC touch data
Inheritance: MonoBehaviour
ファイルを表示 Open project: vmohan7/Navi Class Usage Examples

Public Properties

Property Type Description
DeviceLocationPrefab NaviDevice,
Instance NaviConnectionSDK,

Public Methods

Method Description
AnimObjLocation ( int player_id, string objName, Vector3 location, float time ) : void

Animates a gameobject to a given location on the mobile device. This should be used after you have uploaded an asset bundle to the device.

Awake ( ) : void

First function that is called when scene is loading

CallComponentMethod ( int player_id, string objName, string componentName, string methodName, object parameters ) : void

If an asset bundle has been sent to the screen, this methd allows you to edit any component on game objects in the asset bundle. if there are no parameters, set parameters to null

ClearMobileKeyboard ( int player_id ) : void

Method to clear the text on the mobile keyboard

CloseMobileKeyboard ( int player_id ) : void

Method to close mobile keyboard on device

DestroyObj ( int player_id, string objName ) : void

Destroys a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.

DuplicateObj ( int player_id, string objName, string newName, Vector3 pos, Quaternion rot ) : void

Duplicate a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.

GetMobileHotspotObj ( ) : AndroidJavaObject
GetPlayerPose ( int playerID ) : NaviDevice,

Gets the device information for the specific player

OnDestroy ( ) : void

Called when object is destroyed i.e. when game ends

OpenMobileKeyboard ( int player_id, string initalText, bool hideInputOnKeyboards ) : void

Method to tell connected device that it should open its mobile keyboard

RenderObj ( int player_id, string objName, bool render ) : void

Sets whether to render a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.

ResetDevice ( ) : void

Public Method to reset just the smart device

ResetVR ( int playerID ) : void

Resets the HMD and smart device. Will call OnGameStart once both the device and HMD have been reset. This method is mapped to a 5 finger tap. So whenever a user taps with 5 fingers they will be reset

SendAssetBundle ( int player_id, TextAsset assetFile ) : void

Sends an asset bundle to to the mobile device in order to render the scene

SendData ( ) : void

Method that is called on an interval to broadcast the ipAddress for listening devices

SetDeviceOrientaton ( int player_id, ScreenOrientation, orient, bool canUserChange ) : void

Method to set the device orientation on the mobile device. This uses Unity's enum and sends that to the device

SetInstructions ( int player_id, string instructions ) : void

Method to set the instructions on the instruction panel screen of the mobile device

SetObjLocation ( int player_id, string objName, Vector3 location ) : void

Sets the location of a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.

SetObjRotation ( int player_id, string objName, Quaternion rot ) : void

Sets the rotation of a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.

Start ( ) : void

Called after Gameobject is initalized. We start sending packets to find Navi-compatible devices

StartPlayerSwitchIds ( int playerID, int fingerID, Vector2 pos ) : void

After a reset this method is called, if the player would like to change which device number they are. To change which device number they are, they need to hold & press the number of fingers of the device they want to become. I.e. if they want to become player 2, they touch their device with 2 fingers.

SwitchPlayerIds ( int playerID, int fingerID, Vector2 pos ) : void

Method that is called when a player wants to switch to a given device id.

TouchUp ( int playerID, int fingerID, Vector2 pos ) : void

Listener for when the user touches up on the device

Update ( ) : void

Called every frame to process Network events.

UpdateComponentProperty ( int player_id, string objName, string componentName, string propName, object value, object indicies ) : void

If an asset bundle has been sent to the screen, this method allows you to edit any component on game objects in the asset bundle. if there are no indices, set indices to null

Private Methods

Method Description
ChangePlayerID ( int newID, int currConnection ) : void

Method to tell that device that it has changed to a different player number

CreateSocket ( ) : void

Method that creates the socket on the PC that will be used for receiving data

DeviceConnected ( int connectionID ) : void

Method that is called when a smart device connects

GetPlayerID ( int connectionID ) : int

Given the connection id, we get the player id index

HandlePoseData ( int connectionID, byte recBuffer ) : void

Method to parse and send an event when Pose Data is transfer from smart device

HandleRPC ( int connectionID, byte recBuffer ) : void

Method to parse and send an RPC event from smart device such as recieving touch input

OnConnection ( int connectionID ) : void

Method that is called when a connection is made. We then send a message back to the smart device so that the smart device knows which connection it should use to send different types of data. OnDeviceConnected is called when all connections have been made.

OnDisconnect ( int connectionID ) : void

Method that is called when one of the connection disconnects.

SendAssetData ( int player_id, byte file ) : IEnumerator

Private method to iteratively send asset data to the mobile device, because in general that file will be too big

StartSendingIP ( ) : void

Method that will start broadcasting packets to find a smart device

Method Details

AnimObjLocation() public method

Animates a gameobject to a given location on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public AnimObjLocation ( int player_id, string objName, Vector3 location, float time ) : void
player_id int
objName string
location Vector3
time float
return void

Awake() public method

First function that is called when scene is loading
public Awake ( ) : void
return void

CallComponentMethod() public method

If an asset bundle has been sent to the screen, this methd allows you to edit any component on game objects in the asset bundle. if there are no parameters, set parameters to null
public CallComponentMethod ( int player_id, string objName, string componentName, string methodName, object parameters ) : void
player_id int
objName string
componentName string
methodName string
parameters object
return void

ClearMobileKeyboard() public method

Method to clear the text on the mobile keyboard
public ClearMobileKeyboard ( int player_id ) : void
player_id int
return void

CloseMobileKeyboard() public method

Method to close mobile keyboard on device
public CloseMobileKeyboard ( int player_id ) : void
player_id int
return void

DestroyObj() public method

Destroys a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public DestroyObj ( int player_id, string objName ) : void
player_id int
objName string
return void

DuplicateObj() public method

Duplicate a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public DuplicateObj ( int player_id, string objName, string newName, Vector3 pos, Quaternion rot ) : void
player_id int
objName string
newName string
pos Vector3
rot Quaternion
return void

GetMobileHotspotObj() public method

public GetMobileHotspotObj ( ) : AndroidJavaObject
return UnityEngine.AndroidJavaObject

GetPlayerPose() public method

Gets the device information for the specific player
public GetPlayerPose ( int playerID ) : NaviDevice,
playerID int The id of the player, where 0 is the controller that is used by the headset
return NaviDevice,

OnDestroy() public method

Called when object is destroyed i.e. when game ends
public OnDestroy ( ) : void
return void

OpenMobileKeyboard() public method

Method to tell connected device that it should open its mobile keyboard
public OpenMobileKeyboard ( int player_id, string initalText, bool hideInputOnKeyboards ) : void
player_id int
initalText string
hideInputOnKeyboards bool
return void

RenderObj() public method

Sets whether to render a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public RenderObj ( int player_id, string objName, bool render ) : void
player_id int
objName string
render bool
return void

ResetDevice() public method

Public Method to reset just the smart device
public ResetDevice ( ) : void
return void

ResetVR() public method

Resets the HMD and smart device. Will call OnGameStart once both the device and HMD have been reset. This method is mapped to a 5 finger tap. So whenever a user taps with 5 fingers they will be reset
public ResetVR ( int playerID ) : void
playerID int
return void

SendAssetBundle() public method

Sends an asset bundle to to the mobile device in order to render the scene
public SendAssetBundle ( int player_id, TextAsset assetFile ) : void
player_id int
assetFile UnityEngine.TextAsset
return void

SendData() public method

Method that is called on an interval to broadcast the ipAddress for listening devices
public SendData ( ) : void
return void

SetDeviceOrientaton() public method

Method to set the device orientation on the mobile device. This uses Unity's enum and sends that to the device
public SetDeviceOrientaton ( int player_id, ScreenOrientation, orient, bool canUserChange ) : void
player_id int
orient ScreenOrientation,
canUserChange bool
return void

SetInstructions() public method

Method to set the instructions on the instruction panel screen of the mobile device
public SetInstructions ( int player_id, string instructions ) : void
player_id int
instructions string
return void

SetObjLocation() public method

Sets the location of a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public SetObjLocation ( int player_id, string objName, Vector3 location ) : void
player_id int
objName string
location Vector3
return void

SetObjRotation() public method

Sets the rotation of a gameobject located on the mobile device. This should be used after you have uploaded an asset bundle to the device.
public SetObjRotation ( int player_id, string objName, Quaternion rot ) : void
player_id int
objName string
rot Quaternion
return void

Start() public method

Called after Gameobject is initalized. We start sending packets to find Navi-compatible devices
public Start ( ) : void
return void

StartPlayerSwitchIds() public method

After a reset this method is called, if the player would like to change which device number they are. To change which device number they are, they need to hold & press the number of fingers of the device they want to become. I.e. if they want to become player 2, they touch their device with 2 fingers.
public StartPlayerSwitchIds ( int playerID, int fingerID, Vector2 pos ) : void
playerID int
fingerID int
pos Vector2
return void

SwitchPlayerIds() public method

Method that is called when a player wants to switch to a given device id.
public SwitchPlayerIds ( int playerID, int fingerID, Vector2 pos ) : void
playerID int
fingerID int
pos Vector2
return void

TouchUp() public method

Listener for when the user touches up on the device
public TouchUp ( int playerID, int fingerID, Vector2 pos ) : void
playerID int
fingerID int
pos Vector2
return void

Update() public method

Called every frame to process Network events.
public Update ( ) : void
return void

UpdateComponentProperty() public method

If an asset bundle has been sent to the screen, this method allows you to edit any component on game objects in the asset bundle. if there are no indices, set indices to null
public UpdateComponentProperty ( int player_id, string objName, string componentName, string propName, object value, object indicies ) : void
player_id int
objName string
componentName string
propName string
value object
indicies object
return void

Property Details

DeviceLocationPrefab public_oe property

public NaviDevice, DeviceLocationPrefab
return NaviDevice,

Instance public_oe static_oe property

public static NaviConnectionSDK, Instance
return NaviConnectionSDK,