1.8.2: Changed icon on scene loading toggle and added a create new scene button
This commit is contained in:
parent
38e771c549
commit
de2745d68a
10 changed files with 134 additions and 19 deletions
|
|
@ -24,8 +24,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
private static string[] SCENE_NAMES = new string[0];
|
||||
private static string[] SCENE_SHORT_NAMES = new string[0];
|
||||
private static string[] SCENE_PATHS = new string[0];
|
||||
private static readonly GUIContent LABEL_ADDITIVE = new GUIContent(string.Empty, "Toggles between Single and Additive scene loading");
|
||||
|
||||
private static readonly GUIContent LABEL_SCENE_ADDITIVE = new GUIContent(string.Empty, "Additive scene loading (toogle to Single)");
|
||||
private static readonly GUIContent LABEL_SCENE_SINGLE = new GUIContent(string.Empty, "Single scene loading (toggle to Additive)");
|
||||
private static readonly GUIContent LABEL_SCENE_CREATE = new GUIContent(string.Empty, "Create a new scene");
|
||||
private const float BUTTON_WIDTH = 24.0f;
|
||||
|
||||
private static bool IS_DIRTY = true;
|
||||
|
||||
|
|
@ -142,19 +144,55 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
protected override void Draw(Rect rect)
|
||||
{
|
||||
Initialize();
|
||||
var rect0 = new Rect(rect.x, rect.y, rect.width - 24.0f, rect.height);
|
||||
var rect1 = new Rect(rect0.xMax, rect.y, 24.0f, rect.height);
|
||||
|
||||
var rect0 = new Rect(rect.x, rect.y, rect.width - BUTTON_WIDTH * 2.0f, rect.height);
|
||||
var rect1 = new Rect(rect0.xMax, rect.y, BUTTON_WIDTH, rect.height);
|
||||
var rect2 = new Rect(rect1.xMax, rect.y, BUTTON_WIDTH, rect.height);
|
||||
DrawSceneDropDown(rect0);
|
||||
DrawSceneLoadToggle(rect1);
|
||||
DrawSceneAddButton(rect2);
|
||||
}
|
||||
|
||||
if (GUI.Button(rect0, SCENE_LABEL, styles.popup))
|
||||
ShowDropDown(rect0);
|
||||
private void DrawSceneDropDown(Rect rect)
|
||||
{
|
||||
if (GUI.Button(rect, SCENE_LABEL, styles.popup))
|
||||
ShowDropDown(rect);
|
||||
}
|
||||
|
||||
private void DrawSceneLoadToggle(Rect rect)
|
||||
{
|
||||
bool isScenePickerSetAsAdditive = ToolbarScenePickerSettings.IsScenePickerSetAsAdditive;
|
||||
bool temp = EditorGUI.Toggle(rect1, isScenePickerSetAsAdditive, styles.button);
|
||||
GUI.Label(rect1, temp ? styles.iconPlusSmall : styles.iconPlusTiny, styles.labelCenter);
|
||||
GUI.Label(rect1, LABEL_ADDITIVE, styles.labelCenter);
|
||||
bool tempIsAdditive = EditorGUI.Toggle(rect, isScenePickerSetAsAdditive, styles.button);
|
||||
|
||||
if (temp != isScenePickerSetAsAdditive)
|
||||
ToolbarScenePickerSettings.IsScenePickerSetAsAdditive = temp;
|
||||
if (tempIsAdditive)
|
||||
{
|
||||
GUI.Label(rect, styles.iconSceneAdditive, styles.labelCenter);
|
||||
GUI.Label(rect, LABEL_SCENE_ADDITIVE, styles.labelCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(rect, styles.iconSceneSingle, styles.labelCenter);
|
||||
GUI.Label(rect, LABEL_SCENE_SINGLE, styles.labelCenter);
|
||||
}
|
||||
|
||||
if (tempIsAdditive != isScenePickerSetAsAdditive)
|
||||
ToolbarScenePickerSettings.IsScenePickerSetAsAdditive = tempIsAdditive;
|
||||
}
|
||||
|
||||
private void DrawSceneAddButton(Rect rect)
|
||||
{
|
||||
if (GUI.Button(rect, styles.iconPlusSmall, styles.button))
|
||||
{
|
||||
if (!EditorUtility.DisplayDialog("Create new scene", "Are you sure that you want to create a new scene?", "Yes", "No"))
|
||||
return;
|
||||
|
||||
Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
|
||||
|
||||
if (EditorUtility.DisplayDialog("Create new scene", "Save scene to disk?", "Yes", "No"))
|
||||
EditorSceneManager.SaveScene(scene);
|
||||
}
|
||||
|
||||
GUI.Label(rect, LABEL_SCENE_CREATE, styles.labelCenter);
|
||||
}
|
||||
|
||||
private static void ShowDropDown(Rect rect)
|
||||
|
|
@ -216,7 +254,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 124.0f;
|
||||
return 100.0f + BUTTON_WIDTH * 2.0f;
|
||||
}
|
||||
|
||||
public static void SetAsDirty()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue