public static System.IO.FileInfo CheckOutFile(string fname, CheckOutType type = CheckOutType.CheckOut | CheckOutType.ForceWriteable) { var fullpath = fname; if (!System.IO.File.Exists(fname)) { fullpath = Application.dataPath + "/../" + fname; } var fInfo = new System.IO.FileInfo(fullpath); if (fInfo != null) { if (fInfo.Exists) { if ((UnityEditor.VersionControl.Provider.isActive) && ((type & CheckOutType.CheckOut) == CheckOutType.CheckOut)) { System.Uri uri1 = new System.Uri(fInfo.FullName); System.Uri uri2 = new System.Uri(Application.dataPath); var path = uri2.MakeRelativeUri(uri1).ToString(); UnityEditor.VersionControl.Provider.Checkout(path, UnityEditor.VersionControl.CheckoutMode.Both); //EB.Debug.Log("Checking out asset: " + path); } if (fInfo.IsReadOnly && (type & CheckOutType.ForceWriteable) == CheckOutType.ForceWriteable) { fInfo.Attributes ^= System.IO.FileAttributes.ReadOnly; //EB.Debug.Log("Force readonly file to be writable: " + fname); } } } return(fInfo); }
/// <summary> /// Determine the checkout type /// </summary> /// <returns>The current CheckoutType</returns> public virtual CheckOutType GetCheckoutType() { CheckOutType checkoutType = CheckOutType.Standard; try { checkoutType = (CheckOutType)Enum.Parse(typeof(CheckOutType), AppLogic.AppConfig("Checkout.Type", AppLogic.StoreID(), true)); } catch (Exception) { checkoutType = CheckOutType.Standard; } return(checkoutType); }