It is a library that can easily switch the display pattern of UGUI.
Switch the style by script from index and string.
- Add "UI" => "Skinner" from Add Component in Game Object with Unity Inspector.
- Press "Add New Skin Style" button.
- Press "Add New Skin Parts" button.
- Edit the added Skin Parts and specify the appearance you want to switch.
- Press the "Add New Skin Parts" button to clone the previous skin part, Switch the dropdown and set the required skin parts.
- Repeat 2 ~ 6 for as many skins as you need!
- Switch the Current Select Style and check if each appearance is reflected correctly.
- Create a new script and add "using Pspkurara.UI".
- Add a variable to the script. "[SerializedField] private UISkinner _variable = null;"
- Call the "SetSkin" function and specify the required Skin Style index ("Current Select Style" number in Skinner inspector) as an argument.
using Pspkurara.UI;
public class SampleScript : MonoBehaviour
{
[SerializedField] private UISkinner _yourSkinner = null;
private void Start ()
{
int yourFirstApplySkinStyleIndex = 0;
_yourSkinner.SetSkin (yourFirstApplySkinStyleIndex);
}
public void ChangeSkinStyle ()
{
int yourNextSkinStyleIndex = 0;
_yourSkinner.SetSkin (yourNextSkinStyleIndex);
}
}
- Finish Inspector work up to #6.
- Specify a unique string for "Style Key" directly under "Skin ~" fold.
- Finish Scripting work up to #2.
- Call the "SetSkin" function and specify the required "Style Key" as an argument.
using Pspkurara.UI;
public class SampleScript : MonoBehaviour
{
[SerializedField] private UISkinner _yourSkinner = null;
private void Start ()
{
string yourFirstApplySkinStyleKey = "Default";
_yourSkinner.SetSkin (yourFirstApplySkinStyleKey);
}
public void ChangeSkinStyle ()
{
string yourNextSkinStyleKey = "ChangedSkin";
_yourSkinner.SetSkin (yourNextSkinStyleKey);
}
}
Go to Unity's project folder on the command line and call:
openupm add com.pspkurara.ugui-skinner
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.pspkurara.ugui-skinner": "https://github.com/pspkurara/ugui-skinner.git#upm",
...
},
}
Unity 2017.1 or later
May work in Unity5, but unofficial.
- GitHub page : https://github.com/pspkurara/ugui-skinner