public SnapshotFileData(FileInfo info) { FileInfo = info; using (var snapshot = LoadSnapshot()) { MetaData snapshotMetadata = snapshot.metadata; m_GuiData = new SnapshotFileGUIData(snapshot.recordDate); m_GuiData.name = new GUIContent(Path.GetFileNameWithoutExtension(FileInfo.Name)); m_GuiData.metaInfo = new GUIContent(snapshotMetadata.content); m_GuiData.platform = new GUIContent(snapshotMetadata.platform); RuntimePlatform runtimePlatform; if (TryGetRuntimePlatform(snapshotMetadata.platform, out runtimePlatform)) { m_GuiData.runtimePlatform = runtimePlatform; } m_GuiData.date = new GUIContent(m_GuiData.UtcDateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)); #pragma warning disable 618 m_GuiData.texture = snapshotMetadata.screenshot; #pragma warning restore 618 #if UNITY_2019_3_OR_NEWER RefreshScreenshot(); #endif } }
public SnapshotFileData(FileInfo info) { FileInfo = info; using (var snapshot = LoadSnapshot()) { MetaData snapshotMetadata = snapshot.metadata; var recordDate = snapshot.recordDate; recordDateTicks = recordDate.Ticks; m_GuiData = new SnapshotFileGUIData(recordDate); m_GuiData.name = new GUIContent(Path.GetFileNameWithoutExtension(FileInfo.Name)); m_GuiData.metaInfo = new GUIContent(snapshotMetadata.content); m_GuiData.platform = new GUIContent(snapshotMetadata.platform); RuntimePlatform runtimePlatform; if (TryGetRuntimePlatform(snapshotMetadata.platform, out runtimePlatform)) { m_GuiData.runtimePlatform = runtimePlatform; } m_GuiData.date = new GUIContent(m_GuiData.UtcDateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)); m_GuiData.guiTexture = new GUITexture2DAsset(); if (snapshotMetadata.screenshot != null) { m_GuiData.guiTexture.SetTexture(snapshotMetadata.screenshot, GUITexture2DAsset.SourceType.Snapshot, 0); } RefreshScreenshot(); } }
internal void RefreshScreenshots(SnapshotFileGUIData guiDataFirst, SnapshotFileGUIData guiDataSecond) { if (guiDataFirst != null && m_OpenSnapshotItemUIFirst != null && m_OpenSnapshotItemUIFirst.Image != null) { m_OpenSnapshotItemUIFirst.Image.image = guiDataFirst.texture; } if (guiDataSecond != null && m_OpenSnapshotItemUISecond != null && m_OpenSnapshotItemUISecond.Image != null) { m_OpenSnapshotItemUISecond.Image.image = guiDataSecond.texture; } }
internal void RefreshScreenshots() { SnapshotFileGUIData firstGUIData = null, secondGUIData = null; if (First != null) { First.RefreshScreenshot(); firstGUIData = First.GuiData; } if (Second != null) { Second.RefreshScreenshot(); secondGUIData = Second.GuiData; } m_OpenSnapshotsPane.RefreshScreenshots(firstGUIData, secondGUIData); }
internal void RefreshOpenSnapshots(SnapshotCollectionEnumerator snaps) { SnapshotFileGUIData firstGUIData = null, secondGUIData = null; snaps.Reset(); while (snaps.MoveNext()) { if (First == snaps.Current) { First = snaps.Current; firstGUIData = First.GuiData; firstGUIData.CurrentState = SnapshotFileGUIData.State.Open; } else if (Second == snaps.Current) { Second = snaps.Current; secondGUIData = Second.GuiData; secondGUIData.CurrentState = SnapshotFileGUIData.State.Open; } } m_OpenSnapshotsPane.RefreshScreenshots(firstGUIData, secondGUIData); }
internal void RefreshScreenshots(SnapshotFileGUIData guiDataFirst, SnapshotFileGUIData guiDataSecond) { if (m_OpenSnapshotItemUIFirst != null && m_OpenSnapshotItemUIFirst.Image != null) { var tex = Texture2D.blackTexture; if (guiDataFirst != null && guiDataFirst.guiTexture.Texture != null) { tex = guiDataFirst.guiTexture.Texture; } m_OpenSnapshotItemUIFirst.Image.image = tex; } if (m_OpenSnapshotItemUISecond != null && m_OpenSnapshotItemUISecond.Image != null) { var tex = Texture2D.blackTexture; if (guiDataSecond != null && guiDataSecond.guiTexture.Texture != null) { tex = guiDataSecond.guiTexture.Texture; } m_OpenSnapshotItemUISecond.Image.image = tex; } }
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); }