###前提・実現したいこと
Unity(C#)で、フォルダを監視し、フォルダに新しくファイルが作成されたのをトリガーにして、
ゲームシーンに遷移したいです。
以下のエラーで解決策がわかりません。どなたかご教授願います。よろしくお願いいたします。
###発生している問題・エラーメッセージ
LoadSceneAsyncNameIndexInternal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
上記のエラーメッセージが下記のコード時に表示されます。
###該当のソースコード
public class Director : MonoBehaviour
{
FileSystemWatcher fsw = new FileSystemWatcher();
public void Start ()
{
//監視対象のフォルダの設定
fsw.Path = フォルダパス;
//監視する種類の設定
fsw.NotifyFilter =
(NotifyFilters.Attributes
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName);
//サブディレクトリも監視
fsw.IncludeSubdirectories = true;
//すべてのファイルを監視 fsw.Filter = ""; //イベント設定 fsw.Created += fsw_Created; //監視を開始 fsw.EnableRaisingEvents = true; } public void fsw_Created(object sender, FileSystemEventArgs e) { Debug.Log("Created"); SceneManager.LoadScene("GameScene"); } void Update () { }
}
###試したこと
###補足情報(言語/FW/ツール等のバージョンなど)

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/12/06 17:20
退会済みユーザー
2017/12/07 05:15