1Description 2=========== 3 4This folder contains resources for building a simple demo decompressing and rendering Draco within Unity. 5 6If you are looking for more information on using Draco within Unity, 7[DracoUnity](https://github.com/atteneder/DracoUnity) is a much better resource. 8There are more samples as well as support for more platforms. 9 10In this folder we currently support two types of usages: 11* Import Draco compressed mesh as assets during design time. 12* Load/decode Draco files in runtime. 13 14Prerequisite 15============ 16 17To start, you need to have the Draco unity plugin. You can either use the 18prebuilt libraries provided in this folder or build from source. 19Note that the plugin library for different platforms has different file extension. 20 21| Platform | Library name | 22| -------- | ------------ | 23| Mac OS | dracodec_unity.bundle | 24| Android | libdracodec_unity.so | 25| Windows | dracodec_unity.dll | 26 27Prebuilt Library 28---------------- 29 30We have built library for several platforms: 31 32| Platform | Tested Environment | 33| -------- | ------------------ | 34| .bundle | macOS Sierra + Xcode 8.3.3 | 35| armeabi-v7a(.so) | Android 8.1.0 | 36| .dll | Win10 + Visual Studio 2017 | 37 38Build From Source 39----------------- 40See [BUILDING.md](BUILDING.md) for information on building Draco Unity plug-ins from source. 41 42Create Draco Demo Unity Project 43=============================== 44 45Create a new 3D project in Unity. 46 47Copy Library to Your Project 48---------------------------- 49Copy the plugin library to your Unity project in `Assets/Plugins/`. 50For Android Arm7: 51 52~~~~ bash 53cp path/to/your/libdracodec_unity.so path/to/your/Unity/Project/Assets/Plugins/Android/libs/armeabi-v7a/ 54~~~~ 55 56For Android Arm8: 57 58~~~~ bash 59cp path/to/your/libdracodec_unity.so path/to/your/Unity/Project/Assets/Plugins/Android/libs/arm64-v8a/ 60~~~~ 61 62For Mac: 63 64~~~~ bash 65cp path/to/your/dracodec_unity.bundle path/to/your/Unity/Project/Assets/Plugins/ 66~~~~ 67 68For Win: 69 70~~~~ bash 71cp path/to/your/dracodec_unity.dll path/to/your/Unity/Project/Assets/Plugins/ 72~~~~ 73 74 75Copy Unity Scripts to Your Project 76---------------------------------- 77 78~~~~ bash 79cp unity/DracoDecodingObject.cs path/to/your/Unity/Project/Assets/ 80cp unity/DracoMeshLoader.cs path/to/your/Unity/Project/Assets/ 81~~~~ 82 83Player Settings Change 84------------------------------- 85Open player settings. Make sure `Allow unsafe code` is checked, so Unity can load our plug-ins. 86 87Copy Draco Mesh to Your Project 88------------------------------- 89Because Unity can only recognize file extensions known to Unity, you need to change your compressed .drc file to .drc.bytes so that Unity will recognize it as a binary file. For example, if you have file `bunny.drc` then change the file name to `bunny.drc.bytes`. 90 91~~~~ bash 92cp path/to/your/bunny.drc path/to/your/Unity/Project/Assets/Resources/bunny.drc.bytes 93~~~~ 94 95 96--- 97 98Load Draco Assets in Runtime 99============================ 100For example, please see [DracoDecodingObject.cs](DracoDecodingObject.cs) for usage. To start, you can create an empty GameObject and attach this script to it. [DracoDecodingObject.cs](DracoDecodingObject.cs) will load `bunny.drc.bytes` by default. 101 102Enable Library in Script Debugging 103---------------------------------- 104If you have library for the platform you are working on, e.g. `dracodec_unity.bundle` for Mac or `dracodec_unity.dll` for Windows. You should be able to use the plugin in debugging mode. 105 106--- 107 108Import Compressed Draco Assets 109============================== 110In this section we will describe how to import Draco files (.drc) to Unity as 111other 3D formats at design time, e.g. obj, fbx. 112Note that importing Draco files doesn't mean the Unity project will export models as Draco files. 113 114Copy [DracoFileImporter.cs](Editor/DracoFileImporter.cs) which enables loading (This file is only used for import Draco files): 115 116~~~~ bash 117cp DracoFileImporter.cs path/to/your/Unity/Project/Assets/Editor/ 118~~~~ 119 120If you have followed the previous steps, you just need to copy your asset, e.g. `bunny.drc.bytes`, to `Your/Unity/Project/Assets/Resources`, the project will automatically load the file and add the models to the project. 121 122--- 123