![]() ![]() some code, changing awesomeness to other ISomeAwesomeInterface based on some condition maybe Private ISomeAwesomeInterface awesomeness The SomeAwesomeScript is then used within a monobehaviour like this: public class SomeAwesomeBehaviour : MonoBehaviour Now the DoSomeAwesomeShit is defined in the ISomeAwesomeInterface and the actual implementation is supposed to be unique to every other class that implements this method. initializations, since we cant use constructors when using ScriptableObject this container is supposed to be passed into a scriptableobject like this: public class SomeAwesomeScript : ScriptableObject, ISomeAwesomeInterface Which is simply a container for a bunch of gameobjects. Undo.RegisterCreatedObjectUndo(go, "Create " + go.So I've got A Data Script: Register the creation in the undo system GameObjectUtility.SetParentAndAlign(go, ntext as GameObject) Ensure it gets reparented if this was a context click (otherwise does nothing) GameObject go = new GameObject("Custom Game Object") ![]() Static void CreateCustomGameObject( MenuCommand menuCommand) and propagated to the hierarchy dropdown and hierarchy context menus. Priority 10 ensures it is grouped with the other menu items of the same kind Add a menu item to create custom GameObjects. Rigidbody body = ( Rigidbody)ntext ĭebug.Log("Doubled Rigidbody's Mass to " + body.mass + " from Context Menu.") Static void DoubleMass( MenuCommand command) Add a menu item called "Double Mass" to a Rigidbody's context menu. Static void DoSomethingWithAShortcutKey()ĭebug.Log("Doing something with a Shortcut Key.") and give it a shortcut (ctrl-g on Windows, cmd-g on macOS). Add a menu item named "Do Something with a Shortcut Key" to MyMenu in the menu bar Return Selection.activeTransform != null Return false if no transform is selected. Static bool ValidateLogSelectedTransformName() The menu item will be disabled if this function returns false. ![]() Validate the menu item defined by the function above. so it will only be enabled if we have a transform selected.ĭebug.Log("Selected Transform is on " + + ".") We use a second function to validate the menu item Add a menu item named "Log Selected Transform Name" to MyMenu in the menu bar. Add a menu item named "Do Something" to MyMenu in the menu bar. We encourage using a more descriptive category name than "Create Other" and explicitly With no explicit priority set will receive a priority of 10 instead of the default 1000. Note that for legacy purposes MenuItems in "GameObject/Create Other" This can be achieved by setting its priority With the other GameObject creation menu items. Propagated to the hierarchy Create dropdown and hierarchy context menu, it must be grouped Also note that in order for a menu item in "GameObject/" to be Undo.RegisterCreatedObjectUndo to make the creation undoable and set Selection.activeObject When adding menu items to the "GameObject/" menu to create custom GameObjects, be sure toĬall GameObjectUtility.SetParentAndAlign to ensure that the new GameObject is reparentedĬorrectly in the case of a context click (see example below). "MyMenu/Do_g" won't be interpreted as hotkey, while "MyMenu/Do _g" will. F12, HOME, END, PGUP, PGDN, INS, DEL, TAB, and SPACE.Ī hotkey text must be preceded with a space character. The keys supported like this are: LEFT, RIGHT, UP, DOWN, F1. For example, "#LEFT" would map to Shift-Left. Some special keyboard keys are supported as hotkeys. To create a menu with hotkey G and no key modifiers pressed, use "MyMenu/Do Something _g". For example, to create a menu with the hotkey Shift+Alt+G, use "MyMenu/Do Something #&g". If no special modifier key combinations are required, the key can be given after an underscore. To create a hotkey, use the following special characters: % (ctrl on Windows and Linux, cmd on macOS), ^ (ctrl on Windows, Linux, and macOS), # (shift), & (alt). Only static functions can use the MenuItem attribute. The MenuItem attribute turns any static function into a menu command. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |