Hey I was trying to add PUN VOICE 2. First I get bunch of errors but after reading this article by you I did not get any errors but I did not hear my voice while in debug mode. Is there anything wrong done by me or i just missed something very important?
I have changed 2 line of codes although the weird part is the lines does not match as you said in http://lovattostudio.com/forum/viewtopi ... =60&t=4824
Also after changing codes i re-Integrate and from "Gamedata" I enabled voice chat option. One thing i am not aware of there is a field black in "photon voice" called "sound prefab" I don't know if i have to add sound prefab or not also if i have to add sound prefab then which prefab?
check video--
Voice Integration with PUN VOICE 2 problem
Forum rules
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
Hi,
Seems like something changed in the last version of Photon Voice,
try the following:
change the whole code of PhotonVoiceAddon.cs with this:
and Run the Integration again (MFPS -> Addons -> Voice -> Integrate)
Seems like something changed in the last version of Photon Voice,
try the following:
change the whole code of PhotonVoiceAddon.cs with this:
Code: Select all
using UnityEditor;
using System.Collections.Generic;
using UnityEngine;
using UnityEditorInternal;
using UnityEditor.SceneManagement;
using MFPSEditor;
#if !UNITY_WEBGL && PVOICE
using Photon.Voice.Unity;
using Photon.Voice.PUN;
#endif
public class PhotonVoiceAddon : MonoBehaviour
{
private const string DEFINE_KEY = "PVOICE";
[MenuItem("MFPS/Addons/Voice/Enable")]
private static void Enable()
{
bl_GameData.Instance.UseVoiceChat = true;
EditorUtils.SetEnabled(DEFINE_KEY, true);
}
[MenuItem("MFPS/Addons/Voice/Enable", true)]
private static bool EnableValidate()
{
return !EditorUtils.CompilerIsDefine(DEFINE_KEY);
}
[MenuItem("MFPS/Addons/Voice/Disable")]
private static void Disable()
{
bl_GameData.Instance.UseVoiceChat = false;
EditorUtils.SetEnabled(DEFINE_KEY, false);
}
[MenuItem("MFPS/Addons/Voice/Disable", true)]
private static bool DisableValidate()
{
return EditorUtils.CompilerIsDefine(DEFINE_KEY);
}
[MenuItem("MFPS/Addons/Voice/Integrate")]
private static void Instegrate()
{
#if PVOICE
//setup the player 1
SetUpPlayerPrefab(bl_GameData.Instance.Player1.gameObject);
SetUpPlayerPrefab(bl_GameData.Instance.Player2.gameObject);
#if PSELECTOR
foreach(var p in MFPS.PlayerSelector.bl_PlayerSelectorData.Instance.AllPlayers)
{
if (p.Prefab == null ) continue;
SetUpPlayerPrefab(p.Prefab.gameObject);
}
#endif
if (AssetDatabase.IsValidFolder("Assets/MFPS/Scenes"))
{
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
string path = "Assets/MFPS/Scenes/MainMenu.unity";
EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
bl_Lobby lb = FindObjectOfType<bl_Lobby>();
if (lb != null)
{
GameObject old = GameObject.Find("PhotonVoice");
if(old != null)
{
DestroyImmediate(old);
Debug.Log("Remove old setup");
}
if (FindObjectOfType<PhotonVoiceNetwork>() == null)
{
GameObject nobj = new GameObject("PhotonVoice");
PhotonVoiceNetwork pvs = nobj.AddComponent<PhotonVoiceNetwork>();
pvs.AutoConnectAndJoin = true;
pvs.AutoLeaveAndDisconnect = true;
pvs.ApplyDontDestroyOnLoad = true;
pvs.AutoCreateSpeakerIfNotFound = true;
pvs.KeepAliveInBackground = 5000;
pvs.ApplyDontDestroyOnLoad = true;
Recorder r = nobj.AddComponent<Recorder>();
r.MicrophoneType = Recorder.MicType.Unity;
r.TransmitEnabled = true;
r.VoiceDetection = true;
r.AutoStart = true;
r.DebugEchoMode = true;
pvs.PrimaryRecorder = r;
nobj.AddComponent<bl_PhotonAudioDisabler>().isGlobal = true;
EditorUtility.SetDirty(nobj);
EditorUtility.SetDirty(pvs);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
Debug.Log("Photon Voice Integrated, enable it on GameData.");
}
else
{
Debug.Log("Can't found Menu scene.");
}
}
else
{
Debug.LogWarning("Can't complete the integration of the addons because MFPS folder structure has been change, please do the manual integration.");
}
#else
Debug.LogWarning("Enable Photon Voice addon before integrate.");
#endif
}
#if PVOICE
static void SetUpPlayerPrefab(GameObject prefab)
{
if (prefab == null) return;
GameObject p1 = prefab;
PhotonVoiceView pvv = p1.GetComponent<PhotonVoiceView>();
if (pvv == null)
{
pvv = p1.AddComponent<PhotonVoiceView>();
pvv.UsePrimaryRecorder = true;
pvv.UsePrimaryRecorder = true;
pvv.SetupDebugSpeaker = true;
}
Speaker speaker = p1.GetComponent<Speaker>();
if (speaker == null)
{
speaker = p1.AddComponent<Speaker>();
}
pvv.SpeakerInUse = speaker;
EditorUtility.SetDirty(p1);
}
#endif
[MenuItem("MFPS/Addons/Voice/Package")]
private static void OpenPackagePage()
{
AssetStore.Open("content/130518");
}
[MenuItem("MFPS/Tools/Fix Define Symbols")]
private static void FixDefineSymbols()
{
bool defines = EditorUtils.CompilerIsDefine("LM");
if (!defines)
{
EditorUtils.SetEnabled(DEFINE_KEY, false);
}
}
}
- Argha
- Member
- Posts: 18
- Joined: Mon Apr 20, 2020 4:28 am
Lovatto wrote: ↑Wed Apr 22, 2020 10:49 am Hi,
Seems like something changed in the last version of Photon Voice,
try the following:
change the whole code of PhotonVoiceAddon.cs with this:
I Changed the full code and integrate but result is same. Sound is not coming up. but it seems it's recording.
second time when i try to integrate i get this error--Code: Select all
NullReferenceException: Object reference not set to an instance of an object bl_PlayerVoice.Awake () (at Assets/MFPS/Scripts/Network/Player/bl_PlayerVoice.cs:39) UnityEngine.GameObject:SetActive(Boolean) Photon.Pun.PhotonNetwork:NetworkInstantiate(InstantiateParameters, Boolean, Boolean) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2507) Photon.Pun.PhotonNetwork:Instantiate(String, Vector3, Quaternion, Byte, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2346) bl_GameManager:SpawnPlayerModel(Team) (at Assets/MFPS/Scripts/Network/Room/bl_GameManager.cs:254) bl_GameManager:SpawnPlayer(Team) (at Assets/MFPS/Scripts/Network/Room/bl_GameManager.cs:159) bl_GameManager:SpawnPlayerWithCurrentTeam() (at Assets/MFPS/Scripts/Network/Room/bl_GameManager.cs:283)
- Argha
- Member
- Posts: 18
- Joined: Mon Apr 20, 2020 4:28 am
Today I just Re-Import PUN Voice and PUN2 in My new asset and Try it again with a fresh start guess what! IT JUST WORKED!!!!
but when I start a match it gaves me 1 error -- How to FIX that?
but when I start a match it gaves me 1 error -- How to FIX that?
Code: Select all
[PhotonVoice.PhotonVoiceNetwork] Unexpected: VoiceInfo.UserData should be int/ViewId, received: null UnityEngine.Debug:LogErrorFormat(Object, String, Object[])