Updated README
This commit is contained in:
parent
3e1602162c
commit
55d0393cf8
78
README.md
78
README.md
|
|
@ -15,7 +15,7 @@ An editor window, where the history of all selected assets are shown. An asset i
|
||||||
|
|
||||||
## Toolbar
|
## Toolbar
|
||||||
|
|
||||||
Toolbars to the left and right of the play-buttons. Anything can be added, as long as it is supported by IMGUI.
|
Toolbars to the left and right of the play-buttons by using the `MainToolbarElement`-attribute.
|
||||||
|
|
||||||
|
|
||||||
### Default tools
|
### Default tools
|
||||||
|
|
@ -25,7 +25,6 @@ Several tools are available from start:
|
||||||
* Build: Select build target and build
|
* Build: Select build target and build
|
||||||
* Player Prefs: Delete all PlayerPrefs data
|
* Player Prefs: Delete all PlayerPrefs data
|
||||||
* Scene: Load any scene in the project easily by using the dropdown
|
* Scene: Load any scene in the project easily by using the dropdown
|
||||||
* Target Frame Rate Scale: Adjust target frame rate from [10;144] from a slider
|
|
||||||
* Time Scale: Adjust the time scale from [0;1] from a slider
|
* 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 Canvas: Select and center the camera on any Canvases in the scene
|
||||||
* UI Layer: Toggle the UI layer on/off
|
* UI Layer: Toggle the UI layer on/off
|
||||||
|
|
@ -35,35 +34,40 @@ Several tools are available from start:
|
||||||
|
|
||||||
### Customization
|
### Customization
|
||||||
|
|
||||||
You can create your own toolbar extensions by extending `AbstractToolbarDrawer`.
|
You can create your own toolbar extensions by using the property attribute `MainToolbarElement`.
|
||||||
|
|
||||||
```
|
```
|
||||||
internal sealed class MyCustomTool : AbstractToolbarDrawer
|
[Preserve]
|
||||||
|
[MainToolbarElement("Toolbar/Time Scale", ussName = "", defaultDockIndex = 0, defaultDockPosition = MainToolbarDockPosition.Middle, menuPriority = 500)]
|
||||||
|
public static MainToolbarElement Draw()
|
||||||
{
|
{
|
||||||
public override bool Visible => true;
|
var content = new MainToolbarContent("Time:", "Adjust Time.timeScale from [min;max] and snaps when value is approximately 1.0");
|
||||||
public override bool Enabled => true;
|
return new MainToolbarSlider(content, Time.timeScale, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue, OnTimeScaleValueChanged);
|
||||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
}
|
||||||
public override int Priority => (int)EToolbarPriority.Medium;
|
|
||||||
|
|
||||||
protected override void Draw(Rect rect)
|
private static void OnTimeScaleValueChanged(float value)
|
||||||
{
|
{
|
||||||
// Use IMGUI methods for drawing
|
value = Mathf.Clamp(value, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
|
||||||
}
|
|
||||||
|
|
||||||
public override float CalculateWidth()
|
if (Mathf.Abs(value - 1.0f) < 0.02f)
|
||||||
{
|
value = 1.0f;
|
||||||
// Default width for toolbar buttons is 30
|
|
||||||
return 30.0f;
|
if (!Mathf.Approximately(Time.timeScale, value))
|
||||||
}
|
Time.timeScale = value;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The four properties help define draw and enable state:
|
A list of multiple controls can be done by changing:
|
||||||
|
|
||||||
* `Visible`: If it is visible in the toolbar
|
```
|
||||||
* `Enabled`: If it is enabled in the toolbar (`GUI.enabled`)
|
public static MainToolbarElement Draw()
|
||||||
* `Placement`: If it is placed to the left or right of the play-buttons
|
```
|
||||||
* `Priority`: Sort order/priority, when drawing the tool
|
|
||||||
|
to
|
||||||
|
|
||||||
|
```
|
||||||
|
public static IEnumerable<MainToolbarElement> Draw()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Customization - Settings
|
### Customization - Settings
|
||||||
|
|
@ -71,29 +75,35 @@ The four properties help define draw and enable state:
|
||||||
To add enable/disable settings or more to Preferences -> Toolbar, you can implement `IToolbarSettings`.
|
To add enable/disable settings or more to Preferences -> Toolbar, you can implement `IToolbarSettings`.
|
||||||
|
|
||||||
```
|
```
|
||||||
internal sealed class ToolbarUiSettings : IToolbarSettings
|
internal sealed class ToolbarFooSettings : IToolbarSettings
|
||||||
{
|
{
|
||||||
public string Title => "UI";
|
public string Title => "Foo";
|
||||||
|
|
||||||
private const string PREF_IS_UI_ENABLED = "ToolbarSettings_IsUiEnabled";
|
private const string PREF_MIN_VALUE = "ToolbarSettings_MinValue";
|
||||||
private const string PREF_IS_UI_LAYER_ENABLED = "ToolbarSettings_IsUiLayerEnabled";
|
private const string PREF_MAX_VALUE = "ToolbarSettings_MaxValue";
|
||||||
|
|
||||||
public static bool IsUiEnabled
|
public static float MinValue
|
||||||
{
|
{
|
||||||
get => EditorPrefs.GetBool(PREF_IS_UI_ENABLED, false);
|
get => EditorPrefs.GetFloat(PREF_IS_UI_ENABLED, false);
|
||||||
set => EditorPrefs.SetBool(PREF_IS_UI_ENABLED, value);
|
set => EditorPrefs.SetFloat(PREF_IS_UI_ENABLED, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsUiLayerEnabled
|
public static float MaxValue
|
||||||
{
|
{
|
||||||
get => EditorPrefs.GetBool(PREF_IS_UI_LAYER_ENABLED, false);
|
get => EditorPrefs.GetFloat(PREF_IS_UI_LAYER_ENABLED, false);
|
||||||
set => EditorPrefs.SetBool(PREF_IS_UI_LAYER_ENABLED, value);
|
set => EditorPrefs.SetFloat(PREF_IS_UI_LAYER_ENABLED, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
IsUiEnabled = EditorGUILayout.Toggle("Enable Canvas picker", IsUiEnabled);
|
MinValue = EditorGUILayout.FloatField("Min Value", TimeScaleMinValue);
|
||||||
IsUiLayerEnabled = EditorGUILayout.Toggle("Enable Layer toggle", IsUiLayerEnabled);
|
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");
|
||||||
|
```
|
||||||
Loading…
Reference in a new issue