Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Import the ActivatedPartsInput package (https://www.dropbox.com/s/8trkl476j3a0zfr/ActivatedPartsInput.unitypackage?dl=0) into the Unity project
- // have your part modifier *behaviour* class inherit from ActivatedPartBehaviour, like this:
- public class SomePartBehaviour : ActivatedPartBehaviour
- {
- // inside the part behaviour, put this:
- protected override void Awake()
- {
- if (!ServiceProvider.Instance.GameState.IsInDesigner) // you need this if statement because... well, you don't really, but there's no reason to initialize input if we won't and can't use it! (and I'm lazy, so the ActivatedPartBehaviour doesn't check itself)
- {
- base.Awake(); // this initializes the activation group input
- }
- }
- // replace any occurrences of "InputController.Active", with "this.Active" (or just "Active"... that's preference/style dependent)
- }
- [DesignerPropertyToggleButton("None", "1", "2", "3", "4", "5", "6", "7", "8")]
- public string ActivationGroup;// add these three lines to the part ***modifier*** class, outside any functions
- protected int _ActivationGroup = 0;
- // add this if statement to the part modifier Initialize method
- if (ActivationGroup != "None")
- {
- if (int.TryParse(ActivationGroup, out _ActivationGroup))
- {
- //Debug.Log("Successfully parsed to integer");
- }
- else
- {
- //Debug.Log("Could not parse " + ActivationGroup + " to integer");
- }
- }
- behaviour.ActivationGroup = _ActivationGroup; // and add this to the initialize method sometime after the if statement, and after behaviour has been defined.
- // optionally, set the ActivationGroup in the Unity editor, to set the default value for it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement