Maintenance of the Unity file
-
In Unity itself, when I start the game, everything's fine, and when I co-compiled at .exe, there's no way to fix it? To keep it under the computed act.
using UnityEngine; using System.Collections; using System.IO;
public class GetName : MonoBehaviour {
public string filename = ""; public Name Char; public string playerName; // Use this for initialization void Start () { filename = "PlayerName.txt"; } // Update is called once per frame void Update () { } void OnGUI() { Name Namest = (Name)Char.GetComponent("Name"); GUI.Label(new Rect(10, 110, 90, 100), "Your name:"); playerName = GUI.TextField(new Rect(90, 110, 100, 20), playerName); if (GUI.Button(new Rect(200, 110, 50, 20), "Save")) { StreamWriter sw = new StreamWriter("PlayerName.txt"); sw.WriteLine(playerName); sw.Close(); } }
}
-
- Try to catch an exception, I think it's gonna cause you problems.
I suggest you use it.
AppDomain
for processing of unprocessed exceptions. - I don't recommend keeping the file this way, point out a more specific way to your file.
- Try to download the file from the code and find out his way, maybe he's on some other path. Like a folder.
Temp
♪ - Also use the class.
Application
and its propertiespersistentDataPath
♪streamingAssetsPath
♪
- Try to catch an exception, I think it's gonna cause you problems.
I suggest you use it.