Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

There really should be some kind of lock you can put on certain folders or files in Unity

Discussion in 'Editor & General Support' started by Lethn, Aug 6, 2017.

  1. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    So that's twice this has happened to me now and it's my own stupid fault, I wasn't paying attention to what I was doing and I've managed to delete my resources folder which means I've just wiped out all the prefabs I placed in my game 20 game levels for a nearly finished project and I was just going to place a few more traps and so on in my game to flesh everything out and a couple more shortcuts later BAM!

    I didn't panic, I knew the meta file was in my recycle bin but unfortunately I foolishly right clicked and restored the file directly from the recycle bin. Little did I know, Unity doesn't like this and it actually ended up wiping the damn meta file which I could have saved so now I know that you should just keep a copy of it safe just in case and directly put it in the folder. It didn't just delete the file that got sent to the asset folder you see it had removed that from the recycle bin as well, and this is why I don't trust computers when they do things on their own.

    Adobe Photoshop has features like this where you can lock certain layers to prevent them from being deleted and drawn on by accident, is there any chance that Unity is going to have this put in as well? I'm sick of making mistakes like this, thankfully I have all my sprites sensibly backed up and so on and I roughly remember where I placed everything, it's just a bit of time waste.

    Now if you'll excuse me, I'm going to go and sob pathetically in a corner, I am so glad I didn't put my code in the same folder as well.
     
  2. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Register at gitlab.com, it's free up to 10gb
     
  3. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    I made mention of this really stupid behaviour over in this thread here.. This sort of behaviour for basic file system operations should not be considered acceptable.
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,141
    No, the problem you need to own up to is that you have yet to start using a Version Control System. With a proper VCS you would have been able to quickly recover the files and any modifications that had been made to them from the first time they were added to the project to the last time you committed a change to the repository.

    https://assetstore.unity.com/packages/tools/user-tools/utilities/hierarchy-folder-object-10966
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Proper version control is the right answer. With version control you can restore the missing folder and meta data in a few minutes.

    If you are insistent on doin things the wrong way, Unity will also respect the filesystem. So you could mark critical files as read only there. It seems super painful though.
     
    angrypenguin, Ryiah, Socrates and 2 others like this.
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    Unity will sort of respect the file system. As mentioned in this very thread, what should be a simple operation (restoring from the recycle bin) leads to Unity just outright destroying the file. It doesn't move the file back to the recycle bin, it doesn't accept it into the asset folder as it should, it destroys the file.

    That, to me, seems like the very opposite of respecting the file system. I shouldn't have to go into a repository to get a file back when there's a perfectly good windows operation to do just that locally.
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Just advocate version control. Even Unity's own collab is fine if you have no brain and need security. Just pay the 5 dollars a month or whatever it costs. Stop pooping over your own work, everyone-not-on-version-control-yet.

    I don't take any developer seriously who isn't on version control of some sort. It means they're just messing about for fun. No harm done but anyone with a mind for results: version control.

    I wonder if I've mentioned version control yet? I think Kiwasi did.
     
    orb, theANMATOR2b and angrypenguin like this.
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    BTW I think I forgot something: version control.
     
  9. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,796
    I think Hippo forgot something...

    VERSION CONTROL
     
    angrypenguin, hippocoder and Kiwasi like this.
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    By respecting the file system I mean you can mark a folder as read only in the file system, and Unity will respect that.
     
  11. cyberpunk

    cyberpunk

    Joined:
    Mar 20, 2013
    Posts:
    226
    The moment I discovered the value of version control was as important as when I discovered "debugging" was not about placing print statements everywhere to see the flow of code.
     
  12. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    Well like I wrote in my OP, I have actually got all my files and so on sensibly backed up, you know, sprites, code and so on, it's just I'm going to have to place my prefabs all over again. So I guess what this means is as you guys say I should just make extra copies of folders and stuff I don't want deleted by accident, it just seems like there could be better features to prevent this type of thing like the lock I mentioned on photoshop.

    I know it's easy to be a smug experienced programmer about all this :p but you'd be surprised how easy it is especially in a program like Photoshop or Maya to make catastrophic mistakes if you click something while distracted and not focusing, all this complicated software seems to have a similar problem.
     
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    No, it's just you. Not being smug, but it will carry on being you until you decide not to be sloppy about it. Same thing with leaving the oven on and things like that. You have to choose to be careful.
     
    Meltdown likes this.
  14. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    If was sloppy I wouldn't have backups of all the assets I'm using for this particular game, as for your suggestion about version control I'd rather not rely on any third party tool. I guess once I'm done placing my prefabs I'll simply make a backup of my resources folder outside Unity and if something happens again I'll simply copy it over and keep the majority of my progress.
     
  15. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,141
    That was a rather poor choice, wasn't it?

    Right, it's called human interaction. Humans are inherently illogical. They'll often choose the worst possible solutions and often in spite of the glaringly obvious evidence telling them it was the wrong choice. Then after facing the consequences they'll often go back and do it again.

    https://en.wikipedia.org/wiki/User_error
     
    Last edited: Aug 7, 2017
    orb, Meltdown and Kiwasi like this.
  16. FrankenCreations

    FrankenCreations

    Joined:
    Jun 14, 2017
    Posts:
    326
    Exerpt from suggested user error wiki reading:

    "Experts in interaction design such as Alan Cooper[3] believe this concept puts blame in the wrong place, the user, instead of blaming the error-inducing design and its failure to take into account human limitations. "

    Locking things you consider finished to prevent accidentally changing them dosent seem like an unreasonable request in a complex system.
     
  17. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,141
    Yes, but that's only assuming the individual makes use of them. He's been told in this thread, and I'm fairly certain we've had a similar discussion with him in the past, about version control and he's deliberately choosing to ignore it. At some point you have to stop blaming the software and start blaming the user.
     
    Kiwasi likes this.
  18. FrankenCreations

    FrankenCreations

    Joined:
    Jun 14, 2017
    Posts:
    326
    Oh I see you point here. I'm incredibly new here and was only thinking from this threads information. Being able to lock things does seem handy but would not keep you from needing to back up or use version control. I was just seeing an easy checkbox so when my cat walked across the keyboard and I wasnt looking I knew some things would still be as I left them. I get lazy too, drop my mouse and go digging for it clickin things. Almost a way of telling unity I was done with this part and dont let me screw it up please. This would probably be alot more useful for new users like me than someone who is very used to the editor.
     
  19. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    If we are going to go for locking, I would like to be able to lock specific layers in a scene. That would be convenient.

    Locking asset folders doesn't make much sense for my workflow.
     
    Last edited: Aug 7, 2017
  20. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    Well, this is a wrong choice, because version control software does much better job at tracking changes than manual backups. Copying old version over can also mess up majority of your progress. It is a wrong idea.

    I suggest ot learn git or mercurial. Decent version control also allows you to develop several versions of the same project in parallel, easily revert to old revision, and easily track down when some bug was introduced.

    I'm not sure about gitlab, but bitbucket free account allows private repositories. Unlimited number of them.
     
    orb likes this.
  21. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    I genuinely intend this helpfully, though it's going to sting:
    But you don't have them "sensibly backed up" because you're "going to have to place [your] prefabs all over again". Backup isn't about files, it's about avoiding lost work, and what you've described there is precisely that - you've lost work because that particular piece of work was not backed up - not "sensibly", not at all.

    You're fooling yourself if you think otherwise.

    Not "extra copies". Do you realise that manually moving copies of bits of your work around is itself a great way to lose or damage it?

    Once when I was young I was using manual backup/version control - I'd keep a dated copy of my project at the end of each day. One day I messed something up and needed to revert. Not a big deal, that's a part of why you keep versions, so you can experiment and revert at will. But... oops! I copied the wrong way! Instead of copying the old good project over the new stuffed one I copied the stuffed one over the good one. So I had to revert to my version from the day before that, and lost a whole day of good progress.

    Don't do that. Don't put yourself at risk of doing that. Because...
    ... there are exactly features to help out with this stuff. They're called version control systems and, honestly, if you're still talking about making copies of files after all the things people have already said in this thread then you're just not listening.

    Sign up for Unity Collab or Visual Studio Online or Bitbucket or some other online version control provider and make life easier for yourself.

    (Just make sure that if they're free they offer private repositories!)
     
    orb, Meltdown, Ryiah and 2 others like this.
  22. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    ???

    You don't have to use a third party tool. You can run version control locally and still get benefits. I frequently do this on some of my projects that aren't worth the ten minutes it takes to set up a remote repo.

    And if you are just being tinfoil hatted about putting your work on a server somewhere, you can still use manual backups on top of a version control system. No third parties involved.
     
    Meltdown and Ryiah like this.
  23. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    Assuming that your backup process actually works then what do you have to lose from giving it a try?
     
    Ryiah likes this.
  24. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Bitbucket. Sourcetree.
     
  25. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    All Version Control programs are technically third party tools. So, if the dude has "not invented here" syndrome, he won't have any software to chose from.
     
    orb, Kiwasi and Ryiah like this.
  26. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I think there's a more crucial problem here--the recycle bin restore bug. It's perfectly reasonable to assume that restoring a recycled file will not do the opposite and obliterate it forever. If the solution to the problem is to just have better file management, that's kind of not a solution at all.

    If there was a game-breaking bug that deleted your save data and only triggered if you fell into lava, that's like saying that the solution is "to not go in lava because you should've known better". Everyone should be keeping good file management, but from Unity's point of view, you can't expect every user to know to keep backups and use version control, and you shouldn't use that as an excuse for not fixing bugs. That said, I'm sure a Unity dev will look into this soon.
     
  27. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Sure. But Unity is also a third party tool. So is Windows/Mac/Linux. I figured the guy was opposed to hosting on a third party server, not just using a third party piece of software on their own computer.

    That's not actually what happens. (And you can confirm this in a couple minutes via version control). Deleting a folder will cause Unity to delete the meta data file. Restoring the folder will cause Unity to create a new meta data file. This has the effect of erasing any import settings, as well as assigning a new GUID.

    For assets this is a pain. Unity references assets by their GUID, so changing it breaks all inspector references to an asset.

    But I've honestly never had an issue with a folder meta data. Folders have no import settings. And Unity doesn't normally reference folders directly via their GUID. So there is no harm from deleting an entire folder from the project then restoring it.
     
    SomeGuy22 likes this.
  28. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    I had impression the issue was with actual software solution and not with the server, although I might be wrong about it..

    But then again, "no 3rd party tools" can easily lead to "make your own microchip today using silicon you mined yourself!"
     
    Ryiah and Kiwasi like this.
  29. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Of course, you can't use third party tools for the mining. So you'll probably want to start with mining iron. Which requires bronze tools to get started. So you'll want to start there.

    I feel an infinite regression coming on. Or at least a 13.82 billion year one.
     
  30. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Confession - Hello all - I'm an artist and - I manually duplicate my project folder every evening after working (I know it's wrong). :oops: Luckily this has not bitten me so far.

    Eventually I'm going to move on to proper backing up / versioning - I considered Git? because Kiwasi wrote a detailed setup which I saved for later - but it seemed a bit too involved, too much, too much - IM(artist)O.
    I really just want to point it at a certain directory - set it and forget it - but I haven't found one that is that simple yet.

    Anyone have suggestions for an artist friendly version controls system?
     
  31. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Not git. Git doesn't perform well with large binary assets, like texture or sounds. You can easily explode a tiny project into a massive multi gig affair by including binaries.

    I would tend to submit text based assets (code, prefabs, scenes, metadata ect) to git, and use a more traditional system to back up binaries.

    TL;DR I have no answer for you.
     
    theANMATOR2b likes this.
  32. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    What exactly did you find "unfriendly" about it?

    All version control systems are fiddly to initially learn. Once you understand how they work they're all pretty similar to use in principle. The catch is getting over the initial hurdles, which I think might be roughly similar in terms of difficulty regardless of the system you go with.

    (That's assuming you go with something modern / current. Old systems... well... some of them are a different story.)

    Perforce is the industry standard, for pretty much this reason.

    Also, unlike Git, people can pull down only the parts of a project that they need to work on rather than the whole thing. In Git you'd manage that by having multiple repos, in Perforce everything is in one repo and you just indicate what interests you and what doesn't.

    The catch with Perforce is that while licensing is free (I think) for small teams, managed hosting is nowhere near as readily available. For Git there's no shortage of people who'll give small teams quality hosted tools for free, but I'm yet to find the same for Perforce.

    That said, so far I've not actually had a practical issue with Git for game projects, and there's always Git LFS as well. It's ubiquity, availability of tools, and low cost of entry still make it a winner for many projects.
     
    Kiwasi likes this.
  33. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    Like others mentioned, art assets aren't always the best fit for version control, exactly. You probably have all sorts of versions of an image, perhaps source art is in some vector format the game engine doesn't natively read so you have to export it to PNGs anyway. This is all a great case for proper incremental backups.

    If using macOS there's Time Machine, which makes incremental snapshots of whatever you let it, including the whole OS if you like. Windows 10 has a thing - not as good as the thing in 7, but it's still a thing, and it backs up files. Whichever OS you have, there's a built-in tool to at least back up your home directory.

    But that's only local backups. It's strongly recommended to also have an offsite backup. You could do this by backing up manually a second time at the end of the day and shipping a drive to a different office with a fire safe. Yes, the good, old sneakernet method :)

    A better option, if you actually care about your stuff, is a service like BackBlaze. At $5/month or $50/year (both per computer) you've got unlimited space for personal projects. If you start requiring collaboration and/or more than two computers per person you might have to look into running your own cheap server (Hetzner.de is great).

    The Unity project should of course be in version control. Ignore the Library, commit pretty much everything else and just work off prototype art as long as possible so that you don't make too many changes to large binary data. And of course look into Git LFS if not using Perforce, as @angrypenguin mentioned. Watch this intro video to Git LFS to see how easy it is.

    Running your own Git server is fairly easy with GitLab Omnibus packages, and really easy and lightweight with Gogs (which builds and runs on anything, in case you want a Windows service).

    Version control on a server makes switching computers easier too. Work, commit, push, switch, pull, continue. Git has branches, so you can make an experimental branch and go wild, destroying any scripts you have, then check out the stable branch to get things back to normal if things didn't work out.
     
    theANMATOR2b likes this.
  34. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    We use Git LFS works perfect! But. We buy all our assets, so not many versions of each binary file. Sometimes we modify .fbx or a texure so some versioning is there, but offcourse not close to as if a artist was doing it from scratch. That said LFS works brilliant for us
     
  35. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    I use blender just fine, I could never understood why people find it complex, but now I have used source tree and git for Ludum dare in a team and I have no idea what I was doing even though it seems all I need to do was push and pull.

    And also perforce when I was in the industry but then there was a professional baby sitter and tools to hie the complexity.

    I kind of use dropbox, but is there a dumb version of these things?
     
  36. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    If you're on Windows 10 and are using git, and lots of large files are slowing down git's responsiveness, you could try Microsoft's Git Virtual File System, which is a thing that allows you to not actually have everything in your repo on the local file system.
    It's made to allow Microsoft to have all of their code in a single git repo and still have git be relatively fast. Details.
     
    theANMATOR2b likes this.
  37. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    You explained it well fiddly. As I said I'd really like to just point the version control to a local directory and not worry about it - unless I need it. As a solo dev - I can't be bothered with options I don't need - so they should just be hidden or excluded. I don't enjoy push/pull type workflows. But with incremental versioning (default for my workflow) like a system that records changes to files every 5-15 minutes, that should be just invisible to the user - that is the kind of system I'd like to use.

    In a previous life I worked in a team who used SVN, and once learned - I modified the process to just pull a local copy, work on it until finished and pushed it back up onto the repository. Its just different for art content - especially when working in 3D where the scene has a large quantity of file dependencies, audio, textures, skin, rig, proxies, xrefs etc. That usually causes issues with standard version control systems.

    I also worked on a team who used MS Project, though I don't know the back end on that project - I believe it was handled/set up manually by one of the programmers.

    Didn't someone else mention team viewer or something from Microsoft? Team service? Is that version control?

    Thanks for suggestions - all.
    I'll look into GitLFS -
    I just have trust issues - especially with OS backup systems - I do back up locally and offline as well - weekly just in case.
     
  38. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You can get GIT LFS for free over at gitlab.com
     
  39. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    Team Foundation Server is a humongous framework that tries to do everything, including version control. Here's a blog post that details Microsoft's move to git, and it has a list of the things TFS does:

    1. Source control
    2. Work management
    3. Builds
    4. Release
    5. Testing
    6. Package management
    7. Telemetry
    8. Flighting
    9. Incident management
    10. Localization
    11. Security scanning
    12. Accessibility
    13. Compliance management
    14. Code signing
    15. Static analysis
    16. and much, much more

    If you want the cloud version, that's "Visual Studio Team Services". When something has That Many Uppercase Words in it's name, you kinda know it's a bit too corporate for anything with less than 50 employees.
     
    fffMalzbier likes this.
  40. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    I realise I'm necroing this thread a bit, but I just thought I'd let you know after doing a ton of level design and getting back to where I was before, I have done a full project backup on a separate folder to make sure this disaster doesn't happen again.

    No need for fancy third party tools, just making sure that all my hard work is double copied this time :p
     
  41. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Just in case is this folder on another harddrive?
    If not it should.
    It's not the question of will the hardware brake it's the question when it will happen.
     
  42. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    oh absolutely and actually that happened awhile ago to me as well, my hard drives decided to fail so the ones I have now are brand new thankfully, I'll make a triple backup just to be extra safe.
     
    Last edited: Aug 24, 2017
  43. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,141
    What if you need a file that was from a while back to assist with fixing a regression but you no longer have backed up? ;)

    With a VCS you would be able to retrieve the file in exactly the state it was in back when it was working correctly, but with your solution you would have to start fixing it from scratch. This is one of the major benefits of a VCS outside of normal backups. You can retrieve a file from any point in the history of your project's commits.

    You'll even be able to see the exact changes that were made to the file in question as commits were made.
     
    Kiwasi likes this.
  44. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity collab. It will happily archive everything you ever did providing it's inside a Unity project.
     
    theANMATOR2b likes this.