Question by
Narwhal540 · Oct 03, 2015 at 07:07 PM ·
errorunexpected-symbol
Why do I have errors on all of my private declarations and on my void update?
using UnityEngine;
using System.Collections;
public class NetworkController : MonoBehaviour {
// Use this for initialization
void Start () {
private const string typeName = "TestGame";
private const string gameName = "Room1";
private void StartServer()
{
Network.InitializeServer(4, 25000, !Network.HavePublicAddress());
MasterServer.RegisterHost(typeName, gameName);
}
}
// Update is called once per frame
void Update () {
}
}
Comment
Best Answer
Answer by Oribow · Oct 03, 2015 at 10:49 PM
You should really learn to code first, before you are messing with Unity. Your code gives you errors because: 1. You declared a methode in a methode 2. You declared const vars in a methode 3. You give vars in a methode privatie settings
Here is your code corrected:
using UnityEngine;
using System.Collections;
public class NetworkController : MonoBehaviour
{
private const string typeName = "TestGame";
private const string gameName = "Room1";
// Use this for initialization
void Start()
{
StartServer();
}
private void StartServer()
{
Network.InitializeServer(4, 25000, !Network.HavePublicAddress());
MasterServer.RegisterHost(typeName, gameName);
}
// Update is called once per frame
void Update()
{
}
}
Your answer
Follow this Question
Related Questions
Error CS1519 help 1 Answer
C# unexpected symbol error 1 Answer
error CS1525: Unexpected symbol `)', expecting `(' 1 Answer
Unexpected symbol 1 Answer
Error CS1525: Unexpected symbol `;', expecting `)', or `,' 1 Answer