private void Awake()
 {
     if (_instance != null)
     {
         new UnityException("[onAirXR] ERROR: There must exist only one AirXRServer instance.");
     }
     _instance = this;
     DontDestroyOnLoad(gameObject);
 }
예제 #2
0
    private void Awake()
    {
        ensureGameObjectIntegrity(false);
        if (Application.isPlaying == false)
        {
            return;
        }

        AirXRServer.LoadOnce();

        disableCameras();
        AirXRCameraRigManager.managerOnCurrentScene.RegisterCameraRig(this);
        AirXRCameraRigManager.managerOnCurrentScene.eventDispatcher.MessageReceived += onAirXRMessageReceived;

        playerID = AXRServerPlugin.InvalidPlayerID;

        inputStream = new AirXRServerInputStream(this);

        if (_sendAudio)
        {
            _audioOutputRouter                  = headAnchor.gameObject.AddComponent <AirXRServerAudioOutputRouter>();
            _audioOutputRouter.input            = _audioInput;
            _audioOutputRouter.targetAudioMixer = _targetAudioMixer;
            _audioOutputRouter.exposedRendererIDParameterName = _exposedRendererIDParameterName;
            _audioOutputRouter.targetCameraRig = this;

            if (_audioInput == AirXRServerAudioOutputRouter.Input.AudioListener)
            {
                _audioOutputRouter.output = AirXRServerAudioOutputRouter.Output.All;

                _audioListener = headAnchor.gameObject.AddComponent <AudioListener>();
            }
            else
            {
                _audioOutputRouter.output = AirXRServerAudioOutputRouter.Output.One;
            }
        }

        if (_audioOutputRouter)
        {
            _audioOutputRouter.enabled = false;
        }
        //if (_audioListener) {
        //    _audioListener.enabled = false;
        //}

        _predictiveCameraRig = GetComponent <AirXRPredictiveCameraRig>();
        _cameraEventEmitter  = cameras[0].gameObject.AddComponent <CameraEventEmitter>();

        onAwake();
    }
    void OnAudioFilterRead(float[] data, int channels)
    {
        if (input == Input.AudioPlugin)
        {
            return;
        }

        if (output == Output.All)
        {
            AirXRServer.SendAudioFrameToAllCameraRigs(data, data.Length / channels, channels, AudioSettings.dspTime);
        }
        else if (targetCameraRig != null)
        {
            AirXRServer.SendAudioFrame(targetCameraRig, data, data.Length / channels, channels, AudioSettings.dspTime);
        }
    }
 private void onAirXRSessionDisconnected(int playerID, AirXRServerMessage message)
 {
     AirXRServer.NotifyClientDisconnected(playerID);
 }