109 lines
3.1 KiB
Markdown
109 lines
3.1 KiB
Markdown
# Description
|
|
|
|
This module contains a few helpful editor tools, like favorites, history and some handy toolbar tools.
|
|
|
|
|
|
## Favorites
|
|
|
|
An editor window, where you can pin folders and assets, so you can easily find the most used assets in your project.
|
|
|
|
|
|
## History
|
|
|
|
An editor window, where the history of all selected assets are shown. An asset in the window can be selected to easy get back to previous selections.
|
|
|
|
|
|
## Toolbar
|
|
|
|
Toolbars to the left and right of the play-buttons by using the `MainToolbarElement`-attribute.
|
|
|
|
|
|
### Default tools
|
|
|
|
Several tools are available from start:
|
|
|
|
* Build: Select build target and build
|
|
* Player Prefs: Delete all PlayerPrefs data
|
|
* Scene: Load any scene in the project easily by using the dropdown
|
|
* Time Scale: Adjust the time scale from [0;1] from a slider
|
|
* UI Canvas: Select and center the camera on any Canvases in the scene
|
|
* UI Layer: Toggle the UI layer on/off
|
|
* Settings: Open project or preferences
|
|
* Save: Project save
|
|
|
|
|
|
### Customization
|
|
|
|
You can create your own toolbar extensions by using the property attribute `MainToolbarElement`.
|
|
|
|
```
|
|
[Preserve]
|
|
[MainToolbarElement("Toolbar/Time Scale", ussName = "", defaultDockIndex = 0, defaultDockPosition = MainToolbarDockPosition.Middle, menuPriority = 500)]
|
|
public static MainToolbarElement Draw()
|
|
{
|
|
var content = new MainToolbarContent("Time:", "Adjust Time.timeScale from [min;max] and snaps when value is approximately 1.0");
|
|
return new MainToolbarSlider(content, Time.timeScale, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue, OnTimeScaleValueChanged);
|
|
}
|
|
|
|
private static void OnTimeScaleValueChanged(float value)
|
|
{
|
|
value = Mathf.Clamp(value, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
|
|
|
|
if (Mathf.Abs(value - 1.0f) < 0.02f)
|
|
value = 1.0f;
|
|
|
|
if (!Mathf.Approximately(Time.timeScale, value))
|
|
Time.timeScale = value;
|
|
}
|
|
```
|
|
|
|
A list of multiple controls can be done by changing:
|
|
|
|
```
|
|
public static MainToolbarElement Draw()
|
|
```
|
|
|
|
to
|
|
|
|
```
|
|
public static IEnumerable<MainToolbarElement> Draw()
|
|
```
|
|
|
|
|
|
### Customization - Settings
|
|
|
|
To add enable/disable settings or more to Preferences -> Toolbar, you can implement `IToolbarSettings`.
|
|
|
|
```
|
|
internal sealed class ToolbarFooSettings : IToolbarSettings
|
|
{
|
|
public string Title => "Foo";
|
|
|
|
private const string PREF_MIN_VALUE = "ToolbarSettings_MinValue";
|
|
private const string PREF_MAX_VALUE = "ToolbarSettings_MaxValue";
|
|
|
|
public static float MinValue
|
|
{
|
|
get => EditorPrefs.GetFloat(PREF_IS_UI_ENABLED, false);
|
|
set => EditorPrefs.SetFloat(PREF_IS_UI_ENABLED, value);
|
|
}
|
|
|
|
public static float MaxValue
|
|
{
|
|
get => EditorPrefs.GetFloat(PREF_IS_UI_LAYER_ENABLED, false);
|
|
set => EditorPrefs.SetFloat(PREF_IS_UI_LAYER_ENABLED, value);
|
|
}
|
|
|
|
public void Draw()
|
|
{
|
|
MinValue = EditorGUILayout.FloatField("Min Value", TimeScaleMinValue);
|
|
MaxValue = EditorGUILayout.FloatField("Max Value", TimeScaleMaxValue);
|
|
}
|
|
}
|
|
```
|
|
|
|
If you need to refresh a control, due to changes in settings. Then invoke:
|
|
|
|
```
|
|
MainToolbar.Refresh("Toolbar/Time Scale");
|
|
``` |