- Home /
Does every object have to be static when adding tool bars to Unity?
I've managed to find MenuItem
as the clearest means of adding pop out toolbars to the top of the editor. The only issue I'm having with them is they require all of the functions called to be static. Does Anyone know how to allow static functions to use non static classes and functions?
Here's my custom tool bar script that's responsible for calling everything else:
public class CustomWindow : EditorWindow
{
[MenuItem("Character Controllers/2D/Platformer")]
static void Platformer()
{
MasterCharacterController.TwoD_Camera();
CustomEditorCharController.twoD_Options();
}
[MenuItem("Character Controllers/3D/Third Person")]
static void ThirdPerson()
{
MasterCharacterController.ThreeD_Camera();
CustomEditorCharController.threeD_Options();
}
}
What instances do you need to access?
The idea with a $$anonymous$$enuItem is that it needs to be able to find whatever information it needs, once it's pressed. You're certainly able to use non-static fields and methods, provided you're able to find objects to reference.
For example, you could write a $$anonymous$$enuItem that tweaks any selected FooBarComponent objects that happen to be selected in the scene. When the $$anonymous$$enuItem is called, you can query the Selection class to find out what's selected.
Your answer
Follow this Question
Related Questions
IN-GAME Menu Items 0 Answers
Is MenuItem supported anymore? 2 Answers
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers