Open An4r3w opened 2 years ago
a PhysicalBehaviour
has a list of custom context menu buttons.
The following code shows how to add buttons. Do note that it only works on objects with a PhysicalBehaviour
. The human root object doesn't have one so you'd need to run this script on every limb you want that button to be on.
//assuming Instance is the GameObject, this code will add a "Blow up" button
var phys = Instance.GetComponent<PhysicalBehaviour>();
var button = new ContextMenuButton("uniqueIdentifierPleaseForGodSake", "Blow up", "Blow up the selection", () =>
{
ExplosionCreator.Explode(Instance.transform.position, 8);
});
phys.ContextMenuOptions.Buttons.Add(button);
just for clarity, there are quite a lot of context menu button constructors:
public ContextMenuButton(string identity, string label, string desc, params UnityAction[] actions)l
public ContextMenuButton(string identity, Func<string> label, string desc, params UnityAction[] actions)l
public ContextMenuButton(Func<bool> condition, string identity, Func<string> label, string desc, params UnityAction[] actions)l
public ContextMenuButton(Func<bool> condition, string identity, string label, string desc, params UnityAction[] actions)l
Hello, thank you! I just do not understand how to run the script on every limb.
Hello sorry for posting here again a question >.< but I really can't understand how to make a custom right click option for only my custom humans. Can someone help me?