Пример #1
0
        static void DoIt()
        {
            string[] files = System.IO.Directory.GetFiles("Assets/Doubility3D/CoreData", "*.*", System.IO.SearchOption.AllDirectories);
            files = files.Where(s => s.EndsWith(".mat") || s.EndsWith(".exr") || s.EndsWith(".shader")).ToArray();
            files = Array.ConvertAll <string, string> (files, new Converter <string, string> ((s) => {
                return(s.Replace('\\', '/'));
            }));

            AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
            buildMap [0].assetBundleName = "coreData.bundle";
            buildMap [0].assetNames      = files;

            Dictionary <string, string> dictShaderName2Path = new Dictionary <string, string> ();

            for (int i = 0; i < files.Length; i++)
            {
                if (files [i].EndsWith(".shader"))
                {
                    Shader shader = AssetDatabase.LoadAssetAtPath <Shader> (files [i]);
                    if (dictShaderName2Path.ContainsKey(shader.name))
                    {
                        EditorUtility.DisplayDialog("不得行", "Shader 名字:" + shader.name + "不唯一", "晓得不嘛");
                        return;
                    }
                    dictShaderName2Path.Add(shader.name, files [i]);
                }
            }

            string jsonString = JsonMapper.ToJson(dictShaderName2Path);

            System.IO.File.WriteAllText(ShaderDictionary.Path, jsonString);
            AssetDatabase.Refresh();

            Array.Resize <string> (ref buildMap [0].assetNames, buildMap [0].assetNames.Length + 1);
            buildMap [0].assetNames [buildMap [0].assetNames.Length - 1] = ShaderDictionary.Path;

            if ((EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows64))
            {
                EditorUtility.DisplayDialog("不得行", EditorUserBuildSettings.activeBuildTarget.ToString() + "是不支持的平台", "晓得不嘛");
            }

            string outputFolder = TargetPath.GetHome() + "/.coreData/" + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget);

            if (!System.IO.Directory.Exists(outputFolder))
            {
                System.IO.Directory.CreateDirectory(outputFolder);
            }
            BuildPipeline.BuildAssetBundles(outputFolder, buildMap, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
            EditorUtility.DisplayDialog("搞定了", "核心数据输出完毕", "好了");

            System.IO.File.Delete(ShaderDictionary.Path);
            AssetDatabase.Refresh();
        }
    static void DoIt()
    {
        if (!System.IO.File.Exists(TestData.config_path))
        {
            EditorUtility.DisplayDialog("不得行", "找不到" + TestData.config_path, "咋办喃");
            return;
        }

        string output_folder = TestData.testBundle_path + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget);

        if (!System.IO.Directory.Exists(output_folder))
        {
            System.IO.Directory.CreateDirectory(output_folder);
        }

        string    json = System.IO.File.ReadAllText(TestData.config_path);
        BuildMaps maps = JsonMapper.ToObject <BuildMaps>(json);

        BuildPipeline.BuildAssetBundles(output_folder, maps.buildMap, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
    }
Пример #3
0
    static void DoIt()
    {
        string[] files = System.IO.Directory.GetFiles(ArtWork.path, "*.*", System.IO.SearchOption.AllDirectories);
        files = files.Where(s => s.EndsWith(".tga") || s.EndsWith(".png") || s.EndsWith(".jpg")).ToArray();
        files = Array.ConvertAll <string, string>(files, new Converter <string, string>((s) => { return(s.Replace('\\', '/')); }));

        if ((EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows64))
        {
            EditorUtility.DisplayDialog("不得行", EditorUserBuildSettings.activeBuildTarget.ToString() + "是不支持的平台", "晓得不嘛");
        }

        string[] names = files;
        for (int i = 0; i < names.Length; i++)
        {
            Texture2D texture = AssetDatabase.LoadAssetAtPath <Texture2D>(names[i]);

            string path = names[i].Substring(ArtWork.path.Length);
            path = System.IO.Path.GetDirectoryName(path) + "/" + System.IO.Path.GetFileNameWithoutExtension(path);
            path = TargetPath.GetHome() + "/.root/" + path + "." + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget).ToLower() + ".texture";

            string folder = System.IO.Path.GetDirectoryName(path);
            if (!System.IO.Directory.Exists(folder))
            {
                System.IO.Directory.CreateDirectory(folder);
            }

            ByteBuffer bb = TextureSaver.Save(texture);
            FileSaver.Save(bb, Schema.Context.Texture, path);
        }

        names = null;
        EditorUtility.DisplayDialog("搞定了", "纹理输出完毕", "好了");
    }