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.

KeyBoard Input for Back to scene after prefab editing

Discussion in 'Prefabs' started by kilik128, Sep 18, 2018.

  1. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    907
    Hi i looking for keyboard input for
    Back to scene after prefab editing
    thank's


    ps : keyboard input for back to last prefab editing is welcomme too
     
    Gua likes this.
  2. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    907
    maybie little script can make the job
     
  3. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    790
    Esc would be fine
     
    Deeeds likes this.
  4. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    180
    EDIT: Ignore the example below as we have added builtin shortcuts in 2018.3 after this message. Customize it under: Preferences -> Keys -> Stage.
    Stage/Enter Prefab Mode
    Stage/Go Back



    We have not settled on built-in keyboard shortcuts yet. Until then add this script to an Editor folder.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.SceneManagement;
    4.  
    5. public static class StageShortcuts
    6. {
    7.     [MenuItem("GameObject/Navigate Back %w", false, 10000)]
    8.     static void NavigateBack()
    9.     {
    10.         StageUtility.GoBackToPreviousStage();
    11.     }
    12.  
    13.     [MenuItem("GameObject/Open Selected Prefab %e", true)]
    14.     static bool ValidateOpenSelectedPrefab()
    15.     {
    16.         return !string.IsNullOrEmpty(GetPrefabAssetPath(Selection.activeGameObject));
    17.     }
    18.  
    19.     [MenuItem("GameObject/Open Selected Prefab %e", false, 10000)]
    20.     static void OpenSelectedPrefab()
    21.     {
    22.         var activeGameObject = Selection.activeGameObject;
    23.         var prefabPath = GetPrefabAssetPath(activeGameObject);
    24.         if (!string.IsNullOrEmpty(prefabPath))
    25.         {
    26.             var assetObject = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
    27.             AssetDatabase.OpenAsset(assetObject, EditorUtility.IsPersistent(activeGameObject) ? -1 : activeGameObject.GetInstanceID());
    28.         }
    29.     }
    30.  
    31.     static string GetPrefabAssetPath(GameObject gameObject)
    32.     {
    33.         if (gameObject != null && PrefabUtility.IsPartOfAnyPrefab(gameObject))
    34.         {
    35.             return PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(gameObject);
    36.         }
    37.  
    38.         return null;
    39.     }
    40. }
     
    Last edited: Jan 15, 2019
  5. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    907
    Thank's
     
  6. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    For some reason ctrl+e doesn't open prefab mode, but Ctrl + W does work.
     
  7. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    180
    FYI In 2018.3 we have added keyboard shortcuts you can customize under Preferences -> Keys -> Stage

    See:
    Stage/Enter Prefab Mode
    Stage/Go Back


    The default key for 'Enter Prefab Mode' is [P]
     
    Last edited: Jan 15, 2019