LoginSignup
2
0

More than 3 years have passed since last update.

Unity Editor拡張 ファイル保存ダイアログメモ

Posted at

◆下記URLを参照
http://light11.hatenadiary.com/entry/2018/04/19/192748

■拡張子にtxtと書けば、テキスト形式で保存可能

■Assetsのところを未入力にしてもAssetsフォルダ内がデフォルトで表示される。
(Editor拡張の関数だからしょうがないけどここを何とかしたいな、
 Assetsより外に保存したい時は1階層上に上がる操作が必要)
 

using UnityEngine;
using UnityEditor;

public class SaveFilePanel : EditorWindow {

    private void OnGUI()
    {
        if (GUILayout.Button("保存")) {
            // 保存先のファイルパスを取得する
            var filePath = EditorUtility.SaveFilePanel("題名", "Assets", "保存したいファイル名", "拡張子");

            if (!string.IsNullOrEmpty(filePath)) {
                File.WriteAllText(filePath, "12234567890", Encoding.UTF8);
            }
        }
    }
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0