unity编译器 Selection,AssetDatabase,EditorUtility (EditorUtility基础篇)

今天是最后一篇EditorUtility基础 关于着个类我用的不是很多,希望对大家有所帮助

using UnityEngine;
using System.Collections;
using UnityEditor;

public class TestEditor : EditorWindow
{
   static  string title = "一只学习的小鸟";

    //DisplayProgressBar和ClearProgressBar配合运用
    //DisplayProgressBar(显示或更新进度条)
    //ClearProgressBar(删除进度条)
    //DisplayDialog(显示模态对话框)
    //OpenFilePanel(显示打开文件 对话框并返回所选的路径名称)
    //OpenFolderPanel(显示打开文件夹 对话框并返回所选的路径名称)
    //SaveFilePanel(显示“保存文件”对话框并返回所选的路径名称。)
    //SaveFolderPanel(显示“保存文件夹”对话框并返回所选的路径名称。)
    #region DisplayProgressBar(显示或更新进度条)
    [MenuItem("Examples/DisplayProgressBar")]
    static void DisplayProgressBars()
    {
        EditorUtility.DisplayProgressBar(title, "信息", 3f);
    }
    #endregion

    #region ClearProgressBar(删除进度条)
    [MenuItem("Examples/ClearProgressBar")]
    static void ClearProgressBar()
    {
        EditorUtility.ClearProgressBar();
    }
    #endregion

    #region DisplayDialog(显示模态对话框)
    [MenuItem("Examples/DisplayDialog")]
    static void DisplayDialog()
    {
        EditorUtility.DisplayDialog(title, "消息", "OK");
    }
    #endregion

    #region OpenFilePanel(显示打开文件 对话框并返回所选的路径名称)
    [MenuItem("Examples/OpenFilePanel")]
    static void OpenFilePanel()
    {
        var path = EditorUtility.OpenFilePanel(title, "D:/", "扩展名");
        Debug.Log(path);
    }
    #endregion

    #region OpenFolderPanel(显示打开文件夹 对话框并返回所选的路径名称)
    [MenuItem("Examples/OpenFolderPanel")]
    static void OpenFolderPanel()
    {
        var path = EditorUtility.OpenFolderPanel(title, "D:/学习", "默认名字");
        Debug.Log(path);
    }
    #endregion

    #region SaveFilePanel(显示“保存文件”对话框并返回所选的路径名称。)
    [MenuItem("Examples/SaveFilePanel")]
    static void SaveFilePanel()
    {
        var path = EditorUtility.SaveFilePanel(title, "D:/学习", "默认名字", "扩展名");
        Debug.Log(path);
    }
    #endregion

    #region SaveFolderPanel(显示“保存文件夹”对话框并返回所选的路径名称。)
    [MenuItem("Examples/SaveFolderPanel")]
    static void SaveFolderPanel()
    {
        var path = EditorUtility.SaveFolderPanel(title, "D:/学习", "默认名字");
        Debug.Log(path);
    }
    #endregion




}

有兴趣的小伙伴可以查找Unity Editor 基础篇(九):EditorUtility编辑器工具 - 程序员大本营有其他
 

有其他用法

猜你喜欢

转载自blog.csdn.net/qq_57896821/article/details/121342013
今日推荐