Unity3D game development decompilation AssetBundle extracts game resources, unity3dassetbundle

Source: Internet
Author: User

Unity3D game development decompilation AssetBundle extracts game resources, unity3dassetbundle

Dear friends, welcome to my blog. I am Qin Yuanpei and my blog address is http://www.qinyuanpei.com. Today we are talking about extracting game resources by decompiling Unity3D AssetBundle. The goal of this article is not to teach you how to crack a game developed based on the Unity3D engine, instead, I want to use this article to tell you how to protect your game resources while developing Unity3D games.

Unity3D AssetBundle

For AssetBundle, the actual bloggers mentioned in previous articles. I don't know whether you can remember that I mentioned and used AssetBundle technology when I wrote this series of articles about game development and Lua. Specifically, AssetBundle is a solution for dynamic loading of resource Packaging Boxes in Unity3D. For example, the capacity of a single-host game we usually play is generally relatively large, this is because the producers integrate all the project resources when making the game. However, if we use AssetBundle for this game, we can only provide the core part that supports the game function in the released game, the scenario, model, and other resources in the game are packaged in the form of AssetBundle and then placed on the server, so that when the game client is online, these resources can be downloaded from the server, so as to achieve dynamic loading of game resources, we can see that AssetBundle can help us reduce the game capacity. If the installation package is required, the size of the game package will undoubtedly add a score for the game.

For example, the single-host game xuanyuan Sword 6 has recently been released, from the evaluation of major game websites to the hands-on experience of friends who like standalone games, we all agree that the overall performance of this game is good and we should consider playing it. This will inevitably make the blogger feel a little excited, but he hesitated to see the game capacity of 17 GB. The DOMO team started to use the Unity3D engine from xuanyuan Sword 6. After the first game failure, the DOMO team may make the game better. If you like single-host games, you may wish to play them. After all, the original intention of learning game development is to make good games. If you do not love games, how can you make good games? Well, it's a little far away. Here we notice that an important factor is the game capacity. If DOMO uses AeestBundle, the game capacity will definitely be reduced a lot. But in this way, it is not a standalone game, right!

In Unity3D, AssetBundle is a function in the Professional Edition. In the free version of Unity3D, this function cannot be used. I do not know whether this function is divided into the Personal Edition in Unity5. Now let's take a look at how to use AssetBundle. We mainly use AssetBundle to package and load AssetBundle:

Use Assetbundle to package

The use of AssetBundle packaging is mainly implemented through the BuildPipeline. BuildAssetBundle () method. The prototype of this method is:

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

In this method, the first parameter is of the Object type, indicating an active Object. The second parameter is of the Object [] type, indicating all selected objects; the third parameter is a string type, indicating the path of the resource package to be exported. The resource package extension can be assetbundle or unity3d. The fourth parameter indicates the packaging option, full packaging and dependency packaging are used by default. Here we will focus on the two concepts. Full packaging means that all resources are involved in packaging. For example, if a model has textures and animations, both textures and animations are packed as resources during model packaging. Dependency packaging is relative to Prefab. For example, if PrefabA references the PrefabB object, both objects will be packaged during packaging, this dependency between them will be maintained after packaging. The fifth parameter is the platform selection, because Unity3D is a cross-platform game engine, the current situation of various platforms is different, so now the Unity3D solution is that each platform can only use the AssetBundle corresponding to its own platform. I hope you will pay attention to this when using it. Now let's look at a simple example:

/// <Summary> /// output AssetBundle /// </summary> /// <param name = "type"> platform type </param> static void ExportToAssetBundle (ExportType type, buildTarget target) {// obtain the storage path string savePath = EditorUtility. saveFilePanel ("output as AssetBundle", "", "New Resource", "unity3d"); if (savePath = string. empty) return; // obtain the selected Object [] selection = Selection. getFiltered (typeof (Object), SelectionMode. deepAssets); if (selection. length = 0) return; // package if (type = ExportType. all) {BuildPipeline. buildAssetBundle (null, selection, savePath, BuildAssetBundleOptions. collectDependencies, target);} else {BuildPipeline. buildAssetBundle (obj, null, savePath, BuildAssetBundleOptions. collectDependencies, target );}}

This is a simple method for exporting the AssetBundle resource package. It has two parameters. The first parameter indicates an enumeration type and is defined as ExportType. When Single is used, a specific active object is packed, for example, a model, a scenario, and so on. Taking All indicates packaging All selected objects, such as a scenario. The second parameter indicates the Packaging Platform. The free version of Unity3D does not support AssetBundle, so we cannot demonstrate it here. Please test the specific effect. If you have any questions, leave a message to the blogger.

Load AssetBundle

Loading AssetBundle is a process of downloading resources from the network. Therefore, the Unity3D WWW function is required. This is a simple encapsulation of network protocols, you can access a URL or local address like a browser. HTTP is required to access the WEB address, and File is required to access the local address. Let's look at a specific example:

/// <Summary> /// load an unity3d file // WEB address -- http://server.com/xxx.unity3d // local address -- file ://. absolute path of the unity3d file /// </summary> IEnumerator LoadUnity3DFile (string url) {WWW www = new WWW (url); yield return www; if (www. error! = Null) {Debug. Log (www. error);} else {AssetBundle bundle = www. assetBundle; Instantiate (bundle. mainAsset, Vector3.zero, Quaternion. identity );}}

Here we use bundle directly. assetBundle obtains all resources. If you only need to obtain part of the resources, you only need to use bundle. you can use the Load () method. here you need to input the Resource Name. After resources are used, we can use the bundle. Unload () method to Unload resources to release the memory.

AssetBundle packaging from the decompilation of "New xianjian ol"

Now let's use AssetBundle decompilation of the game "New xianjian ol" to find out which problems should be paid attention to when using AssetBundle packaging. The new xianjian ol game is an online game developed using the Unity3D engine across client games and web games. The game is dominated by the story of the first-generation game of "xianjian Qixia Chuan, players will follow the third-person perspective to start a touching story of the hero. This game is good in general, because it is an online game, and we cannot evaluate it from the perspective of a Single-host game. We know the specific reasons.

Well, why should we choose this game?
* First, the game client only has more than 30 MB, which is suitable for Research (this is the benefit of AssetBundle). * Second, the blogger is a xianjian player, I always hope that one day "Legend of the legend" can be reproduced with 3D technology. This game satisfies the curiosity of the bloggers.
* Third, some friends on the Internet have studied the packaging of the game. Here, I would like to thank some friends who provided some. unity3d files and related files.

The decommission tool we selected is a command line tool called disunity. After the attempt by the blogger, this tool is really powerful and can be unlocked. unity3d files and. assets files, which can be obtained in the form of textures, sounds, models, etc. You can see the details later.

First, we can find the installation directory of "New xianjian ol", and then we can find a folder named assetbundles. Are you afraid you will not know it? This is so obvious! When we open the folder, we will find the Charachers, NPC, Scene, and other folders, and continue to find a lot of them. unity3d files, but all these files are. unity3d is followed by some random strings. According to the prompts of friends, these files are. unity3d files, but in order to interfere with the game production team, we intentionally followed the random characters (haha, is there a weaker encryption method than this ?). The first thing the blogger sees here is that he wants to first load AssetBundle to see if he can read these AssetBundle. Therefore, he decisively changed the file extension and then began to read it in Unity3D, the error reported by the result program seems to be simple. No way. Just unpack it! Enter:

disunity extract C:\Users\Robin\Desktop\s049.unity3d

Next, the program will generate a folder on s049 on the desktop. Open the folder and you can see that Nima has directly obtained the mesh data of the model (. obj) and texture data (. dds) and related Shader. This suddenly made me a little unacceptable. I immediately started Blender to import the grid data. As a result, Lin yueda, a child, appeared in front of us:

Because the blogger will not map the model in Blender, we need to first export the model to FBX format to complete the texture in Unity3D. Now, after importing the model into Unity3D, the texture will be assigned to the model, and Lin yuexiao from childhood will be on the stage. Haha!

Okay, let's look at another one, but there is no texture. You need to identify who it is, haha!

With the disunity tool, we can get more resources, and you can explore the remaining content on your own. Through this part of research, we can summarize the following points and hope you will pay attention when using AsssetBundle technology:
* Try to package multiple resources in an AssetBundle. The advantage of this is that others cannot get your prepared Prefab by loading the AssetBundle.
* Try to divide a premade part into different parts for separate storage. The advantage of this is that even if someone else gets your premade parts, it is incomplete.
* Try to use dynamic scripts to load scenarios rather than package the entire scenario. Even if you package the entire scenario, you need to separate the textures from the model. (therefore, although I have obtained the scene textures of the game, but it's useless)
* Try to use the encryption method to hide the local AssetBundle or use an imperceptible storage location as the storage location of the AssetBundle. Do not use Plaintext data for storage.

Well, today's content is like this. I hope you will like it. AssetBundle packaging is a question worth further research, these ideas raised by bloggers today are just some opinions on the packaging of the game "Xin xianjian ol". If you have different opinions, please join us!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.