Search Unity

Bug EditorUtility.RevealInFinder inconsistency

Discussion in 'Linux' started by codestage, Feb 4, 2016.

  1. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey guys!

    Wow, this is amazing, Unity on Linux! First time I tried Ubuntu, thanks to you, haha =D

    I installed Build #2016010601 and noticed one issue there with the EditorUtility.RevealInFinder() method.
    If I call it with path to some folder, the parent folder will be opened and target folder will be selected in Explorer \ Finder both on Windows and Mac.

    But when I run same code on Linux, target folder is opened itself. It looks inconsistent with how it works on other OSes.

    Same thing about Open Containing Folder context menu in the Project View - it opens selected folder, not containing one.
     
  2. teaspoon

    teaspoon

    Joined:
    Apr 7, 2014
    Posts:
    2
    Additional inconsistencies with RevealInFinder in Windows:

    EditorUtility.RevealInFinder(folder) // opens the parent folder and not the target folder
    EditorUtility.RevealInFinder(filename) // opens the target folder with the file. ***
    ***However if the file doesn't exist the function opens the machine explorer root("This PC")...unless the folder is already open and then it shows the folder.

    These
    EditorUtility.RevealInFinder(folder + "/")
    EditorUtility.RevealInFinder(folder + "/.")

    This behavior is easily reproduced with
    ScreenCapture.CaptureScreenshot(filename, 1);
    EditorUtility.RevealInFinder(filename);
    //CaptuerScreenshot is delayed and "filename" won't exist, so EditorUtility.RevealInFinder(filename) opens the Explorer Root or the Target path folder if it's already opened

    As Dmitriy points out this opens the Parent of the Target Folder
    ScreenCapture.CaptureScreenshot(filename, 1);
    EditorUtility.RevealInFinder(targetFolder);

    There also doesn't seem to be an Documentation for RevealFinder in 2018 or 2017
    https://docs.unity3d.com/ScriptReference/30_search.html?q=RevealInFinder
     
    Last edited: Aug 1, 2018
  3. LazyDog_Rich

    LazyDog_Rich

    Joined:
    Apr 27, 2014
    Posts:
    70
    Hi then there's no way to open the actual folder? I mean I could place a text file there but it could be deleted by the player and then all will fail :/
     
  4. twhittaker

    twhittaker

    Joined:
    May 15, 2018
    Posts:
    10
    Yes for now I hacked in a filecreate before calling RevealInFinder()

    Code (CSharp):
    1.             if (!System.IO.File.Exists(filename))
    2.             {
    3.                 using (FileStream fs = System.IO.File.Create(filename))
    4.                 {}
    5.             }
    6. #if UNITY_EDITOR
    7.         EditorUtility.RevealInFinder(path);
    8. #endif
    9.  
     
    LazyDog_Rich likes this.
  5. LazyDog_Rich

    LazyDog_Rich

    Joined:
    Apr 27, 2014
    Posts:
    70
    Funny I got in a similar conclusion. I made a file check and if the file dint exist I just created it. It is also usefull since it a simple text file I can use as instructions :D

    Still I found weird how theres a function to open the folder of a file, but not one to open a folder itself
     
    twhittaker likes this.
  6. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    247
    to open folder you can use

    Process.Start(path);
     
  7. hurleybird

    hurleybird

    Joined:
    Mar 4, 2013
    Posts:
    258
    Bumping this. EditorUtility.RevealInFinder() should be consistent and should open the actual folder on Windows, not it's parent. Process.Start is... a workaround I guess. I doubt it works on cross platform? Makes my UI glitch a bit (like the scale factor is being changed) for a frame or two when I use it.
     
    mitaywalle likes this.
  8. Chrisi12er

    Chrisi12er

    Joined:
    Sep 7, 2014
    Posts:
    9
    You can use EditorUtility.OpenWithDefaultApp(path) where "path" is actually just a folder path and not a file path. This opens the actual folder in the explorer at least on windows. Can't try it on any other OS though.
     
  9. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    All 3 methods confirmed on Linux.

    Process.Start and EditorUtility.OpenWithDefaultApp being shorter and not needing creation of a file; but also meant for broader usages... But if you make sure the argument is a directory, you should avoid running an executable or opening some other file format by accident.
     
    mitaywalle likes this.
  10. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    If there are inconsistencies, can you file a bug if you haven't already? I'd love to track this.

    Thanks!