0
0
Unityframework~10 mins

Asset bundles and optimization in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load an asset bundle from a file path.

Unity
AssetBundle bundle = AssetBundle.LoadFromFile([1]);
Drag options to blanks, or click blank then click option'
ALoadFromMemory
BmyBundle
C"Assets/Bundles/mybundle"
DLoadAsset
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name without quotes instead of a string path.
Using a method name instead of a file path.
2fill in blank
medium

Complete the code to load an asset named "player" from the asset bundle.

Unity
GameObject player = bundle.[1]<GameObject>("player");
Drag options to blanks, or click blank then click option'
ALoadAsset
BGetAsset
CFindAsset
DLoadFromFile
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetAsset which does not exist.
Using LoadFromFile which loads bundles, not assets.
3fill in blank
hard

Fix the error in unloading the asset bundle but keep loaded assets usable.

Unity
bundle.[1](false);
Drag options to blanks, or click blank then click option'
ADispose
BUnload
CClose
DRelease
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dispose which is not a method on AssetBundle.
Using Unload(true) which unloads assets too.
4fill in blank
hard

Fill both blanks to create a dictionary of asset names and their sizes from an asset bundle.

Unity
Dictionary<string, long> assetSizes = new Dictionary<string, long>() {
    { [1], bundle.GetAssetSize([2]) }
};
Drag options to blanks, or click blank then click option'
A"player"
B"enemy"
Attempts:
3 left
💡 Hint
Common Mistakes
Using different asset names for key and size lookup.
Not using quotes around asset names.
5fill in blank
hard

Fill all three blanks to load an asset bundle asynchronously and get an asset named "tree".

Unity
var request = AssetBundle.LoadFromFileAsync([1]);
request.completed += (asyncOp) => {
    var bundle = request.[2];
    GameObject tree = bundle.[3]<GameObject>("tree");
};
Drag options to blanks, or click blank then click option'
A"Assets/Bundles/environment"
BassetBundle
CLoadAsset
Dbundle
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property name instead of assetBundle.
Using LoadFromFile instead of LoadFromFileAsync.
Not using quotes around the file path.