|
@@ -1,9 +1,9 @@
|
|
|
//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
|
|
//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
|
|
|
//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
|
|
//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
|
|
|
|
|
+using BansheeEngine;
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
-using BansheeEngine;
|
|
|
|
|
|
|
|
|
|
namespace BansheeEditor
|
|
namespace BansheeEditor
|
|
|
{
|
|
{
|
|
@@ -60,6 +60,8 @@ namespace BansheeEditor
|
|
|
private GUIToggle rotateSnapButton;
|
|
private GUIToggle rotateSnapButton;
|
|
|
private GUIFloatField rotateSnapInput;
|
|
private GUIFloatField rotateSnapInput;
|
|
|
|
|
|
|
|
|
|
+ private GUIButton cameraOptionsButton;
|
|
|
|
|
+
|
|
|
private SceneAxesGUI sceneAxesGUI;
|
|
private SceneAxesGUI sceneAxesGUI;
|
|
|
|
|
|
|
|
private bool hasContentFocus = false;
|
|
private bool hasContentFocus = false;
|
|
@@ -183,14 +185,14 @@ namespace BansheeEditor
|
|
|
{
|
|
{
|
|
|
mainLayout = GUI.AddLayoutY();
|
|
mainLayout = GUI.AddLayoutY();
|
|
|
|
|
|
|
|
- GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
|
|
|
|
|
|
|
+ GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
|
|
|
new LocEdString("View"));
|
|
new LocEdString("View"));
|
|
|
- GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
|
|
|
|
|
|
|
+ GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
|
|
|
new LocEdString("Move"));
|
|
new LocEdString("Move"));
|
|
|
- GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
|
|
|
|
|
|
|
+ GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
|
|
|
new LocEdString("Rotate"));
|
|
new LocEdString("Rotate"));
|
|
|
GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
|
|
GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
|
|
|
- new LocEdString("Scale"));
|
|
|
|
|
|
|
+ new LocEdString("Scale"));
|
|
|
|
|
|
|
|
GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
|
|
GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
|
|
|
new LocEdString("Local"));
|
|
new LocEdString("Local"));
|
|
@@ -202,9 +204,9 @@ namespace BansheeEditor
|
|
|
GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
|
|
GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
|
|
|
new LocEdString("Center"));
|
|
new LocEdString("Center"));
|
|
|
|
|
|
|
|
- GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
|
|
|
|
|
|
|
+ GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
|
|
|
new LocEdString("Move snap"));
|
|
new LocEdString("Move snap"));
|
|
|
- GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
|
|
|
|
|
|
|
+ GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
|
|
|
new LocEdString("Rotate snap"));
|
|
new LocEdString("Rotate snap"));
|
|
|
|
|
|
|
|
GUIToggleGroup handlesTG = new GUIToggleGroup();
|
|
GUIToggleGroup handlesTG = new GUIToggleGroup();
|
|
@@ -227,6 +229,9 @@ namespace BansheeEditor
|
|
|
rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
|
|
rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
|
|
|
rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));
|
|
rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));
|
|
|
|
|
|
|
|
|
|
+ GUIContent cameraOptionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Camera options"));
|
|
|
|
|
+ cameraOptionsButton = new GUIButton(cameraOptionsIcon);
|
|
|
|
|
+
|
|
|
viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View);
|
|
viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View);
|
|
|
moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move);
|
|
moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move);
|
|
|
rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
|
|
rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
|
|
@@ -243,6 +248,8 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
|
|
rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
|
|
|
rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value);
|
|
rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value);
|
|
|
|
|
+
|
|
|
|
|
+ cameraOptionsButton.OnClick += () => OnCameraOptionsClicked();
|
|
|
|
|
|
|
|
GUILayout handlesLayout = mainLayout.AddLayoutX();
|
|
GUILayout handlesLayout = mainLayout.AddLayoutX();
|
|
|
handlesLayout.AddElement(viewButton);
|
|
handlesLayout.AddElement(viewButton);
|
|
@@ -261,6 +268,8 @@ namespace BansheeEditor
|
|
|
handlesLayout.AddSpace(10);
|
|
handlesLayout.AddSpace(10);
|
|
|
handlesLayout.AddElement(rotateSnapButton);
|
|
handlesLayout.AddElement(rotateSnapButton);
|
|
|
handlesLayout.AddElement(rotateSnapInput);
|
|
handlesLayout.AddElement(rotateSnapInput);
|
|
|
|
|
+ handlesLayout.AddSpace(10);
|
|
|
|
|
+ handlesLayout.AddElement(cameraOptionsButton);
|
|
|
|
|
|
|
|
GUIPanel mainPanel = mainLayout.AddPanel();
|
|
GUIPanel mainPanel = mainLayout.AddPanel();
|
|
|
rtPanel = mainPanel.AddPanel();
|
|
rtPanel = mainPanel.AddPanel();
|
|
@@ -286,6 +295,19 @@ namespace BansheeEditor
|
|
|
UpdateRenderTexture(Width, Height - HeaderHeight);
|
|
UpdateRenderTexture(Width, Height - HeaderHeight);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void OnCameraOptionsClicked()
|
|
|
|
|
+ {
|
|
|
|
|
+ Vector2I openPosition;
|
|
|
|
|
+ Rect2I buttonBounds = GUIUtility.CalculateBounds(cameraOptionsButton, GUI);
|
|
|
|
|
+
|
|
|
|
|
+ openPosition.x = buttonBounds.x + buttonBounds.width / 2;
|
|
|
|
|
+ openPosition.y = buttonBounds.y + buttonBounds.height / 2;
|
|
|
|
|
+
|
|
|
|
|
+ SceneCameraOptionsDropdown cameraOptionsDropdown = DropDownWindow.Open<SceneCameraOptionsDropdown>(GUI, openPosition);
|
|
|
|
|
+
|
|
|
|
|
+ cameraOptionsDropdown.Initialize(this, cameraController.SceneCameraOptions);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void OnDestroy()
|
|
private void OnDestroy()
|
|
|
{
|
|
{
|
|
|
if (camera != null)
|
|
if (camera != null)
|
|
@@ -429,7 +451,7 @@ namespace BansheeEditor
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Converts screen coordinates into coordinates relative to the scene view render texture.
|
|
/// Converts screen coordinates into coordinates relative to the scene view render texture.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -463,13 +485,13 @@ namespace BansheeEditor
|
|
|
DuplicateSelection();
|
|
DuplicateSelection();
|
|
|
else if (VirtualInput.IsButtonDown(EditorApplication.DeleteKey))
|
|
else if (VirtualInput.IsButtonDown(EditorApplication.DeleteKey))
|
|
|
DeleteSelection();
|
|
DeleteSelection();
|
|
|
- else if(VirtualInput.IsButtonDown(viewToolKey))
|
|
|
|
|
|
|
+ else if (VirtualInput.IsButtonDown(viewToolKey))
|
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.View;
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.View;
|
|
|
- else if(VirtualInput.IsButtonDown(moveToolKey))
|
|
|
|
|
|
|
+ else if (VirtualInput.IsButtonDown(moveToolKey))
|
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Move;
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Move;
|
|
|
- else if(VirtualInput.IsButtonDown(rotateToolKey))
|
|
|
|
|
|
|
+ else if (VirtualInput.IsButtonDown(rotateToolKey))
|
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Rotate;
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Rotate;
|
|
|
- else if(VirtualInput.IsButtonDown(scaleToolKey))
|
|
|
|
|
|
|
+ else if (VirtualInput.IsButtonDown(scaleToolKey))
|
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Scale;
|
|
EditorApplication.ActiveSceneTool = SceneViewTool.Scale;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -497,7 +519,7 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
if (sceneAxesGUI.IsActive())
|
|
if (sceneAxesGUI.IsActive())
|
|
|
sceneAxesGUI.ClearSelection();
|
|
sceneAxesGUI.ClearSelection();
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
else if (Input.IsPointerButtonDown(PointerButton.Left))
|
|
else if (Input.IsPointerButtonDown(PointerButton.Left))
|
|
|
{
|
|
{
|
|
|
mouseDownPosition = scenePos;
|
|
mouseDownPosition = scenePos;
|
|
@@ -516,7 +538,7 @@ namespace BansheeEditor
|
|
|
Selection.SceneObject = draggedSO;
|
|
Selection.SceneObject = draggedSO;
|
|
|
EditorApplication.SetSceneDirty();
|
|
EditorApplication.SetSceneDirty();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
draggedSO = null;
|
|
draggedSO = null;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -579,7 +601,7 @@ namespace BansheeEditor
|
|
|
if (Input.IsButtonHeld(ButtonCode.Space))
|
|
if (Input.IsButtonHeld(ButtonCode.Space))
|
|
|
{
|
|
{
|
|
|
SnapData snapData;
|
|
SnapData snapData;
|
|
|
- sceneSelection.Snap(scenePos, out snapData, new SceneObject[] {draggedSO});
|
|
|
|
|
|
|
+ sceneSelection.Snap(scenePos, out snapData, new SceneObject[] { draggedSO });
|
|
|
|
|
|
|
|
Quaternion q = Quaternion.FromToRotation(Vector3.YAxis, snapData.normal);
|
|
Quaternion q = Quaternion.FromToRotation(Vector3.YAxis, snapData.normal);
|
|
|
draggedSO.Position = snapData.position;
|
|
draggedSO.Position = snapData.position;
|
|
@@ -617,7 +639,7 @@ namespace BansheeEditor
|
|
|
{
|
|
{
|
|
|
if (Input.IsPointerButtonDown(PointerButton.Left))
|
|
if (Input.IsPointerButtonDown(PointerButton.Left))
|
|
|
{
|
|
{
|
|
|
- Rect2I sceneAxesGUIBounds = new Rect2I(Width - HandleAxesGUISize - HandleAxesGUIPaddingX,
|
|
|
|
|
|
|
+ Rect2I sceneAxesGUIBounds = new Rect2I(Width - HandleAxesGUISize - HandleAxesGUIPaddingX,
|
|
|
HandleAxesGUIPaddingY, HandleAxesGUISize, HandleAxesGUISize);
|
|
HandleAxesGUIPaddingY, HandleAxesGUISize, HandleAxesGUISize);
|
|
|
|
|
|
|
|
if (sceneAxesGUIBounds.Contains(scenePos))
|
|
if (sceneAxesGUIBounds.Contains(scenePos))
|
|
@@ -640,14 +662,14 @@ namespace BansheeEditor
|
|
|
bool ctrlHeld = Input.IsButtonHeld(ButtonCode.LeftControl) ||
|
|
bool ctrlHeld = Input.IsButtonHeld(ButtonCode.LeftControl) ||
|
|
|
Input.IsButtonHeld(ButtonCode.RightControl);
|
|
Input.IsButtonHeld(ButtonCode.RightControl);
|
|
|
|
|
|
|
|
- sceneSelection.PickObject(scenePos, ctrlHeld, new SceneObject[] {draggedSO});
|
|
|
|
|
|
|
+ sceneSelection.PickObject(scenePos, ctrlHeld, new SceneObject[] { draggedSO });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
cameraController.EnableInput(false);
|
|
cameraController.EnableInput(false);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
SceneHandles.BeginInput();
|
|
SceneHandles.BeginInput();
|
|
|
sceneHandles.UpdateInput(scenePos, Input.PointerDelta);
|
|
sceneHandles.UpdateInput(scenePos, Input.PointerDelta);
|
|
|
sceneAxesGUI.UpdateInput(scenePos);
|
|
sceneAxesGUI.UpdateInput(scenePos);
|
|
@@ -933,7 +955,7 @@ namespace BansheeEditor
|
|
|
dragSelection = new GUITexture(null, true, EditorStylesInternal.SelectionArea);
|
|
dragSelection = new GUITexture(null, true, EditorStylesInternal.SelectionArea);
|
|
|
selectionPanel.AddElement(dragSelection);
|
|
selectionPanel.AddElement(dragSelection);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
dragSelectionEnd = scenePos;
|
|
dragSelectionEnd = scenePos;
|
|
|
|
|
|
|
|
Rect2I selectionArea = new Rect2I();
|
|
Rect2I selectionArea = new Rect2I();
|