示例#1
0
        public static void CreateVCContextMenu(ref GenericMenu menu, IEnumerable <string> assetPaths)
        {
            bool bHidden = false;;
            bool bSet    = false;
            bool bEqual  = true;

            foreach (string strPath in assetPaths)
            {
                if (!bSet)
                {
                    bHidden = VCSettings.bHidden(strPath);
                }
                else if (bHidden != VCSettings.bHidden(strPath))
                {
                    bEqual = false;
                }
            }
            if (bEqual)
            {
                if (bHidden)
                {
                    menu.AddItem(new GUIContent("Unhide"), false, () => VCSettings.removeHidden(assetPaths));
                }
                else
                {
                    menu.AddItem(new GUIContent("Hide"), false, () => VCSettings.addHidden(assetPaths));
                }
            }

            menu.AddItem(new GUIContent(Terminology.log), false, () => UnityVersionControl.Source.GUI.Windows.VCLogWindow.showLogWindow(assetPaths));
            menu.AddItem(new GUIContent(Terminology.add), false, () => VCCommands.Instance.Add(assetPaths));
            menu.AddItem(new GUIContent(Terminology.getlock), false, () => VCCommands.Instance.GetLock(assetPaths));
            menu.AddItem(new GUIContent(Terminology.commit), false, () => VCCommands.Instance.CommitDialog(assetPaths));
            menu.AddItem(new GUIContent(Terminology.revert), false, () => VCCommands.Instance.RevertDialog(assetPaths));
            menu.AddItem(new GUIContent(Terminology.delete), false, () => VCCommands.Instance.DeleteDialog(assetPaths));
        }
示例#2
0
        public static void CreateVCContextMenu(ref GenericMenu menu, string assetPath, Object instance = null)
        {
            if (VCUtility.ValidAssetPath(assetPath))
            {
                bool ready = VCCommands.Instance.Ready;
                if (ready)
                {
                    var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);
                    if (instance && ObjectUtilities.ChangesStoredInScene(instance))
                    {
                        assetPath = SceneManagerUtilities.GetCurrentScenePath();
                    }
                    var validActions = GetValidActions(assetPath, instance);

                    if (VCSettings.bHidden(assetPath))
                    {
                        menu.AddItem(new GUIContent("Unhide"), false, () => VCSettings.removeHidden(assetPath));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Hide"), false, () => VCSettings.addHidden(assetPath));
                    }


                    if (validActions.showLog)
                    {
                        menu.AddItem(new GUIContent(Terminology.log), false, () => UnityVersionControl.Source.GUI.Windows.VCLogWindow.showLogWindow(new[] { assetPath }));
                    }
                    if (validActions.showDiff)
                    {
                        menu.AddItem(new GUIContent(Terminology.diff), false, () => VCUtility.DiffWithBase(assetPath));
                    }
                    if (validActions.showAdd)
                    {
                        menu.AddItem(new GUIContent(Terminology.add), false, () => VCCommands.Instance.Add(new[] { assetPath }));
                    }
                    if (validActions.showOpen)
                    {
                        menu.AddItem(new GUIContent(Terminology.getlock), false, () => GetLock(assetPath, instance));
                    }
                    if (validActions.showOpenLocal)
                    {
                        menu.AddItem(new GUIContent(Terminology.allowLocalEdit), false, () => AllowLocalEdit(assetPath, instance));
                    }
                    if (validActions.showForceOpen)
                    {
                        menu.AddItem(new GUIContent("Force " + Terminology.getlock), false, () => GetLock(assetPath, instance, OperationMode.Force));
                    }
                    if (validActions.showCommit)
                    {
                        menu.AddItem(new GUIContent(Terminology.commit), false, () => Commit(assetPath, instance));
                    }
                    if (validActions.showUnlock)
                    {
                        menu.AddItem(new GUIContent(Terminology.unlock), false, () => VCCommands.Instance.ReleaseLock(new[] { assetPath }));
                    }
                    if (validActions.showDisconnect)
                    {
                        menu.AddItem(new GUIContent("Disconnect"), false, () => PrefabHelper.DisconnectPrefab(instance as GameObject));
                    }
                    if (validActions.showDelete)
                    {
                        menu.AddItem(new GUIContent(Terminology.delete), false, () => VCCommands.Instance.DeleteDialog(new[] { assetPath }));
                    }
                    if (validActions.showRevert)
                    {
                        menu.AddItem(new GUIContent(Terminology.revert), false, () => Revert(assetPath, instance));
                    }
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("..Busy.."));
                }
            }
        }