Beispiel #1
0
        private static bool ShouleBeEditable(GameObject gameObject)
        {
            var assetPath = gameObject.GetAssetPath();

            if (assetPath == "")
            {
                return(true);
            }
            var assetStatus = gameObject.GetAssetStatus();

            if (!VCUtility.ManagedByRepository(assetStatus))
            {
                return(true);
            }
            bool isPrefab = ObjectUtilities.ChangesStoredInPrefab(gameObject);

            if (isPrefab && LockPrefab(assetPath))
            {
                return(VCUtility.HaveAssetControl(assetStatus));
            }
            else // Treat as scene object
            {
                string scenePath = ObjectUtilities.ObjectToAssetPath(gameObject, false);
                if (scenePath == "")
                {
                    return(true);
                }
                var  vcSceneStatus    = VCCommands.Instance.GetAssetStatus(scenePath);
                bool haveSceneControl = VCUtility.HaveAssetControl(vcSceneStatus);
                bool lockScene        = LockScene(scenePath);
                return(haveSceneControl || !lockScene);
            }
        }
        private static string[] OnWillSaveAssets(string[] assets)
        {
            if (UnityEditorInternal.InternalEditorUtility.inBatchMode ||
                !VCCommands.Active ||
                VCSettings.SaveStrategy == VCSettings.ESaveAssetsStrategy.Unity ||
                VCCommands.Instance.FlusingFiles ||
                EditorApplication.isCompiling)
            {
                return(assets);
            }


            if (assets.Any(a => VCCommands.Instance.GetAssetStatus(a).reflectionLevel == VCReflectionLevel.None))
            {
                VCCommands.Instance.Status(assets, StatusLevel.Previous);
            }

            var toBeSaved = new List <string>();
            var noControl = new List <string>();

            foreach (var asset in assets)
            {
                //D.Log(asset+ " has ignored parentfolder: " + VCCommands.Instance.InIgnoredParentFolder(asset));
                if (VCUtility.HaveAssetControl(asset) || !VCUtility.ManagedByRepository(asset) || asset.InUnversionedParentFolder(VCCommands.Instance) || asset.InIgnoredParentFolder(VCCommands.Instance))
                {
                    toBeSaved.Add(asset);
                }
                else
                {
                    noControl.Add(asset);
                }
            }

            if (noControl.Count > 0)
            {
                foreach (var asset in noControl)
                {
                    string message = string.Format("Unity is trying to save following file which is not under control on {1}.\n\n'{0}'", asset, VCSettings.VersionControlBackend, Terminology.getlock);
                    int    result  = EditorUtility.DisplayDialogComplex("Save File?", message, Terminology.allowLocalEdit, Terminology.getlock, "Do not save");
                    if (result == 0 || result == 1)
                    {
                        toBeSaved.Add(asset);
                        if (result == 0)
                        {
                            VCCommands.Instance.AllowLocalEdit(new[] { asset });
                        }

                        if (result == 1)
                        {
                            VCCommands.Instance.GetLock(new[] { asset }, OperationMode.Normal);
                        }
                    }
                }
            }
            return(toBeSaved.ToArray());
        }
Beispiel #3
0
        private static bool ShouleBeEditable(GameObject gameObject)
        {
            //Debug.Log(gameObject.name + " - " +
            //    gameObject.GetAssetPath() + " - " +
            //    VCUtility.ManagedByRepository(gameObject.GetAssetStatus()) +  " - " +
            //    ObjectUtilities.ChangesStoredInPrefab(gameObject) + " - " +
            //    LockPrefab(gameObject.GetAssetPath()) + " - " +
            //    VCUtility.HaveAssetControl(gameObject.GetAssetStatus()) + " - " +
            //    ObjectUtilities.ObjectToAssetPath(gameObject, false) + " - " +
            //    PrefabUtility.GetPrefabType(gameObject).ToString());

            var assetPath = gameObject.GetAssetPath();

            if (assetPath == "")
            {
                return(true);
            }
            var assetStatus = gameObject.GetAssetStatus();

            if (!VCUtility.ManagedByRepository(assetStatus))
            {
                return(true);
            }
            bool isPrefab = ObjectUtilities.ChangesStoredInPrefab(gameObject);

            if (isPrefab)
            {
                if (LockPrefab(assetPath))
                {
                    return(VCUtility.HaveAssetControl(assetStatus));
                }
                else //Stella: if not-locked prefab, allow editing even though this might affect scene
                {
                    return(true);
                }
            }
            else // Treat as scene object
            {
                string scenePath = ObjectUtilities.ObjectToAssetPath(gameObject, false);
                if (scenePath == "")
                {
                    return(true);
                }
                var  vcSceneStatus    = VCCommands.Instance.GetAssetStatus(scenePath);
                bool haveSceneControl = VCUtility.HaveAssetControl(vcSceneStatus);
                bool lockScene        = LockScene(scenePath);
                return(haveSceneControl || !lockScene);
            }
        }
Beispiel #4
0
        internal static void RefreshEditableObject(GameObject gameObject)
        {
            bool editable           = ShouleBeEditable(gameObject);
            bool parentEditable     = gameObject.transform.parent ? ShouleBeEditable(gameObject.transform.parent.gameObject) : VCUtility.HaveAssetControl(SceneManagerUtilities.GetCurrentScenePath());
            bool prefabHeadEditable = PrefabHelper.IsPrefabRoot(gameObject) && parentEditable;

            if (prefabHeadEditable)
            {
                SetEditable(gameObject, true);
            }
            else
            {
                SetEditable(gameObject, editable);
            }

            foreach (var componentIt in gameObject.GetComponents <Component>())
            {
                if (prefabHeadEditable && componentIt == gameObject.transform)
                {
                    SetEditable(gameObject.transform, true);
                }
                else
                {
                    RefreshEditableComponent(gameObject, componentIt);
                }
            }
        }
Beispiel #5
0
 internal static void RefreshEditableMaterial(Material material)
 {
     SetEditable(material, VCUtility.HaveAssetControl(material) || !LockMaterial(material.GetAssetPath()));
 }
Beispiel #6
0
        private static void SetMaterialLock(Material material, bool gameObjectLocked)
        {
            var  assetPath             = material.GetAssetPath();
            var  assetStatus           = VCCommands.Instance.GetAssetStatus(assetPath);
            bool materialStoredInScene = VCUtility.MaterialStoredInScene(material);
            bool shouldLock            = (materialStoredInScene ? gameObjectLocked : (VCUtility.ManagedByRepository(assetStatus) && !VCUtility.HaveAssetControl(assetStatus))) && LockMaterial(assetPath);

            SetEditable(material, !shouldLock);
        }