Search Unity

Apply changes to prefab - Keyboard shortcut?

Discussion in 'Editor & General Support' started by gtjuggler, Aug 27, 2009.

Thread Status:
Not open for further replies.
  1. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    I find myself dragging the instanced prefab back onto the prefab to apply changes, as going to the menu item is even more cumbersome for me. It seems that there is no key command listed next to it either. Is there a faster way to apply changes to a prefab?
     
  2. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    Just applying the changes to the prefab itself, really. I've grown used to it and hardly notice it any more.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use the keyboard prefs to make one, then. :) I did.

    --Eric
     
  4. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    164
    No keyboard shortcut to Apply modifications in prefabs in Unity 4.3?

    Thanks.
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Would be nice of you to develop that answer a bit...
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    System preferences -> keyboard -> shortcuts -> app shortcuts.

    --Eric
     
  7. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    You lost me completely there... Is that on Mac?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah...did the Windows version even exist when I replied to this topic the first time?

    --Eric
     
  9. Turknor

    Turknor

    Joined:
    Aug 19, 2014
    Posts:
    1
    Most people have forgotten, but all menus in windows applications are accessible via the 'alt' button. So when I need to make changes to a long list of assets and apply them to the prefab, I hit "alt+g" which brings up the game object menu, then hit "a" which will use the 'Apply Changes to Prefab' function since it is the only option in that list that begins with 'a'. The advantage here is that you don't leave the hierarchy frame - for example I just had to delete some children out of +100 prefabs (and had to do so in the hierarchy instead of the project view because the change was deeper than the project view allows you to access). After making my change, I selected the top asset in the list and hit "alt+g" then "a" then "down arrow" (to select the next game object) and repeat until you're done. It's not a keyboard shortcut, but almost as good.
     
    Anisoropos and julenka like this.
  10. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    80
  11. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    Did you read the responses above? You can assign or access it on the OS level.

    Additionally it is trivial to add hot keys to anything you want in unity. See:
    http://docs.unity3d.com/ScriptReference/MenuItem.html
    And for prefab functionality:
    http://docs.unity3d.com/ScriptReference/PrefabUtility.html

    Add them together and you get
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class ApplyPrefabChanges : MonoBehaviour
    5. {
    6.     [MenuItem("Tools/Apply Prefab Changes %#p")]
    7.     static public void applyPrefabChanges()
    8.     {
    9.         var obj = Selection.activeGameObject;
    10.         if(obj!=null)
    11.         {
    12.             var prefab_root = PrefabUtility.FindPrefabRoot(obj);
    13.             var prefab_src = PrefabUtility.GetPrefabParent(prefab_root);
    14.             if(prefab_src!=null)
    15.             {
    16.                 PrefabUtility.ReplacePrefab(prefab_root, prefab_src,  ReplacePrefabOptions.ConnectToPrefab);
    17.                 Debug.Log("Updating prefab : "+AssetDatabase.GetAssetPath(prefab_src));
    18.             }
    19.             else
    20.             {
    21.                 Debug.Log("Selected has no prefab");
    22.             }
    23.         }
    24.         else
    25.         {
    26.             Debug.Log("Nothing selected");
    27.         }
    28.     }
    29. }
    It can be tweaked to behave differently if desired. But basically drop it in an editor folder and it will apply all changes on a selected prefab back to the source prefab when you hit CMD+Shift+p;
     
    laurentlavigne and Erikoinen like this.
  12. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    80
    I did read the above. There's not a settable key for it. There's only 15 customizable keys for Unity, which is ridiculous for a $1500 program as complex as Unity.

    I'm well aware I could code an editor extension that would probably only work half the time. We all shouldn't have to for something so common.

    The alt+G then A doesn't work any more because they added an Audio menu.
     
  13. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    That's kinda the point, Unity does provide customization for key commands, and much, much more, well beyond most applications, through the UnityEditor. Not sure what you mean "half of the time" The editor class (menu item) always works.
     
  14. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    80
    We shouldn't have to customize it to add a hotkey. It should work well out of the box.
     
  15. MarceloBarce

    MarceloBarce

    Joined:
    Jan 6, 2013
    Posts:
    35
    It's great that we can create a script and make new hotkeys, but people are asking for a default hotkey because this shortcut would be GREAT and definitely improve productivity.

    This feature is also so basic and simple that it feels really unpractical and unreasonable to have to add a new script and custom hotkey in every new project you start.

    It's sad to see how some people respond to this kind of request as if it was just bullshit posted by a lazy developer.
     
  16. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    Technically, a few of people have asked about it in a seven year period. Many more people have asked for built in scripts to handle opening doors. ;)

    Unity is a huge tool with one of its key features being it's customizability/extensibility. It is a tool for developers. Adding custom key bindings is not only trivial, but exceptionally powerful. Adding key bindings to less common actions isn't a limitation, is a feature. Shared editor tools have some editable directly in the editor. Much of the rest of unity is editor windows and components. Those can be custom and modified. Having a massive list every action that can be called from a panel or component is impractical. Instead, there is a easy and deep level of customization built in through the editor.

    It is trivial to add a hotkey for doing something like applying changes to prefab. Or you make it apply changes, and save the project. Or applying changes, saving the project, putting it in an assetbundle and uploading it, firing off a tweet about it, but only if the last save was over an hour ago and today is Tuesday, all from a single keystroke. The tools are all right there for you optimize/build your own workflow to any degree of granularity.

    The OP/topic asked simply how to improve his workflow. Several answers were provided:
    - Leverage the OS keybinding.
    - I provided a ready to use script to achieve that.
    - Link provided on how to further customize your editor/experience.
    - A feedback link.

    Additionally there are existing solutions on the Wiki, tutorials and the asset store.

    Anyway... the OP's 7 year old question has been answered extensively. The rest is just noise. Add your comments to the feedback topic if this is a limitation to development for you. Closed.
     
    Last edited: Nov 4, 2016
Thread Status:
Not open for further replies.