Unity3D: In the project window, press alt to display the file suffix. In the unity3d window

Source: Internet
Author: User

Unity3D: In the project window, press alt to display the file suffix. In the unity3d window

When the unity layout is 2By3 or other la s, it is not convenient to view the file suffix and press alt to import the following script to the project.

Using UnityEngine; using UnityEditor; using System. IO; using System. reflection; // on the project page, press alt to display the file extension [InitializeOnLoad] public static class ShowFileExtensions {// ==================== ========================================================== ==================================/// static constructor // using static ShowFileExtensions () {EditorApplication. projec Tsung witemongui + = projectsung witemongui ;} // ================================================ ========================================================== ==// checking editor events // ---------------------------------------------------------------------------------- private static void project=witemongui (string guid, rect rect) {if (Event. current. alt) {// EditorWindow window = GetProjectWindow (); string assetPath = Ass EtDatabase. GUIDToAssetPath (guid); UnityEngine. Object obj = AssetDatabase. LoadAssetAtPath <UnityEngine. Object> (assetPath); if (obj! = Null & AssetDatabase. IsMainAsset (obj )&&! IsDirectory (obj) {if (showsBigIcons) {// just draw it bold in upper left string extension = Path. getExtension (assetPath); GUI. label (rect, extension, EditorStyles. boldLabel);} else {// we overpaint the filename here, does look a bit dirty and might need adjustment of the offset var labelRect = rect. translate (new Vector2 (19f, 1f); var fileName = Path. getFileName (assetPath); GUI. label (labelRect, FileName) ;}} EditorApplication. repaintProjectWindow ();}} // ================================================ ========================================================== ==// getting infos about the project window // specify private static bool showsBigIcons {get {return isTwoColumnMode & listare1_dsize> 16f ;}} private static bool isTwoColumnM Ode {get {var projectWindow = GetProjectWindow (); var projectWindowType = projectWindow. getType (); var modeFieldInfo = projectWindowType. getField ("m_ViewMode", BindingFlags. instance | BindingFlags. nonPublic); int mode = (int) modeFieldInfo. getValue (projectWindow); // 0 = ViewMode. oneColumn // 1 = ViewMode. twoColum return mode = 1 ;}} private static float listare1_dsize {get {var projectWi Ndow = GetProjectWindow (); var projectWindowType = projectWindow. getType (); var propertyInfo = projectWindowType. getProperty ("listare1_dsize", BindingFlags. instance | BindingFlags. public); return (float) propertyInfo. getValue (projectWindow, null );}} /// <summary> // there's a chance here we get the wrong one when two project windows are open /// </summary> private static EditorWindow GetProjec TWindow () {if (EditorWindow. focusedWindow! = Null & EditorWindow. focusedWindow. titleContent. text = "Project") {return EditorWindow. focusedWindow;} return GetExistingWindowByName ("Project");} private static EditorWindow GetExistingWindowByName (string name) {EditorWindow [] windows = Resources. findObjectsOfTypeAll <EditorWindow> (); foreach (var item in windows) {if (item. titleContent. text = name) {return item;} return default (Editor Window );} // ================================================ ========================================================== ==// utilities // ------------------------------------------------------------------------------------ private static Rect Translate (this Rect rect, vector2 delta) {rect. x + = delta. x; rect. y + = delta. y; return rect;} private static bool IsDirectory (UnityEngine. object obj) {if (obj = null) {return false ;} Return obj is DefaultAsset &&! AssetDatabase. IsForeignAsset (obj );}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.