Пример #1
0
    void OnWizardCreate()
    {
        tex = new List <TransformExportData> ();
        mex = new Hashtable();
        mtx = new Hashtable();

        for (var i = 0; i < transforms.Length; i++)
        {
            RecurseTransform(transforms[i]);
        }

        string meshesPath = EditorUtility.SaveFilePanel("Save meshes", FileExport.lastExportPath, "", "js");
        string scenePath  = meshesPath.Substring(0, meshesPath.Length - 3) + "Scene.js";

        StringTemplate mt = FileExport.LoadTemplate("model");

        mt.SetAttribute("prefix", prefix + "Meshes");
        mt.SetAttribute("meshes", mex.Values);
        FileExport.SaveContentsAsFile(mt.ToString(), meshesPath);

        StringTemplate st = FileExport.LoadTemplate("scene");

        st.SetAttribute("prefix", prefix + "Scene");
        st.SetAttribute("meshPrefix", prefix + "Meshes");
        st.SetAttribute("transforms", tex);
        st.SetAttribute("root", tex[0]);
        st.SetAttribute("meshes", mex.Values);
        st.SetAttribute("materials", mtx.Values);
        FileExport.SaveContentsAsFile(st.ToString(), scenePath);

        FileExport.lastExportPath = meshesPath;
    }
Пример #2
0
 public static void saveReport(string path)
 {
     FileExport.SaveContentsAsFile(_i._report, path);
 }
Пример #3
0
    void OnWizardCreate()
    {
        // Rename all gameobjects so that there are none with the same name

        Report.level             = ReportLevel.All;
        Report.useConsole        = useConsole;
        TransformExportData.uidc = 1;

        Report.log("Exporting scene: " + EditorApplication.currentScene);
        Report.log("Platform: " + SystemInfo.operatingSystem);
        Report.log("Unity player: " + Application.unityVersion);

        string meshesPath  = EditorUtility.SaveFilePanel("Save meshes", FileExport.lastExportPath, "", extenstion.ToString());
        int    extl        = (extenstion == Extension.js) ? 3 : 5;
        string scenePath   = meshesPath.Substring(0, meshesPath.Length - extl) + "Scene." + extenstion.ToString();
        string texturePath = meshesPath.Substring(0, meshesPath.LastIndexOf("/") + 1);
        string reportPath  = meshesPath.Substring(0, meshesPath.Length - extl) + "Log.txt";

        Report.log("Exporting to: " + meshesPath + " " + scenePath);

        tex = new List <TransformExportData> ();
        lgx = new List <LightExportData> ();
        cmx = new List <CameraExportData> ();
        led = new List <LightmapExportData> ();

        mex = new Hashtable();
        mtx = new Hashtable();
        txx = new Hashtable();

        int i;

        for (i = 0; i < transforms.Length; i++)
        {
            RecurseTransform(transforms[i], null);
        }

        for (i = 0; i < LightmapSettings.lightmaps.Length; i++)
        {
            led.Add(new LightmapExportData(i));
        }

        StringTemplate mt = FileExport.LoadTemplate("model");

        mt.SetAttribute("prefix", prefix + "Meshes");
        mt.SetAttribute("meshes", mex.Values);
        FileExport.SaveContentsAsFile(FileExport.CleanJSON(mt), meshesPath);

        StringTemplate st = FileExport.LoadTemplate("scene");

        st.SetAttribute("ambient", RenderSettings.ambientLight);

        if (Camera.mainCamera != null)
        {
            st.SetAttribute("background", Camera.mainCamera.backgroundColor);
        }
        else
        {
            st.SetAttribute("background", Color.black);
        }

        st.SetAttribute("prefix", prefix + "Scene");
        st.SetAttribute("meshPrefix", prefix + "Meshes");
        st.SetAttribute("transforms", tex);
        st.SetAttribute("root", tex[0]);
        st.SetAttribute("meshes", mex.Values);
        st.SetAttribute("materials", mtx.Values);
        st.SetAttribute("textures", txx.Values);
        st.SetAttribute("lights", lgx);
        st.SetAttribute("cameras", cmx);
        st.SetAttribute("lightmaps", led);
        FileExport.SaveContentsAsFile(FileExport.CleanJSON(st), scenePath);

        foreach (TextureExportData t in txx.Values)
        {
            t.Save(texturePath, jpegQuality);
        }

        foreach (LightmapExportData d in led)
        {
            d.Save(texturePath, jpegQuality, lightmapBrightness, lightmapContrast);
        }

        Report.log("Exported " + tex.Count + " transforms");
        Report.log("Exported " + txx.Values.Count + " textures");
        Report.log("Exported " + led.Count + " lightmaps");

        FileExport.lastExportPath = meshesPath;

        Report.log("Done!");
        if (generateReport)
        {
            Report.saveReport(reportPath);
        }
    }