void InitializeOpenSnapshotItem(VisualTreeAsset openSnapshotItemTree, Dictionary <string, VisualElement> openSnapshotItemSlots, VisualElement snapshotHolder, ref OpenSnapshotItemUI openSnapshotItemUI, Action openSnapshotHandler) { #if UNITY_2019_1_OR_NEWER var item = openSnapshotItemTree.CloneTree(); #else openSnapshotItemSlots.Clear(); var item = openSnapshotItemTree.CloneTree(openSnapshotItemSlots); #endif item.style.flexGrow = 1; snapshotHolder.Add(item); item.AddManipulator(new Clickable(openSnapshotHandler)); openSnapshotItemUI.Item = item; openSnapshotItemUI.Image = item.Q <Image>("previewImage", "previewImage"); openSnapshotItemUI.Image.scaleMode = ScaleMode.ScaleToFit; openSnapshotItemUI.PlatformIcon = item.Q <Image>("platformIcon", "platformIcon"); openSnapshotItemUI.EditorPlatformIcon = item.Q <Image>("editorIcon", "platformIcon"); openSnapshotItemUI.NoData = item.Q <Label>("noDataLoaded"); openSnapshotItemUI.Name = item.Q <Label>("snapshotName"); openSnapshotItemUI.Date = item.Q <Label>("snapshotDate"); openSnapshotItemUI.Age = item.Q <Label>("snapshotAge"); UIElementsHelper.SetVisibility(openSnapshotItemUI.PlatformIcon, false); UIElementsHelper.SetVisibility(openSnapshotItemUI.EditorPlatformIcon, false); UIElementsHelper.SetVisibility(openSnapshotItemUI.NoData, true); UIElementsHelper.SetVisibility(openSnapshotItemUI.Name, false); }
public void OpenSnapshot(SnapshotFileData snapshot) { if (First != null) { if (Second != null) { Second.GuiData.CurrentState = SnapshotFileGUIData.State.Closed; UIElementsHelper.SwitchVisibility(Second.GuiData.dynamicVisualElements.openButton, Second.GuiData.dynamicVisualElements.closeButton); } Second = First; m_OpenSnapshotsPane.SetSnapshotUIData(false, Second.GuiData, false); Second.GuiData.CurrentState = SnapshotFileGUIData.State.Open; } First = snapshot; m_OpenSnapshotsPane.SetSnapshotUIData(true, snapshot.GuiData, true); First.GuiData.CurrentState = SnapshotFileGUIData.State.InView; var loadedPackedSnapshot = snapshot.LoadSnapshot(); if (loadedPackedSnapshot != null) { m_UIState.SetFirstSnapshot(loadedPackedSnapshot); } }
public void CloseCapture(SnapshotFileData snapshot) { if (snapshot == null) { return; } try { if (Second != null) { if (snapshot == Second) { m_UIState.ClearSecondMode(); Second.GuiData.CurrentState = SnapshotFileGUIData.State.Closed; } else if (snapshot == First) { m_UIState.ClearFirstMode(); if (First != null) { First.GuiData.CurrentState = SnapshotFileGUIData.State.Closed; } First = Second; m_UIState.SwapLastAndCurrentSnapshot(); } else { // The snapshot wasn't open, there is nothing left todo here. return; } UIElementsHelper.SwitchVisibility(snapshot.GuiData.dynamicVisualElements.openButton, snapshot.GuiData.dynamicVisualElements.closeButton); Second = null; m_UIState.CurrentViewMode = UIState.ViewMode.ShowFirst; if (First != null) { m_OpenSnapshotsPane.SetSnapshotUIData(true, First.GuiData, true); } else { m_OpenSnapshotsPane.SetSnapshotUIData(true, null, true); } m_OpenSnapshotsPane.SetSnapshotUIData(false, null, false); // With two snapshots open, there could also be a diff to be closed/cleared. m_UIState.ClearDiffMode(); } else { if (snapshot == First) { First.GuiData.CurrentState = SnapshotFileGUIData.State.Closed; First = null; m_UIState.ClearAllOpenModes(); } else if (snapshot == Second) { Second.GuiData.CurrentState = SnapshotFileGUIData.State.Closed; Second = null; m_UIState.ClearAllOpenModes(); } else { // The snapshot wasn't open, there is nothing left todo here. return; } m_OpenSnapshotsPane.SetSnapshotUIData(true, null, false); m_OpenSnapshotsPane.SetSnapshotUIData(false, null, false); } UIElementsHelper.SwitchVisibility(snapshot.GuiData.dynamicVisualElements.openButton, snapshot.GuiData.dynamicVisualElements.closeButton); } catch (Exception) { throw; } }
public void SetSnapshotUIData(bool first, SnapshotFileGUIData snapshotGUIData, bool isInView) { OpenSnapshotItemUI itemUI = m_OpenSnapshotItemUIFirst; if (!first) { itemUI = m_OpenSnapshotItemUISecond; } if (snapshotGUIData == null) { UIElementsHelper.SwitchVisibility(itemUI.NoData, itemUI.Name); itemUI.Name.text = ""; itemUI.Date.text = ""; itemUI.Age.text = ""; itemUI.Image.image = null; UIElementsHelper.SetVisibility(itemUI.PlatformIcon, false); UIElementsHelper.SetVisibility(itemUI.EditorPlatformIcon, false); itemUI.UtcDateTime = default(DateTime); // one of both snapshots is not open so there is no Age comparison between them. m_OpenSnapshotItemUIFirst.Age.text = ""; m_OpenSnapshotItemUISecond.Age.text = ""; } else { UIElementsHelper.SwitchVisibility(itemUI.Name, itemUI.NoData); itemUI.Name.text = snapshotGUIData.Name.text; itemUI.Date.text = snapshotGUIData.SnapshotDate.text; itemUI.Image.image = snapshotGUIData.MetaScreenshot; UIElementsHelper.SetVisibility(itemUI.PlatformIcon, true); MemoryProfilerWindow.SetPlatformIcons(itemUI.Item, snapshotGUIData); UIElementsHelper.SwitchVisibility(snapshotGUIData.dynamicVisualElements.closeButton, snapshotGUIData.dynamicVisualElements.openButton, true); itemUI.UtcDateTime = snapshotGUIData.UtcDateTime; if (first && secondIsOpen || !first && firstIsOpen) { m_OpenSnapshotItemUIFirst.Age.text = GetAgeDifference(m_OpenSnapshotItemUIFirst.UtcDateTime, m_OpenSnapshotItemUISecond.UtcDateTime); m_OpenSnapshotItemUISecond.Age.text = GetAgeDifference(m_OpenSnapshotItemUISecond.UtcDateTime, m_OpenSnapshotItemUIFirst.UtcDateTime); } } if (first) { firstIsOpen = snapshotGUIData != null; } else { secondIsOpen = snapshotGUIData != null; } if (isInView) { SetFocusFirst(first); SetFocusSecond(!first); SetFocusDiff(false); } else { if (first) { SetFocusFirst(false); } else { SetFocusSecond(false); } } m_DiffButton.SetEnabled(firstIsOpen && secondIsOpen); UpdateWidth(layout.width); }