Unity 定制资源打开方式

作者: 2b75747cf703 | 来源:发表于2016-03-15 18:33 被阅读119次
    using UnityEngine;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using System.IO;
    
    public class OpenAssetHandler
    {
        [OnOpenAsset]
        public static bool OpenTextAsset(int instanceID, int line)
        {
            string assetPath = AssetDatabase.GetAssetPath(instanceID);
    
            Object o = EditorUtility.InstanceIDToObject(instanceID);
            Debug.Log(o);
    
            if (o is MonoScript)
                return false;
    
            string extension = Path.GetExtension(assetPath);
    
            if (o is TextAsset || extension == ".m" || extension == ".mm" || extension == ".h")
            {
                System.Diagnostics.Process.Start(Application.dataPath + "/../" + assetPath);
    
                return true;
            }
    
            return false;
        }
    }
    

    相关文章

      网友评论

        本文标题:Unity 定制资源打开方式

        本文链接:https://www.haomeiwen.com/subject/sllqlttx.html