Alright so im basically working on a script and temporarily i want to use GetString and SetString and so forth to do this and i am but ive ran into a couple of problems and these problem didnt exists until i tried doing so.
Im getting this errors…
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(45,144): error CS1525: Unexpected symbol `{'
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(51,40): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(53,38): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(55,46): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(55,73): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,48): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,60): error CS1519: Unexpected symbol `,' in class, struct, or interface member declaration
Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,73): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration
this is my script
125
125
using UnityEngine;
using System.Collections;
using System;
public class Connect : MonoBehaviour {
public int connectToIP = "127.0.0.1";
public int connectPort = 25000;
public string UserName;
public string passwordToEdit = "My Password";
public bool isUserNameCorrect;
public bool isPasswordCorrect;
void OnGUI (){
if (Network.peerType == NetworkPeerType.Disconnected){
GUILayout.Label("Connection status: Disconnected");
//connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100));
//connectPort = int.Parse(GUILayout.TextField(connectPort.ToString()));
if(GUILayout.TextField("UserName")){
if(UserName = PlayerPrefs.GetString(UserName)){
isUserNameCorrect = true;
}
}
if(passwordToEdit = GUI.PasswordField(new Rect(Screen.width / 2, (Screen.height / 2) - 50, 200, 20), passwordToEdit,"*"[0], 25){
if(passwordToEdit = PlayerPrefs.GetString(passwordToEdit)){
isPasswordCorrect = true;
}
}
GUILayout.BeginVertical();
if (GUILayout.Button ("Login"))
{
if(isUserNameCorrect == true | isPasswordCorrect == true)
{
Network.Connect(connectToIP, connectPort);
}
}
if (GUILayout.Button ("Start Server"))
{
Network.InitializeServer(32, connectPort);
}
GUILayout.EndVertical();
}
else
{
if (Network.peerType == NetworkPeerType.Connecting){
GUILayout.Label("Connection status: Connecting");
} else if (Network.peerType == NetworkPeerType.Client){
GUILayout.Label("Connection status: Client!");
GUILayout.Label("Ping to server: "+Network.GetAveragePing( Network.connections[0] ) );
} else if (Network.peerType == NetworkPeerType.Server){
GUILayout.Label("Connection status: Server!");
GUILayout.Label("Connections: " + Network.connections.length.ToString());
if(Network.connections.length>=1){
GUILayout.Label("Ping to first player: "+Network.GetAveragePing( Network.connections[0] ) );
}
}
if (GUILayout.Button ("Disconnect"))
{
Network.Disconnect(200);
}
}
}
void OnConnectedToServer (){
Debug.Log("This CLIENT has connected to a server");
}
void OnDisconnectedFromServer ( NetworkDisconnection info ){
Debug.Log("This SERVER OR CLIENT has disconnected from a server");
}
void OnFailedToConnect ( NetworkConnectionError error ){
Debug.Log("Could not connect to server: "+ error);
}
void OnPlayerConnected ( NetworkPlayer player ){
Debug.Log("Player connected from: " + player.ipAddress +":" + player.port);
}
void OnServerInitialized (){
Debug.Log("Server initialized and ready");
}
void OnPlayerDisconnected ( NetworkPlayer player ){
Debug.Log("Player disconnected from: " + player.ipAddress+":" + player.port);
}
void OnFailedToConnectToMasterServer ( NetworkConnectionError info ){
Debug.Log("Could not connect to master server: "+ info);
}
void OnNetworkInstantiate ( NetworkMessageInfo info ){
Debug.Log("New object instantiated by " + info.sender);
}
void OnSerializeNetworkView ( BitStream stream , NetworkMessageInfo info ){
}
}
125
and im still currently working on a login system, like a said atm it is temporarily based on a players prefs way to load but i plan on changing that soon.
125