This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06657c386ba945c2a6e83c5e1d0f04d4
timeCreated: 1770026043
@@ -0,0 +1,220 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Diff;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Branch
{
internal class BranchPropertiesPanel
{
internal bool IsChangesetByChangesetModeForTesting
{
get { return mToolbarIndex == 1; }
set { mToolbarIndex = value ? 1 : 0; }
}
internal DiffPanel DiffPanel => mDiffPanel;
internal BranchPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
IRefreshView refreshView,
IAssetStatusCache assetStatusCache,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
IPendingChangesUpdater pendingChangesUpdater,
IIncomingChangesUpdater developerIncomingChangesUpdater,
IIncomingChangesUpdater gluonIncomingChangesUpdater,
EditorWindow parentWindow,
bool isGluonMode)
{
mRepaint = repaint;
mToolbarIndex = SessionState.GetInt(TOOLBAR_INDEX_KEY, defaultValue: 0);
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mDiffPanel = new DiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
mChangesetByChangesetDiffPanel = new ChangesetByChangesetDiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
}
internal void OnEnable()
{
mDiffPanel.OnEnable();
mChangesetByChangesetDiffPanel.OnEnable();
}
internal void OnDisable()
{
mDiffPanel.OnDisable();
mChangesetByChangesetDiffPanel.OnDisable();
}
internal void Update()
{
mDiffPanel.Update();
mPropertiesPanel.Update();
mChangesetByChangesetDiffPanel.Update();
}
internal void ResetForTesting()
{
ClearInfo();
mToolbarIndex = 0;
}
internal void ClearInfo()
{
mSelectedRepObjectInfoData = null;
mPropertiesPanel.ClearInfo();
mDiffPanel.ClearInfo();
mChangesetByChangesetDiffPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
BranchInfo selectedBranchInfo = (BranchInfo)selectedRepObjectInfoData.ObjectInfo;
if (mToolbarIndex == 1)
{
mChangesetByChangesetDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedBranchInfo);
}
else
{
mPropertiesPanel.UpdateInfo(selectedBranchInfo, selectedRepObjectInfoData.RepSpec);
mDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedBranchInfo);
}
}
internal void OnInspectorGUI()
{
if (mToolbarIndex == 1)
mChangesetByChangesetDiffPanel.OnGUI();
else
{
mDiffPanel.OnGUI();
}
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
DoDiffModeButtons();
DrawSeparator();
if (mToolbarIndex == 1)
{
EditorGUILayout.EndVertical();
return;
}
mPropertiesPanel.OnGUI();
DrawSeparator();
EditorGUILayout.EndVertical();
}
void DoDiffModeButtons()
{
EditorGUILayout.BeginVertical();
EditorGUILayout.Space(0.5f);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//GUI.enabled = !mProgressControls.IsOperationRunning();
int previousToolbarIndex = mToolbarIndex;
string[] options = new string[]
{
PlasticLocalization.Name.DiffEntireBranch.GetString(),
PlasticLocalization.Name.DiffByChangeset.GetString()
};
mToolbarIndex = GUILayout.Toolbar(
mToolbarIndex,
options,
UnityStyles.LargeButton,
GUI.ToolbarButtonSize.FitToContents);
GUILayout.FlexibleSpace();
//GUI.enabled = true;
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space(0.5f);
EditorGUILayout.EndVertical();
// If mode changed, update the panel with the currently selected branch
if (previousToolbarIndex != mToolbarIndex)
{
SessionState.SetInt(TOOLBAR_INDEX_KEY, mToolbarIndex);
SetSelectedObject(mSelectedRepObjectInfoData);
}
}
static void DrawSeparator()
{
Rect bottomSeparatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(bottomSeparatorRect, UnityStyles.Colors.BarBorder);
}
int mToolbarIndex;
DiffPanel mDiffPanel;
PropertiesPanel mPropertiesPanel;
ChangesetByChangesetDiffPanel mChangesetByChangesetDiffPanel;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
readonly Action mRepaint;
const string TOOLBAR_INDEX_KEY = "BranchPropertiesPanel.ToolbarIndex";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 14b7fa9fffe443888cccb93957dea182
timeCreated: 1770026998
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 95584824e8c94fafab24cbd922124aff
timeCreated: 1770026047
@@ -0,0 +1,114 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Diff;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Changeset
{
internal class ChangesetPropertiesPanel
{
internal DiffPanel DiffPanel => mDiffPanel;
internal ChangesetPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
IRefreshView refreshView,
IAssetStatusCache assetStatusCache,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
IPendingChangesUpdater pendingChangesUpdater,
IIncomingChangesUpdater developerIncomingChangesUpdater,
IIncomingChangesUpdater gluonIncomingChangesUpdater,
EditorWindow parentWindow,
bool isGluonMode)
{
mRepaint = repaint;
mRepaint = repaint;
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mDiffPanel = new DiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
}
internal void Update()
{
mDiffPanel.Update();
mPropertiesPanel.Update();
}
internal void OnEnable()
{
mDiffPanel.OnEnable();
}
internal void OnDisable()
{
mDiffPanel.OnDisable();
}
internal void ResetForTesting()
{
ClearInfo();
}
internal void ClearInfo()
{
mPropertiesPanel.ClearInfo();
mDiffPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mPropertiesPanel.UpdateInfo(selectedRepObjectInfoData.ObjectInfo, selectedRepObjectInfoData.RepSpec);
mDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedRepObjectInfoData.ObjectInfo);
}
internal void OnInspectorGUI()
{
mDiffPanel.OnGUI();
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
mPropertiesPanel.OnGUI();
Rect separatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(separatorRect, UnityStyles.Colors.BarBorder);
EditorGUILayout.EndVertical();
}
DiffPanel mDiffPanel;
PropertiesPanel mPropertiesPanel;
readonly Action mRepaint;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 87e7b84ff9884881b9aceb446cee6ee5
timeCreated: 1770027014
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f6e1f4a705074105b682329d9d1fe334
timeCreated: 1770026056
@@ -0,0 +1,105 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.BrowseRepository;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Label
{
internal class LabelPropertiesPanel : IGetRepositorySpec
{
internal LabelPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
EditorWindow parentWindow)
{
mRepaint = repaint;
mRepaint = repaint;
mParentWindow = parentWindow;
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mBrowseRepositoryPanel = new BrowseRepositoryPanel(
wkInfo,
this,
parentWindow);
}
internal void OnEnable()
{
mBrowseRepositoryPanel.OnEnable();
}
internal void OnDisable()
{
mBrowseRepositoryPanel.OnDisable();
}
internal void Update()
{
mBrowseRepositoryPanel.Update();
mPropertiesPanel.Update();
}
internal void ResetForTesting()
{
ClearInfo();
}
internal void ClearInfo()
{
mSelectedRepObjectInfoData = null;
mPropertiesPanel.ClearInfo();
mBrowseRepositoryPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
mPropertiesPanel.UpdateInfo(selectedRepObjectInfoData.ObjectInfo, selectedRepObjectInfoData.RepSpec);
mBrowseRepositoryPanel.UpdateInfo((MarkerExtendedInfo)selectedRepObjectInfoData.ObjectInfo);
}
internal void OnInspectorGUI()
{
mBrowseRepositoryPanel.OnGUI();
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
mPropertiesPanel.OnGUI();
Rect separatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(separatorRect, UnityStyles.Colors.BarBorder);
EditorGUILayout.EndVertical();
}
RepositorySpec IGetRepositorySpec.Get()
{
if (mSelectedRepObjectInfoData == null)
return null;
return mSelectedRepObjectInfoData.RepSpec;
}
PropertiesPanel mPropertiesPanel;
BrowseRepositoryPanel mBrowseRepositoryPanel;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
readonly Action mRepaint;
readonly EditorWindow mParentWindow;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9a10c8be3cfa470199e57ef38283bcfd
timeCreated: 1770027025
@@ -0,0 +1,351 @@
using Codice.CM.Common;
using Unity.PlasticSCM.Editor.Diff;
using Unity.PlasticSCM.Editor.Headless;
using Unity.PlasticSCM.Editor.Inspector.Properties.Branch;
using Unity.PlasticSCM.Editor.Inspector.Properties.Changeset;
using Unity.PlasticSCM.Editor.Inspector.Properties.Label;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using EditorWindowInternal = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorWindow;
namespace Unity.PlasticSCM.Editor.Inspector.Properties
{
[CustomEditor(typeof(SelectedRepObjectInfoData))]
internal class PropertiesViewer : UnityEditor.Editor
{
internal BranchPropertiesPanel BranchPropertiesPanel => mBranchPropertiesPanel;
internal ChangesetPropertiesPanel ChangesetPropertiesPanel => mChangesetPropertiesPanel;
public override bool UseDefaultMargins()
{
return false;
}
public override VisualElement CreateInspectorGUI()
{
if (target == null)
return null;
if (mSelectedRepObjectInfoData == target)
return mRootContainer;
mRootContainer = new VisualElement();
IMGUIContainer imguiContainer = new IMGUIContainer(DrawInspectorGUI);
imguiContainer.style.flexGrow = 1;
mRootContainer.Add(imguiContainer);
mRootContainer.RegisterCallback<AttachToPanelEvent>(OnAttatchToPanel);
mRootContainer.RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
SetSelectedObject(target as SelectedRepObjectInfoData);
return mRootContainer;
}
internal void DisposeForTesting()
{
EditorApplication.update -= OnEditorUpdate;
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.ResetForTesting();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.ResetForTesting();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.ResetForTesting();
DestroyImmediate(this);
}
void OnAttatchToPanel(AttachToPanelEvent evt)
{
ScrollView parentScrollView = mRootContainer.GetFirstAncestorOfType<ScrollView>();
if (parentScrollView == null)
return;
UpdateRootContainerHeight(parentScrollView.contentRect.height);
parentScrollView.RegisterCallback<GeometryChangedEvent>(OnScrollGeometryChanged);
}
void OnDetachFromPanel(DetachFromPanelEvent evt)
{
EditorApplication.delayCall += ClearDiffWindowIfNoLivePropertiesViewer;
}
void OnScrollGeometryChanged(GeometryChangedEvent evt)
{
UpdateRootContainerHeight(evt.newRect.height);
}
void UpdateRootContainerHeight(float parentScrollViewHeight)
{
// 7px is the magic number that makes our view to fit
// the Inspector's scrollviewer viewport size
// we need it to avoid the vertical scrollbar to appear
mRootContainer.style.height = parentScrollViewHeight - 7;
}
void OnEnable()
{
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.OnEnable();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.OnEnable();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.OnEnable();
EditorApplication.update += OnEditorUpdate;
}
void OnDestroy()
{
if (mRootContainer == null)
return;
mRootContainer.UnregisterCallback<AttachToPanelEvent>(OnAttatchToPanel);
ScrollView parentScrollView = mRootContainer.GetFirstAncestorOfType<ScrollView>();
parentScrollView?.UnregisterCallback<GeometryChangedEvent>(OnScrollGeometryChanged);
if (target != null && !IsTargetUsedByOtherPropertiesViewer())
DestroyImmediate(target);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateLabelPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
ClearDiffWindow();
}
void OnDisable()
{
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.OnDisable();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.OnDisable();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.OnDisable();
EditorApplication.update -= OnEditorUpdate;
}
void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
ClearDiffWindowCache();
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
object objectInfo = selectedRepObjectInfoData?.ObjectInfo;
mLastObjectInfo = objectInfo;
if (objectInfo == null)
return;
if (objectInfo is BranchInfo)
{
GetOrCreateBranchPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateLabelPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
}
else if (objectInfo is MarkerInfo)
{
GetOrCreateLabelPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
}
else if (objectInfo is ChangesetInfo)
{
GetOrCreateChangesetPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateLabelPropertiesPanel().ClearInfo();
}
}
void DrawInspectorGUI()
{
if (mLastObjectInfo == null)
return;
if (mLastObjectInfo is BranchInfo)
{
GetOrCreateBranchPropertiesPanel().OnHeaderGUI();
GetOrCreateBranchPropertiesPanel().OnInspectorGUI();
}
else if (mLastObjectInfo is MarkerInfo)
{
GetOrCreateLabelPropertiesPanel().OnHeaderGUI();
GetOrCreateLabelPropertiesPanel().OnInspectorGUI();
}
else if (mLastObjectInfo is ChangesetInfo)
{
GetOrCreateChangesetPropertiesPanel().OnHeaderGUI();
GetOrCreateChangesetPropertiesPanel().OnInspectorGUI();
}
}
void OnEditorUpdate()
{
if (mLastObjectInfo == null)
return;
if (mLastObjectInfo is BranchInfo)
GetOrCreateBranchPropertiesPanel().Update();
else if (mLastObjectInfo is MarkerInfo)
GetOrCreateLabelPropertiesPanel().Update();
else if (mLastObjectInfo is ChangesetInfo)
GetOrCreateChangesetPropertiesPanel().Update();
}
BranchPropertiesPanel GetOrCreateBranchPropertiesPanel()
{
if (mBranchPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mBranchPropertiesPanel = new BranchPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
new HeadlessViewSwitcher(),
new HeadlessHistoryViewLauncher(UVCSPlugin.Instance),
new HeadlessRefreshView(),
UVCSPlugin.Instance.AssetStatusCache,
mShowDownloadPlasticExeWindow,
UVCSPlugin.Instance.PendingChangesUpdater,
UVCSPlugin.Instance.DeveloperIncomingChangesUpdater,
UVCSPlugin.Instance.GluonIncomingChangesUpdater,
inspectorWindow,
PlasticGui.Plastic.API.IsGluonWorkspace(mWkInfo));
}
return mBranchPropertiesPanel;
}
LabelPropertiesPanel GetOrCreateLabelPropertiesPanel()
{
if (mLabelPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mLabelPropertiesPanel = new LabelPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
inspectorWindow);
}
return mLabelPropertiesPanel;
}
ChangesetPropertiesPanel GetOrCreateChangesetPropertiesPanel()
{
if (mChangesetPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mChangesetPropertiesPanel = new ChangesetPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
new HeadlessViewSwitcher(),
new HeadlessHistoryViewLauncher(UVCSPlugin.Instance),
new HeadlessRefreshView(),
UVCSPlugin.Instance.AssetStatusCache,
mShowDownloadPlasticExeWindow,
UVCSPlugin.Instance.PendingChangesUpdater,
UVCSPlugin.Instance.DeveloperIncomingChangesUpdater,
UVCSPlugin.Instance.GluonIncomingChangesUpdater,
inspectorWindow,
PlasticGui.Plastic.API.IsGluonWorkspace(mWkInfo));
}
return mChangesetPropertiesPanel;
}
WorkspaceInfo GetWorkspaceInfo()
{
if (mWkInfo == null)
{
mWkInfo = FindWorkspace.InfoForApplicationPath(
ApplicationDataPath.Get(), PlasticGui.Plastic.API);
}
return mWkInfo;
}
bool IsTargetUsedByOtherPropertiesViewer()
{
// check if the current target is displayed in other inspector
PropertiesViewer[] allViewers =
Resources.FindObjectsOfTypeAll<PropertiesViewer>();
foreach (PropertiesViewer viewer in allViewers)
{
if (viewer == this)
continue;
if (viewer.target == target)
return true;
}
return false;
}
static void ClearDiffWindowCache()
{
IUnityDiffWindow diffWindow = GetWindowIfOpened.Diff();
diffWindow?.ClearDiffViewerCache();
}
static void ClearDiffWindow()
{
IUnityDiffWindow diffWindow = GetWindowIfOpened.Diff();
if (diffWindow == null)
return;
diffWindow.ClearDiffViewerCache();
diffWindow.ClearIfShownFrom(DiffSource.DiffPanel);
}
static void ClearDiffWindowIfNoLivePropertiesViewer()
{
PropertiesViewer[] allViewers =
Resources.FindObjectsOfTypeAll<PropertiesViewer>();
foreach (PropertiesViewer viewer in allViewers)
{
if (viewer.mRootContainer != null && viewer.mRootContainer.panel != null)
return;
}
ClearDiffWindow();
}
protected override void OnHeaderGUI() { }
public override void OnInspectorGUI() { }
VisualElement mRootContainer;
object mLastObjectInfo;
WorkspaceInfo mWkInfo;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
BranchPropertiesPanel mBranchPropertiesPanel;
LabelPropertiesPanel mLabelPropertiesPanel;
ChangesetPropertiesPanel mChangesetPropertiesPanel;
LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow =
new LaunchTool.ShowDownloadPlasticExeWindow();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89c8459035a34dab8b0141d4c4e3e3db
timeCreated: 1770026066
@@ -0,0 +1,56 @@
using System;
using Codice.CM.Common;
using Codice.CM.Common.Mount;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties
{
internal class SelectedRepObjectInfoData : ScriptableObject
{
internal RepObjectInfo ObjectInfo { get; private set; }
internal RepositorySpec RepSpec { get; private set; }
internal MountPointWithPath MountPoint { get; private set; }
internal static SelectedRepObjectInfoData Create(
RepObjectInfo objectInfo,
RepositorySpec repSpec,
MountPointWithPath mountPoint = null)
{
SelectedRepObjectInfoData result = CreateInstance<SelectedRepObjectInfoData>();
result.ObjectInfo = objectInfo;
result.RepSpec = repSpec;
result.MountPoint = mountPoint;
return result;
}
internal static void SetActiveObject(
RepObjectInfo objectInfo,
RepositorySpec repSpec,
MountPointWithPath mountPoint = null)
{
// Reassigning Selection.activeObject to a new instance makes Unity rebuild
// the Inspector and recompute the diff, losing the current file selection.
// Skip it when the same object is already displayed (VCS-1008599).
if (IsSameObjectSelected(objectInfo, repSpec))
return;
Selection.activeObject = Create(objectInfo, repSpec, mountPoint);
}
static bool IsSameObjectSelected(
RepObjectInfo objectInfo,
RepositorySpec repSpec)
{
SelectedRepObjectInfoData current =
Selection.activeObject as SelectedRepObjectInfoData;
if (current == null || current.ObjectInfo == null || objectInfo == null)
return false;
return current.ObjectInfo.Equals(objectInfo)
&& current.RepSpec.Equals(repSpec);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b6b94b53391e4873a684f61c6f109710
timeCreated: 1770025975