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) { 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()); }
private static bool IsOpenForEdit(string assetPath, out string message) { if (VCCommands.Active && VCSettings.LockAssets) { var ap = new ComposedString(assetPath).TrimEnd(VCCAddMetaFiles.meta); if (!VCUtility.IsMergableAsset(ap) && ap.StartsWith("Assets/")) { var status = VCCommands.Instance.GetAssetStatus(ap); message = AssetStatusUtils.GetStatusText(status); return(VCUtility.HaveAssetControl(status)); } } message = ""; return(true); }
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))) && VCSettings.LockAssets; SetEditable(material, !shouldLock); }
internal static void RefreshEditableObject(GameObject gameObject) { if (!EditorUtility.IsPersistent(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); } } } }