블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (70)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (11)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-25 09:56


[링크]

http://ronniej.sfuh.tk/%EC%95%A0%EC%85%8B-%EB%B2%88%EB%93%A4-%EA%B8%B0%EC%B4%88-assetbundle-fundamentals-2-%EB%B2%88%EC%97%AD/

반응형
Posted by blueasa
, |


[링크] https://github.com/kimsama/Unity5-AssetBundleSetting

반응형

'Unity3D > AssetBundle' 카테고리의 다른 글

[펌] 에셋번들 생성하기 & 다운로드  (0) 2017.04.12
[링크] 에셋번들 로딩 방식 4가지  (0) 2017.03.03
WWW.LoadFromCacheOrDownload  (0) 2015.04.23
AssetBundle 가이드  (0) 2015.01.26
AssetBundle 버전체크 방식..  (0) 2014.04.21
Posted by blueasa
, |


링크 : http://rcasio80.blogspot.kr/2015/03/wwwloadfromcacheordownload.html

반응형

'Unity3D > AssetBundle' 카테고리의 다른 글

[링크] 에셋번들 로딩 방식 4가지  (0) 2017.03.03
[링크] Unity5-AssetBundleSetting  (0) 2016.07.25
AssetBundle 가이드  (0) 2015.01.26
AssetBundle 버전체크 방식..  (0) 2014.04.21
Unity AssetBundle Dependencies  (0) 2014.03.11
Posted by blueasa
, |

1. AssetBundle 란? 및 필요성

 - 어플리케이션의 Runtime 시 외부에서 Resource(Asset)를 가져올 수 있도록 해주는 Unity3D 고유의 기능

 - 패키지지향 게임과 서비스지향 게임(업데이트)

 - Web 기반과 Smart phone 기반에서의 분할 다운로드
   * 아이폰 앱스토어나 안드로이드 마켓에서 파일이 일정 크기 이상이면 3g로 다운로드가 허용되지 않으며 wi-fi 로 다운 받게 끔 되어 있음.
     여기서 wi-fi 모드로 다운 받게 끔 제한시 다운로드 횟수가 현저히 저하되는 경우 발생 (컨텐츠의 접근성에 심각한 문제가 발생)
     -> 초기 실행 파일을 작게하고 게임 내에서 다운로드 받는 기법 사용하여 해결, 이 경우 AssetBundle 을 사용하여 해결 가능

 

2. Native 구현 vs AssetBundle
  >>  AssetBundle는 Unity3D(Pro만!)에서 제공하는 런타임에 리소스를 가지고 오는 기술을 말하는데

        C#  등으로 직접 구현하는 것과 무슨 차이점이 있고 또, 어떤 특징이 있는가?

 - 모든 플랫폼에서 일관적인 방법으로 이용 가능 (Flash 빌드 제외!)
   * 웹플랫폼으로 만들경우 Sandbox 보안 정책이 적용 - 로컬에서 파일을 읽기는 가능하지만 저장하지 못함.
   * 다른 플랫폼에서는 가능 (stand-alone, ios, android) 
   * AssetBundle을 사용하면 웹플랫폼 빌드 일 때 로컬에 cache로 저장하는 방법이 사용 가능함

     (웹플레이어가 AssetBundle의 cache를 생성 해줌)

참고)  Flash 일경우에는 AssetBundle 및 WWW 클래스 사용 불가능, 웹서버를 사용하는 등의 우회적인 방법만 가능한 것으로 보임

 

 - Unity3D Editor에서 제공하는 Asset pipeline을 Runtime에 이용할 수 있는 유일한 수단
   * AssetBundle을 써야하는 가장 중요한 이유,  
   * 유니티는 에디터하고 플레이어하고 분리가 되어 있는 데 어셋을 불러와서 실제로 사용할 수 있게 가공해주는 건 에디터 밖에 못해줌
      >> 에디터에는 어셋을 임포트 해 주는 기능 하는 임포터가 존재함.
      >> 실제 유니티 프로젝트에서 보는 에셋들은 실제 데이타가 아니라 한번 가공한 데이타 (임포터 할때 마다 유니티 폴더 안 Library 내에 가공한 데이타가 들어감)
      >> 런타임 중에는 메쉬(fbx 파일) 등을 임포트 할 수 없다. 임포트를 하려면 임포터를 거쳐야하는데 임포터는 에디터 밖에 존재 하지 않음.
      >> 유니티는 네이티브한 데이타를 사용하는 데 상당히 제한적인 면이 있다. (예외적으로 텍스처(제약많음), 텍스트에셋 등은 임포터를 거치지 않고 사용할 수 있지만 
           그 외 기타 매터리얼, 게임 오브젝트, 메쉬 등의 오브젝트들은 임포터를 거쳐야 한다.)
      >> 어셋 번들에 에디터 내 임포터를 통해 가공된 데이타를 저장하여 런타임시 해당 어셋 번들을 사용할 수 있다.

 - Push, Pop의 개념을 이용한 AssetBundle끼리의 의존관계 설정 가능
   * 두개 모델이 같이 사용하는 텍스처를 모델과 따로 어셋번들로 뽑아서 두개 모델이 해당 텍스처를 같이 사용하는 식으로 사용 가능.

 - Memory관리 용도로 사용 가능

 - Caching과 Version관리기능 제공
   * 로컬에 캐싱해서 매번 다운로드를 방지. 또한 캐싱시 버전을 부여하여 관리 가능 (이것을 이용하면 온라인 게임의 Patch시스템 구현 가능)

 - WWW class를 이용한 비동기 다운로드가 가능

참고) 유니티 코리아 사이트 공식 문서 AssetBundle -> http://unitykoreawiki.com/index.php?n=KrMain.AssetBundles

3. AssetBundle의 이용 방법

  - 로드

    * WWW.WWW()   http://unity3d.com/support/documentation/ScriptReference/WWW.WWW.html -  가장 일반적인 사용방법
    * AssetBundle.CreateFromMemory()
       >> 메모리 부터 어셋 번들을 생성, binary data 를 읽어와서 메모리를 올려놓고 어셋 번들을 생성하는 기능. 암호화 등의 특수한 처리가 필요할 때 유용
       
    * WWW.LoadFromCacheOrDownload()


 - Asset 얻기

    * AssetBundle.Contains() : 특정 어셋이 있는지 확인
    * AssetBundle.Load() : 실제 어셋을 가져오는 것
    * AssetBundle.LoadAsync() : 어셋을 비동기로 가지고 옴


 - 메모리에서 제거

    * AssetBundle.Unload(bool unloadAllLoadedObjects)
      >> true : 강제로 모두 내려버림. 어셋간 링크가 깨짐. false : 사용하지 않는 것만 추려서 메모리에서 내림 ( GC.Collect()를 먼저 호출해주면 더 안정적으로 동작 )

 

4.  AssetBundle의 생성 방법
    >> BuildPipeline를 이용하여 에디터 상에서만 생성 가능    

 - BuildPipeline.BuildAssetBundle() : 어셋을 어셋번들로 만들 때 일반적으로 사용 

Scene 를 어셋 번들로 생성할 수 있는 방법 
 - BuildPipeline.BuildStreamedSceneAssetBundle() 

 - BuildPipeline.BuildPlayer()

참고)  BuildPipeline.BuildStreamedSceneAssetBundle() 와 BuildPipeline.BuildPlayer() 차이점 이란 ??


 

참고할 만한 예제 소개

 - AssetBundle

 - Caharacter customization

 - Bundle loader

 - Bundle Sync


5. Caching을 이용한 버전과 메모리 관리

 - WWW.LoadFromCacheOrDownload()

 - Cache의 저장 경로

  * Windows7 : C:\Users\사용자이름\AppData\LocalLow\Unity\WebPlayer\Cache

  * Mac : 미확인

  * iOS : Document

  * Android : 미확인

 - Caching class를 이용하여 cache를 관리 Non Cache와 Cache 사용할 때의 메모리 사용방식의 차이가 생김 (Resource 클래스를 사용하는 경우와 유사)

 - Cache는 최대 4GB 까지 사용 가능. Caching class를 사용하여 조절
 - 웹빌드 일 경우 캐슁 라이센스에 영향을 받음 (다른 플렛폼에서는 별도의 캐슁 라이센스 없음)

 - WebPlayer/Cache/Shared 폴더의 사용 용량이 50MB로 제한되며 제한을 해제하기 위해서는 추가적인 라이센스 구매를 해야 함 (경험상 50MB제한이 제대로 동작 안하는 듯 함)

   ( 참고 : http://www.unity3dkorea.com/board/index.php?db=knowhow&no=118&mari_mode=view@view )

 

6. AssetBundle과 MonoScript의 관계

 - Unity3D에서 사용하는 C# 및JavaScript는 다른 일반적인 script언어처럼 인터프리터가 아닌 컴파일 언어이다. (컴파일 언어는 Runtime에 코드를 추가하기가 어려움)

 - 일반적인 경우

 - Assembly의 저장 (DLL?)

 - Lua script의 활용한다면?

 

7. 주의사항

 - AssetBundle.Load() 을 사용할 때 딸꾹질(랙)이 발생함

 - 용량이 큰 다수의 AssetBundle을 로드할 경우 Crash 발생율 큼

 - Web 빌드에서는 Caching.CleanCache() 가 작동 안함

 - Static Mesh를 사용하는 Scene을 Export하면 용량이 크게 증가함

 - Platform에 따라 별도로 제작되야 함

 - Unity3D의 버전에 지나치게 의존적

 - 내용물에 대한 보안기능을 제공 안함

 - 기본적으로 MonoScript의 컴파일 코드는 저장 못함


8. Effective AssetBundle

 - 다운로드를 Queue형태로 관리

 - Cache를 사용해서 Memory사용량을 관리

 - AssetBundle의 구성내용을 저장 및 관리

 - Platform 별로 자동 생성 기능의 필요

 - 보안을 위한 별도의 처리


출처 : https://www.assembla.com/spaces/a-h/wiki/AssetBundle_%EA%B0%80%EC%9D%B4%EB%93%9C/history

반응형

'Unity3D > AssetBundle' 카테고리의 다른 글

[링크] Unity5-AssetBundleSetting  (0) 2016.07.25
WWW.LoadFromCacheOrDownload  (0) 2015.04.23
AssetBundle 버전체크 방식..  (0) 2014.04.21
Unity AssetBundle Dependencies  (0) 2014.03.11
AssetBundle 생성부터 패치 및 적용까지.  (0) 2014.02.27
Posted by blueasa
, |

static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, uint crcBuildAssetBundleOptionsassetBundleOptions = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,BuildTarget targetPlatform = BuildTarget.WebPlayer);

 이 함수를 사용해서 애셋번들을 생성하면 crc값을 얻을 수 있는데요 애셋번들에 포함되어있는 애셋들의 변경 사항이 있는 경우에 저 값이 변하더라고요. 이전에 만든 번들과 crc값이 다르면 수정된거라고 보고 패치를 진행하는 방식으로 구현했습니다.



반응형
Posted by blueasa
, |

Unity AssetBundle Dependencies

In the last few weeks I’ve spent quite a lot of time with Unity’s Asset Bundle system. Understanding how dependencies were tracked. What determines GC cleanup of assets and understanding why the editor profiler produces particular results has been a bit of a struggle. I’m lucky enough to work for a group that allows me to have access to the Unity source code however so this has probably been slightly less painful than it has been for others going down this same path.

First, I’d like to acknowledge what appears to be the most useful piece of Unity Answers information that I’ve come across, located here. This seems to explain the general mechanics of how to include dependencies using the push and then pop method in an editor script.

For my purposes, I created a test project that contained several prefabs all containing simple GUI elements. These elements all used the same fonts and referenced the same textures. This was to verify that, in the editor profiler and in instruments, assets were in fact being shared.

I’ve included my example editor script below to demonstrate some of the methods I used for packing the bundles. In my case, I am traversing all assets in my prefab folder and treating elements with the word “Global” in their name as shared. If I were to have many dependency bundles instead of the one that I have in this example I would have to sort the order in which I am packing these bundles.

using UnityEngine;
using UnityEditor;

using System.IO;
using System.Collections.Generic;

public class AssetBundleBuild : MonoBehaviour
{
    [MenuItem("AssetBundle/Build Bundles")]
    private static void BuildBundles()
    {
        DirectoryInfo directory = new DirectoryInfo(Application.dataPath + "/Prefabs");
        FileInfo[] files = directory.GetFiles("*.prefab", SearchOption.AllDirectories);

        bool shouldPush;

        BuildPipeline.PushAssetDependencies();
        foreach (FileInfo f in files)
        {
            shouldPush = !f.Name.Contains("Global");
            if (shouldPush)
            {
                BuildPipeline.PushAssetDependencies();
            }

            // Get each asset path
            string path = Application.dataPath + "/Bundles/" + f.Name.Substring(0, f.Name.LastIndexOf(".")) + ".bundle";
            string assetPath = f.FullName.Substring(f.FullName.IndexOf("Assets", f.FullName.Length - f.FullName.IndexOf("Assets")));

            Object asset = AssetDatabase.LoadMainAssetAtPath(assetPath);
            //Debug.Log("Asset to pack " + asset + " , " + asset.name);

            BuildAssetBundleOptions options = 
                BuildAssetBundleOptions.DisableWriteTypeTree | 
                BuildAssetBundleOptions.CollectDependencies | 
                BuildAssetBundleOptions.CompleteAssets | 
                BuildAssetBundleOptions.DeterministicAssetBundle;

            if (!shouldPush)
            {
                Object[] d = EditorUtility.CollectDependencies(new Object[] { asset });

                List<Object> dSource = new List<Object>();
                List<string> dNames = new List<string>();

                // In this case I'm attempting to manually collect dependencies for tracking purposes
                // however this does not always seem to be necessary unless you have complex prefab heirarchies
                foreach (Object o in d)
                {
                    if (o != null && !dSource.Contains(o))
                    {
                        Debug.Log(" -- d " + o + " , " + o.name + " , " + o.GetType());

                        dSource.Add(o);
                        dNames.Add(o.name);
                    }
                }

                Debug.Log("::BUILDING DEPENDENCY BUNDLE:: " + asset.name + " , " + dSource.Count);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    dSource.ToArray(), 
                    dNames.ToArray(), 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);
            }
            else
            {
                Debug.Log("::NON DEPENDENCY:: " + asset.name);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    new Object[] { asset }, 
                    new string[] { asset.name }, 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);

                if (shouldPush)
                {
                    BuildPipeline.PopAssetDependencies();
                }
            }
        }

        BuildPipeline.PopAssetDependencies();

        Debug.Log("[AssetBundleBuild] Complete.");
    }
}

Now, from the standpoint of packing shared dependencies, this seemed to work with most asset types such as textures or prefabs but when I included fonts, while they wouldn’t be duplicated across multiple bundles, I would always see two copies of my fonts. One set would be flagged as being ‘used by scripts and native code’ and the other would only be flagged as ‘used by native code’. After performing numerous tests, I discovered that upon opening the dependency bundle containing the font I was interested in, if there was a copy of the font in the project directory as well, both versions would be loaded into Resources. I haven’t been able to verify whether this happens on device as well but my inclination is that it only occurs in the editor.

The Problem of the Decompression Buffer

Another problem that became visible when working with large quantities of bundles that (based off of conversations with Unity technical representatives and the 4.2.0b3 beta client) may have changed in such a way as to render the problem less dire is that Unity, as of 4.1.5, allocates an 8mb decompression buffer per each asset bundle being opened. If there is an attempt to parallelize these requests, each request will allocate it’s own decompression buffer. This can be rather disconcerting as one can see how the allocation amount (especially on restricted memory devices) can really get a guy down.

Although 4.2.0b3 seems to be reducing the decompression buffer size down to 0.5mb per bundle the problem of parallelization still persists. The only immediate solution for individuals loading any quantity of bundles seems to be amortizing the requests in such a way as to prevent too much overlap. If someone out there has a suggestion to mitigate this problem otherwise please drop me a line mcelroy.jon[at]gmail.com


출처 : http://blog.jonmcelroy.com/post/55526714506/unity-assetbundle-dependencies

반응형
Posted by blueasa
, |

링크 : AssetBundle 생성부터 패치 및 적용까지. 0 - 관련 링크들 정리


링크 : AssetBundle 생성부터 패치 및 적용까지. 1 - Build AssetBundle


링크 : AssetBundle 생성부터 패치 및 적용까지. 2 - CoRoutine 활용에서 AssetBundle Patch하기



반응형
Posted by blueasa
, |


Link : http://ceolimdevelop.blogspot.kr/2013/11/unity.html



반응형

'Unity3D > AssetBundle' 카테고리의 다른 글

Unity AssetBundle Dependencies  (0) 2014.03.11
AssetBundle 생성부터 패치 및 적용까지.  (0) 2014.02.27
Unity3D - Asset bundle  (0) 2014.02.26
애셋 번들 정리  (0) 2014.02.26
에셋 번들 사용하기  (0) 2014.02.25
Posted by blueasa
, |


Link : http://www.slideshare.net/GreatTed/unity3d-asset-bundle-29583228

반응형
Posted by blueasa
, |


링크 : http://unitystudy.net/bbs/board.php?bo_table=dustin&wr_id=62&sca=&sfl=wr_subject&stx=%EB%B2%88%EB%93%A4&sop=and

반응형
Posted by blueasa
, |