1
\$\begingroup\$

I am using Unity on Ubuntu 16.04 and I can't rename objects or assets using the F2 key as I could when I was using Windows.

What is the shortcut on Linux then?

\$\endgroup\$
  • \$\begingroup\$ You could also just double click? \$\endgroup\$ – Sidar Nov 6 '17 at 17:06
  • 1
    \$\begingroup\$ @Sidar Double click will take you to the object, you need to click and select, then wait a second or two, then click again to rename. Though using a shortcut is much faster. \$\endgroup\$ – John Hamilton Nov 10 '17 at 11:22
  • \$\begingroup\$ That's what i meant =P but yeah shortcut is faster \$\endgroup\$ – Sidar Nov 10 '17 at 14:24
6
\$\begingroup\$

There's a way to just custom make what you need to do. Put the following code inside a script with the same name (doesn't have to be on a game object).

using UnityEngine;
using UnityEditor;
using System.Reflection;

public class MenuItemsExample
{
    [MenuItem("Edit/Rename _F2")]
    private static void Rename()
    {
        var type = typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow");
        var hierarchyWindow = EditorWindow.GetWindow(type);
        var rename = type.GetMethod("RenameGO", BindingFlags.Instance | BindingFlags.NonPublic);
        rename.Invoke(hierarchyWindow, null);
    }
}

This will bind F2 to a rename functionality, using reflection. I've found this from the Unity forums (had to dig a bit but nothing too hard to find). The name part is mine, that's what binds F2 to the function and there's also a nice menu item that appears in your edit menu. Here's a GIF that shows the functionality (shouldn't be dependent on the OS):

Hope this works, since imgur is banned in my country. (Should work in theory)

Here's the link to the forum post.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.