- Home /
Question by
rewin123 · Sep 14, 2017 at 06:47 PM ·
c#scripting problemnetworkingnetwork
Command method dont change variables on server
Hi all! I have a strange problem. CmdStartLoad dont change longloadData, longpos.
public string longloadData = "";
public int longpos = 0;
[Command]
void CmdStartLoad()
{
Debug.Log("Make copy planet");
map.Save("temp.txt"); //Its work!
Debug.Log("Planet copied");
StreamReader sr = new StreamReader("temp.txt");
longloadData = sr.ReadToEnd(); //Its not work!!!
sr.Close();
longpos = 0; //Its not work!!!
//longloadData is correct only in CmdStartLoad
}
In debugging longloadData changes in CmdStartLoad, but in Update its not changes
void Update () {
if(longloadData.Length > 0)// longloadData = ""
{
string data = "";
int i;
for(i = longpos;i - longpos < packetSize && i < longloadData.Length;i++)
{
data += longloadData[i];
}
RpcLongLoad(data, longpos, longloadData.Length);
longpos = i;
if (longpos == longloadData.Length)
longloadData = "";
}
}
Why did it happen?
Comment