Advertisement
HellFireKoder

Activated Parts Input Implementation Instructions

Feb 4th, 2016 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. // Import the ActivatedPartsInput package (https://www.dropbox.com/s/8trkl476j3a0zfr/ActivatedPartsInput.unitypackage?dl=0) into the Unity project  
  2.  
  3. // have your part modifier *behaviour* class inherit from ActivatedPartBehaviour, like this:
  4. public class SomePartBehaviour : ActivatedPartBehaviour
  5. {
  6.     // inside the part behaviour, put this:
  7.     protected override void Awake()
  8.     {
  9.         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)
  10.         {
  11.             base.Awake(); // this initializes the activation group input
  12.         }
  13.     }
  14.  
  15.     // replace any occurrences of "InputController.Active", with "this.Active" (or just "Active"... that's preference/style dependent)
  16. }
  17.  
  18. [DesignerPropertyToggleButton("None", "1", "2", "3", "4", "5", "6", "7", "8")]
  19. public string ActivationGroup;// add these three lines to the part ***modifier*** class, outside any functions
  20. protected int _ActivationGroup = 0;
  21.  
  22.  
  23. // add this if statement to the  part modifier Initialize method
  24.         if (ActivationGroup != "None")
  25.         {
  26.             if (int.TryParse(ActivationGroup, out _ActivationGroup))
  27.             {
  28.                 //Debug.Log("Successfully parsed to integer");
  29.             }
  30.             else
  31.             {
  32.                 //Debug.Log("Could not parse " + ActivationGroup + " to integer");
  33.             }
  34.         }
  35.         behaviour.ActivationGroup = _ActivationGroup; // and add this to the initialize method sometime after the if statement, and after behaviour has been defined.  
  36.  
  37. // 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