Пример #1
0
 private void OnDestroy()
 {
     if (VRDeviceWasSet.IsMethodAlreadyRegistered(CallInstantiation))
     {
         VRDeviceWasSet.Listeners -= CallInstantiation;
         // Destroy the remote controller
         Destroy(_controllerInstance);
     }
 }
Пример #2
0
        /// <summary>
        /// Callback for whenever one of the player had sent its device info
        /// Generate the corresponding mesh for the used controllers
        /// </summary>
        /// <param name="info"></param>
        private void CallInstantiation(VRDeviceWasSet info)
        {
            // If the player that has send his info is the one corresponding to this player and the remoteControllers dictionary doesn't contains this player yet
            if (info.Player.NickName == photonView.Owner.NickName)
            {
                if (_controllerInstance != null)
                {
                    Destroy(_controllerInstance);
                }

                // If the other user use the simulator, we do not need to generate a controller
                _controllerInstance = info.Player.DeviceUsed == EDevice.SIMULATOR ? null : GameObject.Instantiate(_controllersMesh.ControllersPerDevice[info.Player.DeviceUsed], transform.parent);
            }
        }