void TestSprite() { string abpath = assetbundleRoot + "/" + assetbundleTestSprite; AssetBundle assetBundle = AssetBundle.LoadFromFile(abpath); ABExportHelper.ExportAssetBundleMultipleSprite(assetBundle, exportResources); string[] assetNames = assetBundle.GetAllAssetNames(); for (int i = 0; i < assetNames.Length; i++) { string name = assetNames[i]; UnityEngine.Object obj = assetBundle.LoadAsset <UnityEngine.Object>(name); Sprite sprite = obj as Sprite; if (sprite != null) { GameObject go = new GameObject(name); SpriteRenderer spriteRenderer = go.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = sprite; //string path = resources + "/" + assetbundleTestSprite.Replace(".unity3d", ".png"); //ABExportHelper.ExportSpriteAtlas(sprite, path); //Debug.Log(name + ", " + sprite.associatedAlphaSplitTexture.name + ", " + path); //break; } } assetBundle.Unload(false); }
/// <summary> /// 设置Sprite九宫格 /// </summary> void SetSpriteBorder() { ABExportHelper.SettingSpriteFolder(assetbundleSprite, exportResources, exportAtlasRootPath); ABExportHelper.SettingSpriteFolder(assetbundleTexture, exportResources, exportAtlasRootPath); }
/// <summary> /// 导出Sprite /// </summary> void ExportSprite() { ABExportHelper.ExportAssetBundleSpriteFolder(assetbundleSprite, exportResources, exportAtlasRootPath); ABExportHelper.ExportAssetBundleSpriteFolder(assetbundleTexture, exportResources, exportAtlasRootPath); }