Exemple #1
0
    public static void ConvertV3D()
    {
        //let user select vpp folder he would like to unpack
        string fileSearchMessage = "Select V3D file you would like to convert into a prefab.";
        string defaultPath       = "Assets";

        if (!string.IsNullOrEmpty(lastV3DPath))
        {
            defaultPath = Path.GetDirectoryName(lastV3DPath);
        }
        string filePath = EditorUtility.OpenFilePanel(fileSearchMessage, defaultPath, "v3d,v3m,v3c");

        if (string.IsNullOrEmpty(filePath))
        {
            return;
        }
        if (!UFUtils.IsAssetPath(filePath))
        {
            Debug.LogError("Can only convert files that are in an Asset folder. Please move the file into your Unity project and try again.");
            return;
        }

        lastV3DPath = filePath;

        V3DReader reader = new V3DReader(filePath);

        reader.MakePrefabAtAssetPath();
    }
Exemple #2
0
    private static void ExportFile(string name, string exportFolder, byte[] bytes, int start, int length)
    {
        string ext = "";

        Byte[] fileBytes = new Byte[length];
        for (int i = 0; i < length; i++)
        {
            fileBytes[i] = bytes[start + i];
        }
        string exportPath = exportFolder + '/' + name;

        try {
            File.WriteAllBytes(exportPath, fileBytes);
            ext = Path.GetExtension(name).TrimStart('.').ToLower();
        }
        catch (Exception e) {
            Debug.LogError("Failed to write to " + name + " Because of error: \n" + e);
        }

        //handle extentions that require further processing
        switch (ext)
        {
        case "v3d":
        case "v3m":
        case "v3c":
            V3DReader modelReader = new V3DReader(exportPath);
            modelReader.MakePrefabAtAssetPath();
            break;

        case "vbm":
            VBMReader texReader = new VBMReader(exportPath);
            texReader.MakeMaterialAtAssetPath();
            break;

        case "wav":
            new WavRepairer(exportPath);
            break;
        }
    }