void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
Example #2
0
        public void AwakeChat()
        {
            if (instance != null && instance != this)
            {
                Destroy(this);
                Debug.LogError("Only one instance of VoiceChatRecorder can exist");
                return;
            }
            instance = this;

            foreach (VoiceChatPlayer player in voiceChatPlayers)
            {
                player.StartChat();
            }

            Application.RequestUserAuthorization(UserAuthorization.Microphone);

            if (Microphone.devices.Length == 0)
            {
                Debug.LogError("Mic not found");
                return;
            }
            // VoiceChatSettings.Preset = VoiceChatPreset.Speex_8K;
            VoiceChatClient.StartClient();
        }
 void OnDisable()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
        void OnEnable()
        {
            if (instance != null && instance != this)
            {
                MonoBehaviour.Destroy(this);
                Debug.LogError("Only one instance of VoiceChatRecorder can exist");
                return;
            }

            Application.RequestUserAuthorization(UserAuthorization.Microphone);
            instance = this;
        }
        public override void OnInspectorGUI()
        {
            VoiceChatRecorder recorder = target as VoiceChatRecorder;

            if (Application.isPlaying && Network.isClient)
            {
                EditorGUILayout.LabelField("Available Devices", EditorStyles.boldLabel);

                foreach (string device in recorder.AvailableDevices)
                {
                    EditorGUILayout.LabelField(device);
                }

                EditorGUILayout.LabelField("Selected Device", EditorStyles.boldLabel);

                int      index = Mathf.Clamp(Array.IndexOf(recorder.AvailableDevices, recorder.Device), 0, Int32.MaxValue) + 1;
                string[] devices = new string[1] {
                    "Default"
                }.Concat(recorder.AvailableDevices).ToArray();

                index = EditorGUILayout.Popup(index, devices);

                if (index != 0)
                {
                    recorder.Device = devices[index];
                }
                else
                {
                    recorder.Device = null;
                }

                if (recorder.IsRecording)
                {
                    if (GUILayout.Button("Stop Recording"))
                    {
                        recorder.StopRecording();
                    }
                }
                else
                {
                    if (GUILayout.Button("Start Recording"))
                    {
                        recorder.StartRecording();
                    }
                }
            }
            else
            {
                DrawDefaultInspector();
            }
        }
Example #6
0
 void Start()
 {
     if (instance != null && instance != this)
     {
         Debug.Log(instance.name);
         MonoBehaviour.Destroy(this);
         Debug.LogError("Only one instance of VoiceChatRecorder can exist");
         return;
     }
     // if (!Application.HasUserAuthorization(UserAuthorization.Microphone))
     // {
     //  Application.RequestUserAuthorization(UserAuthorization.Microphone);
     // }
     instance = this;
 }
Example #7
0
 void OnDestroy()
 {
     instance = null;
 }
Example #8
0
 void OnDisable()
 {
     instance = null;
 }
Example #9
0
        void OnEnable()
        {
            if (instance != null && instance != this)
            {
                MonoBehaviour.Destroy(this);
                Debug.LogError("Only one instance of VoiceChatRecorder can exist");
                return;
            }

            Application.RequestUserAuthorization(UserAuthorization.Microphone);
            instance = this;
        }
 void OnDestroy()
 {
     instance = null;
 }
 void OnDisable()
 {
     instance = null;
 }
 void OnDisable()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
 void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }