|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using UnityEditor.UIElements; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.UIElements; |
|
|
|
|
|
|
|
|
|
|
event Action OnUpdateRequested; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>Interface that must implement the EnvironmentLibrary view to communicate with the data management</summary>
|
|
|
|
public interface IEnvironmentDisplayer |
|
|
|
{ |
|
|
|
void Repaint(); |
|
|
|
|
|
|
|
event Action<EnvironmentLibrary> OnChangingEnvironmentLibrary; |
|
|
|
} |
|
|
|
class DisplayWindow : EditorWindow, IViewDisplayer, IEnvironmentDisplayer |
|
|
|
partial class DisplayWindow : EditorWindow, IViewDisplayer |
|
|
|
static class Style |
|
|
|
static partial class Style |
|
|
|
public static readonly GUIContent WindowTitleAndIcon = EditorGUIUtility.TrTextContentWithIcon("Look Dev", CoreEditorUtils.LoadIcon(k_IconFolder, "LookDevMainIcon", forceLowRes: true)); |
|
|
|
} |
|
|
|
internal static readonly GUIContent k_WindowTitleAndIcon = EditorGUIUtility.TrTextContentWithIcon("Look Dev", CoreEditorUtils.LoadIcon(k_IconFolder, "LookDev", forceLowRes: true)); |
|
|
|
|
|
|
|
internal static readonly Texture2D k_Layout1Icon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "Layout1", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_Layout2Icon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "Layout2", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_LayoutVerticalIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LayoutVertical", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_LayoutHorizontalIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LayoutHorizontal", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_LayoutStackIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LayoutCustom", forceLowRes: true); |
|
|
|
// /!\ WARNING:
|
|
|
|
//The following const are used in the uss.
|
|
|
|
//If you change them, update the uss file too.
|
|
|
|
const string k_MainContainerName = "mainContainer"; |
|
|
|
const string k_EnvironmentContainerName = "environmentContainer"; |
|
|
|
const string k_ShowEnvironmentPanelClass = "showEnvironmentPanel"; |
|
|
|
const string k_ViewContainerName = "viewContainer"; |
|
|
|
const string k_FirstViewName = "firstView"; |
|
|
|
const string k_SecondViewName = "secondView"; |
|
|
|
const string k_ToolbarName = "toolbar"; |
|
|
|
const string k_ToolbarRadioName = "toolbarRadio"; |
|
|
|
const string k_TabsRadioName = "tabsRadio"; |
|
|
|
const string k_SideToolbarName = "sideToolbar"; |
|
|
|
const string k_SharedContainerClass = "container"; |
|
|
|
const string k_FirstViewClass = "firstView"; |
|
|
|
const string k_SecondViewsClass = "secondView"; |
|
|
|
const string k_VerticalViewsClass = "verticalSplit"; |
|
|
|
const string k_DebugContainerName = "debugContainer"; |
|
|
|
const string k_ShowDebugPanelClass = "showDebugPanel"; |
|
|
|
internal static readonly Texture2D k_Camera1Icon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "Camera1", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_Camera2Icon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "Camera2", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_LinkIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "Link", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_RightIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "RightArrow", forceLowRes: true); |
|
|
|
internal static readonly Texture2D k_LeftIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LeftArrow", forceLowRes: true); |
|
|
|
|
|
|
|
internal static readonly Texture2D k_RenderdocIcon = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "RenderDoc", forceLowRes: true); |
|
|
|
internal const string k_RenderDocLabel = " Content"; |
|
|
|
|
|
|
|
internal const string k_CameraMenuSync1On2 = "Align Camera 1 with Camera 2"; |
|
|
|
internal const string k_CameraMenuSync2On1 = "Align Camera 2 with Camera 1"; |
|
|
|
internal const string k_CameraMenuReset = "Reset Cameras"; |
|
|
|
|
|
|
|
internal const string k_EnvironmentSidePanelName = "Environment"; |
|
|
|
internal const string k_DebugSidePanelName = "Debug"; |
|
|
|
|
|
|
|
internal const string k_DragAndDropObject = "Drag and drop object here"; |
|
|
|
internal const string k_DragAndDropEnvironment = "Drag and drop environment from side panel here"; |
|
|
|
|
|
|
|
// /!\ WARNING:
|
|
|
|
//The following const are used in the uss.
|
|
|
|
//If you change them, update the uss file too.
|
|
|
|
internal const string k_MainContainerName = "mainContainer"; |
|
|
|
internal const string k_ViewContainerName = "viewContainer"; |
|
|
|
internal const string k_FirstViewName = "firstView"; |
|
|
|
internal const string k_SecondViewName = "secondView"; |
|
|
|
internal const string k_ToolbarName = "toolbar"; |
|
|
|
internal const string k_ToolbarRadioName = "toolbarRadio"; |
|
|
|
internal const string k_TabsRadioName = "tabsRadio"; |
|
|
|
internal const string k_SideToolbarName = "sideToolbar"; |
|
|
|
internal const string k_SharedContainerClass = "container"; |
|
|
|
internal const string k_FirstViewClass = "firstView"; |
|
|
|
internal const string k_SecondViewsClass = "secondView"; |
|
|
|
internal const string k_VerticalViewsClass = "verticalSplit"; |
|
|
|
internal const string k_DebugContainerName = "debugContainer"; |
|
|
|
internal const string k_ShowDebugPanelClass = "showDebugPanel"; |
|
|
|
|
|
|
|
internal const string k_EnvironmentContainerName = "environmentContainer"; |
|
|
|
internal const string k_ShowEnvironmentPanelClass = "showEnvironmentPanel"; |
|
|
|
|
|
|
|
internal const string k_CameraMenuName = "cameraMenu"; |
|
|
|
internal const string k_CameraButtonName = "cameraButton"; |
|
|
|
internal const string k_CameraSeparatorName = "cameraSeparator"; |
|
|
|
|
|
|
|
internal const string k_RenderDocContentName = "renderdoc-content"; |
|
|
|
} |
|
|
|
PopupField<string> m_DebugView; |
|
|
|
VisualElement m_EnvironmentContainer; |
|
|
|
ListView m_EnvironmentList; |
|
|
|
EnvironmentElement m_EnvironmentInspector; |
|
|
|
Toolbar m_EnvironmentListToolbar; |
|
|
|
|
|
|
|
LayoutContext layout |
|
|
|
=> LookDev.currentContext.layout; |
|
|
|
Layout layout |
|
|
|
Layout viewLayout |
|
|
|
get => LookDev.currentContext.layout.viewLayout; |
|
|
|
get => layout.viewLayout; |
|
|
|
if (LookDev.currentContext.layout.viewLayout != value) |
|
|
|
if (layout.viewLayout != value) |
|
|
|
OnLayoutChangedInternal?.Invoke(value, sidePanel); |
|
|
|
OnLayoutChangedInternal?.Invoke(value, layout.showedSidePanel); |
|
|
|
SidePanel sidePanel |
|
|
|
bool environmentSidePanel |
|
|
|
get => LookDev.currentContext.layout.showedSidePanel; |
|
|
|
get => (layout.showedSidePanel & SidePanel.Environment) != 0; |
|
|
|
set |
|
|
|
{ |
|
|
|
bool stored = (layout.showedSidePanel & SidePanel.Environment) != 0; |
|
|
|
if (value != stored) |
|
|
|
{ |
|
|
|
if (value) |
|
|
|
layout.showedSidePanel |= SidePanel.Environment; |
|
|
|
else |
|
|
|
layout.showedSidePanel &= ~SidePanel.Environment; |
|
|
|
ApplySidePanelChange(layout.showedSidePanel); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bool debugView1SidePanel |
|
|
|
{ |
|
|
|
get => (layout.showedSidePanel & SidePanel.DebugView1) != 0; |
|
|
|
if (LookDev.currentContext.layout.showedSidePanel != value) |
|
|
|
bool stored = (layout.showedSidePanel & SidePanel.DebugView1) != 0; |
|
|
|
if (value != stored) |
|
|
|
OnLayoutChangedInternal?.Invoke(layout, value); |
|
|
|
ApplySidePanelChange(value); |
|
|
|
if (value) |
|
|
|
layout.showedSidePanel |= SidePanel.DebugView1; |
|
|
|
else |
|
|
|
layout.showedSidePanel &= ~SidePanel.DebugView1; |
|
|
|
ApplySidePanelChange(layout.showedSidePanel); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bool debugView2SidePanel |
|
|
|
{ |
|
|
|
get => (layout.showedSidePanel & SidePanel.DebugView2) != 0; |
|
|
|
set |
|
|
|
{ |
|
|
|
bool stored = (layout.showedSidePanel & SidePanel.DebugView2) != 0; |
|
|
|
if (value != stored) |
|
|
|
{ |
|
|
|
if (value) |
|
|
|
layout.showedSidePanel |= SidePanel.DebugView2; |
|
|
|
else |
|
|
|
layout.showedSidePanel &= ~SidePanel.DebugView2; |
|
|
|
ApplySidePanelChange(layout.showedSidePanel); |
|
|
|
|
|
|
|
bool debugOneOfViewSidePanel |
|
|
|
=> (layout.showedSidePanel & SidePanel.DebugViewBoth) != 0; |
|
|
|
|
|
|
|
event Action<Layout, SidePanel> OnLayoutChangedInternal; |
|
|
|
event Action<Layout, SidePanel> IViewDisplayer.OnLayoutChanged |
|
|
|
|
|
|
remove => OnClosedInternal -= value; |
|
|
|
} |
|
|
|
|
|
|
|
//event Action<UnityEngine.Object> OnAddingEnvironmentInternal;
|
|
|
|
//event Action<UnityEngine.Object> IEnvironmentDisplayer.OnAddingEnvironment
|
|
|
|
//{
|
|
|
|
// add => OnAddingEnvironmentInternal += value;
|
|
|
|
// remove => OnAddingEnvironmentInternal -= value;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//event Action<int> OnRemovingEnvironmentInternal;
|
|
|
|
//event Action<int> IEnvironmentDisplayer.OnRemovingEnvironment
|
|
|
|
//{
|
|
|
|
// add => OnRemovingEnvironmentInternal += value;
|
|
|
|
// remove => OnRemovingEnvironmentInternal -= value;
|
|
|
|
//}
|
|
|
|
|
|
|
|
event Action<EnvironmentLibrary> OnChangingEnvironmentLibraryInternal; |
|
|
|
event Action<EnvironmentLibrary> IEnvironmentDisplayer.OnChangingEnvironmentLibrary |
|
|
|
{ |
|
|
|
add => OnChangingEnvironmentLibraryInternal += value; |
|
|
|
remove => OnChangingEnvironmentLibraryInternal -= value; |
|
|
|
} |
|
|
|
|
|
|
|
event Action OnUpdateRequestedInternal; |
|
|
|
event Action IViewDisplayer.OnUpdateRequested |
|
|
|
{ |
|
|
|
|
|
|
if (!LookDev.open) |
|
|
|
LookDev.Open(); |
|
|
|
|
|
|
|
titleContent = Style.WindowTitleAndIcon; |
|
|
|
titleContent = Style.k_WindowTitleAndIcon; |
|
|
|
|
|
|
|
rootVisualElement.styleSheets.Add( |
|
|
|
AssetDatabase.LoadAssetAtPath<StyleSheet>(Style.k_uss)); |
|
|
|
|
|
|
|
|
|
|
CreateToolbar(); |
|
|
|
|
|
|
|
m_MainContainer = new VisualElement() { name = k_MainContainerName }; |
|
|
|
m_MainContainer.AddToClassList(k_SharedContainerClass); |
|
|
|
m_MainContainer = new VisualElement() { name = Style.k_MainContainerName }; |
|
|
|
m_MainContainer.AddToClassList(Style.k_SharedContainerClass); |
|
|
|
rootVisualElement.Add(m_MainContainer); |
|
|
|
|
|
|
|
CreateViews(); |
|
|
|
|
|
|
|
|
|
|
ApplyLayout(layout); |
|
|
|
ApplySidePanelChange(sidePanel); |
|
|
|
ApplyLayout(viewLayout); |
|
|
|
ApplySidePanelChange(layout.showedSidePanel); |
|
|
|
} |
|
|
|
|
|
|
|
void OnDisable() => OnClosedInternal?.Invoke(); |
|
|
|
|
|
|
// Layout swapper part
|
|
|
|
var layoutRadio = new ToolbarRadio() { name = k_ToolbarRadioName }; |
|
|
|
var layoutRadio = new ToolbarRadio() { name = Style.k_ToolbarRadioName }; |
|
|
|
CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Layout1", forceLowRes: true), |
|
|
|
CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Layout2", forceLowRes: true), |
|
|
|
CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_LayoutVertical", forceLowRes: true), |
|
|
|
CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_LayoutHorizontal", forceLowRes: true), |
|
|
|
CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_LayoutCustom", forceLowRes: true) |
|
|
|
Style.k_Layout1Icon, |
|
|
|
Style.k_Layout2Icon, |
|
|
|
Style.k_LayoutVerticalIcon, |
|
|
|
Style.k_LayoutHorizontalIcon, |
|
|
|
Style.k_LayoutStackIcon, |
|
|
|
=> layout = (Layout)evt.newValue); |
|
|
|
layoutRadio.SetValueWithoutNotify((int)layout); |
|
|
|
=> viewLayout = (Layout)evt.newValue); |
|
|
|
layoutRadio.SetValueWithoutNotify((int)viewLayout); |
|
|
|
var cameraMenu = new ToolbarMenu() { name = "cameraMenu" }; |
|
|
|
var cameraMenu = new ToolbarMenu() { name = Style.k_CameraMenuName }; |
|
|
|
var cameraToggle = new ToolbarToggle() { name = "cameraButton" }; |
|
|
|
var cameraToggle = new ToolbarToggle() { name = Style.k_CameraButtonName }; |
|
|
|
cameraToggle.value = LookDev.currentContext.cameraSynced; |
|
|
|
|
|
|
|
//Note: when having Image on top of the Toggle nested in the Menu, RegisterValueChangedCallback is not called
|
|
|
|
|
|
|
cameraToggle.SetValueWithoutNotify(LookDev.currentContext.cameraSynced); |
|
|
|
}); |
|
|
|
|
|
|
|
var cameraSeparator = new ToolbarToggle() { name = "cameraSeparator" }; |
|
|
|
var texCamera1 = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Camera1", forceLowRes: true); |
|
|
|
var texCamera2 = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Camera2", forceLowRes: true); |
|
|
|
var texLink = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Link", forceLowRes: true); |
|
|
|
var texRight = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Right", forceLowRes: true); |
|
|
|
var texLeft = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_Left", forceLowRes: true); |
|
|
|
cameraToggle.Add(new Image() { image = texCamera1 }); |
|
|
|
cameraToggle.Add(new Image() { image = texLink }); |
|
|
|
cameraToggle.Add(new Image() { image = texCamera2 }); |
|
|
|
var cameraSeparator = new ToolbarToggle() { name = Style.k_CameraSeparatorName }; |
|
|
|
cameraToggle.Add(new Image() { image = Style.k_Camera1Icon }); |
|
|
|
cameraToggle.Add(new Image() { image = Style.k_LinkIcon }); |
|
|
|
cameraToggle.Add(new Image() { image = Style.k_Camera2Icon }); |
|
|
|
cameraMenu.menu.AppendAction("Align Camera 1 with Camera 2", |
|
|
|
cameraMenu.menu.AppendAction(Style.k_CameraMenuSync1On2, |
|
|
|
cameraMenu.menu.AppendAction("Align Camera 2 with Camera 1", |
|
|
|
cameraMenu.menu.AppendAction(Style.k_CameraMenuSync2On1, |
|
|
|
cameraMenu.menu.AppendAction("Reset Cameras", |
|
|
|
cameraMenu.menu.AppendAction(Style.k_CameraMenuReset, |
|
|
|
(DropdownMenuAction a) => |
|
|
|
{ |
|
|
|
LookDev.currentContext.GetViewContent(ViewIndex.First).ResetCameraState(); |
|
|
|
|
|
|
|
|
|
|
// Side part
|
|
|
|
var sideRadio = new ToolbarRadio(canDeselectAll: true) { name = k_TabsRadioName }; |
|
|
|
sideRadio.AddRadios(new[] { |
|
|
|
"Environment", |
|
|
|
"Debug" |
|
|
|
}); |
|
|
|
sideRadio.RegisterCallback((ChangeEvent<int> evt) => |
|
|
|
var sideEnvironmentToggle = new ToolbarToggle() |
|
|
|
{ |
|
|
|
text = Style.k_EnvironmentSidePanelName, |
|
|
|
name = Style.k_TabsRadioName |
|
|
|
}; |
|
|
|
sideEnvironmentToggle.SetValueWithoutNotify(environmentSidePanel); |
|
|
|
sideEnvironmentToggle.RegisterCallback((ChangeEvent<bool> evt) |
|
|
|
=> environmentSidePanel = evt.newValue); |
|
|
|
|
|
|
|
var sideDebugToggleView1 = new ToolbarToggle() |
|
|
|
{ |
|
|
|
name = Style.k_TabsRadioName |
|
|
|
}; |
|
|
|
var sideDebugToggleView1Container = sideDebugToggleView1.Q(className:"unity-toggle__input"); |
|
|
|
sideDebugToggleView1Container.Add(new Label(Style.k_DebugSidePanelName)); |
|
|
|
sideDebugToggleView1Container.Add(new Image() { image = Style.k_Camera1Icon }); |
|
|
|
sideDebugToggleView1.SetValueWithoutNotify(debugView1SidePanel); |
|
|
|
sideDebugToggleView1.RegisterCallback((ChangeEvent<bool> evt) |
|
|
|
=> debugView1SidePanel = evt.newValue); |
|
|
|
|
|
|
|
var sideDebugToggleView2 = new ToolbarToggle() |
|
|
|
sidePanel = (SidePanel)evt.newValue; |
|
|
|
if (sidePanel == SidePanel.Debug) |
|
|
|
RefreshDebugViews(); |
|
|
|
}); |
|
|
|
sideRadio.SetValueWithoutNotify((int)sidePanel); |
|
|
|
name = Style.k_TabsRadioName |
|
|
|
}; |
|
|
|
var sideDebugToggleView2Container = sideDebugToggleView2.Q(className: "unity-toggle__input"); |
|
|
|
sideDebugToggleView2Container.Add(new Label(Style.k_DebugSidePanelName)); |
|
|
|
sideDebugToggleView2Container.Add(new Image() { image = Style.k_Camera2Icon }); |
|
|
|
sideDebugToggleView2.SetValueWithoutNotify(debugView2SidePanel); |
|
|
|
sideDebugToggleView2.RegisterCallback((ChangeEvent<bool> evt) |
|
|
|
=> debugView2SidePanel = evt.newValue); |
|
|
|
var sideToolbar = new Toolbar() { name = k_SideToolbarName }; |
|
|
|
sideToolbar.Add(sideRadio); |
|
|
|
var sideToolbar = new Toolbar() { name = Style.k_SideToolbarName }; |
|
|
|
sideToolbar.Add(sideEnvironmentToggle); |
|
|
|
sideToolbar.Add(sideDebugToggleView1); |
|
|
|
sideToolbar.Add(sideDebugToggleView2); |
|
|
|
var toolbar = new Toolbar() { name = k_ToolbarName }; |
|
|
|
var toolbar = new Toolbar() { name = Style.k_ToolbarName }; |
|
|
|
toolbar.Add(layoutRadio); |
|
|
|
toolbar.Add(new ToolbarSpacer()); |
|
|
|
toolbar.Add(cameraMenu); |
|
|
|
|
|
|
{ |
|
|
|
var renderDocButton = new ToolbarButton(() => OnRenderDocAcquisitionTriggeredInternal?.Invoke()) |
|
|
|
{ |
|
|
|
name = "renderdoc-content" |
|
|
|
name = Style.k_RenderDocContentName |
|
|
|
renderDocButton.Add(new Image() |
|
|
|
{ |
|
|
|
image = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "renderdoc", forceLowRes: true) |
|
|
|
}); |
|
|
|
renderDocButton.Add(new Label() { text = " Content" }); |
|
|
|
renderDocButton.Add(new Image() { image = Style.k_RenderdocIcon }); |
|
|
|
renderDocButton.Add(new Label() { text = Style.k_RenderDocLabel }); |
|
|
|
toolbar.Add(new ToolbarSpacer()); |
|
|
|
} |
|
|
|
toolbar.Add(sideToolbar); |
|
|
|
rootVisualElement.Add(toolbar); |
|
|
|
|
|
|
if (m_MainContainer == null || m_MainContainer.Equals(null)) |
|
|
|
throw new System.MemberAccessException("m_MainContainer should be assigned prior CreateViews()"); |
|
|
|
|
|
|
|
m_ViewContainer = new VisualElement() { name = k_ViewContainerName }; |
|
|
|
m_ViewContainer.AddToClassList(LookDev.currentContext.layout.isMultiView ? k_SecondViewsClass : k_FirstViewClass); |
|
|
|
m_ViewContainer.AddToClassList(k_SharedContainerClass); |
|
|
|
m_ViewContainer = new VisualElement() { name = Style.k_ViewContainerName }; |
|
|
|
m_ViewContainer.AddToClassList(LookDev.currentContext.layout.isMultiView ? Style.k_SecondViewsClass : Style.k_FirstViewClass); |
|
|
|
m_ViewContainer.AddToClassList(Style.k_SharedContainerClass); |
|
|
|
m_Views[(int)ViewIndex.First] = new Image() { name = k_FirstViewName, image = Texture2D.blackTexture }; |
|
|
|
m_Views[(int)ViewIndex.First] = new Image() { name = Style.k_FirstViewName, image = Texture2D.blackTexture }; |
|
|
|
m_Views[(int)ViewIndex.Second] = new Image() { name = k_SecondViewName, image = Texture2D.blackTexture }; |
|
|
|
m_Views[(int)ViewIndex.Second] = new Image() { name = Style.k_SecondViewName, image = Texture2D.blackTexture }; |
|
|
|
m_ViewContainer.Add(m_Views[(int)ViewIndex.Second]); |
|
|
|
|
|
|
|
var firstOrCompositeManipulator = new SwitchableCameraController( |
|
|
|
|
|
|
{ |
|
|
|
LookDev.currentContext.SetFocusedCamera(index); |
|
|
|
var environment = LookDev.currentContext.GetViewContent(index).environment; |
|
|
|
if (sidePanel == SidePanel.Environment && environment != null) |
|
|
|
if (environmentSidePanel && environment != null) |
|
|
|
m_EnvironmentList.selectedIndex = LookDev.currentContext.environmentLibrary.IndexOf(environment); |
|
|
|
}); |
|
|
|
var secondManipulator = new CameraController( |
|
|
|
|
|
|
{ |
|
|
|
LookDev.currentContext.SetFocusedCamera(ViewIndex.Second); |
|
|
|
var environment = LookDev.currentContext.GetViewContent(ViewIndex.Second).environment; |
|
|
|
if (sidePanel == SidePanel.Environment && environment != null) |
|
|
|
if (environmentSidePanel && environment != null) |
|
|
|
m_EnvironmentList.selectedIndex = LookDev.currentContext.environmentLibrary.IndexOf(environment); |
|
|
|
}); |
|
|
|
var gizmoManipulator = new ComparisonGizmoController(LookDev.currentContext.layout.gizmoState, firstOrCompositeManipulator); |
|
|
|
|
|
|
|
|
|
|
m_NoObject1 = new Label("Drag'n'drop object here"); |
|
|
|
m_NoObject1 = new Label(Style.k_DragAndDropObject); |
|
|
|
m_NoObject2 = new Label("Drag'n'drop object here"); |
|
|
|
m_NoObject2 = new Label(Style.k_DragAndDropObject); |
|
|
|
m_NoEnvironment1 = new Label("Drag'n'drop environment from side panel here"); |
|
|
|
m_NoEnvironment1 = new Label(Style.k_DragAndDropEnvironment); |
|
|
|
m_NoEnvironment2 = new Label("Drag'n'drop environment from side panel here"); |
|
|
|
m_NoEnvironment2 = new Label(Style.k_DragAndDropEnvironment); |
|
|
|
m_NoEnvironment2.style.flexGrow = 1; |
|
|
|
m_NoEnvironment2.style.unityTextAlign = TextAnchor.MiddleCenter; |
|
|
|
m_Views[(int)ViewIndex.First].Add(m_NoObject1); |
|
|
|
|
|
|
// GameObject or Prefab in view
|
|
|
|
new DropArea(new[] { typeof(GameObject) }, m_Views[(int)ViewIndex.First], (obj, localPos) => |
|
|
|
{ |
|
|
|
if (layout == Layout.CustomSplit) |
|
|
|
if (viewLayout == Layout.CustomSplit) |
|
|
|
OnChangingObjectInViewInternal?.Invoke(obj as GameObject, ViewCompositionIndex.Composite, localPos); |
|
|
|
else |
|
|
|
OnChangingObjectInViewInternal?.Invoke(obj as GameObject, ViewCompositionIndex.First, localPos); |
|
|
|
|
|
|
// Environment in view
|
|
|
|
new DropArea(new[] { typeof(Environment), typeof(Cubemap) }, m_Views[(int)ViewIndex.First], (obj, localPos) => |
|
|
|
{ |
|
|
|
if (layout == Layout.CustomSplit) |
|
|
|
if (viewLayout == Layout.CustomSplit) |
|
|
|
OnChangingEnvironmentInViewInternal?.Invoke(obj, ViewCompositionIndex.Composite, localPos); |
|
|
|
else |
|
|
|
OnChangingEnvironmentInViewInternal?.Invoke(obj, ViewCompositionIndex.First, localPos); |
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void CreateDebug() |
|
|
|
{ |
|
|
|
if (m_MainContainer == null || m_MainContainer.Equals(null)) |
|
|
|
throw new System.MemberAccessException("m_MainContainer should be assigned prior CreateEnvironment()"); |
|
|
|
|
|
|
|
m_DebugContainer = new VisualElement() { name = k_DebugContainerName }; |
|
|
|
m_MainContainer.Add(m_DebugContainer); |
|
|
|
if (sidePanel == SidePanel.Debug) |
|
|
|
m_MainContainer.AddToClassList(k_ShowDebugPanelClass); |
|
|
|
|
|
|
|
|
|
|
|
//[TODO: finish]
|
|
|
|
//Toggle greyBalls = new Toggle("Grey balls");
|
|
|
|
//greyBalls.SetValueWithoutNotify(LookDev.currentContext.GetViewContent(LookDev.currentContext.layout.lastFocusedView).debug.greyBalls);
|
|
|
|
//greyBalls.RegisterValueChangedCallback(evt =>
|
|
|
|
//{
|
|
|
|
// LookDev.currentContext.GetViewContent(LookDev.currentContext.layout.lastFocusedView).debug.greyBalls = evt.newValue;
|
|
|
|
//});
|
|
|
|
//m_DebugContainer.Add(greyBalls);
|
|
|
|
|
|
|
|
//[TODO: debug why list sometimes empty on resource reloading]
|
|
|
|
//[TODO: display only per view]
|
|
|
|
|
|
|
|
RefreshDebugViews(); |
|
|
|
} |
|
|
|
|
|
|
|
void RefreshDebugViews() |
|
|
|
{ |
|
|
|
if (m_DebugView != null && m_DebugContainer.Contains(m_DebugView)) |
|
|
|
m_DebugContainer.Remove(m_DebugView); |
|
|
|
|
|
|
|
List<string> list = new List<string>(LookDev.dataProvider?.supportedDebugModes ?? Enumerable.Empty<string>()); |
|
|
|
list.Insert(0, "None"); |
|
|
|
m_DebugView = new PopupField<string>("Debug view mode", list, 0); |
|
|
|
m_DebugView.RegisterValueChangedCallback(evt |
|
|
|
=> LookDev.dataProvider.UpdateDebugMode(list.IndexOf(evt.newValue) - 1)); |
|
|
|
m_DebugContainer.Add(m_DebugView); |
|
|
|
} |
|
|
|
|
|
|
|
static int FirstVisibleIndex(ListView listView) |
|
|
|
=> (int)(listView.Q<ScrollView>().scrollOffset.y / listView.itemHeight); |
|
|
|
|
|
|
|
void CreateEnvironment() |
|
|
|
{ |
|
|
|
if (m_MainContainer == null || m_MainContainer.Equals(null)) |
|
|
|
throw new System.MemberAccessException("m_MainContainer should be assigned prior CreateEnvironment()"); |
|
|
|
|
|
|
|
m_EnvironmentContainer = new VisualElement() { name = k_EnvironmentContainerName }; |
|
|
|
m_MainContainer.Add(m_EnvironmentContainer); |
|
|
|
if (sidePanel == SidePanel.Environment) |
|
|
|
m_MainContainer.AddToClassList(k_ShowEnvironmentPanelClass); |
|
|
|
|
|
|
|
m_EnvironmentInspector = new EnvironmentElement(withPreview: false, () => |
|
|
|
{ |
|
|
|
LookDev.SaveContextChangeAndApply(ViewIndex.First); |
|
|
|
LookDev.SaveContextChangeAndApply(ViewIndex.Second); |
|
|
|
}); |
|
|
|
m_EnvironmentList = new ListView(); |
|
|
|
m_EnvironmentList.AddToClassList("list-environment"); |
|
|
|
m_EnvironmentList.selectionType = SelectionType.Single; |
|
|
|
m_EnvironmentList.itemHeight = EnvironmentElement.k_SkyThumbnailHeight; |
|
|
|
m_EnvironmentList.makeItem = () => |
|
|
|
{ |
|
|
|
var preview = new Image(); |
|
|
|
preview.AddManipulator(new EnvironmentPreviewDragger(this, m_ViewContainer)); |
|
|
|
return preview; |
|
|
|
}; |
|
|
|
m_EnvironmentList.bindItem = (e, i) => |
|
|
|
{ |
|
|
|
(e as Image).image = EnvironmentElement.GetLatLongThumbnailTexture( |
|
|
|
LookDev.currentContext.environmentLibrary[i], |
|
|
|
EnvironmentElement.k_SkyThumbnailWidth); |
|
|
|
}; |
|
|
|
m_EnvironmentList.onSelectionChanged += objects => |
|
|
|
{ |
|
|
|
if (objects.Count == 0 || (LookDev.currentContext.environmentLibrary?.Count ?? 0) == 0) |
|
|
|
{ |
|
|
|
m_EnvironmentInspector.style.visibility = Visibility.Hidden; |
|
|
|
m_EnvironmentInspector.style.height = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_EnvironmentInspector.style.visibility = Visibility.Visible; |
|
|
|
m_EnvironmentInspector.style.height = new StyleLength(StyleKeyword.Auto); |
|
|
|
int firstVisibleIndex = FirstVisibleIndex(m_EnvironmentList); |
|
|
|
Environment environment = LookDev.currentContext.environmentLibrary[m_EnvironmentList.selectedIndex]; |
|
|
|
var container = m_EnvironmentList.Q("unity-content-container"); |
|
|
|
if (m_EnvironmentList.selectedIndex - firstVisibleIndex >= container.childCount || m_EnvironmentList.selectedIndex < firstVisibleIndex) |
|
|
|
{ |
|
|
|
m_EnvironmentList.ScrollToItem(m_EnvironmentList.selectedIndex); |
|
|
|
firstVisibleIndex = FirstVisibleIndex(m_EnvironmentList); |
|
|
|
} |
|
|
|
Image deportedLatLong = container[m_EnvironmentList.selectedIndex - firstVisibleIndex] as Image; |
|
|
|
m_EnvironmentInspector.Bind(environment, deportedLatLong); |
|
|
|
} |
|
|
|
}; |
|
|
|
m_EnvironmentList.onItemChosen += obj => |
|
|
|
EditorGUIUtility.PingObject(LookDev.currentContext.environmentLibrary[(int)obj]); |
|
|
|
m_NoEnvironmentList = new Label("Drag'n'drop EnvironmentLibrary here"); |
|
|
|
m_NoEnvironmentList.style.flexGrow = 1; |
|
|
|
m_NoEnvironmentList.style.unityTextAlign = TextAnchor.MiddleCenter; |
|
|
|
m_EnvironmentContainer.Add(m_EnvironmentInspector); |
|
|
|
|
|
|
|
m_EnvironmentListToolbar = new Toolbar(); |
|
|
|
ToolbarButton addEnvironment = new ToolbarButton(() => |
|
|
|
{ |
|
|
|
LookDev.currentContext.environmentLibrary.Add(); |
|
|
|
RefreshLibraryDisplay(); |
|
|
|
m_EnvironmentList.ScrollToItem(-1); //-1: scroll to end
|
|
|
|
m_EnvironmentList.selectedIndex = LookDev.currentContext.environmentLibrary.Count - 1; |
|
|
|
ScrollToEnd(); |
|
|
|
}) |
|
|
|
{ |
|
|
|
name = "add", |
|
|
|
tooltip = "Add new empty environment" |
|
|
|
}; |
|
|
|
addEnvironment.Add(new Image() { image = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_EnvironmentAdd", forceLowRes: true) }); |
|
|
|
ToolbarButton removeEnvironment = new ToolbarButton(() => |
|
|
|
{ |
|
|
|
if (m_EnvironmentList.selectedIndex == -1) |
|
|
|
return; |
|
|
|
LookDev.currentContext.environmentLibrary.Remove(m_EnvironmentList.selectedIndex); |
|
|
|
RefreshLibraryDisplay(); |
|
|
|
m_EnvironmentList.selectedIndex = -1; |
|
|
|
}) |
|
|
|
{ |
|
|
|
name = "remove", |
|
|
|
tooltip = "Remove environment currently selected" |
|
|
|
}; |
|
|
|
removeEnvironment.Add(new Image() { image = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_EnvironmentDelete", forceLowRes: true) }); |
|
|
|
ToolbarButton duplicateEnvironment = new ToolbarButton(() => |
|
|
|
{ |
|
|
|
if (m_EnvironmentList.selectedIndex == -1) |
|
|
|
return; |
|
|
|
LookDev.currentContext.environmentLibrary.Duplicate(m_EnvironmentList.selectedIndex); |
|
|
|
RefreshLibraryDisplay(); |
|
|
|
m_EnvironmentList.ScrollToItem(-1); //-1: scroll to end
|
|
|
|
m_EnvironmentList.selectedIndex = LookDev.currentContext.environmentLibrary.Count - 1; |
|
|
|
ScrollToEnd(); |
|
|
|
}) |
|
|
|
{ |
|
|
|
name = "duplicate", |
|
|
|
tooltip = "Duplicate environment currently selected" |
|
|
|
}; |
|
|
|
duplicateEnvironment.Add(new Image() { image = CoreEditorUtils.LoadIcon(Style.k_IconFolder, "LookDev_EnvironmentDuplicate", forceLowRes: true) }); |
|
|
|
m_EnvironmentListToolbar.Add(addEnvironment); |
|
|
|
m_EnvironmentListToolbar.Add(removeEnvironment); |
|
|
|
m_EnvironmentListToolbar.Add(duplicateEnvironment); |
|
|
|
m_EnvironmentListToolbar.AddToClassList("list-environment-overlay"); |
|
|
|
|
|
|
|
var m_EnvironmentInspectorSeparator = new VisualElement() { name = "separator-line" }; |
|
|
|
m_EnvironmentInspectorSeparator.Add(new VisualElement() { name = "separator" }); |
|
|
|
m_EnvironmentContainer.Add(m_EnvironmentInspectorSeparator); |
|
|
|
|
|
|
|
VisualElement listContainer = new VisualElement(); |
|
|
|
listContainer.AddToClassList("list-environment"); |
|
|
|
listContainer.Add(m_EnvironmentList); |
|
|
|
listContainer.Add(m_EnvironmentListToolbar); |
|
|
|
|
|
|
|
var environmentListCreationToolbar = new Toolbar() |
|
|
|
{ |
|
|
|
name = "environmentListCreationToolbar" |
|
|
|
}; |
|
|
|
environmentListCreationToolbar.Add(new ToolbarButton(() |
|
|
|
=> EnvironmentLibraryCreator.Create()) |
|
|
|
{ |
|
|
|
text = "New Library", |
|
|
|
tooltip = "Create a new EnvironmentLibrary" |
|
|
|
}); |
|
|
|
environmentListCreationToolbar.Add(new ToolbarButton(() |
|
|
|
=> EnvironmentLibraryLoader.Load(RefreshLibraryDisplay)) |
|
|
|
{ |
|
|
|
text = "Load Library", |
|
|
|
tooltip = "Load an existing EnvironmentLibrary" |
|
|
|
}); |
|
|
|
|
|
|
|
m_EnvironmentContainer.Add(listContainer); |
|
|
|
m_EnvironmentContainer.Add(m_NoEnvironmentList); |
|
|
|
m_EnvironmentContainer.Add(environmentListCreationToolbar); |
|
|
|
|
|
|
|
//add ability to unselect
|
|
|
|
m_EnvironmentList.RegisterCallback<MouseDownEvent>(evt => |
|
|
|
{ |
|
|
|
var clickedIndex = (int)(evt.localMousePosition.y / m_EnvironmentList.itemHeight); |
|
|
|
if (clickedIndex >= m_EnvironmentList.itemsSource.Count) |
|
|
|
{ |
|
|
|
m_EnvironmentList.selectedIndex = -1; |
|
|
|
evt.StopPropagation(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
RefreshLibraryDisplay(); |
|
|
|
} |
|
|
|
|
|
|
|
//necessary as the scrollview need to be updated which take some editor frames.
|
|
|
|
void ScrollToEnd(int attemptRemaining = 5) |
|
|
|
{ |
|
|
|
m_EnvironmentList.ScrollToItem(-1); //-1: scroll to end
|
|
|
|
if (attemptRemaining > 0) |
|
|
|
EditorApplication.delayCall += () => ScrollToEnd(--attemptRemaining); |
|
|
|
} |
|
|
|
|
|
|
|
void RefreshLibraryDisplay() |
|
|
|
{ |
|
|
|
int itemMax = LookDev.currentContext.environmentLibrary?.Count ?? 0; |
|
|
|
if (itemMax == 0 || m_EnvironmentList.selectedIndex == -1) |
|
|
|
{ |
|
|
|
m_EnvironmentInspector.style.visibility = Visibility.Hidden; |
|
|
|
m_EnvironmentInspector.style.height = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_EnvironmentInspector.style.visibility = Visibility.Visible; |
|
|
|
m_EnvironmentInspector.style.height = new StyleLength(StyleKeyword.Auto); |
|
|
|
} |
|
|
|
var items = new List<int>(itemMax); |
|
|
|
for (int i = 0; i < itemMax; i++) |
|
|
|
items.Add(i); |
|
|
|
m_EnvironmentList.itemsSource = items; |
|
|
|
if (LookDev.currentContext.environmentLibrary == null) |
|
|
|
{ |
|
|
|
m_EnvironmentList |
|
|
|
.Q(className: "unity-scroll-view__vertical-scroller") |
|
|
|
.Q("unity-dragger") |
|
|
|
.style.visibility = Visibility.Hidden; |
|
|
|
m_EnvironmentListToolbar.style.visibility = Visibility.Hidden; |
|
|
|
m_NoEnvironmentList.style.display = DisplayStyle.Flex; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_EnvironmentList |
|
|
|
.Q(className: "unity-scroll-view__vertical-scroller") |
|
|
|
.Q("unity-dragger") |
|
|
|
.style.visibility = itemMax == 0 |
|
|
|
? Visibility.Hidden |
|
|
|
: Visibility.Visible; |
|
|
|
m_EnvironmentListToolbar.style.visibility = Visibility.Visible; |
|
|
|
m_NoEnvironmentList.style.display = DisplayStyle.None; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DraggingContext StartDragging(VisualElement item, Vector2 worldPosition) |
|
|
|
=> new DraggingContext( |
|
|
|
rootVisualElement, |
|
|
|
item as Image, |
|
|
|
//note: this even can come before the selection event of the
|
|
|
|
//ListView. Reconstruct index by looking at target of the event.
|
|
|
|
(int)item.layout.y / m_EnvironmentList.itemHeight, |
|
|
|
worldPosition); |
|
|
|
|
|
|
|
void EndDragging(DraggingContext context, Vector2 mouseWorldPosition) |
|
|
|
{ |
|
|
|
Environment environment = LookDev.currentContext.environmentLibrary[context.draggedIndex]; |
|
|
|
if (m_Views[(int)ViewIndex.First].ContainsPoint(mouseWorldPosition)) |
|
|
|
{ |
|
|
|
if (layout == Layout.CustomSplit) |
|
|
|
OnChangingEnvironmentInViewInternal?.Invoke(environment, ViewCompositionIndex.Composite, mouseWorldPosition); |
|
|
|
else |
|
|
|
OnChangingEnvironmentInViewInternal?.Invoke(environment, ViewCompositionIndex.First, mouseWorldPosition); |
|
|
|
} |
|
|
|
else |
|
|
|
OnChangingEnvironmentInViewInternal?.Invoke(environment, ViewCompositionIndex.Second, mouseWorldPosition); |
|
|
|
} |
|
|
|
|
|
|
|
class DraggingContext : IDisposable |
|
|
|
{ |
|
|
|
const string k_CursorFollowerName = "cursorFollower"; |
|
|
|
public readonly int draggedIndex; |
|
|
|
readonly Image cursorFollower; |
|
|
|
readonly Vector2 cursorOffset; |
|
|
|
readonly VisualElement windowContent; |
|
|
|
|
|
|
|
public DraggingContext(VisualElement windowContent, Image draggedElement, int draggedIndex, Vector2 worldPosition) |
|
|
|
{ |
|
|
|
this.windowContent = windowContent; |
|
|
|
this.draggedIndex = draggedIndex; |
|
|
|
cursorFollower = new Image() |
|
|
|
{ |
|
|
|
name = k_CursorFollowerName, |
|
|
|
image = draggedElement.image |
|
|
|
}; |
|
|
|
cursorFollower.tintColor = new Color(1f, 1f, 1f, .5f); |
|
|
|
windowContent.Add(cursorFollower); |
|
|
|
cursorOffset = draggedElement.WorldToLocal(worldPosition); |
|
|
|
|
|
|
|
cursorFollower.style.position = Position.Absolute; |
|
|
|
UpdateCursorFollower(worldPosition); |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateCursorFollower(Vector2 mouseWorldPosition) |
|
|
|
{ |
|
|
|
Vector2 windowLocalPosition = windowContent.WorldToLocal(mouseWorldPosition); |
|
|
|
cursorFollower.style.left = windowLocalPosition.x - cursorOffset.x; |
|
|
|
cursorFollower.style.top = windowLocalPosition.y - cursorOffset.y; |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
if (windowContent.Contains(cursorFollower)) |
|
|
|
windowContent.Remove(cursorFollower); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class EnvironmentPreviewDragger : Manipulator |
|
|
|
{ |
|
|
|
VisualElement m_DropArea; |
|
|
|
DisplayWindow m_Window; |
|
|
|
|
|
|
|
//Note: static as only one drag'n'drop at a time
|
|
|
|
static DraggingContext s_Context; |
|
|
|
|
|
|
|
public EnvironmentPreviewDragger(DisplayWindow window, VisualElement dropArea) |
|
|
|
{ |
|
|
|
m_Window = window; |
|
|
|
m_DropArea = dropArea; |
|
|
|
} |
|
|
|
|
|
|
|
protected override void RegisterCallbacksOnTarget() |
|
|
|
{ |
|
|
|
target.RegisterCallback<MouseDownEvent>(OnMouseDown); |
|
|
|
target.RegisterCallback<MouseUpEvent>(OnMouseUp); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void UnregisterCallbacksFromTarget() |
|
|
|
{ |
|
|
|
target.UnregisterCallback<MouseDownEvent>(OnMouseDown); |
|
|
|
target.UnregisterCallback<MouseUpEvent>(OnMouseUp); |
|
|
|
} |
|
|
|
|
|
|
|
void Release() |
|
|
|
{ |
|
|
|
target.UnregisterCallback<MouseMoveEvent>(OnMouseMove); |
|
|
|
s_Context.Dispose(); |
|
|
|
target.ReleaseMouse(); |
|
|
|
s_Context = null; |
|
|
|
} |
|
|
|
|
|
|
|
void OnMouseDown(MouseDownEvent evt) |
|
|
|
{ |
|
|
|
if (evt.button == 0) |
|
|
|
{ |
|
|
|
target.CaptureMouse(); |
|
|
|
target.RegisterCallback<MouseMoveEvent>(OnMouseMove); |
|
|
|
s_Context = m_Window.StartDragging(target, evt.mousePosition); |
|
|
|
//do not stop event as we still need to propagate it to the ListView for selection
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnMouseUp(MouseUpEvent evt) |
|
|
|
{ |
|
|
|
if (evt.button != 0) |
|
|
|
return; |
|
|
|
if (m_DropArea.ContainsPoint(m_DropArea.WorldToLocal(Event.current.mousePosition))) |
|
|
|
{ |
|
|
|
m_Window.EndDragging(s_Context, evt.mousePosition); |
|
|
|
evt.StopPropagation(); |
|
|
|
} |
|
|
|
Release(); |
|
|
|
} |
|
|
|
|
|
|
|
void OnMouseMove(MouseMoveEvent evt) |
|
|
|
{ |
|
|
|
evt.StopPropagation(); |
|
|
|
s_Context.UpdateCursorFollower(evt.mousePosition); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Rect IViewDisplayer.GetRect(ViewCompositionIndex index) |
|
|
|
{ |
|
|
|
switch (index) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void IViewDisplayer.Repaint() => Repaint(); |
|
|
|
|
|
|
|
void IEnvironmentDisplayer.Repaint() |
|
|
|
=> RefreshLibraryDisplay(); |
|
|
|
|
|
|
|
void ApplyLayout(Layout value) |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
case Layout.HorizontalSplit: |
|
|
|
case Layout.VerticalSplit: |
|
|
|
if (!m_ViewContainer.ClassListContains(k_FirstViewClass)) |
|
|
|
m_ViewContainer.AddToClassList(k_FirstViewClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(k_SecondViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(k_SecondViewsClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(Style.k_FirstViewClass)) |
|
|
|
m_ViewContainer.AddToClassList(Style.k_FirstViewClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(Style.k_SecondViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(Style.k_SecondViewsClass); |
|
|
|
m_ViewContainer.AddToClassList(k_VerticalViewsClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(k_VerticalViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(k_FirstViewClass); |
|
|
|
m_ViewContainer.AddToClassList(Style.k_VerticalViewsClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(Style.k_VerticalViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(Style.k_FirstViewClass); |
|
|
|
} |
|
|
|
for (int i = 0; i < 2; ++i) |
|
|
|
m_Views[i].style.display = DisplayStyle.Flex; |
|
|
|
|
|
|
if (!m_ViewContainer.ClassListContains(k_FirstViewClass)) |
|
|
|
m_ViewContainer.AddToClassList(k_FirstViewClass); |
|
|
|
if (m_ViewContainer.ClassListContains(k_SecondViewsClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(k_SecondViewsClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(Style.k_FirstViewClass)) |
|
|
|
m_ViewContainer.AddToClassList(Style.k_FirstViewClass); |
|
|
|
if (m_ViewContainer.ClassListContains(Style.k_SecondViewsClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(Style.k_SecondViewsClass); |
|
|
|
if (m_ViewContainer.ClassListContains(k_FirstViewClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(k_FirstViewClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(k_SecondViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(k_SecondViewsClass); |
|
|
|
if (m_ViewContainer.ClassListContains(Style.k_FirstViewClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(Style.k_FirstViewClass); |
|
|
|
if (!m_ViewContainer.ClassListContains(Style.k_SecondViewsClass)) |
|
|
|
m_ViewContainer.AddToClassList(Style.k_SecondViewsClass); |
|
|
|
m_Views[0].style.display = DisplayStyle.None; |
|
|
|
m_Views[1].style.display = DisplayStyle.Flex; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
//Add flex direction here
|
|
|
|
if (value == Layout.VerticalSplit) |
|
|
|
m_ViewContainer.AddToClassList(k_VerticalViewsClass); |
|
|
|
else if (m_ViewContainer.ClassListContains(k_VerticalViewsClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(k_VerticalViewsClass); |
|
|
|
m_ViewContainer.AddToClassList(Style.k_VerticalViewsClass); |
|
|
|
else if (m_ViewContainer.ClassListContains(Style.k_VerticalViewsClass)) |
|
|
|
m_ViewContainer.RemoveFromClassList(Style.k_VerticalViewsClass); |
|
|
|
switch (sidePanel) |
|
|
|
IStyle GetEnvironmentContenairDraggerStyle() |
|
|
|
=> m_EnvironmentContainer.Q(className: "unity-base-slider--vertical").Q("unity-dragger").style; |
|
|
|
|
|
|
|
if (environmentSidePanel) |
|
|
|
{ |
|
|
|
if (!m_MainContainer.ClassListContains(Style.k_ShowEnvironmentPanelClass)) |
|
|
|
m_MainContainer.AddToClassList(Style.k_ShowEnvironmentPanelClass); |
|
|
|
|
|
|
|
if (m_EnvironmentList.selectedIndex != -1) |
|
|
|
m_EnvironmentContainer.Q<EnvironmentElement>().style.visibility = Visibility.Visible; |
|
|
|
GetEnvironmentContenairDraggerStyle().display = DisplayStyle.Flex; |
|
|
|
m_EnvironmentContainer.style.display = DisplayStyle.Flex; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (m_MainContainer.ClassListContains(Style.k_ShowEnvironmentPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(Style.k_ShowEnvironmentPanelClass); |
|
|
|
|
|
|
|
m_EnvironmentContainer.Q<EnvironmentElement>().style.visibility = Visibility.Hidden; |
|
|
|
GetEnvironmentContenairDraggerStyle().display = DisplayStyle.None; |
|
|
|
m_EnvironmentContainer.style.display = DisplayStyle.None; |
|
|
|
} |
|
|
|
|
|
|
|
if (debugOneOfViewSidePanel) |
|
|
|
case SidePanel.None: |
|
|
|
if (m_MainContainer.ClassListContains(k_ShowEnvironmentPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(k_ShowEnvironmentPanelClass); |
|
|
|
if (m_MainContainer.ClassListContains(k_ShowDebugPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(k_ShowDebugPanelClass); |
|
|
|
m_EnvironmentContainer.Q<EnvironmentElement>().style.visibility = Visibility.Hidden; |
|
|
|
m_EnvironmentContainer.Q(className: "unity-base-slider--vertical").Q("unity-dragger").style.display = DisplayStyle.None; |
|
|
|
m_EnvironmentContainer.style.display = DisplayStyle.None; |
|
|
|
break; |
|
|
|
case SidePanel.Environment: |
|
|
|
if (!m_MainContainer.ClassListContains(k_ShowEnvironmentPanelClass)) |
|
|
|
m_MainContainer.AddToClassList(k_ShowEnvironmentPanelClass); |
|
|
|
if (m_MainContainer.ClassListContains(k_ShowDebugPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(k_ShowDebugPanelClass); |
|
|
|
if (m_EnvironmentList.selectedIndex != -1) |
|
|
|
m_EnvironmentContainer.Q<EnvironmentElement>().style.visibility = Visibility.Visible; |
|
|
|
m_EnvironmentContainer.Q(className: "unity-base-slider--vertical").Q("unity-dragger").style.display = DisplayStyle.Flex; |
|
|
|
m_EnvironmentContainer.style.display = DisplayStyle.Flex; |
|
|
|
break; |
|
|
|
case SidePanel.Debug: |
|
|
|
if (m_MainContainer.ClassListContains(k_ShowEnvironmentPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(k_ShowEnvironmentPanelClass); |
|
|
|
if (!m_MainContainer.ClassListContains(k_ShowDebugPanelClass)) |
|
|
|
m_MainContainer.AddToClassList(k_ShowDebugPanelClass); |
|
|
|
m_EnvironmentContainer.Q<EnvironmentElement>().style.visibility = Visibility.Hidden; |
|
|
|
m_EnvironmentContainer.Q(className: "unity-base-slider--vertical").Q("unity-dragger").style.display = DisplayStyle.None; |
|
|
|
m_EnvironmentContainer.style.display = DisplayStyle.None; |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new ArgumentException("Unknown SidePanel"); |
|
|
|
if (!m_MainContainer.ClassListContains(Style.k_ShowDebugPanelClass)) |
|
|
|
m_MainContainer.AddToClassList(Style.k_ShowDebugPanelClass); |
|
|
|
UpdateSideDebugPanelProperties(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (m_MainContainer.ClassListContains(Style.k_ShowDebugPanelClass)) |
|
|
|
m_MainContainer.RemoveFromClassList(Style.k_ShowDebugPanelClass); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|