UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors (Deploying to WebGL) - c#

So I am getting this error:
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002cc] in <3371b3e2e5754acd87e600e068350da5>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <3371b3e2e5754acd87e600e068350da5>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
I've looked up the error on google but I am not getting any answers. The game is working just fine in unity editor.
The error says build Player a lot so I assumed it's a compiling error in building the player. I am using the Photon Player Scripts and their scripts for game manager. (Photon Voice 2, Photon Chat, Photon Fusion, Photon Realtime)
Anyways here is the script:
using UnityEngine;
using Photon.Pun;
public class GameManager : MonoBehaviour
{
public GameObject playerPrefab;
void Start()
{
PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(Random.Range(-5f, 5f), Random.Range(3f, 5f), Random.Range(-5f, 5f)), playerPrefab.transform.rotation);
}
}
I have 2 Scenes: "Connect&Lobby" and second scene "Main"
Also, here are some of the errors above this error (But I'm sure these aren't causing the build problems):
Error building Player because scripts had compiler errors
Assets\Photon\PhotonVoice\Demos\DemoVoiceUI\Scripts\MicrophoneDropdownFiller.cs(110,28): error CS0103: The name 'Microphone' does not exist in the current context
I've been dealing with this issue for couple days now it's really annoying.
Also, the player script has no compiler errors pretty sure: (Take a look)
using UnityEngine;
using Photon.Pun;
using TMPro;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
public PhotonView photonView;
public GameObject usernameCanvas;
public TMP_Text usernameText;
void Awake()
{
if (photonView.IsMine)
{
usernameText.text = PhotonNetwork.NickName;
}
else
{
usernameText.text = photonView.Owner.NickName;
}
}
void Update()
{
if (!photonView.IsMine)
{
usernameCanvas.SetActive(true);
}
}
}

Error The name 'Microphone' does not exist in the current context is the reason why you cannot build your project (at least, it is one of the reasons, perhaps, there are some more there)
According to the unity3d documentation, Microphone class is not supported in WebGL.
I saw this page but didn't test it myself. Anyway, you can give it a try =)

There is other problem with you pc or laptop some of security or vpn apps dont allow you to build your unity project just checkout your pc and build it again

Related

My visual studio script is not working in Unity

I just started game development and got into a problem
whenever I load my Visual Studio code into Unity it says
The refrenced script unknown on this behaviour is missing
This is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VirtualManMovement : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Hello, World!") ;
}
// Update is called once per frame
void Update()
{
}
}
I need a solution for this
This may happen is the file name does not match the class name. Make sure that the file containing this script is also named VirtualManMovement.cs
Make sure in Unity you go to edit -> preferences and see that you have Unity External tools in Your IDE Selected.
Ensure your Code File Name is the same as your Class to prevent confusion.
I was confused as well when I first started. Hopefully, you find this useful

Oculus Builds Not Running(Crashing)

I have made a unity physics based Jetski Game and am having trouble with getting it onto my Oculus Quest 2 and it actually working. For me I am stuck in a place that doesn't have good enough Wi-Fi to run air link and don't have the cable link. These has caused me to build it straight onto the headset itself. When running it on the headset the three loading dots would start playing its animation and never stop, but when you clicked the oculus button it would come up with the error "JetSki has stopped working." (JetSki is the game name.)
These are the tools that I am using and other information that may be needed:
How I set up the keystore: https://www.youtube.com/watch?v=qFS77pQ2VaQ
How I set up VR in unity: https://www.youtube.com/watch?v=HhtTtvBF5bI and https://www.youtube.com/watch?v=8PCNNro7Rt0
How I am getting the inputs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InteractionInput : MonoBehaviour
{
public InputActionProperty triggerPress, triggerBool;
public InputActionProperty gripPress, gripBool;
[HideInInspector]
public float gripValue, triggerValue;
[HideInInspector]
public bool gripPressed, triggerPressed;
void Update()
{
triggerValue = triggerPress.action.ReadValue<float>();
triggerPressed = triggerBool.action.ReadValue<bool>();
gripValue = gripPress.action.ReadValue<float>();
gripPressed = gripBool.action.ReadValue<bool>();
}
}
How I am building the project:
I have searched everywhere and all I can find are random threads on stack overflow and unity forums. Yet these are talking about if it crashes when connected to a pc and none of those have helped. There is no one that I have found that is in this exact problem. After this searching I also tried to use the Side Quest to upload the .apk to my headset but I got another error: self signed certificate in certificate chain. Any tips or solutions would be greatly appreciated.
Thanks
Stan :)

Is there any solution for "destination" error with NavMeshAgent in Unity?

I'm working on "Indoor Navigation" using Vuforia in unity. I have scanned the map using "Vuforia Area Target Creator" and import area targets to Unity Project, then I have merged mulitple area targets as one area target, then I have Created NavMesh and NavMesh Agent, then I want to test if the NavMeshAgent move to destination or not. I'm following Unity Manual: https://docs.unity3d.com/Manual/nav-MoveToDestination.html
When I wrote this script, I get this error:
My Script:
// MoveTo.cs
using UnityEngine;
using UnityEngine.AI;
public class MoveTo : MonoBehaviour {
public Transform goal;
void Start () {
NavMeshAgent agent = GetComponent<NavMeshAgent>();
agent.destination = goal.position;
}
}
I also searched on Youtube, I found that someone wrote the same code for his game and working with him, What's the problem ??
Can any one help me in this ?
private void Start()
{
NavMeshAgent agent = GetComponent<NavMeshAgent>();
agent.SetDestination(goal.position);
}
if you want to set your agent destination to the target than change your code like upon code.

How to Implement NetworkManagers?

I'm fairly new to Unity, and very new to networking concepts. I'm trying to attach a NetworkManager script containing a custom OnServerAddPlayer function to an empty game object with a NetworkManager game component. However, when I attempt to do this, I receive a "the script class cannot be found... ...ensure the file name and script class match" error.
My research has suggested vaguely that perhaps only MonoBehaviour scripts can be attached to GameObjects (?), but I haven't been able to find anything explicitly stating this anywhere. And if one can't attach NetworkManager scripts to GameObjects, how would one reference variables on the NetworkManager component like startPositions and spawnPrefabs? And does the script need to be attached to a GameObject for public override OnServerAddPlayer (NetworkConnection conn, short playerControllerId) {...} to be called?
Thank you in advance!
Edit:
Here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
class PlayerManager : NetworkManager {
int roundRobin = 0;
public GameObject newPlayerParent;
NetworkManager manager;
public override void OnServerAddPlayer (NetworkConnection conn, short playerControllerId) {
manager = gameObject.GetComponent<NetworkManager>();
Transform positionObject = manager.startPositions [roundRobin];
GameObject newPlayer = GameObject.Instantiate(manager.spawnPrefabs[roundRobin], positionObject.position, positionObject.rotation, newPlayerParent.transform);
}
}
I am trying to attach the script by dragging it from the project view onto the inspector for an empty object with the NetworkManager, NetworkManagerHUD, and NetworkDiscovery components attached.
Only classes inheriting from Component can be attached to a GameObject, which includes MonoBehaviour. NetworkManager does inherit from MonoBehaviour though, so that's not the problem.
The error message is your best guide here. Make sure your class is in a file called PlayerManager.cs, and there are no other classes defined in the same class.

SpeechLib.SpVoiceClass:GetVoices does crash my Unity executable

I created a project with Unity (version 4.5.3f3).
I only wrote a simple script as follow:
using UnityEngine;
using System.Collections;
using SpeechLib;
public class SpeechTest : MonoBehaviour
{
private SpVoice voice;
void Start()
{
voice = new SpVoice();
voice.GetVoices("","");
}
// Update is called once per frame
void Update()
{
if (Input.anyKeyDown)
{
voice.Speak("Hello, world!", SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
}
}
Here you can download the test project for Unity: https://dl.dropboxusercontent.com/u/12184013/TextToSpeech.zip
When I try to play (in Unity editor), the game runs without problems.
Instead, when I build and run the game, it crashes.
When i comment this line
ISpeechObjectTokens voices = voice.GetVoices();
the game doesn't crash after I rebuilt it.
I need to call GetVoices method, because I want to set a new voice in the "SpVoice voice" object.
Here is the solution: http://forum.unity3d.com/threads/speechlib-spvoiceclass-getvoices-does-crash-my-unity-executable.268011/#post-1772720
In a nutshell the library [Unity Install Directory]\Editor\Data\Mono\lib\mono\2.0\CustomMarshalers.dll should be included in the Unity project (adding it as a asset).

Categories