Search Unity

Drag and drop stopped working in Editor

Discussion in 'Editor & General Support' started by fatboynotslim, Aug 19, 2013.

  1. kk99

    kk99

    Joined:
    Nov 5, 2013
    Posts:
    81
    having the same issue and as soon as you mentioned this I realized it too.

    Using Windows 7 and it looks like Google Drive has completely corrupted the Folder Permissions.

    If I create a new Folder I can move and drag and drop files but all existing one are broken.
    Once Google Drive finished syncing their crap, the new folders are ReadOnly too and dragging no longer possible.

    any solution for this? Its just killing my efficiency . . .


    All those tips and tricks did not work
     
    Last edited: Oct 2, 2021
    JVimes likes this.
  2. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    same here thats google drive related. the new google drive did probably mess with some files
     
  3. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    anyone i wrote a script to move files/folder via rightclick Move/this

    go to folder right click in free space Move/Here

    Also you can Move/Move next in here > Move to marked folder if u want to select the folder first.
    Unitys drag and drop in the project´view isnt that good anyway.

    It moves meta files too. Test it first in another project, i just used it to move cs files in standard assets, but working 12 hours alrdy.
    Also i think its not working if u click on a folder and do move/here, you need to be inside the folder and click on any free space. Just tested that works too. great tool night


    Code (CSharp):
    1.  
    2. static UnityEngine.Object[] copyForMove;
    3.     [MenuItem("Assets/Move/This")]
    4.     private static void CopyForMove()
    5.     {
    6.         copyForMove = (UnityEngine.Object[])Selection.objects.Clone(); //
    7.         foreach (UnityEngine.Object o in copyForMove)
    8.         {
    9.             Debug.Log(AssetDatabase.GetAssetPath(o));
    10.             //  Debug.Log(o.GetType());
    11.         }
    12.     }
    13.     [MenuItem("Assets/Move/This", true)]
    14.     private static bool CopyForMoveValidation()
    15.     {
    16.         return Selection.objects != null && Selection.objects.Length > 0;
    17.     }
    18.     [MenuItem("Assets/Move/Here", true)]
    19.     private static bool PasteHereValidator()
    20.     {
    21.         return copyForMove != null && copyForMove.Length > 0;
    22.     }
    23.     [MenuItem("Assets/Move/Here")]
    24.     private static void PasteHere()
    25.     {
    26.         var path = "";
    27.         var obj = Selection.activeObject;
    28.         if (obj == null) path = "Assets";
    29.         else path = AssetDatabase.GetAssetPath(obj.GetInstanceID());
    30.         if (path.Length > 0)
    31.         {
    32.             MoveFiles(path, copyForMove);
    33.         }
    34.         else
    35.         {
    36.             Debug.Log("Not in assets folder");
    37.         }
    38.  
    39.     }
    40.  
    41.     private static void MoveFiles(string path, UnityEngine.Object[] toMove)
    42.     {
    43.         if (AssetDatabase.IsValidFolder(path))
    44.         {
    45.             Debug.Log("Target: " + path);
    46.             foreach (UnityEngine.Object o in toMove)
    47.             {
    48.                 string sourcePath = AssetDatabase.GetAssetPath(o);
    49.                 Debug.Log("Source: " + sourcePath);
    50.                 if (AssetDatabase.IsValidFolder(sourcePath))
    51.                 {
    52.                     string metafile = sourcePath + ".meta";
    53.  
    54.                     string dirn = path + "/" + Path.GetFileName(sourcePath);
    55.                     Debug.Log("new target: " + dirn + " " + Path.GetFileName(sourcePath));
    56.                     FileUtil.MoveFileOrDirectory(sourcePath, dirn);
    57.                     Debug.Log(sourcePath + " >> " + dirn);
    58.  
    59.  
    60.                     Debug.Log(metafile + " >> " + path + "/" + Path.GetFileName(metafile));
    61.                     FileUtil.MoveFileOrDirectory(metafile, path + "/" + Path.GetFileName(metafile));
    62.  
    63.  
    64.                 }
    65.                 else
    66.                 {
    67.                     string fileName = Path.GetFileName(sourcePath);
    68.                     string metafile = fileName + ".meta";
    69.  
    70.                     string emptyPath = sourcePath.Replace(fileName, "");
    71.  
    72.  
    73.                     FileUtil.MoveFileOrDirectory(emptyPath + fileName, path + "/" + fileName);
    74.                     FileUtil.MoveFileOrDirectory(emptyPath + metafile, path + "/" + metafile);
    75.                     Debug.Log(emptyPath + fileName + " >> " + path + "/" + fileName);
    76.                     Debug.Log(emptyPath + metafile + " >> " + path + "/" + metafile);
    77.                 }
    78.             }
    79.             copyForMove = null;
    80.             AssetDatabase.Refresh();
    81.         }
    82.         else
    83.         {
    84.             Debug.Log("File");
    85.         }
    86.     }
    87.  
    88.     static string pathToMove = "";
    89.     [MenuItem("Assets/Move/Move next in here")]
    90.     private static void MoveNextInHere()
    91.     {
    92.         var path = "";
    93.         var obj = Selection.activeObject;
    94.         if (obj == null) path = "Assets";
    95.         else path = AssetDatabase.GetAssetPath(obj.GetInstanceID());
    96.         if (path.Length > 0)
    97.         {
    98.             if (AssetDatabase.IsValidFolder(path))
    99.             {
    100.                 Debug.Log("We go there " + path);
    101.                 pathToMove = path;
    102.             }
    103.             else
    104.             {
    105.                 Debug.Log("File");
    106.             }
    107.         }
    108.         else
    109.         {
    110.             Debug.Log("Not in assets folder");
    111.         }
    112.  
    113.     }
    114.  
    115.  
    116.     [MenuItem("Assets/Move/Move to marked folder")]
    117.     private static void WillMoveNext()
    118.     {
    119.         MoveFiles(pathToMove, Selection.objects);
    120.         pathToMove = "";
    121.     }
    122.     [MenuItem("Assets/Move/Move to marked folder", true)]
    123.     private static bool WillMoveNextValidator()
    124.     {
    125.         return pathToMove != "";
    126.     }
    127.  
     
  4. Neohun

    Neohun

    Joined:
    Oct 30, 2018
    Posts:
    77
    Alright I have found a solution for that problem if you have a backup that you have created before google cloud I mean a backup not "infected" by google drive than all you need to do is:
    - backup your latest progress project then remove it from the projects folder
    - and copy your "not infected" backup into the projects folder
    - then copy/paste your latest project's "assets" folder only (the project which is broken by google drive) into your backup project.. it'll ask "do you want to replace"? the files which has the same name: confirm it..
    also you need to copy paste the last project's all visual studio solution files to make the scripts run properly.. and you're done!

    so if you had backup before google drive "infection" then you can fix this way, drag and drop works properly now..
    And I have decided to use unity collaborate it's much much better and clean approach than the google drive since it's a version control system.. Alternatively you can use plastic scm which is owned by unity as I understand it's for large projects.. both solution is free to start I highly recommend it.. and never ever use google drive or anything other than version control systems for unity projects again.. lesson learned..
     
    Last edited: Oct 5, 2021
  5. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    120
    Found a fix

    Pretty sure it was Google Drive updating that changed the attributes of all the folders to archived read only. Just needed a little bump to get it back to normal. Google Drive is gone from my life forever now. I recommend the same for anyone else using it. Find an alternative. Next time it may not just be an attribute change.

    Step(s)

    Go to command line and change the attributes on the folders.

    cd /d (your path for asset folder), run this, and open your project.

    attrib /d /s -a -r

    https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/attrib

    For one project, I had to add the command line -noUpm to Hub, start the project, close the project, and remove the -noUpm from the command line and then it worked. Something had its hooks in that project that may not be related so this step is probably not be needed for most people.

    That allowed me to move files again.

    As with all things, back up your work before you take these actions!
    No matter how benign an action seems, always have a backup.
     
  6. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    676
    Fixed it for me, thanks!

    Can't say for sure, but I also suspect Google Drive had a role in this. Only seems to affect projects that I created in the Google Drive folder.
     
    icyblaze16 and Welfarecheck like this.
  7. shaunnortonAU

    shaunnortonAU

    Joined:
    Jan 19, 2018
    Posts:
    9
    jlbaker2779 your fix worked perfectly. You have saved me a lot of time. Thanks!
    I also had Google Drive, I think this is what caused it.
     
    Stevens-R-Miller likes this.
  8. E_Urban

    E_Urban

    Joined:
    Sep 16, 2014
    Posts:
    8
    you are a life saver. thank you!
     
  9. dragologic

    dragologic

    Joined:
    Oct 28, 2012
    Posts:
    16
    I have tried all solutions.
    None of them works for me.
    I am using Windows 10.
     
  10. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Restarting the computer fixed it for me -.-
     
  11. Aviark13

    Aviark13

    Joined:
    Apr 12, 2014
    Posts:
    6
    This method also sort of fixed it for me, it didn't fix every folder, but most. It definitely seems to be google drive related, if I start a fresh project outside of my google drive folders and do things there, I have no issues.
     
  12. GoldenChief

    GoldenChief

    Joined:
    Mar 26, 2020
    Posts:
    4
    Hi. I am unable to drag and drop in Build. In Editor everything works fine, same goes for the Play Mode as well. But when I build the game, the drag and drop stops working. Using Unity 2018.4.2
     
    justin666 likes this.
  13. Weeros

    Weeros

    Joined:
    Oct 5, 2018
    Posts:
    4
    Wow, you just saved me hours and hours either manually copying each file into a new folder or rebuilding the whole project from scratch & existing assets, thank you so much. I also foolishly thought it would be great idea to start using the project from Google Drive to ensure it's kept safe. Time to study how github works instead..
     
    AldeRoberge likes this.
  14. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    Same problem here! I can't drag and drop folders in the Editor. This happened after installing Google Drive and making the project folder to sync with it. Closing Google Drive doesn't help.
     
  15. irmik54cn

    irmik54cn

    Joined:
    Jul 21, 2021
    Posts:
    1
    I thought it was something related with my computer or Unity. I tried explorer method but didn't work.

    BUT THEN IT TURNS OUT IT WAS MY FAULT!

    I was trying to do a basic score counter for my game. I had to drag and drop a few thing from hierarchy to ScoreManager but black slashed circle appeared. I made some research about this for a few hours. I watched the tutorial I'm using again and again but no. "Everything" was the same.

    Except one thing.

    I thought I must made a mistake with the script, kinda true but the real problem was... Text and TextMeshPro is not the same. I'm using new versions of Unity so I couldn't find Text, I guess. I had to create score with TextMeshPro and I thought it was okay. Turns out it's not, if you're having problem similar to mine here check this https://stackoverflow.com/questions...et-textmeshpro-text-to-variable-slot-in-unity it solved my problem.
    Something like:
    public Text ScoreText; --> public TMP_Text ScoreText; solved my problem.

    The things you try to drag and drop may not be suitable for what you want. You can check to drag and drop other thing in Unity, so you can understand if something is wrong with Unity in general or about the thing you want.

    I'm a beginner but I just wanted to share it for others that don't know a lot about coding and Unity, like me. Just a basic problem but took me hours to solve it.
     
  16. sohamxbr

    sohamxbr

    Joined:
    Apr 9, 2020
    Posts:
    12
    Revoke the administrator privilege from unity hub, and restart your PC.It worked for me. (Unity hub>Right click>Properties>Compatibility>Privilege level (here turn off the administrator privilege ))
     
  17. repka_3

    repka_3

    Joined:
    Jan 26, 2016
    Posts:
    3
    28-12-2022. Keeping ESC pressed WHILE randomly keeping clicked left anr right mouse button, solved for me. It's so incredible I'm ashame to say this. LoL. Thank dude from the past.
     
  18. Michael_Starmik

    Michael_Starmik

    Joined:
    Mar 15, 2020
    Posts:
    8
    In case somebody is still having this issue, I have one more observation:

    I cannot drag and drop assets into Unity inspector from folders that are INSIDE of the project I am working on.
    If I move this folder OUTSIDE of project, drag&drop works again...
     
  19. CymeRia67

    CymeRia67

    Joined:
    Jun 9, 2016
    Posts:
    1
    It worked for me, Thanks!
     
    Welfarecheck likes this.
  20. Lusidace

    Lusidace

    Joined:
    Apr 3, 2018
    Posts:
    1
    I've been searching for a solution for hours, this one finally worked! Thank you so much!
     
  21. ScottPepe

    ScottPepe

    Joined:
    Jul 8, 2023
    Posts:
    2

    why did that fix it ???