Ejemplo n.º 1
0
        public void TestIsPrivateSelection()
        {
            try
            {
                PlasticApiMock apiMock = new PlasticApiMock();

                Plastic.InitializeAPIForTesting(apiMock);

                string fooPath = Path.Combine(Path.GetTempPath(), "foo.c");
                string barPath = Path.Combine(Path.GetTempPath(), "bar.c");

                Asset fooAsset = new Asset(fooPath);
                Asset barAsset = new Asset(barPath);

                apiMock.SetupGetWorkspaceTreeNode(fooPath, null);
                apiMock.SetupGetWorkspaceTreeNode(barPath, null);
                apiMock.SetupGetWorkingBranch(new BranchInfo());

                AssetList assetList = new AssetList();
                assetList.Add(fooAsset);
                assetList.Add(barAsset);

                SelectedAssetGroupInfo groupInfo =
                    SelectedAssetGroupInfo.BuildFromAssetList(
                        assetList,
                        new AssetStatusCacheMock());

                Assert.IsTrue(groupInfo.IsPrivateSelection);
            }
            finally
            {
                Plastic.InitializeAPIForTesting(new PlasticAPI());
            }
        }
Ejemplo n.º 2
0
    static void Checkout()
    {
        AssetList assets = new AssetList();

#if FUXI_DEVELOPER
        assets.Add(new Asset("Assets/Scripts/"));
#elif FUXI_ARTIST
        assets.Add(new Asset("Assets/Builds/"));
#endif
        Task t = Provider.Checkout(assets, CheckoutMode.Both);
        t.Wait();
    }
Ejemplo n.º 3
0
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }

            var files = Directory.GetFiles(tempOutputPath, "*.*", SearchOption.AllDirectories);

            var assetList = new AssetList();

            foreach (string f in files)
            {
                assetList.Add(Provider.GetAssetByPath(f.Replace(tempOutputPath, "")));
            }

            var checkoutTask = Provider.Checkout(assetList, CheckoutMode.Exact);

            checkoutTask.Wait();

            var failedToCheckout = checkoutTask.assetList.Where(a => (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly);

            if (!checkoutTask.success || failedToCheckout.Any())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", failedToCheckout.Select(a => a.fullName + " (" + a.state + ")").Aggregate((acc, curr) => acc + Environment.NewLine + "\t" + curr));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }

            FileUtil.CopyDirectoryRecursive(tempOutputPath, ".", true);
            FileUtil.DeleteFileOrDirectory(tempOutputPath);
        }
Ejemplo n.º 4
0
        public static string Checkout(this string file)
        {
            AssetList list = new AssetList();

            list.Add(new Asset(file));

            if (File.Exists(file))
            {
                try
                {
                    Provider.Checkout(list, CheckoutMode.Asset).Wait();
                    Debug.Log("Checked out file: " + file);
                }
                catch (System.Exception)
                {
                    try
                    {
                        //Set it writable
                        File.SetAttributes(file, FileAttributes.Normal);
                        Debug.LogWarning("Set writable: " + file);
                    }
                    catch (System.Exception)
                    {
                        Debug.LogError("Can't checkout file: " + file);
                    }
                }
            }

            return(file);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get an <see cref="UnityEditor.VersionControl.AssetList"/> from an <paramref name="absoluteDirectoryPath"/>.
        /// </summary>
        /// <param name="absoluteDirectoryPath">A fully qualified path on disk to query.</param>
        /// <param name="searchPattern">The search pattern to look for files with.</param>
        /// <param name="searchOption">What level of searching should be done.</param>
        /// <returns>An <see cref="UnityEditor.VersionControl.AssetList"/> containing any valid assets under version control.</returns>
        public static AssetList GetAssetListFromFolder(string absoluteDirectoryPath, string searchPattern = "*.*",
                                                       SearchOption searchOption = SearchOption.AllDirectories)
        {
            if (absoluteDirectoryPath == null || !Directory.Exists(absoluteDirectoryPath))
            {
                return(null);
            }

            AssetList checkoutAssets = new AssetList();

            string[] filePaths = Directory.GetFiles(absoluteDirectoryPath, searchPattern, searchOption);
            int      length    = filePaths.Length;

            for (int i = 0; i < length; i++)
            {
                Asset foundAsset =
                    Provider.GetAssetByPath(filePaths[i].Replace(UnityEngine.Application.dataPath, ""));
                if (foundAsset != null)
                {
                    checkoutAssets.Add(foundAsset);
                }
            }

            return(checkoutAssets);
        }
Ejemplo n.º 6
0
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }
            string[]  files  = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
            AssetList assets = new AssetList();

            foreach (string str in files)
            {
                assets.Add(Provider.GetAssetByPath(str.Replace("Temp/ScriptUpdater/", string.Empty)));
            }
            Task task = Provider.Checkout(assets, CheckoutMode.Exact);

            task.Wait();
            IEnumerable <Asset> source = task.assetList.Where <Asset>((Func <Asset, bool>)(a => (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly));

            if (!task.success || source.Any <Asset>())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", (object)source.Select <Asset, string>((Func <Asset, string>)(a => a.fullName + " (" + (object)a.state + ")")).Aggregate <string>((Func <string, string, string>)((acc, curr) => acc + Environment.NewLine + "\t" + curr)));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
            }
            else
            {
                FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
                FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
            }
        }
            public void Perform(AssetList list, BaseObject source = null, BaseObject target = null)
            {
                switch (_mode)
                {
                case Mode.Source:
                    if (source != null)
                    {
                        if (_operator == Operator.Add)
                        {
                            list.Add(source);
                        }
                        else
                        {
                            list.Remove(source);
                        }
                    }
                    break;

                case Mode.Target:
                    if (target != null)
                    {
                        if (_operator == Operator.Add)
                        {
                            list.Add(target);
                        }
                        else
                        {
                            list.Remove(target);
                        }
                    }
                    break;

                case Mode.AssetList:
                    if (_assetList != null)
                    {
                        if (_operator == Operator.Add)
                        {
                            list.AddRange(_assetList);
                        }
                        else
                        {
                            list.RemoveRange(_assetList);
                        }
                    }
                    break;
                }
            }
        public BoolWithMessage AddAsset()
        {
            string errorMessage = ValidateAssetInfo(null);

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                return(BoolWithMessage.False($"The following errors were found:\n\n{errorMessage}"));
            }

            Asset newAsset = new Asset()
            {
                ID           = $"{SelectedAssetID}{SelectedIDExtension}",
                Author       = SelectedAssetAuthor,
                Category     = SelectedAssetCategory,
                Description  = SelectedAssetDescription,
                Name         = SelectedAssetName,
                PreviewImage = SelectedAssetImageUrl,
                UpdatedDate  = DateTime.UtcNow,
                Version      = 1,
            };


            if (!string.IsNullOrWhiteSpace(SelectedAssetUpdatedDate))
            {
                DateTime.TryParse(SelectedAssetUpdatedDate, out DateTime updateDate);
                if (updateDate != null && updateDate != DateTime.MinValue)
                {
                    newAsset.UpdatedDate = updateDate;
                }
            }

            double.TryParse(SelectedAssetVersion, out double version);

            if (version <= 0)
            {
                newAsset.Version = version;
            }

            if (SelectedAssetDownloadType == "Url")
            {
                newAsset.DownloadLink = AssetCatalog.FormatUrl(SelectedAssetDownloadUrl);
            }
            else if (SelectedAssetDownloadType == "Google Drive")
            {
                newAsset.DownloadLink = $"rsmm://GDrive/{SelectedAssetDownloadUrl}";
            }


            AssetViewModel viewModel = new AssetViewModel(newAsset);

            AssetList.Add(viewModel);

            AssetToEdit   = null;
            SelectedAsset = null;
            SelectedAsset = AssetList[AssetList.Count - 1];

            return(BoolWithMessage.True());
        }
Ejemplo n.º 9
0
        public void AddAsset(string assetId)
        {
            if (m_basicAssetsList == null)
            {
                LoadBasicAssets();
            }

            AssetList.Add(assetId);
        }
Ejemplo n.º 10
0
        public void TestIsNotFileSelection()
        {
            string barPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            try
            {
                PlasticApiMock apiMock = new PlasticApiMock();

                Plastic.InitializeAPIForTesting(apiMock);

                string fooPath = Path.Combine(Path.GetTempPath(), "foo.c");

                Directory.CreateDirectory(barPath);

                Asset fooAsset = new Asset(fooPath);
                Asset barAsset = new Asset(barPath);

                WorkspaceTreeNode fooNode = BuildWorkspaceTreeNode.Controlled();

                apiMock.SetupGetWorkspaceTreeNode(fooPath, fooNode);
                apiMock.SetupGetWorkingBranch(new BranchInfo());

                AssetList assetList = new AssetList();
                assetList.Add(fooAsset);
                assetList.Add(barAsset);

                SelectedAssetGroupInfo groupInfo =
                    SelectedAssetGroupInfo.BuildFromAssetList(
                        assetList,
                        new AssetStatusCacheMock());

                Assert.IsFalse(groupInfo.IsFileSelection);
            }
            finally
            {
                Plastic.InitializeAPIForTesting(new PlasticAPI());

                if (Directory.Exists(barPath))
                {
                    Directory.Delete(barPath);
                }
            }
        }
Ejemplo n.º 11
0
    static void Submit()
    {
        var t = Provider.ChangeSets();

        t.Wait();

        AssetList assets = new AssetList();
        var       log    = "";

#if FUXI_DEVELOPER
        assets.Add(new Asset("Assets/Scripts/"));
        log = Application.productName + "Developer Auto Submit";
#elif FUXI_ARTIST
        assets.Add(new Asset("Assets/Builds/"));
        log = Application.productName + "Artist Auto Submit";
#endif
        Task t2 = Provider.Submit(t.changeSets[0], assets, log, false);
        t2.Wait();
    }
Ejemplo n.º 12
0
        internal void AddAsset(AssetObjectInfo assetInfo)
        {
            if (AssetList == null)
            {
                AssetList = new List <AssetObjectInfo>();
            }

            assetInfo.SetParent(this);
            AssetList.Add(assetInfo);
        }
Ejemplo n.º 13
0
    static void GetLatestBuild()
    {
        Debug.Log("同步美术资源中");
        AssetList assets = new AssetList();

        assets.Add(new Asset("Assets/Builds/"));
        Task t = Provider.GetLatest(assets);

        t.Wait();
        Debug.Log("美术资源同步完成");
    }
        AssetList AssetOperations.IAssetSelection.GetSelectedAssets()
        {
            AssetList result = new AssetList();

            foreach (UnityEngine.Object obj in UnityEditor.Selection.objects)
            {
                result.Add(new Asset(AssetsPath.GetFullPath(obj)));
            }

            return(result);
        }
Ejemplo n.º 15
0
        private void Apply()
        {
            var changedIndices = new List <int>();
            var changedScripts = new List <MonoScript>();

            for (int i = 0; i < m_AllScripts.Length; i++)
            {
                if (MonoImporter.GetExecutionOrder(m_AllScripts[i]) != m_AllOrders[i])
                {
                    changedIndices.Add(i);
                    changedScripts.Add(m_AllScripts[i]);
                }
            }

            bool editable = true;

            if (Provider.enabled)
            {
                var needToCheckout = new AssetList();
                foreach (var s in changedScripts)
                {
                    var asset = Provider.GetAssetByPath(AssetDatabase.GetAssetPath(s));
                    if (asset == null) // script might be outside of the project (e.g. in a package)
                    {
                        continue;
                    }
                    if (AssetDatabase.IsMetaFileOpenForEdit(s, StatusQueryOptions.UseCachedIfPossible))
                    {
                        continue; // might not need a checkout (not connected, etc.)
                    }
                    needToCheckout.Add(asset);
                }
                if (needToCheckout.Any())
                {
                    var task = Provider.Checkout(needToCheckout, CheckoutMode.Meta);
                    task.Wait();
                    editable = task.success;
                }
            }

            if (editable)
            {
                foreach (int index in changedIndices)
                {
                    MonoImporter.SetExecutionOrder(m_AllScripts[index], m_AllOrders[index]);
                }

                PopulateScriptArray();
            }
            else
            {
                Debug.LogError("Could not checkout scrips in version control for changing script execution order");
            }
        }
Ejemplo n.º 16
0
        public void TestHasAnyLockedRemoteInSelection()
        {
            try
            {
                PlasticApiMock apiMock = new PlasticApiMock();

                Plastic.InitializeAPIForTesting(apiMock);

                string fooPath = Path.Combine(Path.GetTempPath(), "foo.c");
                string barPath = Path.Combine(Path.GetTempPath(), "bar.c");

                Asset fooAsset = new Asset(fooPath);
                Asset barAsset = new Asset(barPath);

                WorkspaceTreeNode fooNode = BuildWorkspaceTreeNode.Controlled();
                WorkspaceTreeNode barNode = BuildWorkspaceTreeNode.Controlled();

                apiMock.SetupGetWorkspaceTreeNode(fooPath, fooNode);
                apiMock.SetupGetWorkspaceTreeNode(barPath, barNode);
                apiMock.SetupGetWorkingBranch(new BranchInfo());

                AssetList assetList = new AssetList();
                assetList.Add(fooAsset);
                assetList.Add(barAsset);

                AssetStatusCacheMock assetStatusCache = new AssetStatusCacheMock();

                assetStatusCache.SetStatus(fooPath, AssetStatus.LockedRemote);

                SelectedAssetGroupInfo groupInfo =
                    SelectedAssetGroupInfo.BuildFromAssetList(
                        assetList,
                        assetStatusCache);

                Assert.IsTrue(groupInfo.HasAnyRemoteLockedInSelection);
            }
            finally
            {
                Plastic.InitializeAPIForTesting(new PlasticAPI());
            }
        }
        static AssetList GetStatusCachedIfPossible(List <string> fromPaths, bool synchronous)
        {
            var assets = new AssetList {
                Capacity = fromPaths.Count
            };

            foreach (var path in fromPaths)
            {
                assets.Add(GetStatusCachedIfPossible(path, synchronous));
            }
            return(assets);
        }
Ejemplo n.º 18
0
    static void UpdateAssetList(AssetList list, string dir)
    {
        DirectoryInfo dirInfo = new DirectoryInfo(dir);

        if (dirInfo.Exists == false)
        {
            return;
        }

        string[] files = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories);

        for (int i = 0; i < files.Length; ++i)
        {
            string file = files[i].Replace("\\", "/").ToLower();
            if (file.EndsWith(".meta", System.StringComparison.Ordinal) ||
                file.EndsWith(".manifest", System.StringComparison.Ordinal))
            {
                continue;
            }

            string name      = Path.GetFileName(file);
            string assetPath = name;

            if (file.Contains("assets/"))
            {
                assetPath = file.Substring(file.IndexOf("assets/", System.StringComparison.Ordinal));
            }
            Object target = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
            string md5    = target.GetInstanceID().ToString();

            AssetFile asset = list.Get(name);
            if (asset == null)
            {
                asset = list.Get(assetPath);
            }
            if (asset == null)
            {
                asset = list.Get(md5);
            }
            if (asset == null)
            {
                asset       = new AssetFile();
                asset.name  = name;
                asset.asset = assetPath;
            }

            asset.size = 0;

            asset.md5 = md5;

            list.Add(asset);
        }
    }
Ejemplo n.º 19
0
        //NOTE: this now assumes that version control is on and we are not working offline. Also all paths are expected to be versioned
        public static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] deletionResults, RemoveAssetOptions option)
        {
            Assert.IsTrue(deletionResults.Length == assetPaths.Length);

            //NOTE: we only submit assets for deletion in batches because PlasticSCM will time out the
            // connection to the provider process with too many assets
            int deletionBatchSize = 1000;

            for (int batchStart = 0; batchStart < assetPaths.Length; batchStart += deletionBatchSize)
            {
                var deleteAssetList = new AssetList();
                for (int i = batchStart; i < batchStart + deletionBatchSize && i < assetPaths.Length; i++)
                {
                    Asset asset = Provider.GetAssetByPath(assetPaths[i]);
                    deleteAssetList.Add(asset);

                    if (asset == null)
                    {
                        Debug.LogWarningFormat("Asset not found in path '{0}', (null) value returned", assetPaths[i]);
                    }
                }

                Task task = null;

                try
                {
                    task = Provider.Delete(deleteAssetList);

                    task.SetCompletionAction(CompletionAction.UpdatePendingWindow);
                    task.Wait();
                }
                catch (Exception e)
                {
                    Debug.LogWarningFormat("Not all files were deleted by version control: {0}", e.Message);
                }

                if (task != null && task.success)
                {
                    for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++)
                    {
                        deletionResults[i] = File.Exists(assetPaths[i]) ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.DidDelete;
                    }
                }
                else
                {
                    //NOTE: we most likely don't know which assets failed to actually be deleted
                    for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++)
                    {
                        deletionResults[i] = AssetDeleteResult.FailedDelete;
                    }
                }
            }
        }
Ejemplo n.º 20
0
 private static void UpdateFilesInVCIfNeeded()
 {
     if (Provider.enabled)
     {
         string[]  strArray = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
         AssetList assets   = new AssetList();
         foreach (string str in strArray)
         {
             assets.Add(Provider.GetAssetByPath(str.Replace("Temp/ScriptUpdater/", string.Empty)));
         }
         Task task = Provider.Checkout(assets, CheckoutMode.Exact);
         task.Wait();
         if (< > f__am$cache0 == null)
         {
Ejemplo n.º 21
0
 private static void UpdateFilesInVCIfNeeded()
 {
     if (Provider.enabled)
     {
         string[] strArray = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
         AssetList assets = new AssetList();
         foreach (string str in strArray)
         {
             assets.Add(Provider.GetAssetByPath(str.Replace("Temp/ScriptUpdater/", string.Empty)));
         }
         Task task = Provider.Checkout(assets, CheckoutMode.Exact);
         task.Wait();
         if (<>f__am$cache0 == null)
         {
Ejemplo n.º 22
0
        public void TestSelectedCount()
        {
            try
            {
                PlasticApiMock apiMock = new PlasticApiMock();

                Plastic.InitializeAPIForTesting(apiMock);

                string fooPath = Path.Combine(Path.GetTempPath(), "foo.c");
                string barPath = Path.Combine(Path.GetTempPath(), "bar.c");

                Asset fooAsset = new Asset(fooPath);
                Asset barAsset = new Asset(barPath);

                WorkspaceTreeNode fooNode = BuildWorkspaceTreeNode.Controlled();
                WorkspaceTreeNode barNode = BuildWorkspaceTreeNode.Controlled();

                apiMock.SetupGetWorkspaceTreeNode(fooPath, fooNode);
                apiMock.SetupGetWorkspaceTreeNode(barPath, barNode);
                apiMock.SetupGetWorkingBranch(new BranchInfo());

                AssetList assetList = new AssetList();
                assetList.Add(fooAsset);
                assetList.Add(barAsset);

                SelectedAssetGroupInfo groupInfo =
                    SelectedAssetGroupInfo.BuildFromAssetList(
                        assetList,
                        new AssetStatusCacheMock());

                Assert.AreEqual(2, groupInfo.SelectedCount);
            }
            finally
            {
                Plastic.InitializeAPIForTesting(new PlasticAPI());
            }
        }
Ejemplo n.º 23
0
        AssetList AssetOperations.IAssetSelection.GetSelectedAssets()
        {
            AssetList result = new AssetList();

            // We filter for assets because it is possible for user
            // to select things in both project and scene views at the same time
            UnityEngine.Object[] selectedObjects =
                Selection.GetFiltered <UnityEngine.Object>(SelectionMode.Assets);

            foreach (UnityEngine.Object obj in selectedObjects)
            {
                result.Add(new Asset(AssetsPath.GetFullPath(obj)));
            }

            return(result);
        }
        private static bool ValidateVCSFiles(IEnumerable <string> files, string tempOutputPath)
        {
            var assetList = new AssetList();

            foreach (string f in files)
            {
                assetList.Add(Provider.GetAssetByPath(f.Replace(tempOutputPath, "")));
            }

            // Verify that all the files are also in assetList
            // This is required to ensure the copy temp files to destination loop is only working on version controlled files
            // Provider.GetAssetByPath() can fail i.e. the asset database GUID can not be found for the input asset path
            foreach (var f in files)
            {
                var rawAssetPath = f.Replace(tempOutputPath, "");
                // VCS assets path separator is '/' , file path might be '\' or '/'
                var assetPath  = (Path.DirectorySeparatorChar == '\\') ? rawAssetPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) : rawAssetPath;
                var foundAsset = assetList.Where(asset => (asset.path == assetPath));
                if (!foundAsset.Any())
                {
                    Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to add file to list): {0}", rawAssetPath);
                    APIUpdaterManager.ReportExpectedUpdateFailure();
                    return(false);
                }
            }

            var checkoutTask = Provider.Checkout(assetList, CheckoutMode.Exact);

            checkoutTask.Wait();

            // Verify that all the files we need to operate on are now editable according to version control
            // One of these states:
            // 1) UnderVersionControl & CheckedOutLocal
            // 2) UnderVersionControl & AddedLocal
            // 3) !UnderVersionControl
            var notEditable = assetList.Where(asset => asset.IsUnderVersionControl && !asset.IsState(Asset.States.CheckedOutLocal) && !asset.IsState(Asset.States.AddedLocal));

            if (!checkoutTask.success || notEditable.Any())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", notEditable.Select(a => a.fullName + " (" + a.state + ")").Aggregate((acc, curr) => acc + Environment.NewLine + "\t" + curr));
                APIUpdaterManager.ReportExpectedUpdateFailure();
                return(false);
            }

            return(true);
        }
Ejemplo n.º 25
0
        private void ShowScriptPopup(Rect r)
        {
            int length = m_DefaultTimeScripts.Count;

            string[] names         = new string[length];
            bool[]   enabled       = new bool[length];
            var      lockedScripts = new HashSet <MonoScript>();

            if (Provider.enabled)
            {
                var assetList    = new AssetList();
                var pathToScript = new Dictionary <string, MonoScript>();

                for (int i = 0; i < length; i++)
                {
                    var metaPath = AssetDatabase.GetTextMetaFilePathFromAssetPath(AssetDatabase.GetAssetPath(m_DefaultTimeScripts[i]));

                    if (Provider.GetAssetByPath(metaPath) != null)
                    {
                        assetList.Add(Provider.GetAssetByPath(metaPath));
                        pathToScript.Add(metaPath, m_DefaultTimeScripts[i]);
                    }
                }

                Provider.Status(assetList).Wait();

                const Asset.States kExclusiveLockedRemote = Asset.States.Exclusive | Asset.States.LockedRemote;
                foreach (var asset in assetList)
                {
                    if ((asset.state & kExclusiveLockedRemote) == kExclusiveLockedRemote)
                    {
                        lockedScripts.Add(pathToScript[asset.metaPath]);
                    }
                }
            }

            for (int c = 0; c < length; c++)
            {
                names[c]   = m_DefaultTimeScripts[c].GetClass().FullName;      // TODO: localization with a proper database.
                enabled[c] = !lockedScripts.Contains(m_DefaultTimeScripts[c]); //List item is disabled when asset is locked
            }
            EditorUtility.DisplayCustomMenu(r, names, enabled, null, MenuSelection, null);
        }
Ejemplo n.º 26
0
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }
            string[]  files     = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
            AssetList assetList = new AssetList();

            string[] array = files;
            for (int i = 0; i < array.Length; i++)
            {
                string text = array[i];
                assetList.Add(Provider.GetAssetByPath(text.Replace("Temp/ScriptUpdater/", string.Empty)));
            }
            Task task = Provider.Checkout(assetList, CheckoutMode.Both);

            task.Wait();
            IEnumerable <Asset> source =
                from a in task.assetList
                where (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly
                select a;

            if (!task.success || source.Any <Asset>())
            {
                string   arg_103_0 = "[API Updater] Files cannot be updated (failed to checkout): {0}";
                object[] expr_BA   = new object[1];
                expr_BA[0] = (
                    from a in source
                    select string.Concat(new object[]
                {
                    a.fullName,
                    " (",
                    a.state,
                    ")"
                })).Aggregate((string acc, string curr) => acc + Environment.NewLine + "\t" + curr);
                Debug.LogErrorFormat(arg_103_0, expr_BA);
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }
            FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
            FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
        }
Ejemplo n.º 27
0
		private static void UpdateFilesInVCIfNeeded()
		{
			if (!Provider.enabled)
			{
				return;
			}
			string[] files = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
			AssetList assetList = new AssetList();
			string[] array = files;
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i];
				assetList.Add(Provider.GetAssetByPath(text.Replace("Temp/ScriptUpdater/", string.Empty)));
			}
			Task task = Provider.Checkout(assetList, CheckoutMode.Both);
			task.Wait();
			IEnumerable<Asset> source = 
				from a in task.assetList
				where (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly
				select a;
			if (!task.success || source.Any<Asset>())
			{
				string arg_103_0 = "[API Updater] Files cannot be updated (failed to checkout): {0}";
				object[] expr_BA = new object[1];
				expr_BA[0] = (
					from a in source
					select string.Concat(new object[]
					{
						a.fullName,
						" (",
						a.state,
						")"
					})).Aggregate((string acc, string curr) => acc + Environment.NewLine + "\t" + curr);
				Debug.LogErrorFormat(arg_103_0, expr_BA);
				ScriptUpdatingManager.ReportExpectedUpdateFailure();
				return;
			}
			FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
			FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
		}
 private static void UpdateFilesInVCIfNeeded()
 {
   if (!Provider.enabled)
     return;
   string[] files = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
   AssetList assets = new AssetList();
   foreach (string str in files)
     assets.Add(Provider.GetAssetByPath(str.Replace("Temp/ScriptUpdater/", string.Empty)));
   Task task = Provider.Checkout(assets, CheckoutMode.Exact);
   task.Wait();
   IEnumerable<Asset> source = task.assetList.Where<Asset>((Func<Asset, bool>) (a => (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly));
   if (!task.success || source.Any<Asset>())
   {
     Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", (object) source.Select<Asset, string>((Func<Asset, string>) (a => a.fullName + " (" + (object) a.state + ")")).Aggregate<string>((Func<string, string, string>) ((acc, curr) => acc + Environment.NewLine + "\t" + curr)));
     ScriptUpdatingManager.ReportExpectedUpdateFailure();
   }
   else
   {
     FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
     FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
   }
 }
        //NOTE: this now assumes that version control is on and we are not working offline. Also all paths are expected to be versioned
        public static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] deletionResults, RemoveAssetOptions option)
        {
            Assert.IsTrue(deletionResults.Length == assetPaths.Length);

            //NOTE: we only submit assets for deletion in batches because PlasticSCM will time out the
            // connection to the provider process with too many assets
            int deletionBatchSize = 1000;

            for (int batchStart = 0; batchStart < assetPaths.Length; batchStart += deletionBatchSize)
            {
                var deleteAssetList = new AssetList();
                for (int i = batchStart; i < batchStart + deletionBatchSize && i < assetPaths.Length; i++)
                {
                    deleteAssetList.Add(Provider.GetAssetByPath(assetPaths[i]));
                }

                Task task = Provider.Delete(deleteAssetList);

                task.SetCompletionAction(CompletionAction.UpdatePendingWindow);
                task.Wait();

                if (task.success)
                {
                    for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++)
                    {
                        deletionResults[i] = File.Exists(assetPaths[i]) ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.DidDelete;
                    }
                }
                else
                {
                    //NOTE: we most likely don't know which assets failed to actually be deleted
                    for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++)
                    {
                        deletionResults[i] = AssetDeleteResult.FailedDelete;
                    }
                    ;
                }
            }
        }
Ejemplo n.º 30
0
        static AssetList GetInspectorAssets(UnityEditor.Editor inspector)
        {
            AssetList result = new AssetList();

            if (inspector == null)
            {
                return(result);
            }

            foreach (UnityEngine.Object obj in inspector.targets)
            {
                string assetPath = AssetsPath.GetFullPath(obj);

                if (string.IsNullOrEmpty(assetPath))
                {
                    continue;
                }

                result.Add(new Asset(assetPath));
            }

            return(result);
        }
Ejemplo n.º 31
0
        public static string Checkout(this string file)
        {
            if (!Provider.enabled || !Provider.hasCheckoutSupport)
            {
                //Do nothing if revision control is disabled, or if the revision system does not require checkouts
                return(file);
            }

            AssetList list = new AssetList();

            list.Add(new Asset(file));

            if (File.Exists(file))
            {
                try
                {
                    Provider.Checkout(list, CheckoutMode.Asset).Wait();
                    Debug.Log("Checked out file: " + file);
                }
                catch (System.Exception)
                {
                    try
                    {
                        //Set it writable
                        File.SetAttributes(file, FileAttributes.Normal);
                        Debug.LogWarning("Set writable: " + file);
                    }
                    catch (System.Exception)
                    {
                        Debug.LogError("Can't checkout file: " + file);
                    }
                }
            }

            return(file);
        }
Ejemplo n.º 32
0
    static void RevertIllegalOperation()
    {
        AssetList assets = new AssetList();

#if FUXI_DEVELOPER
        assets.Add(new Asset("Assets/Builds/"));
#elif FUXI_ARTIST
        assets.Add(new Asset("Assets/AddressableAssetsData/"));
        assets.Add(new Asset("Assets/Scripts/"));
        assets.Add(new Asset("Assets/Plugins/"));
        assets.Add(new Asset("Assets/Resources/"));
        assets.Add(new Asset("Assets/ThirdParty/"));
#endif
        if (Provider.RevertIsValid(assets, RevertMode.Normal))
        {
            Task t = Provider.Revert(assets, RevertMode.Normal);
            t.Wait();
        }
    }
Ejemplo n.º 33
0
        void OnGUI()
        {
            if (styles == null)
            {
                styles            = new Styles();
                styles.toggleSize = styles.toggle.CalcSize(new GUIContent("X"));
            }

            if (!UnityConnect.instance.canBuildWithUPID)
            {
                ShowAlert();
            }
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginVertical();

            string message             = "";
            var    buildSettingsLocked = !AssetDatabase.IsOpenForEdit(kEditorBuildSettingsPath, out message, StatusQueryOptions.UseCachedIfPossible);

            using (new EditorGUI.DisabledScope(buildSettingsLocked))
            {
                ActiveScenesGUI();
                // Clear all and Add Current Scene
                GUILayout.BeginHorizontal();
                if (buildSettingsLocked)
                {
                    GUI.enabled = true;

                    if (Provider.enabled && GUILayout.Button(styles.checkOut))
                    {
                        Asset asset     = Provider.GetAssetByPath(kEditorBuildSettingsPath);
                        var   assetList = new AssetList();
                        assetList.Add(asset);
                        Provider.Checkout(assetList, CheckoutMode.Asset);
                    }
                    GUILayout.Label(message);
                    GUI.enabled = false;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(styles.addOpenSource))
                {
                    AddOpenScenes();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            GUILayout.BeginHorizontal(GUILayout.Height(351));
            ActiveBuildTargetsGUI();
            GUILayout.Space(10);
            GUILayout.BeginVertical();
            ShowBuildTargetSettings();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUILayout.EndVertical();
            GUILayout.Space(10);
            GUILayout.EndHorizontal();
        }
        private void SuiteRunSave(object pubobj) {
            var run = (SuiteRun)pubobj;
            Logger.Log(LogMessage.SeverityType.Debug, run.ToString());

            if(string.IsNullOrEmpty(run.SuiteRef)) {
                Logger.Log(LogMessage.SeverityType.Debug, "Suite Reference is null or empty. Skipping...");
                return;
            }

            var q = new Query(TestSuiteType);
            var term = new FilterTerm(TestSuiteType.GetAttributeDefinition("Reference"));
            term.Equal(run.SuiteRef);
            q.Filter = term;
            var r = Services.Retrieve(q);

            if(r.Assets.Count == 0) {
                Logger.Log(LogMessage.SeverityType.Debug, "No TestSuite found by reference: " + run.SuiteRef);
                return;
            }

            var save = new AssetList();

            foreach(var testsuite in r.Assets) {
                var testrun = Services.New(TestRunType, testsuite.Oid);

                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Name"), run.Name);
                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Description"), run.Description);
                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Date"), run.Stamp);

                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Passed"), run.Passed);
                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Failed"), run.Failed);
                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("NotRun"), run.NotRun);

                testrun.SetAttributeValue(TestRunType.GetAttributeDefinition("Elapsed"), run.Elapsed);

                LogSuiteRun(testrun);

                save.Add(testrun);
            }

            Services.Save(save);
        }
Ejemplo n.º 35
0
		public static AssetList GetAssetListFromSelection()
		{
			AssetList assetList = new AssetList();
			Asset[] array = Provider.Internal_GetAssetArrayFromSelection();
			Asset[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				Asset item = array2[i];
				assetList.Add(item);
			}
			return assetList;
		}
Ejemplo n.º 36
0
 private void OnGUI()
 {
   this.InitStyles();
   if (!WindowPending.s_DidReload)
   {
     WindowPending.s_DidReload = true;
     this.UpdateWindow();
   }
   this.CreateResources();
   Event current = Event.current;
   float fixedHeight = EditorStyles.toolbar.fixedHeight;
   bool flag1 = false;
   GUILayout.BeginArea(new Rect(0.0f, 0.0f, this.position.width, fixedHeight));
   GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
   EditorGUI.BeginChangeCheck();
   int num = this.incomingList.Root != null ? this.incomingList.Root.ChildCount : 0;
   this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
   this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, GUIContent.Temp("Incoming" + (num != 0 ? " (" + num.ToString() + ")" : string.Empty)), EditorStyles.toolbarButton, new GUILayoutOption[0]);
   if (EditorGUI.EndChangeCheck())
     flag1 = true;
   GUILayout.FlexibleSpace();
   EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
   foreach (CustomCommand customCommand in Provider.customCommands)
   {
     if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
       customCommand.StartTask();
   }
   EditorGUI.EndDisabledGroup();
   if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth - this.s_DeleteChangesetsButtonWidth) > 0 && this.HasEmptyPendingChangesets() && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton, new GUILayoutOption[0]))
     this.DeleteEmptyPendingChangesets();
   if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth) > 0 && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
   {
     EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
     EditorWindow.FocusWindowIfItsOpen<InspectorWindow>();
     GUIUtility.ExitGUI();
   }
   Color color1 = GUI.color;
   GUI.color = new Color(1f, 1f, 1f, 0.5f);
   bool flag2 = GUILayout.Button((Texture) this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);
   bool flag3 = flag1 || flag2;
   GUI.color = color1;
   if (current.isKey && GUIUtility.keyboardControl == 0 && (current.type == EventType.KeyDown && current.keyCode == KeyCode.F5))
   {
     flag3 = true;
     current.Use();
   }
   if (flag3)
   {
     if (flag2)
       Provider.InvalidateCache();
     this.UpdateWindow();
   }
   GUILayout.EndArea();
   Rect rect = new Rect(0.0f, fixedHeight, this.position.width, (float) ((double) this.position.height - (double) fixedHeight - 17.0));
   bool flag4 = false;
   GUILayout.EndHorizontal();
   bool flag5;
   if (!Provider.isActive)
   {
     Color color2 = GUI.color;
     GUI.color = new Color(0.8f, 0.5f, 0.5f);
     rect.height = fixedHeight;
     GUILayout.BeginArea(rect);
     GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     string text = "DISABLED";
     if (Provider.enabled)
     {
       if (Provider.onlineState == OnlineState.Updating)
       {
         GUI.color = new Color(0.8f, 0.8f, 0.5f);
         text = "CONNECTING...";
       }
       else
         text = "OFFLINE";
     }
     GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     rect.y += rect.height;
     if (!string.IsNullOrEmpty(Provider.offlineReason))
       GUI.Label(rect, Provider.offlineReason);
     GUI.color = color2;
     flag5 = false;
   }
   else
   {
     flag5 = !this.m_ShowIncoming ? flag4 | this.pendingList.OnGUI(rect, this.hasFocus) : flag4 | this.incomingList.OnGUI(rect, this.hasFocus);
     rect.y += rect.height;
     rect.height = 17f;
     GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
     GUIContent content = new GUIContent("Apply All Incoming Changes");
     Vector2 vector2 = EditorStyles.miniButton.CalcSize(content);
     WindowPending.ProgressGUI(new Rect(rect.x, rect.y - 2f, (float) ((double) rect.width - (double) vector2.x - 5.0), rect.height), Provider.activeTask, false);
     if (this.m_ShowIncoming)
     {
       Rect position = rect;
       position.width = vector2.x;
       position.height = vector2.y;
       position.y = rect.y + 2f;
       position.x = (float) ((double) this.position.width - (double) vector2.x - 5.0);
       EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
       if (GUI.Button(position, content, EditorStyles.miniButton))
       {
         Asset asset = new Asset(string.Empty);
         AssetList assets = new AssetList();
         assets.Add(asset);
         Provider.GetLatest(assets).SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
       }
       EditorGUI.EndDisabledGroup();
     }
   }
   if (!flag5)
     return;
   this.Repaint();
 }
Ejemplo n.º 37
0
 /// <summary>
 ///   <para>Return version control information about the currently selected assets.</para>
 /// </summary>
 public static AssetList GetAssetListFromSelection()
 {
   AssetList assetList = new AssetList();
   foreach (Asset asset in Provider.Internal_GetAssetArrayFromSelection())
     assetList.Add(asset);
   return assetList;
 }
        private QueryResult ParseAttributeQueryResult(XmlElement element, Query query) {
            var list = new AssetList();

            var asset = new Asset(query.Oid);
            list.Add(asset);

            var attribdef = metaModel.GetAttributeDefinition(query.AssetType.Token + "." + element.GetAttribute("name"));

            ParseAttributeNode(asset, attribdef, element);

            return new QueryResult(list, 1, query);
        }
Ejemplo n.º 39
0
 /// <summary>
 /// <para>Checkout an asset or list of asset from the version control system.</para>
 /// </summary>
 /// <param name="assets">List of assets to checkout.</param>
 /// <param name="mode">Tell the Provider to checkout the asset, the .meta file or both.</param>
 /// <param name="asset">Asset to checkout.</param>
 public static Task Checkout(Object[] assets, CheckoutMode mode)
 {
     AssetList list = new AssetList();
     foreach (Object obj2 in assets)
     {
         Asset assetByPath = GetAssetByPath(AssetDatabase.GetAssetPath(obj2));
         list.Add(assetByPath);
     }
     return Internal_Checkout(list.ToArray(), mode);
 }
Ejemplo n.º 40
0
		private void OnUnaddedFilesGUI()
		{
			AssetList assetList = new AssetList();
			string text = string.Empty;
			foreach (Asset current in this.assetList)
			{
				if (!current.IsState(Asset.States.OutOfSync) && !current.IsState(Asset.States.Synced) && !current.IsState(Asset.States.AddedLocal))
				{
					text = text + current.prettyPath + "\n";
					assetList.Add(current);
				}
			}
			GUILayout.Label("Files to add", EditorStyles.boldLabel, new GUILayoutOption[0]);
			GUILayout.Label("Some additional files need to be added:", new GUILayoutOption[0]);
			GUI.enabled = false;
			GUILayout.TextArea(text, new GUILayoutOption[0]);
			GUI.enabled = true;
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Add files", new GUILayoutOption[0]))
			{
				this.taskAdd = Provider.Add(assetList, false);
				this.taskAdd.SetCompletionAction(CompletionAction.OnAddedChangeWindow);
			}
			if (GUILayout.Button("Abort", new GUILayoutOption[0]))
			{
				this.taskSubmit = null;
				this.submitResultCode = 256;
				this.submitErrorMessage = null;
				base.Close();
			}
			GUILayout.EndHorizontal();
		}
Ejemplo n.º 41
0
 private void OnUnaddedFilesGUI()
 {
     AssetList assets = new AssetList();
     string text = "";
     foreach (Asset asset in this.assetList)
     {
         if ((!asset.IsState(Asset.States.OutOfSync) && !asset.IsState(Asset.States.Synced)) && !asset.IsState(Asset.States.AddedLocal))
         {
             text = text + asset.prettyPath + "\n";
             assets.Add(asset);
         }
     }
     GUILayout.Label("Files to add", EditorStyles.boldLabel, new GUILayoutOption[0]);
     GUILayout.Label("Some additional files need to be added:", new GUILayoutOption[0]);
     GUI.enabled = false;
     GUILayout.TextArea(text, new GUILayoutOption[0]);
     GUI.enabled = true;
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     if (GUILayout.Button("Add files", new GUILayoutOption[0]))
     {
         this.taskAdd = Provider.Add(assets, false);
         this.taskAdd.SetCompletionAction(CompletionAction.OnAddedChangeWindow);
     }
     if (GUILayout.Button("Abort", new GUILayoutOption[0]))
     {
         this.ResetAndClose();
     }
     GUILayout.EndHorizontal();
 }
Ejemplo n.º 42
0
 /// <summary>
 /// <para>Return version control information about the currently selected assets.</para>
 /// </summary>
 public static AssetList GetAssetListFromSelection()
 {
     AssetList list = new AssetList();
     Asset[] assetArray = Internal_GetAssetArrayFromSelection();
     foreach (Asset asset in assetArray)
     {
         list.Add(asset);
     }
     return list;
 }
 private QueryResult ParseAssetQueryResult(XmlElement element, Query query) {
     var list = new AssetList();
     list.Add(ParseAssetNode(element));
     return new QueryResult(list, 1, query);
 }
Ejemplo n.º 44
0
 /// <summary>
 ///   <para>Checkout an asset or list of asset from the version control system.</para>
 /// </summary>
 /// <param name="assets">List of assets to checkout.</param>
 /// <param name="mode">Tell the Provider to checkout the asset, the .meta file or both.</param>
 /// <param name="asset">Asset to checkout.</param>
 public static Task Checkout(Object[] assets, CheckoutMode mode)
 {
   AssetList assetList = new AssetList();
   foreach (Object asset in assets)
   {
     Asset assetByPath = Provider.GetAssetByPath(AssetDatabase.GetAssetPath(asset));
     assetList.Add(assetByPath);
   }
   return Provider.Internal_Checkout(assetList.ToArray(), mode);
 }
Ejemplo n.º 45
0
		public static Task Checkout(UnityEngine.Object[] assets, CheckoutMode mode)
		{
			AssetList assetList = new AssetList();
			for (int i = 0; i < assets.Length; i++)
			{
				UnityEngine.Object assetObject = assets[i];
				string assetPath = AssetDatabase.GetAssetPath(assetObject);
				Asset assetByPath = Provider.GetAssetByPath(assetPath);
				assetList.Add(assetByPath);
			}
			return Provider.Internal_Checkout(assetList.ToArray(), mode);
		}
 private void OnGUI()
 {
   if (BuildPlayerWindow.styles == null)
   {
     BuildPlayerWindow.styles = new BuildPlayerWindow.Styles();
     BuildPlayerWindow.styles.toggleSize = BuildPlayerWindow.styles.toggle.CalcSize(new GUIContent("X"));
     this.lv.rowHeight = (int) BuildPlayerWindow.styles.levelString.CalcHeight(new GUIContent("X"), 100f);
   }
   BuildPlayerWindow.InitBuildPlatforms();
   if (!UnityConnect.instance.canBuildWithUPID)
     this.ShowAlert();
   GUILayout.Space(5f);
   GUILayout.BeginHorizontal();
   GUILayout.Space(10f);
   GUILayout.BeginVertical();
   string message = string.Empty;
   bool disabled = !AssetDatabase.IsOpenForEdit("ProjectSettings/EditorBuildSettings.asset", out message);
   EditorGUI.BeginDisabledGroup(disabled);
   this.ActiveScenesGUI();
   GUILayout.BeginHorizontal();
   if (disabled)
   {
     GUI.enabled = true;
     if (Provider.enabled && GUILayout.Button("Check out"))
     {
       Asset assetByPath = Provider.GetAssetByPath("ProjectSettings/EditorBuildSettings.asset");
       AssetList assets = new AssetList();
       assets.Add(assetByPath);
       Provider.Checkout(assets, CheckoutMode.Asset);
     }
     GUILayout.Label(message);
     GUI.enabled = false;
   }
   GUILayout.FlexibleSpace();
   if (GUILayout.Button("Add Open Scenes"))
     this.AddOpenScenes();
   GUILayout.EndHorizontal();
   EditorGUI.EndDisabledGroup();
   GUILayout.Space(10f);
   GUILayout.BeginHorizontal(GUILayout.Height(301f));
   this.ActiveBuildTargetsGUI();
   GUILayout.Space(10f);
   GUILayout.BeginVertical();
   this.ShowBuildTargetSettings();
   GUILayout.EndVertical();
   GUILayout.EndHorizontal();
   GUILayout.Space(10f);
   GUILayout.EndVertical();
   GUILayout.Space(10f);
   GUILayout.EndHorizontal();
 }
Ejemplo n.º 47
0
        public void saveAssets(string projectPath, string name, bool locked)
        {
            if (Assets.items != null)
            {
                AssetList package = new AssetList();

                for (int i = 0; i < Assets.items.Count; i++)
                {
                    Asset asset = Assets.items[i];

                    if (asset.package == name)
                    {
                        package.Add(asset);
                    }
                }

                if (package.Count > 0)
                    Serialization.serialize(Path.Combine(projectPath, name.Replace(" ", "_") + ".pak"), package);
            }
        }
Ejemplo n.º 48
0
 private void OnUnaddedFilesGUI()
 {
   AssetList assets = new AssetList();
   string text = string.Empty;
   using (List<Asset>.Enumerator enumerator = this.assetList.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       Asset current = enumerator.Current;
       if (!current.IsState(Asset.States.OutOfSync) && !current.IsState(Asset.States.Synced) && !current.IsState(Asset.States.AddedLocal))
       {
         text = text + current.prettyPath + "\n";
         assets.Add(current);
       }
     }
   }
   GUILayout.Label("Files to add", EditorStyles.boldLabel, new GUILayoutOption[0]);
   GUILayout.Label("Some additional files need to be added:");
   GUI.enabled = false;
   GUILayout.TextArea(text);
   GUI.enabled = true;
   GUILayout.BeginHorizontal();
   GUILayout.FlexibleSpace();
   if (GUILayout.Button("Add files"))
   {
     this.taskAdd = Provider.Add(assets, false);
     this.taskAdd.SetCompletionAction(CompletionAction.OnAddedChangeWindow);
   }
   if (GUILayout.Button("Abort"))
     this.ResetAndClose();
   GUILayout.EndHorizontal();
 }