コード例 #1
0
        public async Task <IActionResult> PutAssetBundleModel(int id, AssetBundleModel assetBundleModel)
        {
            if (id != assetBundleModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(assetBundleModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AssetBundleModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
ファイル: DevAssist.cs プロジェクト: komastar/AvoidBrick
        public static void BuildAssetBundles(AssetBundleModel assetBundleModel)
        {
            Debug.Log("Build AssetBundles Begin");
            if (null == assetBundleModel)
            {
                Debug.Log("-----BUILD ONLY-----");
            }

            EditorUtility.DisplayProgressBar("Build AssetBundles", "Building...", 0.25f);

            string assetBundlesPath = "Assets/AssetBundles.bin";
            string persistentPath   = $"{Application.persistentDataPath}/AssetBundles";

            if (false == Directory.Exists(assetBundlesPath))
            {
                Directory.CreateDirectory(assetBundlesPath);
            }

            if (false == Directory.Exists(persistentPath))
            {
                Directory.CreateDirectory(persistentPath);
            }

            Debug.Log("AssetBudnels Building...");
            BuildPipeline.BuildAssetBundles(
                assetBundlesPath
                , BuildAssetBundleOptions.UncompressedAssetBundle
#if UNITY_ANDROID
                , BuildTarget.Android);
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [FromForm] AssetBundleModel assetBundleModel)
        {
            if (id != assetBundleModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(assetBundleModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssetBundleModelExists(assetBundleModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(assetBundleModel));
        }
コード例 #4
0
        public async Task <IActionResult> PostAssetBundleModel([FromForm] AssetBundleUploadModel assetBundleUploadModel)
        {
            AssetBundleModel assetBundleModel = assetBundleUploadModel;

            if (ModelState.IsValid)
            {
                var saveDir = Path.Combine(_env.WebRootPath, assetBundleModel.Project, assetBundleModel.BundleVersion);
                if (!Directory.Exists(saveDir))
                {
                    Directory.CreateDirectory(saveDir);
                }

                var filePaths = new List <string>();
                foreach (var formFile in assetBundleUploadModel.Files)
                {
                    if (formFile.Length > 0)
                    {
                        var filePath = Path.Combine(saveDir, formFile.FileName);

                        filePaths.Add(filePath);
                        using var stream = new FileStream(filePath, FileMode.Create);
                        await formFile.CopyToAsync(stream);
                    }
                }

                var find = _context.AssetBundleModel.SingleOrDefault(
                    m => m.Project == assetBundleModel.Project && m.Branch == assetBundleModel.Branch);

                if (null == find)
                {
                    _context.Add(assetBundleModel);
                }
                else
                {
                    find.Name              = assetBundleModel.Name;
                    find.Project           = assetBundleModel.Project;
                    find.UpdateTime        = DateTime.Now;
                    find.BundleVersionCode = assetBundleModel.BundleVersionCode;
                    find.BundleVersion     = assetBundleModel.BundleVersion;

                    _context.Update(find);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction(nameof(Index)));
        }
コード例 #5
0
    public override void OnXGUI()
    {
        //TODO List
        if (Selection.objects != null && Selection.objects.Length > 0)
        {
            selectedObject = Selection.objects[0];
        }

        if (CreateSpaceButton("Packing Selected Objects"))
        {
            Object[] objects = Selection.objects;

            string path = EditorUtility.SaveFilePanel("Create A Bundle", AssetDatabase.GetAssetPath(objects[0]), "newbundle.assetbundle", "assetbundle");
            if (path == "")
            {
                return;
            }


            CreateXMLWithDependencies(objects, path);

            BuildPipeline.BuildAssetBundle(
                null, objects,
                path,
                BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.UncompressedAssetBundle
                | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android);
        }

        if (CreateSpaceButton("GetObject"))
        {
            string path = EditorUtility.OpenFilePanel("Open A Bundle", Application.streamingAssetsPath, "");
            if (path == "")
            {
                return;
            }
            _bundlepath   = "file://" + path;
            LoadingConfig = true;
            asset         = null;
//			AssetDatabase.Refresh();
            if (currBundle != null)
            {
                currBundle.Unload(true);
            }
        }

        if (CreateSpaceButton("Clean Cache"))
        {
            currentBundleObjects = null;
            Caching.CleanCache();
        }

        if (LoadingConfig)
        {
            XLogger.Log("start loading");
            if (null == asset)
            {
                asset = new WWW(_bundlepath);
            }
            LoadingConfig = false;
        }
//		Logger.Log(string.Format("asset == null is {0}" , asset == null));
        if (asset != null)
        {
//			Logger.Log("asset.isDone is " + asset.isDone);
//			if(asset.isDone){

            XLogger.Log("end loading");
            currBundle = asset.assetBundle;
            if (currBundle == null)
            {
                CreateNotification("Selected the asset bundle 's format is error.");
                LoadingConfig = false;
                asset         = null;
                return;
            }
                        #if UNITY_5_0
            currentBundleObjects = currBundle.LoadAllAssets();
                        #endif
                        #if UNITY_4_6
            currentBundleObjects = currBundle.LoadAll();
                        #endif
            LoadingConfig = false;
            asset         = null;
//			}
        }



        if (null != currentBundleObjects)
        {
            for (int pos = 0; pos < currentBundleObjects.Length; pos++)
            {
                CreateObjectField(currentBundleObjects[pos].GetType().ToString(), currentBundleObjects[pos]);
            }
        }

        if (CreateSpaceButton("Add A AssetBundle"))
        {
            allAssets.Add(new AssetBundleModel());
        }
        if (CreateSpaceButton("Clean All AssetBundle"))
        {
            allAssets.Clear();
        }
        if (CreateSpaceButton("Collect") && allAssets.Count > 0)
        {
            List <AssetBundleModel> AllChilds = new List <AssetBundleModel>();
            sortAssets.Clear();

            BundlePath = EditorUtility.SaveFolderPanel("Save Bundles", Application.streamingAssetsPath, "");
            if (BundlePath == null)
            {
                return;
            }
            BundlePath += "/";
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement  root   = xmlDoc.CreateElement("root");
            for (int pos = 0; pos < allAssets.Count; pos++)
            {
                if (allAssets[pos].ParentName.Equals(""))
                {
                    sortAssets.Add(allAssets[pos].ModelName, allAssets[pos]);
                    XmlElement child = xmlDoc.CreateElement(allAssets[pos].ModelName);
                    root.AppendChild(child);
                }
                else
                {
                    AllChilds.Add(allAssets[pos]);
                }
//				allAssets.Remove(allAssets[pos]);
            }
            for (int pos = 0; pos < AllChilds.Count; pos++)
            {
                sortAssets[AllChilds[pos].ParentName].Childs.Add(AllChilds[pos]);
                XmlElement child = xmlDoc.CreateElement(AllChilds[pos].ModelName);
                root.SelectSingleNode(AllChilds[pos].ParentName).AppendChild(child);
//				allAssets.Remove(allAssets[pos]);
            }
            xmlDoc.AppendChild(root);
            xmlDoc.Save(BundlePath + "bundle.xml");
            foreach (var bundle in sortAssets)
            {
                bundle.Value.PackingSelf();
            }
//			allAssets.Clear();
            AssetDatabase.Refresh();
            CreateNotification("Create asset bundle success!");
        }

        for (int pos = 0; pos < allAssets.Count; pos++)
        {
            AssetBundleModel Item = allAssets[pos];
            BeginHorizontal();
            Item.ModelName  = CreateStringField("Name", allAssets[pos].ModelName);
            Item.ParentName = CreateStringField("Dependencies", allAssets[pos].ParentName);
            if (CreateSpaceButton("Add Asset") && null != selectedObject)
            {
                Item.Assets.AddRange(Selection.objects);
            }
            if (CreateSpaceButton("Remove Bundle"))
            {
                allAssets.RemoveAt(pos);
            }
            EndHorizontal();
            CreateSpaceBox();

            for (int idx = 0; idx < Item.Assets.Count; idx++)
            {
                BeginHorizontal();
                CreateObjectField("child_" + idx, Item.Assets[idx]);
                if (CreateSpaceButton("Remove"))
                {
                    Item.Assets.RemoveAt(idx);
                }
                EndHorizontal();
            }

            CreateSpaceBox();
        }
    }