Would you tell me a specific example?
I did the following processes in detail.
####################
## create SampleSpriteCollectionData
####################
1 i create tk2dSpriteCollection. example name is "SampleSpriteCollection"
2 I pressed the "OpenEditor..." button, and I added images , and committed.
3 Then, the folder that named "SampleSpriteCollection Data" was created by automatic.
####################
## make assetBundel
####################
4 I selected "SampleSpriteCollection Data" folder and did ExportAssetBundle.
--sample code--
using UnityEngine;
using UnityEditor;
//ref by
http://shibomb.1108tones.com/archives/1885public class ExportAssetBundles {
[MenuItem("Assets/Build AssetBundle From Selection - Track dependencies - MobilePlayer")]
static void ExportResourceToMobilePlayer () {
// Bring up save panel
string path = EditorUtility.SaveFilePanel ("Save Resource", "", Selection.activeObject.name, "");
Debug.Log(path);
if (path.Length != 0) {
// Build the resource file from the active selection.
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path + ".unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,
BuildTarget.WebPlayer);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path + ".iPhone.unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,
BuildTarget.iPhone);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path + ".Android.unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,
BuildTarget.Android);
Selection.objects = selection;
}
}
}
----
5 I compressed atlas images maximally.
Here is core of my idea.
When the program is executed, switched from "dirty atlas SpriteCollection in project" to "clean atlas SpriteCollection that load from assetBundle".
i think, "dirty atlas SpriteCollection in project" is Proxy
####################
## load assetBundel
####################
6 The assetBundle loaded as tk2dSpriteCollectionData type.
--sample code--
tk2dSpriteCollectionData d = bundle.Load("SampleSpriteCollection", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
----
####################
## reset sprite
####################
7 listup game objects.
--sample code--
List<GameObject> UIs = new List<GameObject>();
List<GameObject> Stage = new List<GameObject>();
List<GameObject> items = new List<GameObject>();
public GameObject StagePrefab; //it is PreFab
public void search(){
addList(list,GameObject.Find("Button1"));
addList(list,GameObject.Find("Button2"));
findchild(StagePrefab);
foreach(GameObject g inGameObject. FindGameObjectsWithTag("staticItem")){
addList(items,g);
}
}
public void findchild(GameObject g){
foreach( Transform child in g.transform)
{
addList(Stage,child.gameObject);
findchild(child);
}
}
public void addList(List<GameObject> l, GameObject g){
tk2dSprite s = g.GetComponent<tk2dSprite>();
if(s.Collection.name != "SampleSpriteCollection"){
return;
}
l.add(g);
return;
}
-----
8 It rewrite all of tk2dSpriteCollecttion gameObjects that listed.
--sample code--
foreach(GameObject g in list1){
if(s.Collection.name != "SampleSpriteCollection"){
continue;
}
tk2dSprite s = g.GetComponent<tk2dSprite>();
string spritename = s.Collection.spriteDefinitions[s.spriteId].name;
s.Collection = d;
s.SetSprite(spritename);
s.Build();
}
foreach(GameObject g in list2){
.....
-----
9 Game start!
In particular, No.8 and No.7, is slow by generating for each scene.
Increasing processes for each type of SpriteCollection is slow too.
If it can replace only the "dirty atlas images of "SampleSpriteCollection" that are present in my project and I don't need to do No.8, I'm glad.
Please tell me if there is an other recommended development method with using assetBundle.