Advertisement
Guest User

Untitled

a guest
May 31st, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1.         private void AddFilter()
  2.         {
  3.             //Loads the RealChute parachutes icon
  4.             Texture2D normal = new Texture2D(32, 32), selected = new Texture2D(32, 32);
  5.             normal.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.PluginDataURL, "FilterIcon.png")));
  6.             selected.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.PluginDataURL, "FilterIcon_selected.png")));
  7.             Icon icon = new Icon("RC_Parachutes", normal, selected);
  8.  
  9.             //Adds the Parachutes filter to the Filter by Function category
  10.             PartCategorizer.Category filterByFunction = PartCategorizer.Instance.filters
  11.                 .Find(f => f.button.categoryName == "Filter by Function");
  12.             PartCategorizer.AddCustomSubcategoryFilter(filterByFunction, "Parachutes", "Parachutes", icon,
  13.                 p => p.moduleInfos.Any(m => m.moduleName == "RealChute" || m.moduleName == "Parachute"));
  14.  
  15.             //Sets the buttons in the Filter by Module category
  16.             List<PartCategorizer.Category> modules = PartCategorizer.Instance.filters
  17.                 .Find(f => f.button.categoryName == "Filter by Module").subcategories;
  18.             modules.Remove(modules.Find(m => m.button.categoryName == "Procedural Chute"));
  19.             modules.Select(m => m.button).Single(b => b.categoryName == "RealChute").SetIcon(icon);
  20.  
  21.             //Apparently needed to make sure the buttons in Filter by Function show when the editor is loaded
  22.             UIRadioButton button = filterByFunction.button.activeButton;
  23.             button.SetState(UIRadioButton.State.False, UIRadioButton.CallType.APPLICATION, null, false);
  24.             button.SetState(UIRadioButton.State.True, UIRadioButton.CallType.APPLICATION, null, false);
  25.         }
  26.  
  27.     private void Awake()
  28.     {
  29.                 GameEvents.onGUIEditorToolbarReady.Add(AddFilter);
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement