Hi, i like to know if its possible to define my own key-shortcuts? It would be very helpful if i could define my own keys for switching between the "Textured", "wireframe" and "Tex-wire".. I looked in "edit-preferences-keys" but i found no way to set my own keys. Is that possible? Thanks for your help..
5 Answers
5You can create a menu item in Unity and assign your own shortcut.
This one hides or shows the selected GameObject by pressing H:
@MenuItem ("GameObject/Hide Selection _h")
static function HideSelection () {
go = Selection.activeGameObject;
if ( go.renderer.enabled == true) {
go.renderer.enabled = false;
}
else {
go.renderer.enabled = true;
}
}
You can find a lot of examples here: MenuItem
It doesn't look like you can.
You could download a cheatsheet to make it easier to learn them though. See: http://ethicalgames.wordpress.com/2009/02/20/unity-3d-keyboad-shortcuts-pdf/
I finally found the solution!
Thanks to this blog post: How to Add Your Own Tools to Unity’s Editor
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public static class EditorHotkeysTracker
{
static EditorHotkeysTracker()
{
SceneView.onSceneGUIDelegate += view =>
{
var e = Event.current;
if (e != null && e.keyCode != KeyCode.None)
Debug.Log("Key pressed in editor: " + e.keyCode);
};
}
}
Is it possible to bind keyboard shortcuts in an editor script with new version of Unity 4.3?
Thanks.
Check this tutorial site, there you can see how to define custom shortcuts for your MenuItem.
Could you clarify what the difference is between "prefab" and "normal models" in your project? Once they get included in the game, any editor-usable information about prefab status gets lost. All GameObjects become prefabs. Other types like Texture you can tell apart by type.
– RudyTheDev
[Check this side][1] [1]: http://unity3d.com/learn/tutorials/modules/intermediate/editor/menu-items?playlist=17090
– ocimumI have a character with an axe as a weapon, the axe itself has the script attached to it, and activates it when needed. It also has a 2d box collider trigger.
– The_Hero