- Home /
Can't Add Script: Can't add component 'NetworkManager'
Trying To add script But it won't Let me gives the Error Cant add Script Cant add component "NetworkManager" Because it dosn't exist. Check to See if File Name and Class Name Match.
the File name is NetworkManager.cs Here is the Script:
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public Camera standbyCamera;
// Use this for initialization
void Start () {
Connect ();
}
void Connect() {
PhotonNetwork.ConnectUsingSettings( "1.0" );
}
void OnGUI() {
GUILayout.Label( PhotonNetwork.connectionStateDetailed.ToString() );
}
void OnJoinedLobby() {
Debug.Log ("OnJoinedLobby");
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed() {
Debug.Log ("OnPhotonRandomJoinFailed");
PhotonNetwork.CreateRoom( null );
}
}
Does it happen with this specific file? If yes, then copy and paste this code in a new file and try to add that to your object.
Answer by DanVioletSagmiller · Jun 02, 2017 at 05:04 PM
There is already a Unity class called NetworkManager. It's not the error I would assume to see, but it might be the fact there are two classes with the same names.
Your answer
![](https://koobas.hobune.stream/wayback/20220613151739im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
cant add script 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
enabling and disabling hingeJoint in Unity 4.3 2 Answers
C# Adding Components From Other Gameobjects 3 Answers
Very strange NullReference Problem 2 Answers