Esempio n. 1
0
        internal static void CutCopySelectedAssets(PerformedAction action)
        {
            performedAction = action;

            if (Selection.objects.Length > 0)
            {
                CutCopyAssets(Selection.objects);
            }
        }
Esempio n. 2
0
 public async Task CreateUserActivity(PerformedAction action, string username = null, string drinkId = null, string drinkName = null,
                                      string searchedPhrase = null, int?score = null)
 {
     using var httpClient = new HttpClient();
     var newUserActivity = new UserActivityDto
     {
         Username       = username,
         Action         = action,
         DrinkId        = drinkId,
         DrinkName      = drinkName,
         SearchedPhrase = searchedPhrase,
         Score          = score
     };
     var content  = new StringContent(JsonConvert.SerializeObject(newUserActivity), Encoding.UTF8, "application/json");
     var response = await httpClient.PostAsync(CreateActivityAddress, content);
 }
Esempio n. 3
0
        static int[] PasteFoldersAfterCut(string destination = null)
        {
            List <string> pastedObjects = new List <string>();

            string[] assetPaths = new string[assetClipboard.Count];

            int counter = 0;

            foreach (var item in assetClipboard)
            {
                assetPaths[counter] = AssetDatabase.GetAssetPath(ObjectIdentifier.ToObject(item));
                counter++;
            }

            if (counter > 0)
            {
                Undo.RegisterAssetsMoveUndo(assetPaths);
            }

            counter = 0;
            foreach (var item in assetClipboard)
            {
                var assetPath = assetPaths[counter];

                var newPath = AssetDatabase.GenerateUniqueAssetPath(GetValidPath(assetPath, destination));
                if (String.IsNullOrEmpty(AssetDatabase.MoveAsset(assetPath, newPath)))
                {
                    pastedObjects.Add(newPath);
                    counter++;
                }
            }

            Reset();
            performedAction = PerformedAction.None;
            AssetDatabase.Refresh();

            int[] copiedAssets = new int[pastedObjects.Count];

            for (int i = 0; i < pastedObjects.Count; i++)
            {
                copiedAssets[i] = AssetDatabase.LoadMainAssetAtPath(pastedObjects[i]).GetInstanceID();
            }

            return(copiedAssets);
        }
Esempio n. 4
0
        internal static void CutCopySelectedFolders(int[] instanceIDs, PerformedAction action)
        {
            Reset();
            performedAction = action;
            AssetDatabase.Refresh();

            int assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets");

            foreach (int instanceID in instanceIDs)
            {
                if (instanceID == assetsFolderInstanceID)
                {
                    continue;
                }

                ObjectIdentifier.GetObjectIdentifierFromInstanceID(instanceID, out var identifier);
                assetClipboard.Add(identifier);
            }
        }
Esempio n. 5
0
        internal static void PasteSelectedAssets(bool isTwoColumnView)
        {
            string targetPath;

            // If we are using OneColumnLayout rely on object selection, otherwise rely on active folder
            if (!isTwoColumnView && Selection.objects.Length == 1)
            {
                targetPath = AssetDatabase.GetAssetPath(Selection.activeObject);

                // If selected object is folder, make sure we paste into it.
                if (AssetDatabase.IsValidFolder(targetPath))
                {
                    targetPath += "/";
                }
                else
                {
                    targetPath = Path.GetDirectoryName(targetPath);
                }
            }
            else
            {
                targetPath = ProjectWindowUtil.GetActiveFolderPath();
            }

            switch (performedAction)
            {
            case PerformedAction.Copy:
                Selection.objects = PasteCopiedAssets(targetPath).ToArray();
                break;

            case PerformedAction.Cut:
                Selection.objects = PasteCutAssets(targetPath).ToArray();
                performedAction   = PerformedAction.None;
                break;
            }
        }
Esempio n. 6
0
 internal static void CancelCut()
 {
     Reset();
     performedAction = PerformedAction.None;
 }
Esempio n. 7
0
 internal static void DuplicateSelectedAssets()
 {
     performedAction   = PerformedAction.None;
     Selection.objects = DuplicateAssets(Selection.objects).ToArray();
 }
Esempio n. 8
0
 public WaitForWorkerAction(PerformedAction action, NetMessageHandler handler)
 {
     m_action  = action;
     m_handler = handler;
 }