【发布时间】:2014-08-25 00:58:28
【问题描述】:
我在这里有一个函数来存储块的坐标。看起来不错,但控制台给了我这个错误:
BCE0019: 'WriteLine' is not a member of 'System.IO.StreamReader'
如果您知道如何解决此问题,我将不胜感激。
function writeChunks(fileName : String, xco : int, yco : int, zco : int) {
var sr = System.IO.File.OpenText(fileName);
sr.WriteLine("Chunk ("
+ xco + ", "
+ yco + ", "
+ zco + ")");
sr.Close();
}
更新 1 这段代码:
function writeChunks(fileName : String, xco : int, yco : int, zco : int) {
var sr = System.IO.File.OpenText(fileName);
System.IO.File.WriteAllText("C:/youfilename.txt", "Chunk ("
+ xco + ", "
+ yco + ", "
+ zco + ")");
sr.Close();
}
给我这个错误:
DirectoryNotFoundException: Could not find a part of the path "C:\Reactor Games\chunks.txt".
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/FileStream.cs:292)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/StreamWriter.cs:124)
System.IO.StreamWriter..ctor (System.String path, Boolean append)
(wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool)
System.IO.File.CreateText (System.String path) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/File.cs:159)
infiniteTerrain+$saveLoadedChunk$5+$.MoveNext () (at Assets/Script/infiniteTerrain.js:61)
更新 2 这段代码:
function writeChunks(fileName : String, xco : int, yco : int, zco : int) {
var sw = new StreamWriter("fileName");
sw.WriteLine("Chunk ("
+ xco + ", "
+ yco + ", "
+ zco + ")");
sw.Close();
}
给我这个错误:
BCE0005: Unknown identifier: 'StreamWriter'.
【问题讨论】:
-
还没有,我不知道它可能是什么:(
-
对你的问题投了赞成票.. 让更多人看到它:-)
-
将测试并尝试修复问题,但直到 8:00 之后才能使用 Unity 3d 库。投票虽然有用
-
@user3722399 DirectoryNotFoundException 表示您需要该目录。创建一个名为 Reactor Games 的目录。
-
请注意,UnityScript 与 Javascript 不同。 wiki.unity3d.com/index.php?title=UnityScript_versus_JavaScript
标签: unity3d .net unityscript