Simple Interaction System for MSC
This has two types On/Off and One you can press once
How to Work with it:
1.For On/Off:
1.Add a collider to your object and set it as a trigger.
2.Add the component to your object.
3.Assign the trigger you created earlier to the component’s trigger field.
4.(Optional) Set the text for the On and Off states that will be displayed on screen.
5.(Important) Create a delegate for the actions that should happen when it is pressed, both for On and for Off. You can put any functionality you want to be executed when pressed.
SphereCollider testrigger = airfiltertrim.AddComponent<SphereCollider>();
testrigger.isTrigger = true;
InteractableSwitch test = airfiltertrim.AddComponent<InteractableSwitch>();
test.trigger = testrigger;
test.OnText = "On";
test.OffText = "Off";
test.onswitchOn = delegate
{
airfiltertrim.transform.localEulerAngles = new Vector3(10, 3, 5);
};
test.onswitchOff = delegate
{
airfiltertrim.transform.localEulerAngles = Vector3.zero;
};2.For one-time interaction:
1.Add a collider to your object and set it as a trigger.
2.Add the component to your object.
3.Assign the trigger you created earlier to the component’s trigger field.
4.(Optional) Set the text for the value that will be displayed on screen.
5.(Important) Create a delegate for the action that should happen when it is pressed. If you do not destroy the object as in my example, simply disable the component so that it can no longer be interacted with, if desired.
SphereCollider testrigger = airfiltertrim.AddComponent<SphereCollider>();
testrigger.isTrigger = true;
Interactable test = airfiltertrim.AddComponent<Interactable>();
test.trigger = testrigger;
test.mouseovertext = "Destoy Filter Trim";
test.ifclicked = delegate
{
GameObject.Destroy(airfiltertrim);
};