i have attempted in panel working out remaining amount of total percentage , setting top limit of slider either seems inaccurate because logic wrong or breaks panel.
currently panel scripted shown below maximum sliders can reach 10 label showing me total dont go on highly impractical.
public static int ammoxboxespercent = editorprefs.getint("ammo"); public static int medickitspercent = editorprefs.getint("medickits"); public static int amountofitemsperzone = editorprefs.getint("amount"); public static int totalpercentageval; public static int maxtotalvalue = 10; [menuitem("enviroment controls/ object spawners control panel")] private static void showeditor() { editorwindow.getwindow<objectspawnerscontrolpanel>(false, "obj spawners cp"); } void ongui() { ammoxboxespercent = editorguilayout.intslider("ammox box percent", ammoxboxespercent, 1, 10); editorprefs.setint("ammo", ammoxboxespercent); medickitspercent = editorguilayout.intslider("medic kit percent", medickitspercent, 1, 10); editorprefs.setint("medickits", medickitspercent); amountofitemsperzone = editorguilayout.intslider("amount of items spawned @ each zone", amountofitemsperzone, 1, 5); editorprefs.setint("amount", amountofitemsperzone); totalpercentageval = medickitspercent + ammoxboxespercent; editorguilayout.labelfield ("total percentage far : " + totalpercentageval.tostring() + "0"); editorguilayout.labelfield ("total must not go above 100"); }
the goal have when set first slider 6 set limit of second slider 4 because percentage limit 10 (representing 100 percent in case)
anybody know decent method achieve this?
fairly easy. calculate 10 - ammoxboxespercent
, use max value intslider
medickitspercent
.
1 thing you'd want set lower limit medickitspercent
0, in case hit 10 on ammoxboxespercent
(since want total 10 @ max)
medickitspercent = editorguilayout.intslider("medic kit percent", medickitspercent, 0, maxtotalvalue - ammoxboxespercent);
Comments
Post a Comment