public void RenameSnapshot(SnapshotFileData snapshot, string name) { int nameStart = snapshot.FileInfo.FullName.LastIndexOf(snapshot.FileInfo.Name); string targetPath = snapshot.FileInfo.FullName.Substring(0, nameStart) + name + MemoryProfilerWindow.k_SnapshotFileExtension; if (targetPath == snapshot.FileInfo.FullName) { snapshot.GuiData.dynamicVisualElements.snapshotNameLabel.text = snapshot.GuiData.name.text; snapshot.GuiData.RenamingFieldVisible = false; return; } snapshot.GuiData.name = new GUIContent(name); snapshot.GuiData.dynamicVisualElements.snapshotNameLabel.text = name; snapshot.GuiData.RenamingFieldVisible = false; #if UNITY_2019_3_OR_NEWER if (snapshot.GuiData.texture != null) { string possibleSSPath = Path.ChangeExtension(snapshot.FileInfo.FullName, ".png"); if (File.Exists(possibleSSPath)) { File.Move(possibleSSPath, Path.ChangeExtension(targetPath, ".png")); } } #endif //move snapshot after screenshot snapshot.FileInfo.MoveTo(targetPath); m_Info.Refresh(); }
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); } }
void SwapOpenSnapshots() { var temp = Second; Second = First; First = temp; m_UIState.SwapLastAndCurrentSnapshot(); if (First != null) { m_OpenSnapshotsPane.SetSnapshotUIData(true, First.GuiData, m_UIState.CurrentViewMode == UIState.ViewMode.ShowFirst); } else { m_OpenSnapshotsPane.SetSnapshotUIData(true, null, false); } if (Second != null) { m_OpenSnapshotsPane.SetSnapshotUIData(false, Second.GuiData, m_UIState.CurrentViewMode == UIState.ViewMode.ShowSecond); } else { m_OpenSnapshotsPane.SetSnapshotUIData(false, null, false); } }
public void RemoveSnapshotFromCollection(SnapshotFileData snapshot) { snapshot.FileInfo.Delete(); m_Snapshots.Remove(snapshot); #if UNITY_2019_3_OR_NEWER string possibleSSPath = Path.ChangeExtension(snapshot.FileInfo.FullName, ".png"); if (File.Exists(possibleSSPath)) { File.Delete(possibleSSPath); } #endif m_Info.Refresh(); }
//void UpdateSnapshotCollectionUI() //{ // bool diffmode = Second != null; // bool oneSnapshotIsLoaded = !diffmode && First != null; // using (var enumerator = m_MemorySnapshotsCollection.GetEnumerator()) // { // while (enumerator.MoveNext()) // { // bool isFirst = enumerator.Current == First; // bool isSecond = enumerator.Current == Second; // bool currentSnapshotIsLoaded = isFirst || isSecond; // UIElementsHelper.SwitchVisibility(enumerator.Current.GuiData.dynamicVisualElements.closeButton, enumerator.Current.GuiData.dynamicVisualElements.openButton, currentSnapshotIsLoaded); // bool enableDiff = oneSnapshotIsLoaded && !currentSnapshotIsLoaded; // bool currentSnapshotIsInDiffMode = diffmode && currentSnapshotIsLoaded; // } // } //} public void CloseAllOpenSnapshots() { if (Second != null) { CloseCapture(Second); Second = null; } if (First != null) { CloseCapture(First); First = null; } }
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 bool IsSnapshotOpen(SnapshotFileData snapshot) { return(snapshot == First || snapshot == Second); }