Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Lock your game objects with UnityLock - $2 on the Asset Store

Discussion in 'Assets and Asset Store' started by Deleted User, Oct 25, 2012.

  1. Deleted User

    Deleted User

    Guest


    UnityLock is a new editor utility that lets you lock game objects in your scene. When an object is locked it can't be moved or deleted, no components can be added or removed, and no existing components can be modified. Please note that this is an editor extension only; locked objects are fully editable at runtime via scripts. UnityLock only prevents modification of objects inside the editor.

    There are lots of times when you may want to make an object un-editable - and now you can.

    - If you have static level geometry placed where you want it, just lock it to prevent accidentally moving or deleting it.
    - If you have game objects that are singleton or "manager" type objects, now you can configure their components and then lock them to prevent them from being deleted or moved around the scene.
    - If you just need to temporarily prevent an object from being modified while you work around it just quickly lock it, do your work, and then unlock the object.

    Personally I thought it was a bit weird that Unity didn't already have a lock button. For example in tools like Photoshop it can be quite helpful to lock layers to prevent them from being edited. It lets you isolate your editable state and make sure you're only affecting things you want. This asset adds that functionality to Unity in an extremely simple way.

    UnityLock adds a menu under GameObject where you'll find all the functionality:



    Additionally, as you can see, there are keyboard shortcuts for the two common operations which lock or unlock a game object and all of its children. This makes working with UnityLock a lot simpler than having to always use the menu.

    When locked, the object's inspector will be all disabled and, in Unity 4, the "Add Component" button is no longer present. This lets you quickly tell that the object is locked.



    Updates:
    Nov 2 - Version 1.1 is available and includes some cool new features. See this post for the details.

    UnityLock is available for free! on the Asset Store: u3d.as/content/nick-gravelyn/unity-lock/3v5
     
    Last edited by a moderator: May 18, 2013
    KeepTrying likes this.
  2. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    when locked you cannot select it, it would be better.
     
  3. Deleted User

    Deleted User

    Guest

    That might be possible. I can take a look and see.
     
    Last edited by a moderator: Oct 25, 2012
  4. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Agreed, this would be very helpful
     
  5. Deleted User

    Deleted User

    Guest

    I assume you both mean "cannot select it in the scene view"? Selecting in the hierarchy would still be required to ever unlock the objects. :)
     
  6. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    yes of course. If you could make an icon or grey out in hierarchy, that would be good too.
     
  7. Deleted User

    Deleted User

    Guest

    I've got the icon in the hierarchy; not too hard.



    I'm also adding in support for undo/redo as I've found without it you can get into weird situations. Consider this series of events:

    1) Move an object.
    2) Scale an object.
    3) Lock an object.
    4) Hit undo 3 times.

    One might expect to undo the move and scale, but since the lock wasn't in the undo stack the object remains locked and thus the undos for the scale and move silently do nothing. Now the lock/unlock operations are in the undo stack so in the case above you'll first undo the lock, then undo the scale, and then the move, just like one would expect.

    I also have found a way to suppress most selections in the scene view. There doesn't seem to be a way to stop selection rectangles on objects with meshes, however I've found a way to suppress all standard left click selection as well as selection rectangles over objects like lights and cameras which have no mesh representation.

    It definitely helps, especially if you've got a lot of static level meshes you want to lock. If you drag a selection rectangle you might hit them, but just left clicking in the scene will no longer select them.

    Lastly I'm adding a preferences window under Window->UnityLock Preferences to control all three of these changes so that users can customize it how they want.



    I will be submitting this update tonight so it should be available soon.
     
    Last edited by a moderator: Nov 2, 2012
  8. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Great! Can't wait to see the new changes
     
  9. Deleted User

    Deleted User

    Guest

    Version 1.1 has been accepted by Unity and should be available for download now or very soon.
     
  10. vincent.yu

    vincent.yu

    Joined:
    Dec 14, 2012
    Posts:
    1
    Great..........no more wrong objects selected !!!
     
  11. EugeneKiver

    EugeneKiver

    Joined:
    Jan 4, 2012
    Posts:
    5
    Lock state on prefabbed objects resets after every unity restart, making this add-on almost useless for heavy prefabs users. And it wasn't mentioned in the description.
     
  12. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Can you add password system?
     
  13. mattimus

    mattimus

    Joined:
    Mar 8, 2008
    Posts:
    576
    It looks like prefab editing breaks the lock.

    1) Make a prefab
    2) Place an instance of the prefab in a scene
    3) Lock the prefab instance
    4) Edit the prefab in the Project pane.
    5) Placed prefab becomes unlocked.
     
  14. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    If you can save locks in between unity restarts, you can up the price.
     
  15. Can-Baycay

    Can-Baycay

    Joined:
    Dec 14, 2010
    Posts:
    27
    We have the same problem here. UnityLock is a great utility but totally useless if prefabs won't be handled correctly. Any plans on that?
     
  16. mattimus

    mattimus

    Joined:
    Mar 8, 2008
    Posts:
    576
    After buying a copy of UnityLock, I re-wrote a considerable amount of it to change the interface a bit and also allow locking to persist through prefab changes. Though being that part of the original code belongs to a paid product, I'm not quite sure on the etiquette for releasing it.
     
  17. shelshok

    shelshok

    Joined:
    Feb 18, 2013
    Posts:
    10
    That's great to hear. Why not send it to the developer?
     
  18. Deleted User

    Deleted User

    Guest

    Sorry for the lack of replies; been busy with work and starting my own company.

    I've made the asset free on the store because of my lack of time to properly support it. I never had time to investigate fixes for the prefabs because I wasn't using them a lot in my levels at the time. Now that this is a free asset, please feel free to share any code or modifications you'd like with each other to make it more useful.
     
  19. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,

    Nice Stuff but,
    password lock unlock system available????????????
     
  20. OuPas1

    OuPas1

    Joined:
    May 3, 2013
    Posts:
    18
    Do you plan on releasing your version now that the original is free?
     
  21. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    I've made some modifications to UnityLock script to make it more easy to use: Now you can lock/unlock directly in the hierarchy panel. Using the left button to perform a normal lock/unlock. Clicking with the right button do it recursively.

    I haven't looked into the prefab protection problem, but still now is very easy to use (i'm using it a lot in my projects in conjuntion with the Free Editor Enhacements: http://forum.unity3d.com/threads/149569-FREE-Editor-enhancements-Extensions-in-project-window!-Components-in-heirarchy!
    ).

    View attachment $UnityLockImproved.unitypackage

    Enjoy!

    EDIT : You''ll need to enable (if it is disable for some reason) the 'Show lock icon in hierarchy' option in the UnityLock's preferences panel (Menu->Window->UnityLock Preferences).
     
    Last edited: Aug 5, 2013
  22. Spidyy

    Spidyy

    Joined:
    Mar 6, 2011
    Posts:
    184
    Haha, I didn't see your post so I did the same myself...

    - lock/unlock in the hierarchy by left click on the icon (if made visible)
    - Ctrl + left click to lock/unlock recursively
    - changed the recursive system for LockRecursively and UnlockRecursively to use real recursive functions.
    - Right click on the lock/unlock icons bring a context menu with the lock/unlock/lock recursively/unlock recursively options.
    - Changed the icons to make them smaller and simpler. (but not optimized for Standard version of Unity. :/)

    View attachment $UnityLock.unitypackage

    Having this stuff for free is great, it helps a lot.
     
    Last edited: Aug 9, 2013
  23. umauj

    umauj

    Joined:
    Nov 20, 2011
    Posts:
    80
    AWESOME tool! Thanks so much for it!
     
  24. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Last time I checked it wasnt working on latest version 4.x I think.. can someone confirm?
     
  25. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    168
    EDIT: It's work on Unity 4.3.3 :)
    I confirm. Doesn't work on Unity 4.3.
     
    Last edited: Jan 24, 2014
  26. sphericPrawn

    sphericPrawn

    Joined:
    Oct 12, 2013
    Posts:
    244
    It works on mine ( 4.3.0 ), it just threw a couple of warnings saying 'Undo.RegisterSceneUndo' was obsolete at line 123 and 144. I tried a little bit to update the line to what the error report suggested but I couldn't get it working so I just removed the conditional statements that had those lines. Works perfectly for locking and unlocking objects as far as I can tell.
     
  27. Deleted User

    Deleted User

    Guest

    I've had no issues with 4.3 on my end. Also I did move UnityLock into a Github repo with a bunch of my other free Unity code and fixed up those compiler warnings to use the new undo APIs: https://github.com/nickgravelyn/UnityToolbag
     
  28. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    Moving a Parent while its children stay where and as they are as if they was not parented to it in Editor mode thats what i am after... best with a shortcut like "if control is pressed do not affect your children in any way" looks like no one can do that
     
    Last edited: Jan 30, 2014
  29. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    When I double click to lock object in inspector, it only locks that gameobject only. Can you make option to lock all children
     
  30. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Can you also update for 4.5, seems to be broken on it
     
    gregroberts likes this.
  31. Wanzyee

    Wanzyee

    Joined:
    Jul 24, 2015
    Posts:
    135
    Could those lock state of objects be saved in scene or prefab?
    I've tried myself to code before, but it can't be saved.
    Since I used hideFlags, which isn't serialized.
     
  32. gOzaru84

    gOzaru84

    Joined:
    Oct 1, 2016
    Posts:
    8
    Thank you for your hardwork @nickgravelyn, especially for making it free.
    When my game project is done and I get some money, I'll send you some as gratitude.
    Your package really helps me out a lot.
    For anyone who want to lock the children, press Ctrl + shift + L.
    Unlock them, press Ctrl + Shift + U.
    Read the readme file inside Asset > Editor >UnityLock
     
  33. brodskis

    brodskis

    Joined:
    Mar 30, 2017
    Posts:
    3
    sounds like what I'm looking for @nickgravelyn. I went to the asset store but it has been "Depreciated" Any moves to develop it further? i need something like this to prevent all the accidental mistakes