コード例 #1
0
    private void PrepareData(string modelType)
    {
        var inputConfig = new InputConfiguration();

        AssetDirs.CreateAssetDirectory(AssetDirs.TempAssetsDir);
        var assetBundleCreator = new AssetBundleCreator(inputConfig.OutputDir);
        var modelConverter     = new ModelConverter();

        Log.Info("Preprocessing started!");
        var  modelImporter = InitializeModelImporter(modelType, modelConverter, inputConfig.RootDirectory);
        bool loadModel     = true;

        try
        {
            while (loadModel)
            {
                modelImporter.GetModelData();
                assetBundleCreator.Create(modelImporter);
                if (Application.isBatchMode)
                {
                    loadModel = false;
                }
                else
                {
                    loadModel = EditorUtility.DisplayDialog("", "Do you want to load another model?", "Yes", "No");
                }
            }
        }
        finally
        {
            RecursiveDeleter.DeleteRecursivelyWithSleep(AssetDirs.TempAssetsDir);
            Log.Info("Preprocessing finished!");
        }
    }
コード例 #2
0
    //Creates appropriate AssetBundle for the model.
    private void CreateAssetBundle(AssetBundleBuild[] buildMapArray)
    {
        Directory.CreateDirectory(outputPath);
        BuildPipeline.BuildAssetBundles(outputPath, buildMapArray, BuildAssetBundleOptions.None, BuildTarget.WSAPlayer);

        // this is necessary to clear references to this asset

        Texture2D texture = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDirs.TempAssetsDir + "/icon.asset");

        UnityEngine.Object.DestroyImmediate(texture, true);

        // this is still necessary even after above DestroyImmediate.
        AssetDatabase.DeleteAsset(AssetDirs.TempAssetsDir + "/icon.asset");

        //Cleaning up an unnecessesary bundle
        string folderBundle = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(outputPath));

        RecursiveDeleter.DeleteRecursivelyWithSleep(folderBundle);
        RecursiveDeleter.DeleteRecursivelyWithSleep(folderBundle + ".manifest");
    }