55public class BuildAssetBundles
66{
77 [ MenuItem ( "Window/Build FairyGUI Example Bundles" ) ]
8- public static void Builde ( )
8+ public static void Build ( )
99 {
10- #if ( UNITY_5 || UNITY_5_3_OR_NEWER )
11- for ( int i = 0 ; i < 10 ; i ++ )
12- {
13- AssetImporter . GetAtPath ( "Assets/FairyGUI/Examples/Resources/Icons/i" + i + ".png" ) . assetBundleName = "fairygui-examples/i" + i + ".ab" ;
14- }
15-
16- AssetImporter . GetAtPath ( "Assets/FairyGUI/Examples/Resources/UI/BundleUsage_fui.bytes" ) . assetBundleName = "fairygui-examples/bundleusage.ab" ;
17- AssetImporter . GetAtPath ( "Assets/FairyGUI/Examples/Resources/UI/BundleUsage_atlas0.png" ) . assetBundleName = "fairygui-examples/bundleusage.ab" ;
10+ string basePath = "Assets/FairyGUI/Examples/Resources/" ;
11+ if ( AssetImporter . GetAtPath ( basePath + "Icons/i0.png" ) == null )
12+ basePath = "Assets/Examples/Resources/" ;
1813
19- BuildPipeline . BuildAssetBundles ( Application . streamingAssetsPath , BuildAssetBundleOptions . None , BuildTarget . Android ) ;
20- #else
2114 for ( int i = 0 ; i < 10 ; i ++ )
2215 {
23- Object obj = AssetDatabase . LoadAssetAtPath ( "Assets/FairyGUI/Examples/Resources/Icons/i" + i + ".png" , typeof ( Object ) ) ;
24- BuildPipeline . BuildAssetBundle ( obj , null , Path . Combine ( Application . streamingAssetsPath , "fairygui-examples/i" + i + ".ab" ) ,
25- BuildAssetBundleOptions . CollectDependencies , BuildTarget . Android ) ;
16+ AssetImporter . GetAtPath ( basePath + "Icons/i" + i + ".png" ) . assetBundleName = "fairygui-examples/i" + i + ".ab" ;
2617 }
2718
28- Object mainAsset = AssetDatabase . LoadAssetAtPath ( "Assets/FairyGUI/Examples/Resources/UI/BundleUsage_fui.bytes" , typeof ( Object ) ) ;
29- Object [ ] assets = new Object [ ] {
30- AssetDatabase . LoadAssetAtPath ( "Assets/FairyGUI/Examples/Resources/UI/BundleUsage_atlas0.png" , typeof ( Object ) )
31- } ;
19+ AssetImporter . GetAtPath ( basePath + "UI/BundleUsage_fui.bytes" ) . assetBundleName = "fairygui-examples/bundleusage.ab" ;
20+ AssetImporter . GetAtPath ( basePath + "UI/BundleUsage_atlas0.png" ) . assetBundleName = "fairygui-examples/bundleusage.ab" ;
21+
22+ if ( ! Directory . Exists ( Application . streamingAssetsPath ) )
23+ Directory . CreateDirectory ( Application . streamingAssetsPath ) ;
3224
33- BuildPipeline . BuildAssetBundle ( mainAsset , assets , Path . Combine ( Application . streamingAssetsPath , "fairygui-examples/bundleusage.ab" ) ,
34- BuildAssetBundleOptions . CollectDependencies , BuildTarget . Android ) ;
35- AssetDatabase . Refresh ( ) ;
36- #endif
25+ BuildPipeline . BuildAssetBundles ( Application . streamingAssetsPath , BuildAssetBundleOptions . None , BuildTarget . Android ) ;
3726 }
3827}
0 commit comments