Feb. 26, 2015
1.0.0
v4.6.1
Better Button is an add-on asset for Unity's built in UI system.
To use BetterButton effectively, you should be comforatble with coding.
In order to use Better Button, you'll first need to add one to your scene. We recommend you use the GameObject menu (from the toolbar or by right-clicking in the scene hierarchy). Doing so this way will pre-set some of the settings for the Unity Button.
With the menu open, add the button by going to:
Create Other > BetterButton
BetterButton can also be found in the Component Menu under:
Component Menu > Boilerpowered > BetterButton
Below are the public variables that are available to you:
button.scriptWithMethod; // MonoBehaviour, the script that has the method
button.methodToInvoke; // string, the name of the method to invoke
button.methodParameters; // Array, parameters needed for your function, if necessary
button.IsInteractable; // bool, get/set whether the button can be used
button.uiButton; // gets the Unity Button from the gameObject
button.uiText; // gets the Unity Text that is a part of the button
The public functions thare are available are:
button.InvokeMethod() // Invokes the method in the specified script
button.UpdateInvoke() // Update the Unity button's listener
button.UpdateButtonImage( Image image ) // Change the button's image
And that's all you'll need in order to make Unity's Button that much better! We've also included a button in BetterButton's inspector that updates all the RectTransform
components based on the button's image
To change the script with a method and the method to invoke, you could do something like this:
void SetButtonMethod( BetterButton button, MonoBehaviour script, string method )
{
if ( button != null )
{
button.scriptWithMethod = script;
button.methodToInvoke = method;
//This must be called whenever the script or method has changed
button.UpdateInvoke();
}
}
To change the text of the button:
button.uiText.text = "BetterButton";
To use methodParameters
, we must first have a class that will hold the parameter. Let's say we want a string, so we create a class called StringParameter that contains the following:
public string text = "";
Once the class has been made and added to the methodParameters
array, we can get the value of the parameter with a function like this:
public string GetString( object[] parameters, int index )
{
if ( parameters == null || parameters.Length == 0 )
return "";
return ( (StringParameter)parameters[index] ).text;
}
We can then use the above function to actually do something with the value of the parameter, like so:
public void UseParameter()
{
string test = "";
if ( button != null )
{
test = GetString( button.methodParameters, 0 );
}
//Do something with the string
}
Mar. 3, 2015
1.2.0
Package: v4.5.4
Source Code: v3.4
Menu Navigation is a transform-based navigation solution for custom menus in Unity3D. It's been created to make it easy to highlight menu items when using a controller or keyboard.
It is very easy to add and remove buttons to highlight but you'll need to be able to code in order to make the most of of Menu Navigation.
In order to start using Menu Navigation, you must add the component to a game object in your scene. You can find the component under:
Component Menu > Boilerpowered > MenuNavigation
After adding the component, you should make sure you've added set the Button Highlight
field in the inspector. This is what will be displayed around your buttons.
To add buttons to Menu Navigation, you'll need to set up the rows and columns you want to navigate with. How you set this up depends on what you've set Direction
to. If you plan to use Vertical
or Horizontal
, you only need one row with however many columns you wish. If you plan to use Both
, you'll have to add multiple rows and each row needs to have it's own set of columns added to it.
To add/remove a row, use the plus or minus button next to the bold Rows
text. To add/remove a column to a row, use the plus or minus button next to the row element's name, which looks like Row 0
, for example.
All you are required to do at this point is to drag the transform of your buttons into each of the column fields.
As mentioned before, in order to make the most of Menu Navigation, you'll have to set what the position of the highlight will do in code. Below are the public variables that are always available to you:
nav.direction; // enum, set which direction to navigate in
nav.wrapHighlight; // bool, set whether to wrap the highlight
nav.invert; // bool, invert navigation controls
nav.canUse; // bool, set whether to update the highlight and get input
nav.ColumnIndex; // int, current column in a row
nav.RowIndex; // int, current row
nav.TableIndex; // int, unique index of a button in the array
nav.buttonPosition; // int, same as TableIndex
Before moving on, it's worth taking a moment to explain what TableIndex
is. So let's say you have an array of buttons like below:
Legend: [row,column]
[0,0], [0,1], [0,2], [0,3], [0,4], [0,5]
[1,0], [1,1], [1,2], [1,3], [1,4], [1,5]
[2,0], [2,1], [2,2], [2,3], [2,4], [2,5]
What TableIndex
does is determine a unique id for each button, from left to right, top to bottom. So the above array of buttons above looks like this with TableIndex
:
0, 1, 2, 3, 4, 5
6, 7, 8, 9, 10, 11
12, 13, 14, 15, 16, 17
In order to have something happen when the highlight is at a particular index, we do something like this:
if ( nav.canUse && nav.buttonPosition == 0 )
{
//Do something
}
If you want your "something" to happen, let's say, on a button press, you could put the above if
statement inside of another one that is checking for when a button has been pressed.
Finally, to set a button to be skipped, it must be added to Removeable Buttons
. To add/remove elements of the list, use the plus or minus button. Once you've added a new element, all you have to do is set the row and column indices in the Button to Remove
field (X is the row index and Y is the column index). You can also specify if the button you are skipping should be skipped on only a particular Unity platform.
Note: For various reasons, we can't use TableIndex
when setting which button to skip.
MenuNavigation.cs
and ObjectManager.cs
to the source folder of your project and everything should work.CONTROLS_MANAGER
to Scripting Define Symbols
in Player Settings > Other Settings
for all platforms you plan to support.Horizontal
and Vertical
axes is too low. They need to be increased for them to be effective.UNITY_GUI
to Scripting Define Symbols
in Player Settings > Other Settings
for each platform you plan to use it on.Mar. 9, 2015
1.1.0
v4.5.4
Controls Manager is a package meant to get you using InControl in your project faster. This means that having the our minimum required version of InControl is a requirement for using Controls Manager. Do not attempt to use Controls Manager without having InControl already added.
As with InControl, you need to be comforatble with coding in order to make Controls Manager useful to you.
First of all, make sure you have the minimum required version of InControl in your project. After you've done that, add CONTROLS_MANAGER
to Scripting Define Symbols
in Player Settings > Other Settings
for all platforms you plan to support.
Controls Manager is a singleton class. As such, it does not need to be added to a game object in your scene in order to use it. However, if you feel the need to add it to a gameObject
in your scene, you can find it under:
Component Menu > Boilerpowered > Input > ControlsManager
Controls Manager is set up to inherit everything that we have implemented from a base class so that you will be able to add any project specific inputs you might want without having to worry about messing anything up in the base class.
This setup also allows you to use ControlsManager in a shared repository if you have a shared code base between projects.
Below are the public variables that are available to you in the base class:
controls.inControlManager; // InControlManager, component script from InControl in order to initialize InControl
controls.customProfilePrefix; // string, set the prefix of your custom profiles
controls.customProfiles; // List<string>, the name of your custom profiles
controls.AnyControllerConnected; // bool, true if more than 1 controller deivce is connected
controls.InControl; // gets inControlManager (or adds it if it isn't there)
controls.UseXInput; // bool, enabled XInput in InControl
controls.players; // List<PlayerControls>, list of players
Below are the public variables that are available to you in the ControlsManager
class:
controls.player1; // PlayerControls, specific player from the list of players
controls.player2; // PlayerControls, specific player from the list of players
controls.player3; // PlayerControls, specific player from the list of players
controls.player4; // PlayerControls, specific player from the list of players
You'll notice that we only include 4 players by default. If you wish to add or remove players, use the plus or minus button next to Max Players
in the inspector.
Controls Manager provides access to all standard inputs provided by InControl. They are accessed through each player's PlayerControls
script. PlayerControls
is also set up to inherit from a base class so, just like Controls Manager, you can add your own custom inputs without worrying about messing up the base class.
To check if any player has pressed a button, we do this in an Update function:
if ( ControlsManager.Instance.GetA1() )
{
//Do something when any player uses Action1
}
To check if a particular player has pressed a button, we do this in an Update function:
if ( ControlsManager.Instance.player1.GetA1() )
{
//Do something when player1 uses Action1
}
To check if a particular player is holding a button, we do this in an Update function:
if ( ControlsManager.Instance.player1.GetA1( true ) )
{
//Do something when player1 holds Action1
}
To change a player's device:
//SetPlayerDevice requires the player and the device index
ControlsManager.Instance.SetPlayerDevice( ControlsManager.Instance.player2, 2 );
There should only be one instance of Controls Manager in your game. It has been set to be persistent across scene loads to prevent this issue.
If you need help or just want to get in touch, please fill out the contact form below!