Esempio n. 1
0
        public static ValidActions GetValidActions(string assetPath, Object instance = null)
        {
            if (!VCCommands.Active || string.IsNullOrEmpty(assetPath))
            {
                return(noAction);
            }

            var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);

            ValidActions validActions;
            bool         isPrefab              = instance != null && PrefabHelper.IsPrefab(instance);
            bool         isPrefabParent        = isPrefab && PrefabHelper.IsPrefabParent(instance);
            bool         isFolder              = AssetDatabase.IsValidFolder(assetPath);
            bool         diffableAsset         = VCUtility.IsDiffableAsset(assetPath);
            bool         mergableAsset         = VCUtility.IsMergableAsset(assetPath);
            bool         modifiedDiffableAsset = diffableAsset && assetStatus.fileStatus != VCFileStatus.Normal;
            bool         modifiedMeta          = assetStatus.MetaStatus().fileStatus != VCFileStatus.Normal;
            bool         lockedMeta            = assetStatus.MetaStatus().lockStatus == VCLockStatus.LockedHere;
            bool         modified              = assetStatus.fileStatus == VCFileStatus.Modified;
            bool         deleted        = assetStatus.fileStatus == VCFileStatus.Deleted;
            bool         added          = assetStatus.fileStatus == VCFileStatus.Added;
            bool         unversioned    = assetStatus.fileStatus == VCFileStatus.Unversioned;
            bool         ignored        = assetStatus.fileStatus == VCFileStatus.Ignored;
            bool         replaced       = assetStatus.fileStatus == VCFileStatus.Replaced;
            bool         lockedByOther  = assetStatus.lockStatus == VCLockStatus.LockedOther;
            bool         managedByRep   = VCUtility.ManagedByRepository(assetStatus);
            bool         haveControl    = VCUtility.HaveAssetControl(assetStatus);
            bool         haveLock       = VCUtility.HaveVCLock(assetStatus);
            bool         allowLocalEdit = assetStatus.LocalEditAllowed();
            bool         pending        = assetStatus.reflectionLevel == VCReflectionLevel.Pending;

            validActions.showAdd        = !pending && !ignored && unversioned;
            validActions.showOpen       = !pending && !validActions.showAdd && !added && !haveLock && !deleted && !isFolder && !mergableAsset && (!lockedByOther || allowLocalEdit);
            validActions.showDiff       = !pending && !ignored && !deleted && modifiedDiffableAsset && managedByRep;
            validActions.showCommit     = !pending && !ignored && !allowLocalEdit && (haveLock || added || deleted || modifiedDiffableAsset || isFolder || modifiedMeta);
            validActions.showRevert     = !pending && !ignored && !unversioned && (haveControl || modified || added || deleted || replaced || modifiedDiffableAsset || modifiedMeta || lockedMeta);
            validActions.showDelete     = !pending && !ignored && !deleted && !lockedByOther;
            validActions.showOpenLocal  = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && !haveLock && !mergableAsset;
            validActions.showUnlock     = !pending && !ignored && !allowLocalEdit && haveLock;
            validActions.showUpdate     = !pending && !ignored && !added && managedByRep && instance != null;
            validActions.showForceOpen  = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && lockedByOther && Event.current.shift;
            validActions.showDisconnect = isPrefab && !isPrefabParent;

            return(validActions);
        }
Esempio n. 2
0
        public static string GetLockStatusMessage(VersionControlStatus assetStatus)
        {
            string lockMessage = assetStatus.lockStatus.ToString();

            if (assetStatus.lockStatus == VCLockStatus.LockedOther)
            {
                lockMessage = Terminology.getlock + " by: " + assetStatus.owner;
            }
            if (assetStatus.lockStatus == VCLockStatus.LockedHere)
            {
                lockMessage = Terminology.getlock + " Here: " + assetStatus.owner;
            }
            if (assetStatus.lockStatus == VCLockStatus.NoLock)
            {
                if (ComposedString.IsNullOrEmpty(assetStatus.assetPath))
                {
                    lockMessage = "Not saved";
                }
                else if (assetStatus.fileStatus == VCFileStatus.Added)
                {
                    lockMessage = "Added";
                }
                else if (assetStatus.fileStatus == VCFileStatus.Replaced)
                {
                    lockMessage = "Replaced";
                }
                else
                {
                    lockMessage = VCUtility.ManagedByRepository(assetStatus) ? "Not " + Terminology.getlock : "Not on Version Control";
                }
            }
            if (assetStatus.LocalEditAllowed())
            {
                lockMessage = Terminology.allowLocalEdit;
                if ((assetStatus.lockStatus == VCLockStatus.LockedOther))
                {
                    lockMessage += " (" + Terminology.getlock + " By: " + assetStatus.owner + " )";
                }
            }
            if (assetStatus.fileStatus == VCFileStatus.Modified)
            {
                lockMessage += "*";
            }
            return(lockMessage);
        }
Esempio n. 3
0
        private void HandleInput()
        {
            if (c_bNeedsRefresh)
            {
                RefreshStatus();
                c_bNeedsRefresh = false;
            }

            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.F5)
                {
                    RefreshStatus();
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.Delete)
                {
                    VCUtility.VCDeleteWithConfirmation(GetSelectedAssets());
                    Event.current.Use();
                }
            }
        }
        private void Initialize()
        {
            baseFilter = s => false;
            guiFilter  = s => true;

            columnSelection  = new MultiColumnState.Column(new GUIContent("[]"), data => new GUIContent(masterSelection.Contains(data) ? " ☑" : " ☐"));
            columnAssetPath  = new MultiColumnState.Column(new GUIContent("AssetPath"), data => new GUIContent(data.assetPath.Compose()));
            columnOwner      = new MultiColumnState.Column(new GUIContent("Owner"), data => new GUIContent(data.owner, data.lockToken));
            columnFileStatus = new MultiColumnState.Column(new GUIContent("Status"), GetFileStatusContent);
            columnMetaStatus = new MultiColumnState.Column(new GUIContent("Meta"), data => GetFileStatusContent(data.MetaStatus()));
            columnFileType   = new MultiColumnState.Column(new GUIContent("Type"), data => new GUIContent(GetFileType(data.assetPath.Compose())));
            columnConflict   = new MultiColumnState.Column(new GUIContent("Conflict"), data => new GUIContent(data.treeConflictStatus.ToString()));
            columnChangelist = new MultiColumnState.Column(new GUIContent("ChangeList"), data => new GUIContent(data.changelist.Compose()));

            var guiSkin = EditorGUIUtility.GetBuiltinSkin(EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector);

            multiColumnState = new MultiColumnState();

            multiColumnState.Comparer = (r1, r2, c) =>
            {
                var r1Text = c.GetContent(r1.data).text;
                var r2Text = c.GetContent(r2.data).text;
                if (r1Text == null)
                {
                    r1Text = "";
                }
                if (r2Text == null)
                {
                    r2Text = "";
                }
                //D.Log("Comparing: " + r1Text + " with " + r2Text + " : " + r1Text.CompareTo(r2Text));
                return(String.CompareOrdinal(r1Text, r2Text));
            };

            Func <GenericMenu> rowRightClickMenu = () =>
            {
                var selected = multiColumnState.GetSelected().Select(status => status.assetPath.Compose());
                if (!selected.Any())
                {
                    return(new GenericMenu());
                }
                GenericMenu menu = new GenericMenu();
                if (selected.Count() == 1)
                {
                    VCGUIControls.CreateVCContextMenu(ref menu, selected.First());
                }
                else
                {
                    VCGUIControls.CreateVCContextMenu(ref menu, selected);
                }
                var selectedObjs = selected.Select(a => AssetDatabase.LoadMainAssetAtPath(a)).ToArray();
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Show in Project"), false, () =>
                {
                    Selection.objects = selectedObjs;
                    EditorGUIUtility.PingObject(Selection.activeObject);
                });
                menu.AddItem(new GUIContent("Show on Harddisk"), false, () =>
                {
                    Selection.objects = selectedObjs;
                    EditorApplication.ExecuteMenuItem((Application.platform == RuntimePlatform.OSXEditor ? "Assets/Reveal in Finder" : "Assets/Show in Explorer"));
                });
                return(menu);
            };

            Func <MultiColumnState.Column, GenericMenu> headerRightClickMenu = column =>
            {
                var menu = new GenericMenu();
                //menu.AddItem(new GUIContent("Remove"), false, () => { ToggleColumn(column); });
                return(menu);
            };

            // Return value of true steals the click from normal selection, false does not.
            Func <MultiColumnState.Row, MultiColumnState.Column, bool> cellClickAction = (row, column) =>
            {
                GUI.FocusControl("");
                if (column == columnSelection)
                {
                    var currentSelection = multiColumnState.GetSelected();
                    if (currentSelection.Contains(row.data))
                    {
                        bool currentRowSelection = masterSelection.Contains(row.data);
                        foreach (var selectionIt in currentSelection)
                        {
                            if (currentRowSelection)
                            {
                                masterSelection.Remove(selectionIt);
                            }
                            else
                            {
                                masterSelection.Add(selectionIt);
                            }
                        }
                    }
                    else
                    {
                        if (masterSelection.Contains(row.data))
                        {
                            masterSelection.Remove(row.data);
                        }
                        else
                        {
                            masterSelection.Add(row.data);
                        }
                    }
                    return(true);
                }
                return(false);
                //D.Log(row.data.assetPath.Compose() + " : "  + column.GetContent(row.data).text);
            };

            options = new MultiColumnViewOption
            {
                headerStyle          = new GUIStyle(guiSkin.button),
                rowStyle             = new GUIStyle(guiSkin.label),
                rowRightClickMenu    = rowRightClickMenu,
                headerRightClickMenu = headerRightClickMenu,
                cellClickAction      = cellClickAction,
                widths            = new float[] { 200 },
                doubleClickAction = status =>
                {
                    if (VCUtility.IsDiffableAsset(status.assetPath) && VCUtility.ManagedByRepository(status) && status.fileStatus == VCFileStatus.Modified)
                    {
                        VCUtility.DiffWithBase(status.assetPath.Compose());
                    }
                    else
                    {
                        AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(status.assetPath.Compose()));
                    }
                }
            };

            options.headerStyle.fixedHeight      = 20.0f;
            options.rowStyle.onNormal.background = IconUtils.CreateSquareTexture(4, 1, new Color(0.24f, 0.5f, 0.87f, 0.75f));
            options.rowStyle.margin  = new RectOffset(2, 2, 2, 1);
            options.rowStyle.border  = new RectOffset(0, 0, 0, 0);
            options.rowStyle.padding = new RectOffset(0, 0, 0, 0);

            if (showMasterSelection)
            {
                multiColumnState.AddColumn(columnSelection);
                options.widthTable.Add(columnSelection.GetHeader().text, 25);
            }

            multiColumnState.AddColumn(columnAssetPath);
            options.widthTable.Add(columnAssetPath.GetHeader().text, 500);

            multiColumnState.AddColumn(columnFileStatus);
            options.widthTable.Add(columnFileStatus.GetHeader().text, 90);

            multiColumnState.AddColumn(columnMetaStatus);
            options.widthTable.Add(columnMetaStatus.GetHeader().text, 100);

            multiColumnState.AddColumn(columnFileType);
            options.widthTable.Add(columnFileType.GetHeader().text, 80);

            multiColumnState.AddColumn(columnOwner);
            options.widthTable.Add(columnOwner.GetHeader().text, 60);

            multiColumnState.AddColumn(columnChangelist);
            options.widthTable.Add(columnChangelist.GetHeader().text, 120);

            //columnConflictState.AddColumn(columnConflict);
            options.widthTable.Add(columnConflict.GetHeader().text, 80);
        }
Esempio n. 5
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.."));
                }
            }
        }
Esempio n. 6
0
 public static bool HaveAssetControl(this VersionControlStatus vcs)
 {
     return(VCUtility.HaveAssetControl(vcs));
 }
        static void SceneViewUpdate(SceneView sceneView)
        {
            EditorUpdate();
            if (!shouldDraw)
            {
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                string assetPath = selectionPath;
                VCUtility.RequestStatus(assetPath, VCSettings.HierarchyReflectionMode);
                vcSceneStatus = VCCommands.Instance.GetAssetStatus(assetPath);
                validActions  = VCGUIControls.GetValidActions(assetPath);
            }

            buttonStyle = new GUIStyle(EditorStyles.miniButton)
            {
                margin = new RectOffset(0, 0, 0, 0), fixedWidth = 80
            };

            backgroundGuiStyle           = VCGUIControls.GetVCBox(vcSceneStatus);
            backgroundGuiStyle.padding   = new RectOffset(4, 8, 1, 1);
            backgroundGuiStyle.margin    = new RectOffset(1, 1, 1, 1);
            backgroundGuiStyle.border    = new RectOffset(1, 1, 1, 1);
            backgroundGuiStyle.alignment = TextAnchor.MiddleCenter;

            var rect = new Rect(5, 5, 800, 100);

            Handles.BeginGUI();
            GUILayout.BeginArea(new Rect(0, 0, rect.width, rect.height));
            GUILayout.BeginHorizontal();
            GUILayout.TextField(AssetStatusUtils.GetLockStatusMessage(vcSceneStatus), backgroundGuiStyle);
            GUILayout.Label(selectionPath.Substring(selectionPath.LastIndexOf('/') + 1));
            GUILayout.EndHorizontal();


            int       numberOfButtons = 0;
            const int maxButtons      = 4;

            using (GUILayoutHelper.Vertical())
            {
                using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
                {
                    if (validActions.showAdd)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.add, buttonStyle))
                        {
                            SceneManagerUtilities.SaveActiveScene();
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showOpen)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.getlock, buttonStyle))
                        {
                            VCCommands.Instance.GetLockTask(new[] { selectionPath });
                        }
                    }
                    if (validActions.showCommit)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.commit, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showRevert)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(new GUIContent(Terminology.revert, "Shift-click to " + Terminology.revert + " without confirmation"), buttonStyle))
                        {
                            var sceneAssetPath = new[] { selectionPath };
                            if (Event.current.shift || VCUtility.VCDialog(Terminology.revert, sceneAssetPath))
                            {
                                VCCommands.Instance.Revert(sceneAssetPath);
                            }
                        }
                    }
                    if (validActions.showOpenLocal)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.allowLocalEdit, buttonStyle))
                        {
                            VCCommands.Instance.AllowLocalEdit(new[] { selectionPath });
                        }
                    }
                    if (validActions.showUnlock)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.unlock, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.ReleaseLock(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showForceOpen)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button("Force Open", buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCUtility.GetLock(selectionPath, OperationMode.Force));
                        }
                    }

                    // bug: Workaround for a bug in Unity to avoid Tools getting stuck when number of GUI elements change while right mouse is down.
                    using (GUILayoutHelper.Enabled(false))
                    {
                        for (int i = numberOfButtons; i <= maxButtons; ++i)
                        {
                            GUI.Button(new Rect(0, 0, 0, 0), "", EditorStyles.label);
                        }
                    }
                }
            }


            GUILayout.EndArea();
            Handles.EndGUI();
        }
Esempio n. 8
0
 private static void MultiSceneHierarchyElement(string assetPath, Rect selectionRect)
 {
     VCUtility.RequestStatus(assetPath, VCSettings.HierarchyReflectionMode);
     DrawIcon(selectionRect, IconUtils.rubyIcon, assetPath, null, -20f);
 }
Esempio n. 9
0
 static void Refresh()
 {
     VCUtility.RequestStatus(SceneManagerUtilities.GetCurrentScenePath(), VCSettings.HierarchyReflectionMode);
     SceneView.RepaintAll();
 }
Esempio n. 10
0
        static bool drawButtons(string _strAssetPath)
        {
            var validActions = VCGUIControls.GetValidActions(_strAssetPath);

            int       numberOfButtons = 0;
            const int maxButtons      = 5;

            bool bNeedsRepaint = false;

            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                numberOfButtons++;
                if (GUILayout.Button("Refresh", buttonStyle))
                {
                    Refresh(_strAssetPath);
                }

                if (validActions.showAdd)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(Terminology.add, buttonStyle))
                    {
                        bNeedsRepaint = true;

                        SceneManagerUtilities.SaveActiveScene();
                        OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { _strAssetPath }));
                    }
                }
                if (validActions.showOpen)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(Terminology.getlock, buttonStyle))
                    {
                        bNeedsRepaint = true;

                        Refresh(_strAssetPath);
                        if (!validActions.showOpen)
                        {
                            EditorUtility.DisplayDialog("Cannot open Scene!", "This scene has been opened by another user since the last refresh.", "Ok");
                        }
                        else
                        {
                            VCCommands.Instance.GetLockTask(new[] { _strAssetPath });
                        }
                    }
                }
                if (validActions.showCommit)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(Terminology.commit, buttonStyle))
                    {
                        bNeedsRepaint = true;

                        OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { _strAssetPath }));
                    }
                }
                if (validActions.showRevert)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(new GUIContent(Terminology.revert, "Shift-click to " + Terminology.revert + " without confirmation"), buttonStyle))
                    {
                        bNeedsRepaint = true;

                        var assetPath = new[] { _strAssetPath };
                        if (Event.current.shift || VCUtility.VCDialog(Terminology.revert, assetPath))
                        {
                            VCCommands.Instance.Revert(assetPath);
                            OnNextUpdate.Do(AssetDatabase.Refresh);
                        }
                    }
                }
                if (validActions.showOpenLocal)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(Terminology.allowLocalEdit, buttonStyle))
                    {
                        bNeedsRepaint = true;

                        VCCommands.Instance.AllowLocalEdit(new[] { _strAssetPath });
                    }
                }
                if (validActions.showUnlock)
                {
                    numberOfButtons++;
                    if (GUILayout.Button(Terminology.unlock, buttonStyle))
                    {
                        bNeedsRepaint = true;

                        OnNextUpdate.Do(() => VCCommands.Instance.ReleaseLock(new[] { _strAssetPath }));
                    }
                }
                if (validActions.showForceOpen)
                {
                    numberOfButtons++;
                    if (GUILayout.Button("Force Open", buttonStyle))
                    {
                        bNeedsRepaint = true;

                        OnNextUpdate.Do(() => VCUtility.GetLock(_strAssetPath, OperationMode.Force));
                    }
                }

                // bug: Workaround for a bug in Unity to avoid Tools getting stuck when number of GUI elements change while right mouse is down.
                using (GUILayoutHelper.Enabled(false))
                {
                    for (int i = numberOfButtons; i <= maxButtons; ++i)
                    {
                        GUI.Button(new Rect(0, 0, 0, 0), "", EditorStyles.label);
                    }
                }
            }

            return(bNeedsRepaint);
        }
Esempio n. 11
0
 static void Refresh(string _strAssetPath)
 {
     VCUtility.RequestStatus(_strAssetPath, VCSettings.HierarchyReflectionMode);
     SceneView.RepaintAll();
 }
Esempio n. 12
0
        public static void CreateVCContextMenu(ref GenericMenu menu, string assetPath, Object instance = null)
        {
            if (VCUtility.ValidAssetPath(assetPath))
            {
                bool ready = VCCommands.Instance.Ready;
                if (ready)
                {
                    if (instance && ObjectUtilities.ChangesStoredInScene(instance))
                    {
                        assetPath = SceneManagerUtilities.GetCurrentScenePath();
                    }
                    var validActions = GetValidActions(assetPath, instance);

                    if ((validActions & ValidActions.Diff) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.diff), false, () => MergeHandler.DiffWithBase(assetPath));
                    }
                    if ((validActions & ValidActions.Add) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.add), false, () => VCCommands.Instance.Add(new[] { assetPath }));
                    }
                    if ((validActions & ValidActions.Open) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.getlock), false, () => GetLock(assetPath, instance));
                    }
                    if ((validActions & ValidActions.OpenLocal) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.allowLocalEdit), false, () => AllowLocalEdit(assetPath, instance));
                    }
                    if ((validActions & ValidActions.Commit) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.commit), false, () => Commit(assetPath, instance));
                    }
                    if ((validActions & ValidActions.Unlock) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.unlock), false, () => VCCommands.Instance.ReleaseLock(new[] { assetPath }));
                    }
                    if ((validActions & ValidActions.Delete) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.delete), false, () => VCCommands.Instance.Delete(new[] { assetPath }));
                    }
                    if ((validActions & ValidActions.Revert) != 0)
                    {
                        menu.AddItem(new GUIContent(Terminology.revert), false, () => Revert(assetPath, instance));
                    }
                    if ((validActions & ValidActions.UseTheirs) != 0)
                    {
                        menu.AddItem(new GUIContent("Use Theirs"), false, () => VCCommands.Instance.Resolve(new [] { assetPath }, ConflictResolution.Theirs));
                    }
                    if ((validActions & ValidActions.UseMine) != 0)
                    {
                        menu.AddItem(new GUIContent("Use Mine"), false, () => VCCommands.Instance.Resolve(new [] { assetPath }, ConflictResolution.Mine));
                    }
                    if ((validActions & ValidActions.Merge) != 0)
                    {
                        menu.AddItem(new GUIContent("Merge"), false, () => MergeHandler.ResolveConflict(assetPath));
                    }
                    if ((validActions & ValidActions.AddChangeList) != 0)
                    {
                        menu.AddItem(new GUIContent("Add To " + Terminology.changelist), false, () => ChangeListWindow.Open(new [] { assetPath }));
                    }
                    if ((validActions & ValidActions.RemoveChangeList) != 0)
                    {
                        menu.AddItem(new GUIContent("Remove From " + Terminology.changelist), false, () => VCCommands.Instance.ChangeListRemove(new [] { assetPath }));
                    }
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("..Busy.."));
                }
            }
        }
Esempio n. 13
0
        public static ValidActions GetValidActions(string assetPath, Object instance = null)
        {
            using (sceneviewUpdateMarker.Auto())
            {
                if (!VCCommands.Active || string.IsNullOrEmpty(assetPath))
                {
                    return(noAction);
                }

                var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);

                bool isPrefab              = instance != null && PrefabHelper.IsPrefab(instance);
                bool isPrefabParent        = isPrefab && PrefabHelper.IsPrefabParent(instance);
                bool isFolder              = AssetDatabase.IsValidFolder(assetPath);
                bool diffableAsset         = MergeHandler.IsDiffableAsset(assetPath);
                bool mergableAsset         = MergeHandler.IsMergableAsset(assetPath);
                bool modifiedDiffableAsset = diffableAsset && assetStatus.fileStatus != VCFileStatus.Normal;
                bool modifiedMeta          = assetStatus.MetaStatus().fileStatus != VCFileStatus.Normal;
                bool lockedMeta            = assetStatus.MetaStatus().lockStatus == VCLockStatus.LockedHere;
                bool modified              = assetStatus.fileStatus == VCFileStatus.Modified;
                bool localOnly             = assetStatus.localOnly;
                bool deleted        = assetStatus.fileStatus == VCFileStatus.Deleted;
                bool added          = assetStatus.fileStatus == VCFileStatus.Added;
                bool unversioned    = assetStatus.fileStatus == VCFileStatus.Unversioned;
                bool ignored        = assetStatus.fileStatus == VCFileStatus.Ignored;
                bool replaced       = assetStatus.fileStatus == VCFileStatus.Replaced;
                bool lockedByOther  = assetStatus.lockStatus == VCLockStatus.LockedOther;
                bool managedByRep   = VCUtility.ManagedByRepository(assetStatus);
                bool haveControl    = VCUtility.HaveAssetControl(assetStatus);
                bool haveLock       = VCUtility.HaveVCLock(assetStatus);
                bool allowLocalEdit = assetStatus.LocalEditAllowed();
                bool pending        = assetStatus.reflectionLevel == VCReflectionLevel.Pending;
                bool mergeinfo      = assetStatus.property == VCProperty.Modified;
                bool conflicted     = assetStatus.fileStatus == VCFileStatus.Conflicted;
                bool hasChangeSet   = !ComposedString.IsNullOrEmpty(assetStatus.changelist);

                bool showAdd    = !pending && !ignored && unversioned;
                bool showOpen   = !pending && !showAdd && !added && !haveLock && !deleted && !isFolder && !mergableAsset && ((!lockedByOther && !localOnly) || allowLocalEdit);
                bool showDiff   = !pending && !ignored && !deleted && modifiedDiffableAsset && managedByRep;
                bool showCommit = !pending && !ignored && !allowLocalEdit && !localOnly && (haveLock || added || deleted || modifiedDiffableAsset || modifiedMeta || mergeinfo);
                bool showRevert = !pending && !ignored && !unversioned &&
                                  (haveControl || modified || added || deleted || replaced || modifiedDiffableAsset || modifiedMeta || lockedMeta || mergeinfo);
                bool showDelete           = !pending && !ignored && !deleted && !lockedByOther;
                bool showOpenLocal        = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && !haveLock && !mergableAsset && !localOnly;
                bool showUnlock           = !pending && !ignored && !allowLocalEdit && haveLock;
                bool showUpdate           = !pending && !ignored && !added && managedByRep && instance != null;
                bool showUseTheirs        = !pending && !ignored && conflicted;
                bool showUseMine          = !pending && !ignored && conflicted;
                bool showMerge            = !pending && !ignored && conflicted && mergableAsset;
                bool showAddChangeList    = !pending && !ignored && !unversioned;
                bool showRemoveChangeList = !pending && !ignored && hasChangeSet;

                ValidActions validActions = 0;
                if (showAdd)
                {
                    validActions |= ValidActions.Add;
                }
                if (showOpen)
                {
                    validActions |= ValidActions.Open;
                }
                if (showDiff)
                {
                    validActions |= ValidActions.Diff;
                }
                if (showCommit)
                {
                    validActions |= ValidActions.Commit;
                }
                if (showRevert)
                {
                    validActions |= ValidActions.Revert;
                }
                if (showDelete)
                {
                    validActions |= ValidActions.Delete;
                }
                if (showOpenLocal)
                {
                    validActions |= ValidActions.OpenLocal;
                }
                if (showUnlock)
                {
                    validActions |= ValidActions.Unlock;
                }
                if (showUpdate)
                {
                    validActions |= ValidActions.Update;
                }
                if (showUseTheirs)
                {
                    validActions |= ValidActions.UseTheirs;
                }
                if (showUseMine)
                {
                    validActions |= ValidActions.UseMine;
                }
                if (showMerge)
                {
                    validActions |= ValidActions.Merge;
                }
                if (showAddChangeList)
                {
                    validActions |= ValidActions.AddChangeList;
                }
                if (showRemoveChangeList)
                {
                    validActions |= ValidActions.RemoveChangeList;
                }

                return(validActions);
            }
        }
Esempio n. 14
0
 public static bool ModifiedWithoutLock(this VersionControlStatus vcs)
 {
     return(vcs.fileStatus == VCFileStatus.Modified && vcs.lockStatus != VCLockStatus.LockedHere && !VCUtility.IsMergableAsset(vcs.assetPath));
 }
Esempio n. 15
0
        static void SceneViewUpdate(SceneView sceneView)
        {
            using (sceneviewUpdateMarker.Auto())
            {
                InitializeIfNeeded();
                if (!shouldDraw)
                {
                    return;
                }

                // This optimization is causing problems for following sceneview GUI, so removed for now.
                //if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag)
                //    return;

                var stateRect     = new Rect(2f, 2f, buttonWidth, buttonHeight);
                var selectionRect = new Rect(2f + buttonWidth, 1f, 700f, buttonHeight);
                var buttonRect    = new Rect(2f, 2f, buttonWidth, buttonHeight);

                Handles.BeginGUI();

                GUI.TextField(stateRect, AssetStatusUtils.GetStatusText(vcSceneStatus), backgroundGuiStyle);
                GUI.Label(selectionRect, selectionPath.Substring(selectionPath.LastIndexOf('/') + 1), EditorStyles.miniLabel);

                int       numberOfButtons = 0;
                const int maxButtons      = 4;

                using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
                {
                    if ((validActions & ValidActions.Add) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, addContent, buttonStyle))
                        {
                            SceneManagerUtilities.SaveActiveScene();
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }

                    if ((validActions & ValidActions.Open) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, getLockContent, buttonStyle))
                        {
                            VCCommands.Instance.GetLockTask(new[] { selectionPath });
                        }
                    }

                    if ((validActions & ValidActions.Commit) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, commitContent, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }

                    if ((validActions & ValidActions.Revert) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, revertContent, buttonStyle))
                        {
                            var sceneAssetPath = new[] { selectionPath };
                            if (Event.current.shift || VCUtility.VCDialog(Terminology.revert, sceneAssetPath))
                            {
                                VCCommands.Instance.Revert(sceneAssetPath);
                            }
                        }
                    }

                    if ((validActions & ValidActions.OpenLocal) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, allowLocalEditContent, buttonStyle))
                        {
                            VCCommands.Instance.AllowLocalEdit(new[] { selectionPath });
                        }
                    }

                    if ((validActions & ValidActions.Unlock) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, unlockContent, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.ReleaseLock(new[] { selectionPath }));
                        }
                    }

                    // bug: Workaround for a bug in Unity to avoid Tools getting stuck when number of GUI elements change while right mouse is down.
                    using (GUILayoutHelper.Enabled(false))
                    {
                        for (int i = numberOfButtons; i <= maxButtons; ++i)
                        {
                            GUI.Button(new Rect(0, 0, 0, 0), "", EditorStyles.label);
                        }
                    }
                }
                Handles.EndGUI();
            }
        }
Esempio n. 16
0
 static void EditorUpdate()
 {
     shouldDraw = VCSettings.SceneviewGUI && VCCommands.Active && VCUtility.ValidAssetPath(SceneManagerUtilities.GetCurrentScenePath());
 }
Esempio n. 17
0
 static void Refresh()
 {
     VCUtility.RequestStatus(GetSelectionsPersistentAssetPath(), VCSettings.HierarchyReflectionMode);
     SceneView.RepaintAll();
 }
 static void EditorUpdate()
 {
     selectionPath = GetSelectionsPersistentAssetPath();
     shouldDraw    = VCSettings.SceneviewGUI && VCCommands.Active && VCUtility.ValidAssetPath(selectionPath);
 }
Esempio n. 19
0
        public static void VersionControlStatusGUI(GUIStyle style, VersionControlStatus assetStatus, Object obj, bool showAddCommit, bool showLockAndAllowLocalEdit, bool showRevert, bool confirmRevert = false)
        {
            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (assetStatus.lockStatus == VCLockStatus.LockedHere || assetStatus.ModifiedOrLocalEditAllowed() || !VCUtility.ManagedByRepository(assetStatus))
                {
                    if (!assetStatus.ModifiedOrLocalEditAllowed() && obj.GetAssetPath() != "" && showAddCommit)
                    {
                        if (GUILayout.Button((VCUtility.ManagedByRepository(assetStatus) ? Terminology.commit : Terminology.add), GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                }

                if (!VCUtility.HaveVCLock(assetStatus) && VCUtility.ManagedByRepository(assetStatus) && showLockAndAllowLocalEdit)
                {
                    if (assetStatus.fileStatus == VCFileStatus.Added)
                    {
                        if (GUILayout.Button(Terminology.commit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                    else if (assetStatus.lockStatus != VCLockStatus.LockedOther)
                    {
                        if (GUILayout.Button(Terminology.getlock, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.GetLockTask(obj.ToAssetPaths());
                        }
                    }
                    if (!assetStatus.LocalEditAllowed())
                    {
                        if (GUILayout.Button(Terminology.allowLocalEdit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.AllowLocalEdit(obj.ToAssetPaths());
                        }
                    }
                }

                if (showRevert)
                {
                    if (GUILayout.Button(Terminology.revert, GetPrefabToolbarStyle(style, VCUtility.ShouldVCRevert(obj))))
                    {
                        if ((!confirmRevert || Event.current.shift) || VCUtility.VCDialog(Terminology.revert, obj))
                        {
                            var seletedGo   = Selection.activeGameObject;
                            var revertedObj = VCUtility.Revert(obj);
                            OnNextUpdate.Do(() => Selection.activeObject = ((obj is GameObject) ? revertedObj : seletedGo));
                        }
                    }
                }
            }
        }
Esempio n. 20
0
    private void BuildCreation()
    {
        #region Root Transform
        // [VCCase] - Set creation root Transform

        if (m_Attribute.m_Type == ECreation.Sword)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpSwordHilt || cdata.m_Type == EVCComponent.cpLgSwordHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.SwordLarge)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpLgSwordHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.SwordDouble)
        {
            Transform pivot = null;
            int       cdcnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand)
                {
                    pivot = cdata.m_Entity.transform;
                    //SingleHandSword
                    Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword");//VCConfig.s_Parts[cdata.m_ComponentId].m_ResObj
                    go.gameObject.name = "SingleHandSwordL";
                    m_RootL.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    m_RootL.transform.Rotate(Vector3.up, -90, Space.World);
                    m_RootL.transform.Rotate(Vector3.right, 90, Space.World);
                    m_RootL.transform.Rotate(Vector3.up, 180, Space.World);
                    m_RootL.transform.Rotate(Vector3.forward, 180, Space.World);
                    m_RootL.transform.localPosition = -pivot.position;
                    cdcnt++;
                }

                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand)
                {
                    pivot = cdata.m_Entity.transform;

                    Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword");
                    go.gameObject.name = "SingleHandSwordR";


                    //m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    //m_Root.transform.Rotate(Vector3.up, -90, Space.World);
                    //m_Root.transform.Rotate(Vector3.right, 90, Space.World);
                    //m_Root.transform.localPosition = pivot.position;
                    m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    m_Root.transform.Rotate(Vector3.up, -90, Space.World);
                    m_Root.transform.Rotate(Vector3.right, 90, Space.World);
                    m_Root.transform.Rotate(Vector3.up, 180, Space.World);
                    m_Root.transform.Rotate(Vector3.forward, 180, Space.World);
                    m_Root.transform.localPosition = -pivot.position;
                    cdcnt++;
                }

                if (cdcnt == 2)
                {
                    break;
                }
            }
        }

        else if (m_Attribute.m_Type == ECreation.Bow)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpBowGrip)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            AlignPivotInChild(m_Root.transform, pivot);
        }
        else if (m_Attribute.m_Type == ECreation.Axe)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpAxeHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.Shield)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpShieldHandle)
                {
                    pivot = cdata.m_Entity.GetComponent <VCPShieldHandle>().m_PivotPoint;
                    break;
                }
            }
            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.HandGun || m_Attribute.m_Type == ECreation.Rifle)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpGunHandle)
                {
                    pivot = cdata.m_Entity.GetComponent <VCPGunHandle>().m_FirstHandPoint;
                    break;
                }
            }
            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.Vehicle)
        {
            Vector3 pivot     = m_Attribute.m_CenterOfMass;
            float   sum_y     = 0;
            int     wheel_cnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpVehicleWheel)
                {
                    sum_y += cdata.m_Entity.GetComponent <VCEComponentTool>().m_DrawPivot.position.y;
                    wheel_cnt++;
                }
            }
            pivot.y = sum_y / (float)wheel_cnt - 0.1f;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Aircraft)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Boat)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.SimpleObject)
        {
            VCComponentData pivotCmpt = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpPivot)
                {
                    pivotCmpt = cdata;
                    break;
                }
            }

            Vector3 pivot;
            if (pivotCmpt != null)
            {
                pivot = pivotCmpt.m_Position;
            }
            else
            {
                pivot = m_Attribute.m_CenterOfMass;
            }
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Robot)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.AITurret)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.ArmorHead ||
                 m_Attribute.m_Type == ECreation.ArmorBody ||
                 m_Attribute.m_Type == ECreation.ArmorArmAndLeg ||
                 m_Attribute.m_Type == ECreation.ArmorHandAndFoot ||
                 m_Attribute.m_Type == ECreation.ArmorDecoration
                 )
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }

        #endregion

        #region Top Script

        // [VCCase] - Create top scripts
        creationController         = m_Prefab.AddComponent <CreationController>();
        creationController.enabled = false;
        creationController.Init(
            m_PartGroup.transform,
            m_MeshGroup.transform,
            m_DecalGroup.transform,
            m_EffectGroup.transform,
            this);

        switch (m_Attribute.m_Type)
        {
        case ECreation.Sword:
        {
            PeSword      sword      = m_Prefab.AddComponent <PeSword>();
            VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpSwordHilt);
            properties.CopyTo(sword, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            if (properties.Attacktrigger != null)
            {
                for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                {
                    properties.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                    properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                }
            }
        }
        break;

        case ECreation.SwordLarge:
        {
            PeSword      sword      = m_Prefab.AddComponent <PeSword>();
            VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpLgSwordHilt);
            properties.CopyTo(sword, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            if (properties.Attacktrigger != null)
            {
                for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                {
                    properties.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                    properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                }
            }
        }
        break;

        case ECreation.SwordDouble:
        {
            PETwoHandWeapon sword      = m_Prefab.AddComponent <PETwoHandWeapon>();
            VCPSwordHilt    properties = FindComponent <VCPSwordHilt>(EVCComponent.cpDbSwordHilt);
            properties.CopyTo(sword, this);
            sword.m_LHandWeapon = m_RootL;
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            int cnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null)
                {
                    cnt++;
                    VCPSwordHilt hiltL = cdata.m_Entity.GetComponent <VCPSwordHilt>();
                    if (hiltL == null)
                    {
                        continue;
                    }

                    for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                    {
                        hiltL.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                        hiltL.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                    }
                }

                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null)
                {
                    cnt++;
                    VCPSwordHilt hiltR = cdata.m_Entity.GetComponent <VCPSwordHilt>();
                    if (hiltR == null)
                    {
                        continue;
                    }

                    for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                    {
                        hiltR.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.y;
                        hiltR.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.w;
                    }
                }
                if (cnt == 2)
                {
                    break;
                }
            }
        }
        break;


        case ECreation.Bow:
        {
            PEBow      bow           = m_Prefab.AddComponent <PEBow>();
            VCPBowGrip bowProperties = FindComponent <VCPBowGrip>(EVCComponent.cpBowGrip);
            bowProperties.CopyTo(bow, this);
        }
        break;

        case ECreation.Axe:
        {
            PEAxe      axe           = m_Prefab.AddComponent <PEAxe>();
            VCPAxeHilt axeProperties = FindComponent <VCPAxeHilt>(EVCComponent.cpAxeHilt);
            axeProperties.CopyTo(axe, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            axe.m_AnimSpeed = VCUtility.GetAxeAnimSpeed(weight);
        }
        break;

        case ECreation.Shield:
        {
            PESheild sheild = m_Prefab.AddComponent <PESheild>();
            sheild.showOnVehicle = false;
        }
        break;

        case ECreation.Rifle:
        case ECreation.HandGun:
        {
            PEGun        gun = m_Prefab.AddComponent <PEGun>();
            VCPGunHandle handleProperties = FindComponent <VCPGunHandle>(EVCComponent.cpGunHandle);
            VCPGunMuzzle muzzleProperties = FindComponent <VCPGunMuzzle>(EVCComponent.cpGunMuzzle);
            handleProperties.CopyTo(gun);
            muzzleProperties.CopyTo(gun);
        }
        break;

        case ECreation.Vehicle:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Aircraft:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Boat:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Robot:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.AITurret:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.SimpleObject:
            break;

        case ECreation.ArmorHead:
        case ECreation.ArmorBody:
        case ECreation.ArmorArmAndLeg:
        case ECreation.ArmorHandAndFoot:
        case ECreation.ArmorDecoration:
            break;

        default:
            break;
        }

        #endregion
    }