データディレクトリやキャッシュディレクトリをエクスプローラで開く

この記事は2017年10月20日にqiitaに投稿した内容です。

環境

Unity2017.1.1p3

概要

persistentDataPathやCacheのパスを忘れてしまうのでメニューから開けるようにしました。 それだけです。

プログラム

Assets/Editor/ShowInExplorer.cs

using UnityEditor;
using UnityEngine;

public class ShowInExplorer
{
    [MenuItem( "Tools/ShowInExplorer/PersistentDataPath" )]
    private static void OpenPersistentDataPath()
    {
        var path = Application.persistentDataPath;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/DataPath" )]
    private static void OpenDataPath()
    {
        var path = Application.dataPath;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/TemporaryCachePath" )]
    private static void OpenTemporaryCachePath()
    {
        var path = Application.temporaryCachePath;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/DefaultCachePath" )]
    private static void OpenDefaultCachePath()
    {
        var path = Caching.defaultCache.path;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/StreamingAssetsPath" )]
    private static void OpenStreamingAssetsPath()
    {
        var path = Application.streamingAssetsPath;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/ApplicationPath" )]
    private static void OpenApplicationPath()
    {
        var path = EditorApplication.applicationPath;
        RevealInFinder( path );
    }

    [MenuItem( "Tools/ShowInExplorer/ApplicationContentsPath" )]
    private static void OpenApplicationContentsPath()
    {
        var path = EditorApplication.applicationContentsPath;
        RevealInFinder( path );
    }

    private static void RevealInFinder( string path )
    {
        Debug.Log( "ShowInExplorer:" + path );
        EditorUtility.RevealInFinder( path );
    }
}