This commit is contained in:
2025-01-17 13:10:42 +01:00
commit 4536213c91
15115 changed files with 1442174 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
* text=auto
# Unity files
*.meta -text merge=unityyamlmerge diff
*.unity -text merge=unityyamlmerge diff
*.asset -text merge=unityyamlmerge diff
*.prefab -text merge=unityyamlmerge diff
*.mat -text merge=unityyamlmerge diff
*.anim -text merge=unityyamlmerge diff
*.controller -text merge=unityyamlmerge diff
*.overrideController -text merge=unityyamlmerge diff
*.physicMaterial -text merge=unityyamlmerge diff
*.physicsMaterial2D -text merge=unityyamlmerge diff
*.playable -text merge=unityyamlmerge diff
*.mask -text merge=unityyamlmerge diff
*.brush -text merge=unityyamlmerge diff
*.flare -text merge=unityyamlmerge diff
*.fontsettings -text merge=unityyamlmerge diff
*.guiskin -text merge=unityyamlmerge diff
*.giparams -text merge=unityyamlmerge diff
*.renderTexture -text merge=unityyamlmerge diff
*.spriteatlas -text merge=unityyamlmerge diff
*.terrainlayer -text merge=unityyamlmerge diff
*.mixer -text merge=unityyamlmerge diff
*.shadervariants -text merge=unityyamlmerge diff
# Image formats
*.psd filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.bmp filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.iff filter=lfs diff=lfs merge=lfs -text
*.pict filter=lfs diff=lfs merge=lfs -text
*.dds filter=lfs diff=lfs merge=lfs -text
*.xcf filter=lfs diff=lfs merge=lfs -text
# Audio formats
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.aiff filter=lfs diff=lfs merge=lfs -text
*.aif filter=lfs diff=lfs merge=lfs -text
*.mod filter=lfs diff=lfs merge=lfs -text
*.it filter=lfs diff=lfs merge=lfs -text
*.s3m filter=lfs diff=lfs merge=lfs -text
*.xm filter=lfs diff=lfs merge=lfs -text
# Video formats
*.mov filter=lfs diff=lfs merge=lfs -text
*.avi filter=lfs diff=lfs merge=lfs -text
*.asf filter=lfs diff=lfs merge=lfs -text
*.mpg filter=lfs diff=lfs merge=lfs -text
*.mpeg filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
# 3D formats
*.fbx filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
*.max filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.dae filter=lfs diff=lfs merge=lfs -text
*.mb filter=lfs diff=lfs merge=lfs -text
*.ma filter=lfs diff=lfs merge=lfs -text
*.3ds filter=lfs diff=lfs merge=lfs -text
*.dfx filter=lfs diff=lfs merge=lfs -text
*.c4d filter=lfs diff=lfs merge=lfs -text
*.lwo filter=lfs diff=lfs merge=lfs -text
*.lwo2 filter=lfs diff=lfs merge=lfs -text
*.abc filter=lfs diff=lfs merge=lfs -text
*.3dm filter=lfs diff=lfs merge=lfs -text
# Build
*.dll filter=lfs diff=lfs merge=lfs -text
*.pdb filter=lfs diff=lfs merge=lfs -text
*.mdb filter=lfs diff=lfs merge=lfs -text
# Packaging
*.zip filter=lfs diff=lfs merge=lfs -text
*.7z filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text

View File

@@ -0,0 +1,50 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
# Uncomment this line if you wish to ignore the asset store tools plugin
# [Aa]ssets/AssetStoreTools*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo/Rider/VSCode solution and project files
ExportedObj/
.consulo/
.vscode/
.idea/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties

View File

@@ -0,0 +1,5 @@
{
"timestamp": 1727270513,
"signature": "WYtMyxpmZcpBtwuSDb2WvASiX8KEOZbleM8m/fiOQanxBTqeJGZSm3ELqRJ/2df+puNt7B92k3xsVQO9FL+y2mBDp4/Be+5S3ToJnRSRU8oPa/04LE6bx+0MDcAMUalay5UJw3ANYaIy8SEFsIkuTu/00RnNZMeo3sed61nrqN5S3AXaTSKfkHmhFp0PCwnJ9TbWvu4Ztbsg3P6AkCpBHTdbqtLF4qHwG9kYlROJZr6/bPnT2I9cxfEK5EC610EqfUWLaXvAL7rgRjqFJagu+JbSsob7gY4GB/9zbJPkG+HPbBbVf/9XuS1xJaovORUFQKiqUCxm0ez/ix2rWgt+Z6fdSUj65eSxy/JTWfSeqLpi2JnaAXPIQVwHrryHIZ8RRRtKcNT+Qm1OnCMT9D6+PamaoSmacqMVSSwPJL45YWnvY4sLZW7aMLP47TMGTj2xBvVawgqV7NFa1MswBfDr8QBTemd8ZKjgSH5QfpHj77yZ1SWV2mrRDZ7d9vTveIqE",
"publicKey": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUFzdUhXYUhsZ0I1cVF4ZEJjTlJKSAordHR4SmoxcVY1NTdvMlZaRE1XaXhYRVBkRTBEMVFkT1JIRXNSS1RscmplUXlERU83ZlNQS0ZwZ1A3MU5TTnJCCkFHM2NFSU45aHNQVDhOVmllZmdWem5QTkVMenFkVmdEbFhpb2VpUnV6OERKWFgvblpmU1JWKytwbk9ySTRibG4KS0twelJlNW14OTc1SjhxZ1FvRktKT0NNRlpHdkJMR2MxSzZZaEIzOHJFODZCZzgzbUovWjBEYkVmQjBxZm13cgo2ZDVFUXFsd0E5Y3JZT1YyV1VpWXprSnBLNmJZNzRZNmM1TmpBcEFKeGNiaTFOaDlRVEhUcU44N0ZtMDF0R1ZwCjVNd1pXSWZuYVRUemEvTGZLelR5U0pka0tldEZMVGdkYXpMYlpzUEE2aHBSK0FJRTJhc0tLTi84UUk1N3UzU2cKL2xyMnZKS1IvU2l5eEN1Q20vQWJkYnJMbXk0WjlSdm1jMGdpclA4T0lLQWxBRWZ2TzV5Z2hSKy8vd1RpTFlzUQp1SllDM0V2UE16ZGdKUzdGR2FscnFLZzlPTCsxVzROY05yNWdveVdSUUJ0cktKaWlTZEJVWmVxb0RvSUY5NHpCCndGbzJJT1JFdXFqcU51M3diMWZIM3p1dGdtalFra3IxVjJhd3hmcExLWlROQWdNQkFBRT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 47777d81697d65f45befb6ccd55b2324
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
# Access remote projects
1. In the Unity Hub v3, click **Open** > **Open Remote Project** to see the list of your version control repositories that contain a Unity project.
2. Select the project and click **Next**.
3. Select the Editor version and platform and click the **change version** button.
4. Your local version control workspace will be created for you. The latest version of the project will be downloaded and the Editor will open with the latest version of your Unity project.

View File

@@ -0,0 +1,11 @@
# Add team members
To invite team members to contribute to your project:
1. From the toolbar, click Invite Members to Workspace.
![Invite members to project](images/InviteMembers.png)
2. In your DevOps version control dashboard, click Add new user.
You can also send invitations and add different permission types for each user.

View File

@@ -0,0 +1,27 @@
# Create projects
To create projects:
1. In the Unity Editor, open the Unity Version Control window and click on **Create Workspace**.
It will suggest names for your repository (shared files and history on the server) and workspace (your local copy on your computer).
If you wish to use an existing version control repository, click the three dots next to the repository name, and select a repository from the list.
2. Select the type of workspace that fits your needs.
* **Developer workspace**
With this workspace, you can work with branching and merging.
* **Gluon workspace**
This workspace tailored for artists allows you to pick the files you want to work on and check them back in without updating your whole workspace.
3. Add asset files associated with your project.
version control will display the project files from the asset folder in the **Pending changes** tab. You can choose specific files to include or add all to the repository by selecting the files and clicking Checkin changes.
version control will automatically perform a check in for appropriate folders and files such as package files and project settings when its set up from the Unity Editor. You can view these in the **Changesets tab.**
Once your initial asset check in is complete, youre set up with version control for Unity and ready to create.
## See also
See also the get started detailed guides:
* [Get started with a new repository](GetStartedNewRepository.md).
* [Get started with an existing repository](GetStartedExistingRepository.md).

View File

@@ -0,0 +1,12 @@
# Get started with Unity Version Control
The Version Control package provides an integration of Unity Version Control (Unity VCS, formerly Plastic SCM) in the Unity Editor.
Unity Version Control enables you to work collaboratively by providing advanced features such as branching, locking, merging, and a standalone Desktop GUI.
Learn more about [Unity Version Control](https://unity.com/solutions/version-control).
* To start with a new version control repository for your project, see [Get started with a new repository](GetStartedNewRepository.md).
* To start from an existing Unity Version Control repository, see [Get started with an existing repository](GetStartedExistingRepository.md).
For more information on how to get started, refer to the [Unity Version Control documentation](https://docs.unity.com/ugs/en-us/manual/devops/manual/unity-version-control).

View File

@@ -0,0 +1,15 @@
# Get started with an existing Unity Version Control repository
Suppose you want to start working on a Unity project in an existing Unity Version Control repository and already have a Unity Version Control account linked to your Unity ID. In that case, you will be able to open the project straight from the **Unity Hub**. A workspace will automatically be created for your project on your machine.
1. In the Unity Hub v3 Beta, click **Open** > **Open remote project** to see the list of your Unity Version Control repositories that contain a Unity project.
2. Click the project and click **Next**.
3. Click the Editor version and platform and click the **change version** button.
4. In the Editor pop-up, click the **Migrate** button to migrate your local workspace to a Unity Version Control workspace
5. Once the migration is completed, click the **Open Unity Version Control** button.
![Plastic Hub](images/plasticHub.gif)
## Accessing the Unity Version Control Window
You can access the **Unity Version Control** window in the Unity Editor by clicking **Window** > **Unity Version Control**.

View File

@@ -0,0 +1,24 @@
# Get started with a new version control repository
**Note**: To start from an existing version control repository, see [Get started with an existing version control repository](GetStartedExistingRepository.md).
You can walk through a straightforward onboarding wizard when creating a repository for your Unity project. This new wizard will help you:
* Set up your account and configure your repository for your Unity project, enabling you to sync to a version control Cloud Edition repository.
* Generate a standard ignore file that prevents unnecessary components of your Unity project from being checked in.
* Automatically do the first check-in so that your repository is in sync with your local changes.
1. Open your Unity project.
2. To access the version control window in the Unity Editor, click **Window** > **version control**:
![version control window](images/AccessingUnityVersionControl.png)
3. In the version control onboarding window, complete the steps to continue:
![Onboarding](images/Onboarding.png)
Unity connects your project to your version control Cloud repository; version control automatically creates an ignore file in the workspace for Unity projects so it doesn't track files that shouldn't be part of the repository. It also creates a standard automatic checkin during the initial setup. So now you're all set to start using version control!
![Automatic setup](images/AutomaticSetup.png)
**Note**: Basic version control actions, such as viewing pending changes, checking in changes, and viewing changesets, dont require a version control Client install. However, if you want to use more advanced features, such as branching and diffing changeset, you will be prompted to download the version control client (if you have not already done so):
![Advanced features](images/AdvancedFeatures.png)

View File

@@ -0,0 +1,13 @@
# Unity version control for Git users
| **GIT**| **Unity VCS**| **Explanation**|
|:--|:--|:--|
| To Commit| To Check in| To Check in is to submit changes to the repo.|
| Commit| Changeset| Each new change on the history of the repo, grouping several individual file and directory changes.|
| Master| Main| When you create a repo in Unity VCS, there's always an "empty" branch. Unity VCS calls it Main.|
| To checkout | To update| Downloading content to the workspace (working copy). This is called "update" because in Unity VCS, "checkout" has a different meaning.|
|| Checkout| When you checkout a file in Unity VCS, you're saying you are going to modify the file.|
|| Exclusive checkout or lock | This is locking a file so nobody can touch it. Its only useful for non-mergeable files, like binaries, images, or art in a video game.|
| Rebase|| Unity VCS handles branching differently than Git. In Unity VCS, a rebase is just a merge operation.|
| Repository | Repository| Where the entire history of the project is stored.
| Working copy | Workspace| In Git, you have the working copy and the repository in the exact location. You have a working copy and a .git hidden dir with the repository. In Unity VCS, this is slightly different since repositories and workspaces are separated. You can have several workspaces working with the same local repository.

View File

@@ -0,0 +1,41 @@
# Glossary
## General terms
### Project
In Unity, you use a project to design and develop a game. A project stores all of the files related to a game, such as the asset and **Scene** files. See [2D or 3D projects](https://docs.unity3d.com/Manual/2Dor3D.html).
### Version Control
A system for managing changes to a set of files. You can use Unity in conjunction with most **version control** tools, including **Unity Version Control** and **Perforce**. See [Version Control](https://docs.unity3d.com/Manual/VersionControl.html).
### Ignore file
A special file used in many **Version Control** Systems which specifies files to be excluded from **version control**. In Unity projects, several folders should be excluded from **version control**.
### Repository
A shared history of changes made to the project's files, saved on a server.
### Workspace
Your local copy of the repository, interacting with the version control system. It's where you download the project's files, make the required changes and perform checkins.
### Check-in
Check-in is the act of submitting changes from your workspace to the shared repository. You can enter a comment before checking in your changes.
## Unity Version Control terms
### Developer Workflow
Developers have access to the branch explorer directly from inside Unity and easily switch branches.
### Gluon Workflow
Artists can take advantage of the Gluon visualized interface and workflow from inside Unity.
### Organization
The organization handles different sets of repositories in the Cloud. Inside the organization, you can create as many repositories as you need.

View File

@@ -0,0 +1,43 @@
# Overview of features
## Pending Changes
The **Pending Changes** tab allows you to view all pending changes in your workspace. These changes are not checked into the repository. In this tab, you can select which files you want to check in, add a comment, and check in the changes.
![Pending changes tab](images/PendingChanges.png)
**Note** : You can check in a specific file using the version control contextual menu in the project view or the **Checkin** button in the **Inspector** window.
![Inspector window](images/InspectorWindow.png)
In the example below, the user adds a GameScene. They can check in the scene using the **Pending Changes** tab or the **Checkin** option in the contextual menu.
![Checkin using contextual menu](images/GamesSceneExample.png)
## Incoming Changes
The **Incoming Changes** tab allows you to view all incoming changes and conflicts and update your local project. Any changes made to your project prompts an "**Incoming changes**" notification at the top right of the version control window.
**Tip** : Check the **Incoming Changes** tab frequently to avoid facing future change conflicts in your team.
![Incoming changes tab](images/IncomingChanges.gif)
## Project History
Use the **Changesets** tab to view all changes made to your project as they occur chronologically, along with who made the changes and when. You can sort by columns and alter the chronological view of the story.
![Changesets tab](images/ProjectHistory.png)
Double-click any file in a changeset to go to the **File History** tab, and display every changeset. In the **File History view**, right-click on a change and click **Save the revision as…** to restore the file's former state. This is useful if you had previously deleted some logic that you now need.
![File history view](images/FileHistory.png)
You can also view the changes made to a specific file in the **Project view** through a contextual menu, then revert to an earlier revision of the file.
![Revert changes in project view](images/ProjectView.gif)
## Locks
The **File locks** tab allows you to list and filter all locks in your repository, and gives you the ability to release or remove them selectively. To open the view, you can use the "Show Locks" button available in the toolbar.
![File locks view](images/FileLocks.png)

View File

@@ -0,0 +1,6 @@
# More help
To find more information on working with the Unity version control plug-in, see [Getting started with Unity Version control](https://docs.unity3d.com/2022.1/Documentation/Manual/PlasticSCMPluginGettingStarted.html).
You can also post and find questions related to Unity version control in the [Unity forum](https://forum.unity.com/forums/plastic-scm.605/).

View File

@@ -0,0 +1,5 @@
# Quick start guide
The Version Control package provides an integration of Unity Version Control (Unity VCS, formerly Plastic SCM) in the Unity Editor.
[Get started with Unity Version Control](GetStarted.md)

View File

@@ -0,0 +1,10 @@
# Connect Unity Cloud Build
Unity Cloud Build is a [continuous integration](https://docs.unity3d.com/2022.2/Documentation/Manual/UnityCloudBuild.html#automated-build-generation) that automatically creates multiplatform builds in the Cloud in minutes. You can point Cloud Build toward your version control system to:
* Automate new builds
* Build faster
* Catch problems earlier
* Iterate on your builds more efficiently with agility.
To get started, see [Pay as you go with Cloud Build](https://docs.unity3d.com/2022.2/Documentation/Manual/UnityCloudBuildMeteredBilling.html).

View File

@@ -0,0 +1,19 @@
* [About the Version Control package](index.md)
* [Quick start guide](QuickStartGuide.md)
* [Create projects](CreateProjects.md)
* [Access remote projects](AccessRemoteProjects.md)
* [Add team members](AddMembers.md)
* [Connect Cloud Build](ReconnectCB.md)
* [Get started with Unity Version Control](GetStarted.md)
* [Get started with a new version control repository](GetStartedNewRepository.md)
* [Get started with an existing version control repository](GetStartedExistingRepository.md)
* [Main features](MainFeatures.md)
* [Pending Changes](MainFeatures.md#pending-changes)
* [Incoming Changes](MainFeatures.md#incoming-changes)
* [Project History](MainFeatures.md#project-history)
* [Locks](MainFeatures.md#locks)
* [Unity Version Control for Git users](GitUsers.md)
* [Glossary](Glossary.md)
* [General terms](Glossary.md#general-terms)
* [Unity Version Control terms](Glossary.md#unity-version-control-terms)
* [More help](MoreHelp.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

View File

@@ -0,0 +1,8 @@
# About the Version Control package
The Version Control package provides an integration of Unity Version Control (Unity VCS, formerly Plastic SCM) in the Unity Editor.
It is installed by default with the Editor, and follows the Unity support schedule. The minimum supported version of the Unity Editor is 2020.3.48f1 LTS.
* [Quick start guide](QuickStartGuide.md)
* [Get started with Unity Version Control](GetStarted.md)

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3eedd97b804f5a546a8817f8be60e318
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d5ae383aa416ba14e800dff2526122ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using UnityEngine;
namespace Unity.PlasticSCM.Editor
{
internal static class ApplicationDataPath
{
internal static string Get()
{
return mApplicationDataPath ?? Application.dataPath;
}
internal static void InitializeForTesting(string applicationDataPath)
{
mApplicationDataPath = applicationDataPath;
}
internal static void Reset()
{
mApplicationDataPath = null;
}
static string mApplicationDataPath;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 50503d5b64dbddc48a0bcba68901b3d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,5 @@
using System.Runtime.CompilerServices;
using UnityEngine;
[assembly: InternalsVisibleTo("Unity.PlasticSCM.EditorTests")]
[assembly: InternalsVisibleTo("Unity.PlasticSCM.DevTools")]

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d50ac3212a7ff5a4795bf609a2a20350
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3f8e034331c39c4f823ac31228dc4d9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,274 @@
using Codice.Client.BaseCommands;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Items;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.AssetMenu
{
internal interface IAssetFilesFilterPatternsMenuOperations
{
void AddFilesFilterPatterns(
FilterTypes type, FilterActions action, FilterOperationType operation);
}
internal class AssetFilesFilterPatternsMenuBuilder
{
internal string IgnoredSubmenuItem { get { return mIgnoredSubmenuItem; } }
internal string HiddenChangesSubmenuItem { get { return mHiddenChangesSubmenuItem; } }
internal AssetFilesFilterPatternsMenuBuilder(
int ignoredMenuItemsPriority,
int hiddenChangesMenuItemsPriority)
{
mIgnoredMenuItemsPriority = ignoredMenuItemsPriority;
mHiddenChangesMenuItemsPriority = hiddenChangesMenuItemsPriority;
mIgnoredSubmenuItem = string.Format(
"{0}/{1}",
PlasticLocalization.GetString(PlasticLocalization.Name.PrefixUnityVersionControlMenu),
PlasticLocalization.GetString(PlasticLocalization.Name.MenuAddToIgnoreList));
mHiddenChangesSubmenuItem = string.Format(
"{0}/{1}",
PlasticLocalization.GetString(PlasticLocalization.Name.PrefixUnityVersionControlMenu),
PlasticLocalization.GetString(PlasticLocalization.Name.MenuAddToHiddenChangesList));
}
internal void SetOperations(
IAssetFilesFilterPatternsMenuOperations operations)
{
mOperations = operations;
}
internal void UpdateMenuItems(FilterMenuActions actions)
{
UpdateIgnoredMenuItems(actions);
UpdateHiddenChangesMenuItems(actions);
HandleMenuItem.UpdateAllMenus();
}
internal void RemoveMenuItems()
{
RemoveIgnoredMenuItems();
RemoveHiddenChangesMenuItems();
}
internal void IgnoredByName_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.Ignored, FilterActions.ByName,
GetIgnoredFilterOperationType());
}
internal void IgnoredByExtension_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.Ignored, FilterActions.ByExtension,
GetIgnoredFilterOperationType());
}
internal void IgnoredByFullPath_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.Ignored, FilterActions.ByFullPath,
GetIgnoredFilterOperationType());
}
internal void HiddenChangesByName_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.HiddenChanges, FilterActions.ByName,
GetHiddenChangesFilterOperationType());
}
internal void HiddenChangesByExtension_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.HiddenChanges, FilterActions.ByExtension,
GetHiddenChangesFilterOperationType());
}
internal void HiddenChangesByFullPath_Click()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.AddFilesFilterPatterns(
FilterTypes.HiddenChanges, FilterActions.ByFullPath,
GetHiddenChangesFilterOperationType());
}
void UpdateIgnoredMenuItems(FilterMenuActions actions)
{
RemoveIgnoredMenuItems();
mIgnoredSubmenuItem = string.Format(
"{0}/{1}",
PlasticLocalization.Name.PrefixUnityVersionControlMenu.GetString(),
actions.IgnoredTitle);
if (!actions.Operations.HasFlag(FilterMenuOperations.Ignore))
{
HandleMenuItem.AddMenuItem(
mIgnoredSubmenuItem,
mIgnoredMenuItemsPriority,
DisabledMenuItem_Click, ValidateDisabledMenuItem);
return;
}
mIgnoredByNameMenuItem = GetIgnoredMenuItemName(actions.FilterByName);
mIgnoredByExtensionMenuItem = GetIgnoredMenuItemName(actions.FilterByExtension);
mIgnoredByFullPathMenuItem = GetIgnoredMenuItemName(actions.FilterByFullPath);
HandleMenuItem.AddMenuItem(
mIgnoredByNameMenuItem,
mIgnoredMenuItemsPriority,
IgnoredByName_Click, ValidateEnabledMenuItem);
if (actions.Operations.HasFlag(FilterMenuOperations.IgnoreByExtension))
HandleMenuItem.AddMenuItem(
mIgnoredByExtensionMenuItem,
mIgnoredMenuItemsPriority,
IgnoredByExtension_Click, ValidateEnabledMenuItem);
HandleMenuItem.AddMenuItem(
mIgnoredByFullPathMenuItem,
mIgnoredMenuItemsPriority,
IgnoredByFullPath_Click, ValidateEnabledMenuItem);
}
void UpdateHiddenChangesMenuItems(FilterMenuActions actions)
{
RemoveHiddenChangesMenuItems();
mHiddenChangesSubmenuItem = string.Format(
"{0}/{1}",
PlasticLocalization.Name.PrefixUnityVersionControlMenu.GetString(),
actions.HiddenChangesTitle);
if (!actions.Operations.HasFlag(FilterMenuOperations.HideChanged))
{
HandleMenuItem.AddMenuItem(
mHiddenChangesSubmenuItem,
mHiddenChangesMenuItemsPriority,
DisabledMenuItem_Click, ValidateDisabledMenuItem);
return;
}
mHiddenChangesByNameMenuItem = GetHiddenChangesMenuItemName(actions.FilterByName);
mHiddenChangesByExtensionMenuItem = GetHiddenChangesMenuItemName(actions.FilterByExtension);
mHiddenChangesByFullPathMenuItem = GetHiddenChangesMenuItemName(actions.FilterByFullPath);
HandleMenuItem.AddMenuItem(
mHiddenChangesByNameMenuItem,
mIgnoredMenuItemsPriority,
HiddenChangesByName_Click, ValidateEnabledMenuItem);
if (actions.Operations.HasFlag(FilterMenuOperations.HideChangedByExtension))
HandleMenuItem.AddMenuItem(
mHiddenChangesByExtensionMenuItem,
mIgnoredMenuItemsPriority,
HiddenChangesByExtension_Click, ValidateEnabledMenuItem);
HandleMenuItem.AddMenuItem(
mHiddenChangesByFullPathMenuItem,
mIgnoredMenuItemsPriority,
HiddenChangesByFullPath_Click, ValidateEnabledMenuItem);
}
void RemoveIgnoredMenuItems()
{
HandleMenuItem.RemoveMenuItem(mIgnoredSubmenuItem);
HandleMenuItem.RemoveMenuItem(mIgnoredByNameMenuItem);
HandleMenuItem.RemoveMenuItem(mIgnoredByExtensionMenuItem);
HandleMenuItem.RemoveMenuItem(mIgnoredByFullPathMenuItem);
}
void RemoveHiddenChangesMenuItems()
{
HandleMenuItem.RemoveMenuItem(mHiddenChangesSubmenuItem);
HandleMenuItem.RemoveMenuItem(mHiddenChangesByNameMenuItem);
HandleMenuItem.RemoveMenuItem(mHiddenChangesByExtensionMenuItem);
HandleMenuItem.RemoveMenuItem(mHiddenChangesByFullPathMenuItem);
}
FilterOperationType GetIgnoredFilterOperationType()
{
return GetFilterOperationType(
mIgnoredByNameMenuItem,
PlasticLocalization.Name.MenuAddToIgnoreList);
}
FilterOperationType GetHiddenChangesFilterOperationType()
{
return GetFilterOperationType(
mHiddenChangesByNameMenuItem,
PlasticLocalization.Name.MenuAddToHiddenChangesList);
}
static FilterOperationType GetFilterOperationType(string menuItemName, PlasticLocalization.Name expectedTitle)
{
string[] split = menuItemName.Split('/');
if (split.Length < 2)
return FilterOperationType.Remove;
string parentMenu = split[split.Length - 2];
return parentMenu.StartsWith(expectedTitle.GetString())
? FilterOperationType.Add
: FilterOperationType.Remove;
}
void DisabledMenuItem_Click() { }
bool ValidateEnabledMenuItem() { return true; }
bool ValidateDisabledMenuItem() { return false; }
string GetIgnoredMenuItemName(string filterPattern)
{
return UnityMenuItem.GetText(
mIgnoredSubmenuItem,
UnityMenuItem.EscapedText(filterPattern));
}
string GetHiddenChangesMenuItemName(string filterPattern)
{
return UnityMenuItem.GetText(
mHiddenChangesSubmenuItem,
UnityMenuItem.EscapedText(filterPattern));
}
IAssetFilesFilterPatternsMenuOperations mOperations;
string mIgnoredSubmenuItem;
string mHiddenChangesSubmenuItem;
string mIgnoredByNameMenuItem;
string mHiddenChangesByNameMenuItem;
string mIgnoredByExtensionMenuItem;
string mHiddenChangesByExtensionMenuItem;
string mIgnoredByFullPathMenuItem;
string mHiddenChangesByFullPathMenuItem;
readonly int mIgnoredMenuItemsPriority;
readonly int mHiddenChangesMenuItemsPriority;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b4eb3fe08d1dc86419dee5ddcc40baae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,330 @@
using UnityEditor.VersionControl;
using Codice.CM.Common;
using Codice.Client.Common.EventTracking;
using Codice.LogWrapper;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Items;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Tool;
namespace Unity.PlasticSCM.Editor.AssetMenu
{
internal class AssetMenuItems
{
internal static void Enable(
WorkspaceInfo wkInfo,
IAssetStatusCache assetStatusCache)
{
if (mIsEnabled)
return;
mLog.Debug("Enable");
mWkInfo = wkInfo;
mAssetStatusCache = assetStatusCache;
mIsEnabled = true;
mAssetSelection = new ProjectViewAssetSelection(UpdateFilterMenuItems);
mFilterMenuBuilder = new AssetFilesFilterPatternsMenuBuilder(
IGNORE_MENU_ITEMS_PRIORITY,
HIDDEN_MENU_ITEMS_PRIORITY);
AddMenuItems();
}
internal static void Disable()
{
mLog.Debug("Disable");
mIsEnabled = false;
RemoveMenuItems();
if (mAssetSelection != null)
mAssetSelection.Dispose();
mWkInfo = null;
mAssetStatusCache = null;
mAssetSelection = null;
mFilterMenuBuilder = null;
mOperations = null;
}
internal static void BuildOperations(
WorkspaceInfo wkInfo,
WorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
GluonGui.ViewHost viewHost,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
PlasticGui.WorkspaceWindow.NewIncomingChangesUpdater incomingChangesUpdater,
IAssetStatusCache assetStatusCache,
IMergeViewLauncher mergeViewLauncher,
PlasticGui.Gluon.IGluonViewSwitcher gluonViewSwitcher,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
bool isGluonMode)
{
if (!mIsEnabled)
Enable(wkInfo, assetStatusCache);
AssetOperations assetOperations = new AssetOperations(
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
viewHost,
workspaceOperationsMonitor,
incomingChangesUpdater,
mAssetStatusCache,
mergeViewLauncher,
gluonViewSwitcher,
mAssetSelection,
showDownloadPlasticExeWindow,
isGluonMode);
mOperations = assetOperations;
mFilterMenuBuilder.SetOperations(assetOperations);
}
static void RemoveMenuItems()
{
mFilterMenuBuilder.RemoveMenuItems();
HandleMenuItem.RemoveMenuItem(
PlasticLocalization.GetString(PlasticLocalization.Name.PrefixUnityVersionControlMenu));
HandleMenuItem.UpdateAllMenus();
}
static void UpdateFilterMenuItems()
{
AssetList assetList = ((AssetOperations.IAssetSelection)
mAssetSelection).GetSelectedAssets();
SelectedPathsGroupInfo info = AssetsSelection.GetSelectedPathsGroupInfo(
mWkInfo.ClientPath, assetList, mAssetStatusCache);
FilterMenuActions actions =
assetList.Count != info.SelectedCount ?
new FilterMenuActions() :
FilterMenuUpdater.GetMenuActions(info);
mFilterMenuBuilder.UpdateMenuItems(actions);
}
static void AddMenuItems()
{
// TODO: Try removing this
// Somehow first item always disappears. So this is a filler item
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.PendingChangesPlasticMenu),
PENDING_CHANGES_MENU_ITEM_PRIORITY,
PendingChanges, ValidatePendingChanges);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.PendingChangesPlasticMenu),
PENDING_CHANGES_MENU_ITEM_PRIORITY,
PendingChanges, ValidatePendingChanges);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.AddPlasticMenu),
ADD_MENU_ITEM_PRIORITY,
Add, ValidateAdd);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.CheckoutPlasticMenu),
CHECKOUT_MENU_ITEM_PRIORITY,
Checkout, ValidateCheckout);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.CheckinPlasticMenu),
CHECKIN_MENU_ITEM_PRIORITY,
Checkin, ValidateCheckin);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.UndoPlasticMenu),
UNDO_MENU_ITEM_PRIORITY,
Undo, ValidateUndo);
UpdateFilterMenuItems();
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.DiffPlasticMenu),
GetPlasticShortcut.ForAssetDiff(),
DIFF_MENU_ITEM_PRIORITY,
Diff, ValidateDiff);
HandleMenuItem.AddMenuItem(
GetPlasticMenuItemName(PlasticLocalization.Name.HistoryPlasticMenu),
GetPlasticShortcut.ForHistory(),
HISTORY_MENU_ITEM_PRIORITY,
History, ValidateHistory);
HandleMenuItem.UpdateAllMenus();
}
static void PendingChanges()
{
ShowWindow.Plastic();
mOperations.ShowPendingChanges();
}
static bool ValidatePendingChanges()
{
return true;
}
static void Add()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.Add();
}
static bool ValidateAdd()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.Add);
}
static void Checkout()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.Checkout();
}
static bool ValidateCheckout()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.Checkout);
}
static void Checkin()
{
TrackFeatureUseEvent.For(
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
TrackFeatureUseEvent.Features.ContextMenuCheckinOption);
if (mOperations == null)
ShowWindow.Plastic();
mOperations.Checkin();
}
static bool ValidateCheckin()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.Checkin);
}
static void Undo()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.Undo();
}
static bool ValidateUndo()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.Undo);
}
static void Diff()
{
if (mOperations == null)
ShowWindow.Plastic();
mOperations.ShowDiff();
}
static bool ValidateDiff()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.Diff);
}
static void History()
{
ShowWindow.Plastic();
mOperations.ShowHistory();
}
static bool ValidateHistory()
{
return ShouldMenuItemBeEnabled(
mWkInfo.ClientPath, mAssetSelection, mAssetStatusCache,
AssetMenuOperations.History);
}
static bool ShouldMenuItemBeEnabled(
string wkPath,
AssetOperations.IAssetSelection assetSelection,
IAssetStatusCache statusCache,
AssetMenuOperations operation)
{
AssetList assetList = assetSelection.GetSelectedAssets();
if (assetList.Count == 0)
return false;
SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
BuildFromAssetList(wkPath, assetList, statusCache);
if (assetList.Count != selectedGroupInfo.SelectedCount)
return false;
AssetMenuOperations operations = AssetMenuUpdater.
GetAvailableMenuOperations(selectedGroupInfo);
return operations.HasFlag(operation);
}
static string GetPlasticMenuItemName(PlasticLocalization.Name name)
{
return string.Format("{0}/{1}",
PlasticLocalization.GetString(PlasticLocalization.Name.PrefixUnityVersionControlMenu),
PlasticLocalization.GetString(name));
}
static IAssetMenuOperations mOperations;
static ProjectViewAssetSelection mAssetSelection;
static AssetFilesFilterPatternsMenuBuilder mFilterMenuBuilder;
static bool mIsEnabled;
static IAssetStatusCache mAssetStatusCache;
static WorkspaceInfo mWkInfo;
#if UNITY_6000_0_OR_NEWER
// Puts Unity Version Control in a new section, as it precedes the Create menu with the old value
const int BASE_MENU_ITEM_PRIORITY = 71;
#else
// Puts Unity Version Control right below the Create menu
const int BASE_MENU_ITEM_PRIORITY = 19;
#endif
// incrementing the "order" param by 11 causes the menu system to add a separator
const int PENDING_CHANGES_MENU_ITEM_PRIORITY = BASE_MENU_ITEM_PRIORITY;
const int ADD_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 11;
const int CHECKOUT_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 12;
const int CHECKIN_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 13;
const int UNDO_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 14;
const int IGNORE_MENU_ITEMS_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 25;
const int HIDDEN_MENU_ITEMS_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 26;
const int DIFF_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 37;
const int HISTORY_MENU_ITEM_PRIORITY = PENDING_CHANGES_MENU_ITEM_PRIORITY + 38;
static readonly ILog mLog = PlasticApp.GetLogger("AssetMenuItems");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c8a8e3e4456f9149905cf2c80aa41a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,224 @@
using System;
using UnityEditor.VersionControl;
using Codice;
using Codice.Client.Commands.WkTree;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetsOverlays;
using Unity.PlasticSCM.Editor.AssetUtils;
namespace Unity.PlasticSCM.Editor.AssetMenu
{
[Flags]
internal enum AssetMenuOperations : byte
{
None = 0,
Checkout = 1 << 0,
Diff = 1 << 1,
History = 1 << 2,
Add = 1 << 3,
Checkin = 1 << 4,
Undo = 1 << 5,
}
internal class SelectedAssetGroupInfo
{
internal int SelectedCount;
internal bool IsControlledSelection;
internal bool IsCheckedInSelection;
internal bool IsCheckedOutSelection;
internal bool IsPrivateSelection;
internal bool IsAddedSelection;
internal bool IsFileSelection;
internal bool HasAnyAddedInSelection;
internal bool HasAnyRemoteLockedInSelection;
internal static SelectedAssetGroupInfo BuildFromAssetList(
string wkPath,
AssetList assetList,
IAssetStatusCache statusCache)
{
bool isCheckedInSelection = true;
bool isControlledSelection = true;
bool isCheckedOutSelection = true;
bool isPrivateSelection = true;
bool isAddedSelection = true;
bool isFileSelection = true;
bool hasAnyAddedInSelection = false;
bool hasAnyRemoteLockedInSelection = false;
int selectedCount = 0;
foreach (Asset asset in assetList)
{
string fullPath = AssetsPath.GetFullPathUnderWorkspace.
ForAsset(wkPath, asset.path);
if (fullPath == null)
continue;
SelectedAssetGroupInfo singleFileGroupInfo = BuildFromSingleFile(
fullPath, asset.isFolder, statusCache);
if (!singleFileGroupInfo.IsCheckedInSelection)
isCheckedInSelection = false;
if (!singleFileGroupInfo.IsControlledSelection)
isControlledSelection = false;
if (!singleFileGroupInfo.IsCheckedOutSelection)
isCheckedOutSelection = false;
if (!singleFileGroupInfo.IsPrivateSelection)
isPrivateSelection = false;
if (!singleFileGroupInfo.IsAddedSelection)
isAddedSelection = false;
if (!singleFileGroupInfo.IsFileSelection)
isFileSelection = false;
if (singleFileGroupInfo.HasAnyAddedInSelection)
hasAnyAddedInSelection = true;
if (singleFileGroupInfo.HasAnyRemoteLockedInSelection)
hasAnyRemoteLockedInSelection = true;
selectedCount++;
}
return new SelectedAssetGroupInfo()
{
IsCheckedInSelection = isCheckedInSelection,
IsCheckedOutSelection = isCheckedOutSelection,
IsControlledSelection = isControlledSelection,
IsPrivateSelection = isPrivateSelection,
IsAddedSelection = isAddedSelection,
IsFileSelection = isFileSelection,
HasAnyAddedInSelection = hasAnyAddedInSelection,
HasAnyRemoteLockedInSelection = hasAnyRemoteLockedInSelection,
SelectedCount = selectedCount,
};
}
internal static SelectedAssetGroupInfo BuildFromSingleFile(
string fullPath,
bool isDirectory,
IAssetStatusCache statusCache)
{
bool isCheckedInSelection = true;
bool isControlledSelection = true;
bool isCheckedOutSelection = true;
bool isPrivateSelection = true;
bool isAddedSelection = true;
bool isFileSelection = true;
bool hasAnyAddedInSelection = false;
bool hasAnyRemoteLockedInSelection = false;
WorkspaceTreeNode wkTreeNode =
PlasticGui.Plastic.API.GetWorkspaceTreeNode(fullPath);
if (isDirectory)
isFileSelection = false;
if (CheckWorkspaceTreeNodeStatus.IsPrivate(wkTreeNode))
isControlledSelection = false;
else
isPrivateSelection = false;
if (CheckWorkspaceTreeNodeStatus.IsCheckedOut(wkTreeNode))
isCheckedInSelection = false;
else
isCheckedOutSelection = false;
if (CheckWorkspaceTreeNodeStatus.IsAdded(wkTreeNode))
hasAnyAddedInSelection = true;
else
isAddedSelection = false;
AssetStatus assetStatus = statusCache.GetStatus(fullPath);
if (ClassifyAssetStatus.IsLockedRemote(assetStatus))
hasAnyRemoteLockedInSelection = true;
return new SelectedAssetGroupInfo()
{
IsCheckedInSelection = isCheckedInSelection,
IsCheckedOutSelection = isCheckedOutSelection,
IsControlledSelection = isControlledSelection,
IsPrivateSelection = isPrivateSelection,
IsAddedSelection = isAddedSelection,
IsFileSelection = isFileSelection,
HasAnyAddedInSelection = hasAnyAddedInSelection,
HasAnyRemoteLockedInSelection = hasAnyRemoteLockedInSelection,
SelectedCount = 1,
};
}
}
internal interface IAssetMenuOperations
{
void ShowPendingChanges();
void Add();
void Checkout();
void Checkin();
void Undo();
void ShowDiff();
void ShowHistory();
}
internal static class AssetMenuUpdater
{
internal static AssetMenuOperations GetAvailableMenuOperations(
SelectedAssetGroupInfo info)
{
AssetMenuOperations result = AssetMenuOperations.None;
if (info.SelectedCount == 0)
{
return result;
}
if (info.IsControlledSelection &&
info.IsCheckedInSelection &&
info.IsFileSelection &&
!info.HasAnyRemoteLockedInSelection)
{
result |= AssetMenuOperations.Checkout;
}
if (info.IsFileSelection &&
info.IsPrivateSelection)
{
result |= AssetMenuOperations.Add;
}
if (info.IsFileSelection &&
info.IsControlledSelection &&
info.IsCheckedOutSelection)
{
result |= AssetMenuOperations.Checkin;
result |= AssetMenuOperations.Undo;
}
if (info.SelectedCount == 1 &&
info.IsControlledSelection &&
!info.HasAnyAddedInSelection &&
info.IsFileSelection)
{
result |= AssetMenuOperations.Diff;
}
if (info.SelectedCount == 1 &&
info.IsControlledSelection &&
!info.HasAnyAddedInSelection)
{
result |= AssetMenuOperations.History;
}
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c456fa791a741a045a8a99ee73af2ae6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,319 @@
using System.IO;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.VersionControl;
using Codice.Client.BaseCommands;
using Codice.Client.Commands;
using Codice.Client.Commands.WkTree;
using Codice.Client.Common;
using Codice.Client.Common.EventTracking;
using Codice.Client.Common.Threading;
using Codice.CM.Common;
using GluonGui;
using PlasticGui;
using PlasticGui.Gluon;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.Diff;
using PlasticGui.WorkspaceWindow.Items;
using Unity.PlasticSCM.Editor.AssetMenu.Dialogs;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.PendingChanges.Dialogs;
using GluonCheckoutOperation = GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer.Operations.CheckoutOperation;
using GluonUndoCheckoutOperation = GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer.Operations.UndoCheckoutOperation;
using GluonAddoperation = GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer.Operations.AddOperation;
namespace Unity.PlasticSCM.Editor.AssetMenu
{
internal class AssetOperations :
IAssetMenuOperations,
IAssetFilesFilterPatternsMenuOperations
{
internal interface IAssetSelection
{
AssetList GetSelectedAssets();
}
internal AssetOperations(
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
ViewHost viewHost,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
NewIncomingChangesUpdater newIncomingChangesUpdater,
IAssetStatusCache assetStatusCache,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonViewSwitcher,
IAssetSelection assetSelection,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
bool isGluonMode)
{
mWkInfo = wkInfo;
mWorkspaceWindow = workspaceWindow;
mViewSwitcher = viewSwitcher;
mHistoryViewLauncher = historyViewLauncher;
mViewHost = viewHost;
mWorkspaceOperationsMonitor = workspaceOperationsMonitor;
mNewIncomingChangesUpdater = newIncomingChangesUpdater;
mAssetStatusCache = assetStatusCache;
mMergeViewLauncher = mergeViewLauncher;
mGluonViewSwitcher = gluonViewSwitcher;
mAssetSelection = assetSelection;
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
mIsGluonMode = isGluonMode;
mGuiMessage = new UnityPlasticGuiMessage();
mProgressControls = new EditorProgressControls(mGuiMessage);
}
void IAssetMenuOperations.ShowPendingChanges()
{
mViewSwitcher.ShowPendingChanges();
}
void IAssetMenuOperations.Add()
{
List<string> selectedPaths = GetSelectedPaths.ForOperation(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets(),
mAssetStatusCache,
AssetMenuOperations.Add);
if (mIsGluonMode)
{
GluonAddoperation.Add(
mViewHost,
mProgressControls,
mGuiMessage,
selectedPaths.ToArray(),
false,
RefreshAsset.VersionControlCache);
return;
}
AddOperation.Run(
mWorkspaceWindow,
mProgressControls,
null,
null,
selectedPaths,
false,
mNewIncomingChangesUpdater,
RefreshAsset.VersionControlCache);
}
void IAssetMenuOperations.Checkout()
{
List<string> selectedPaths = GetSelectedPaths.ForOperation(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets(),
mAssetStatusCache,
AssetMenuOperations.Checkout);
if (mIsGluonMode)
{
GluonCheckoutOperation.Checkout(
mViewHost,
mProgressControls,
mGuiMessage,
selectedPaths.ToArray(),
false,
RefreshAsset.VersionControlCache,
mWkInfo);
return;
}
CheckoutOperation.Checkout(
mWorkspaceWindow,
null,
mProgressControls,
selectedPaths,
mNewIncomingChangesUpdater,
RefreshAsset.VersionControlCache,
mWkInfo);
}
void IAssetMenuOperations.Checkin()
{
List<string> selectedPaths = GetSelectedPaths.ForOperation(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets(),
mAssetStatusCache,
AssetMenuOperations.Checkin);
if (!CheckinDialog.CheckinPaths(
mWkInfo,
selectedPaths,
mAssetStatusCache,
mIsGluonMode,
mWorkspaceWindow,
mViewHost,
mWorkspaceOperationsMonitor,
mGuiMessage,
mMergeViewLauncher,
mGluonViewSwitcher))
return;
RefreshAsset.UnityAssetDatabase();
}
void IAssetMenuOperations.Undo()
{
List<string> selectedPaths = GetSelectedPaths.ForOperation(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets(),
mAssetStatusCache,
AssetMenuOperations.Undo);
SaveAssets.ForPathsWithoutConfirmation(
selectedPaths, mWorkspaceOperationsMonitor);
if (mIsGluonMode)
{
GluonUndoCheckoutOperation.UndoCheckout(
mWkInfo,
mViewHost,
mProgressControls,
selectedPaths.ToArray(),
false,
RefreshAsset.UnityAssetDatabase);
return;
}
UndoCheckoutOperation.Run(
mWorkspaceWindow,
null,
mProgressControls,
selectedPaths,
mNewIncomingChangesUpdater,
RefreshAsset.UnityAssetDatabase);
}
void IAssetMenuOperations.ShowDiff()
{
if (mShowDownloadPlasticExeWindow.Show(
mWkInfo,
mIsGluonMode,
TrackFeatureUseEvent.Features.InstallPlasticCloudFromShowDiff,
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromFromShowDiff,
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromFromShowDiff))
return;
string selectedPath = AssetsSelection.GetSelectedPath(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets());
DiffInfo diffInfo = null;
IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);
waiter.Execute(
/*threadOperationDelegate*/ delegate
{
string symbolicName = GetSymbolicName(selectedPath);
string extension = Path.GetExtension(selectedPath);
diffInfo = PlasticGui.Plastic.API.BuildDiffInfoForDiffWithPrevious(
selectedPath, symbolicName, selectedPath, extension, mWkInfo);
},
/*afterOperationDelegate*/ delegate
{
if (waiter.Exception != null)
{
ExceptionsHandler.DisplayException(waiter.Exception);
return;
}
DiffOperation.DiffWithPrevious(
diffInfo,
null,
null);
});
}
void IAssetMenuOperations.ShowHistory()
{
Asset selectedAsset = AssetsSelection.GetSelectedAsset(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets());
string selectedPath = Path.GetFullPath(selectedAsset.path);
WorkspaceTreeNode node = PlasticGui.Plastic.API.
GetWorkspaceTreeNode(selectedPath);
mHistoryViewLauncher.ShowHistoryView(
node.RepSpec,
node.RevInfo.ItemId,
selectedPath,
selectedAsset.isFolder);
}
void IAssetFilesFilterPatternsMenuOperations.AddFilesFilterPatterns(
FilterTypes type,
FilterActions action,
FilterOperationType operation)
{
List<string> selectedPaths = AssetsSelection.GetSelectedPaths(
mWkInfo.ClientPath,
mAssetSelection.GetSelectedAssets());
string[] rules = FilterRulesGenerator.GenerateRules(
selectedPaths, mWkInfo.ClientPath, action, operation);
bool isApplicableToAllWorkspaces = !mIsGluonMode;
bool isAddOperation = operation == FilterOperationType.Add;
FilterRulesConfirmationData filterRulesConfirmationData =
FilterRulesConfirmationDialog.AskForConfirmation(
rules, isAddOperation, isApplicableToAllWorkspaces, EditorWindow.focusedWindow);
AddFilesFilterPatternsOperation.Run(
mWkInfo, mWorkspaceWindow, type, operation, filterRulesConfirmationData);
}
static string GetSymbolicName(string selectedPath)
{
WorkspaceTreeNode node = PlasticGui.Plastic.API.
GetWorkspaceTreeNode(selectedPath);
string branchName = string.Empty;
BranchInfoCache.TryGetBranchName(
node.RepSpec, node.RevInfo.BranchId, out branchName);
string userName = PlasticGui.Plastic.API.GetUserName(
node.RepSpec.Server, node.RevInfo.Owner);
string symbolicName = string.Format(
"cs:{0}@{1} {2} {3}",
node.RevInfo.Changeset,
string.Format("br:{0}", branchName),
userName,
"Workspace Revision");
return symbolicName;
}
readonly WorkspaceInfo mWkInfo;
readonly IViewSwitcher mViewSwitcher;
readonly IHistoryViewLauncher mHistoryViewLauncher;
readonly IWorkspaceWindow mWorkspaceWindow;
readonly ViewHost mViewHost;
readonly WorkspaceOperationsMonitor mWorkspaceOperationsMonitor;
readonly NewIncomingChangesUpdater mNewIncomingChangesUpdater;
readonly IAssetStatusCache mAssetStatusCache;
readonly IMergeViewLauncher mMergeViewLauncher;
readonly IGluonViewSwitcher mGluonViewSwitcher;
readonly bool mIsGluonMode;
readonly GuiMessage.IGuiMessage mGuiMessage;
readonly EditorProgressControls mProgressControls;
readonly IAssetSelection mAssetSelection;
readonly LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c8b452bcd72d8248a3297ff656f0a7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor.VersionControl;
using PlasticGui.WorkspaceWindow.Items;
using Unity.PlasticSCM.Editor.AssetsOverlays;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetUtils;
namespace Unity.PlasticSCM.Editor.AssetMenu
{
internal static class AssetsSelection
{
internal static Asset GetSelectedAsset(
string wkPath,
AssetList assetList)
{
if (assetList.Count == 0)
return null;
foreach (Asset asset in assetList)
{
if (AssetsPath.GetFullPathUnderWorkspace.
ForAsset(wkPath, asset.path) == null)
continue;
return asset;
}
return null;
}
internal static string GetSelectedPath(
string wkPath,
AssetList assetList)
{
Asset result = GetSelectedAsset(wkPath, assetList);
if (result == null)
return null;
return Path.GetFullPath(result.path);
}
internal static List<string> GetSelectedPaths(
string wkPath,
AssetList assetList)
{
List<string> result = new List<string>();
foreach (Asset asset in assetList)
{
string fullPath = AssetsPath.GetFullPathUnderWorkspace.
ForAsset(wkPath, asset.path);
if (fullPath == null)
continue;
result.Add(fullPath);
}
return result;
}
internal static SelectedPathsGroupInfo GetSelectedPathsGroupInfo(
string wkPath,
AssetList assetList,
IAssetStatusCache statusCache)
{
SelectedPathsGroupInfo result = new SelectedPathsGroupInfo();
if (assetList.Count == 0)
return result;
result.IsRootSelected = false;
result.IsCheckedoutEverySelected = true;
result.IsDirectoryEverySelected = true;
result.IsCheckedinEverySelected = true;
result.IsChangedEverySelected = true;
foreach (Asset asset in assetList)
{
string fullPath = AssetsPath.GetFullPathUnderWorkspace.
ForAsset(wkPath, asset.path);
if (fullPath == null)
continue;
if (MetaPath.IsMetaPath(fullPath))
fullPath = MetaPath.GetPathFromMetaPath(fullPath);
AssetStatus status = statusCache.GetStatus(fullPath);
string assetName = GetAssetName(asset);
result.IsCheckedoutEverySelected &= ClassifyAssetStatus.IsCheckedOut(status);
result.IsDirectoryEverySelected &= asset.isFolder;
result.IsCheckedinEverySelected &= false; // TODO: not implemented yet
result.IsChangedEverySelected &= false; // TODO: not implemented yet
result.IsAnyDirectorySelected |= asset.isFolder;
result.IsAnyPrivateSelected |= ClassifyAssetStatus.IsPrivate(status) || ClassifyAssetStatus.IsIgnored(status);
result.FilterInfo.IsAnyIgnoredSelected |= ClassifyAssetStatus.IsIgnored(status);
result.FilterInfo.IsAnyHiddenChangedSelected |= ClassifyAssetStatus.IsHiddenChanged(status);
result.SelectedCount++;
if (result.SelectedCount == 1)
{
result.FirstIsControlled = ClassifyAssetStatus.IsControlled(status);
result.FirstIsDirectory = asset.isFolder;
result.FilterInfo.CommonName = assetName;
result.FilterInfo.CommonExtension = Path.GetExtension(assetName);
result.FilterInfo.CommonFullPath = asset.assetPath;
continue;
}
if (result.FilterInfo.CommonName != assetName)
result.FilterInfo.CommonName = null;
if (result.FilterInfo.CommonExtension != Path.GetExtension(assetName))
result.FilterInfo.CommonExtension = null;
if (result.FilterInfo.CommonFullPath != asset.assetPath)
result.FilterInfo.CommonFullPath = null;
}
return result;
}
static string GetAssetName(Asset asset)
{
if (asset.isFolder)
return Path.GetFileName(Path.GetDirectoryName(asset.path));
return asset.fullName;
}
}
}

Some files were not shown because too many files have changed in this diff Show More