コード例 #1
0
        private static void ReMoveAssetOnVC(string from, string to)
        {
            VersionControlStatus status = VCCommands.Instance.GetAssetStatus(from);
            string topUnversionedFolder;

            if (VCUtility.ManagedByRepository(status) && !InUnversionedParentFolder(from, out topUnversionedFolder))
            {
                if (DisplayConfirmationDialog("Move", from, status))
                {
                    if (InUnversionedParentFolder(to, out topUnversionedFolder))
                    {
                        string msg    = "Versioned files are moved into an unversioned folder. Add following unversioned folder first?\n\n" + topUnversionedFolder;
                        int    result = EditorUtility.DisplayDialogComplex("Add Folder?", msg, "Yes", "No", "Cancel");
                        if (result == 0)
                        {
                            //MoveAssetBack(from, to);
                            VCCommands.Instance.Add(new[] { topUnversionedFolder });
                            VCCommands.Instance.Status(new[] { topUnversionedFolder }, StatusLevel.Local);
                        }
                        if (result == 1)
                        {
                            //VCCommands.Instance.Delete(new[] { from }, OperationMode.Force);
                            return;
                        }
                        if (result == 2)
                        {
                            MoveAssetBack(from, to);
                            return;
                        }
                    }
                    //else
                    //{
                    //    MoveAssetBack(from, to);
                    //}

                    //VCCommands.Instance.Move(from, to);
                    AssetDatabase.Refresh();
                    GameObjectToAssetPathCache.ClearObjectToAssetPathCache();
                }
                else
                {
                    MoveAssetBack(from, to);
                }
            }
        }
コード例 #2
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (VCCommands.Active)
            {
                D.Log("OnPostprocessAllAssets : imported: " + importedAssets.Length + ", deleted: " + deletedAssets.Length + ", moved: " + movedAssets.Length + ", movedFrom: " + movedAssets.Length);

                if (VCSettings.HandleFileMove == VCSettings.EHandleFileMove.Simple)
                {
                    if (deletedAssets.Length == 0 && movedAssets.Length > 0 && movedAssets.Length == movedFromAssetPaths.Length)
                    {
                        callcount++;
                        if (callcount == 1)
                        {
                            var parentFolders = RemoveFilesIfParentFolderInList(movedAssets);
                            for (int i = 0; i < movedAssets.Length; ++i)
                            {
                                string from = movedFromAssetPaths[i];
                                string to   = movedAssets[i];
                                if ((File.Exists(to) || Directory.Exists(to) && !File.Exists(from) && !Directory.Exists(from)) && parentFolders.Contains(to))
                                {
                                    ReMoveAssetOnVC(movedFromAssetPaths[i], movedAssets[i]);
                                }
                            }
                            callcount--;
                        }
                    }
                }

                changedAssets.AddRange(importedAssets);
                changedAssets.AddRange(movedAssets);
                changedAssets.AddRange(deletedAssets);
                changedAssets.AddRange(movedFromAssetPaths);
                if (changedAssets.Count > 0)
                {
                    changedAssets = changedAssets.Distinct().ToList();
                    VCCommands.Instance.RemoveFromDatabase(changedAssets);
                    VCCommands.Instance.RequestStatus(changedAssets, StatusLevel.Previous);
                    changedAssets.Clear();
                }
            }
            GameObjectToAssetPathCache.ClearObjectToAssetPathCache();
        }