0
using UnityEngine;
using System.Collections;

public class Network1 : MonoBehaviour {
    // Use this for initialization
    void Start () {
    }

    // Update is called once per frame
    void Update () {
    }

    void OnGUI() {
        Debug.Log ("OnGUI()");
        if (NetworkPeerType == NetworkPeerType.Disconnected){
            if (GUI.Button (new Rect(10, 30, 120, 20), "Join a game")){
                Network.Connect("127.0.0.1", 25001);
            }
            if (GUI.Button (new Rect(10, 50, 120, 20), "Host a game")){
                Network.InitializeServer(32, 25001, false);
            }
            else if (Network.peerType == NetworkPeerType.Client){
                GUI.Label(new Rect(10, 10, 300, 20), "Status: Connected as a Client");
                if (GUI.Button (new Rect(10, 30, 120, 20), "Leave lobby")){
                    Network.Disconnect(200);
                }
            }
        }
    }
}

That's my code. It throws this error: Assets/Network1.cs(15,21): error CS0119: Expression denotes a type', where avariable', value' ormethod group' was expected

I've googled it for a while now and can't seem to get a relevant answer. Any help is appreciated.

1 Answer 1

1
if (NetworkPeerType == NetworkPeerType.Disconnected){

this should probably be:

if (Network.peerType == NetworkPeerType.Disconnected){
3
  • didn't this generate at least a warning? Would surprise me if the compiler didn't complain.
    – CodeSmile
    Aug 24, 2014 at 8:03
  • It did throw an error, and I wasn't able to run the game.
    – Bigdog_00
    Aug 24, 2014 at 15:18
  • ob yeah right, you mentioned this in the question, sorry :)
    – CodeSmile
    Aug 24, 2014 at 17:42

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.