Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by lorenzo233 · Feb 19, 2015 at 09:17 AM ·

Help Error CS0111

Help I am a begin coder and i keep getting this error that I don't know how to fix.

here's my code:

 using UnityEngine;
 using System.Collections;
 
 public class NetworkManger : MonoBehaviour {
 
     SpawnSpot[] spawnSpots;
 
     public bool offlineMode = false;
 
     bool conecting = false;
 
     ArrayList chatMessages;
     int maxChatMessages = 5;
 
     string roomName = "Room01";
 
     int maxPlayer = 1;
 
     string maxPlayerString = "1";
 
     Room[] game;
 
     Vector2 ScrollPosition;
 
     // Use this for initialization
     void Start () {
         spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
         PhotonNetwork.player.name = PlayerPrefs.GetString("Username", "Guest");
         chatMessages = new ArrayList();
     }
 
     void OnDestroy() {
         PlayerPrefs.SetString("Username", PhotonNetwork.player.name);
     }
 
     public void AddChatMessage(string m) {
         GetComponent<PhotonView> ().RPC ("AddChatMessage_RPC", PhotonTargets.All, m);
     }
 
     [RPC]
     void AddChatMessage_RPC(string m) {
         while(chatMessages.Count >= maxChatMessages) {
             chatMessages.RemoveAt (0);
         }
         chatMessages.Add(m);
     }
 
     void Connect() {
         PhotonNetwork.ConnectUsingSettings ("1.0.0");
     }
 
     void OnGUI() {
         GUILayout.Label( PhotonNetwork.connectionStateDetailed.ToString() );
 
         if (PhotonNetwork.connected == false && conecting == false) {
             GUILayout.BeginArea (new Rect (0, 0, Screen.width, Screen.height));
             GUILayout.BeginHorizontal ();
             GUILayout.FlexibleSpace ();
             GUILayout.BeginVertical ();
 
             GUILayout.BeginHorizontal ();
             GUILayout.Label ("User Name");
             PhotonNetwork.player.name = GUILayout.TextField (PhotonNetwork.player.name);
             GUILayout.EndHorizontal ();
 
             if(GUILayout.Button ("Sgin In")) {
                 Connect();
                 conecting = true;
             }
 
             if(GUILayout.Button ("Play as Guest")) {
                 Connect();
                 conecting = true;
                 PhotonNetwork.player.name = ("Guest");
             }
 
             if(GUILayout.Button ("Exit")) {
                 Application.Quit();
             }
 
             GUILayout.FlexibleSpace();
             GUILayout.EndVertical();
             GUILayout.FlexibleSpace();
             GUILayout.EndHorizontal();
             GUILayout.EndArea();
         }
 
         if(PhotonNetwork.connected == true && conecting == false) {
             GUILayout.BeginArea(new Rect (0, 0, Screen.width, Screen.height));
             GUILayout.BeginVertical();
             GUILayout.FlexibleSpace();
 
             foreach(string msg in chatMessages) {
                 GUILayout.Label(msg);
             }
 
             GUILayout.EndVertical();
             GUILayout.EndArea();
         }
     }
 
     void OnJoinedLobby() {
         Debug.Log ("OnJoinedLobby");
         PhotonNetwork.JoinRandomRoom();
     }
     
     void OnPhotonRandomJoinFailed() {
         Debug.Log ("OnPhotonRandomJoinFailed");
         PhotonNetwork.CreateRoom( null );
     }
     
     void OnJoinedRoom() {
         Debug.Log ("OnJoinedRoom");
     }
 
     void OnGUI() {
 
         GUILayout.Label ("Welcome: " + PhotonNetwork.player.name);
         GUILayout.Label ("Room Name:");
         roomName = GUILayout.TextField ("Room Name"); //For network room name ask and recieve
         GUILayout.Label ("Max Amount of player 1-20:");
         maxPlayerString = GUILayout.TextField (maxPlayerString, 2);
         
         if (maxPlayerString != "") { // if there is a character of max players
             
             maxPlayer = int.Parse(maxPlayerString); // parse the max player text field into a string.
             
             if (maxPlayer > 20) maxPlayer = 20; // if I enter above 20 reset the max to 20 .
             if (maxPlayer == 0) maxPlayer =1; // if i'm below 1 reset min of 1
         }
         
         if (GUILayout.Button ("Create Room")) {
             
             if (roomName != "" && maxPlayer > 0) { // if the room name has a name and max players are larger then 0
                 PhotonNetwork.CreateRoom (roomName, true, true, maxPlayer);// then create a photon room visible
                 SpawnMyPlayer();
                 conecting = false;
             }
         }
     
         GUILayout.Space(20);
         GUI.color = Color.red;
         GUILayout.Box("Game Rooms");
         GUI.color = Color.white;
         GUILayout.Space(20);
     
         scrollPosition = GUILayout.BeginScrollView(scrollPosition, false ,true, GUILayout.Width(400), GUILayout.Height(300));
     
         foreach ( RoomInfo game in PhotonNetwork.GetRoomList()) // Each RoomInfo "game" in the amount of games created "rooms" display the fallowing.
             {
         
             GUI.color = Color.green;
             GUILayout.Box(game.name + " " + game.playerCount + "/" + game.maxPlayers); //Thus we are in a for loop of games rooms display the game.name provide assigned above, playercount, and max players provided. EX 2/20
             GUI.color = Color.white;
         
             if (GUILayout.Button("Join Room") ) {
                 PhotonNetwork.JoinRoom(game.name); // Next to each room there is a button to join the listed game.name in the current loop.
                 SpawnMyPlayer();
                 conecting = false;
             }
         }
     
         GUILayout.EndScrollView();
         GUILayout.EndArea();
     
     }
     
     void SpawnMyPlayer() {
         AddChatMessage("Spawning Player: " + PhotonNetwork.player.name);
         if(spawnSpots == null) {
             Debug.LogError ("001");
             return;
         }
     
         SpawnSpot mySpawnSpot = spawnSpots[ Random.Range (0, 1) ];
         GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
     
         ((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true;
         ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true;
         ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true;
         myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true);
     }
 }
 
 

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HarshadK · Feb 19, 2015 at 07:31 AM 1
Share

It is a Compiler Error CS0111

It is thrown when a class contains two member declarations with the same name and parameter types.

While posting a question also post the exact error message from console as it contains valuable information like line number.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiwasi · Feb 19, 2015 at 09:18 AM

You've got OnGUI declared twice with the same parameters. This is not allowed. Either delete one entirely, or copy the contents of one into the other.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Help Ship Controll 0 Answers

how can i get a pause screen to work 0 Answers

Trying to make Collider Activate with key code 1 Answer

How do I make my player face the direction its moving. 0 Answers

Changing Force of object 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges