示例#1
0
                public JsonObject BuildConfig()
                {
                    JsonObject json = new JsonObject();

                    JsonObject jsonObj = new JsonObject();

                    jsonObj["bundleName"] = new JsonString(bundleName + lhBundleBuilder.buildParameter.stuff);
                    jsonObj["mainAsset"]  = new JsonString(Path.GetFileNameWithoutExtension(mainAsset.path));
                    JsonArray allAssets = new JsonArray();

                    for (int i = 0; i < includeList.Count; i++)
                    {
                        allAssets.Add(new JsonString(Path.GetFileNameWithoutExtension(includeList[i].path)));
                    }
                    jsonObj["allAssets"] = allAssets;
                    JsonArray dependencyJson = new JsonArray();
                    var       dependencyList = GetAllDependencies();

                    for (int i = 0; i < dependencyList.Count; i++)
                    {
                        dependencyJson.Add(new JsonString(dependencyList[i]));
                    }
                    jsonObj["dependencies"] = dependencyJson;
                    json[bundleName]        = jsonObj;
                    if (childList != null)
                    {
                        for (int i = 0; i < childList.Count; i++)
                        {
                            json.AddArrayValue(childList[i].BuildConfig());
                        }
                    }
                    return(json);
                }
示例#2
0
            public void BuildSelected()
            {
                string configPath = CombinePath(
                    lhBundleBuilder.GetApplicationPath(),
                    lhBundleBuilder.buildParameter.outputRootFolder,
                    lhBundleBuilder.buildParameter.buildTarget.ToString(),
                    m_groupName,
                    m_groupName
                    );
                FileInfo configFileInfo = new FileInfo(configPath);

                if (!configFileInfo.Directory.Exists)
                {
                    configFileInfo.Directory.Create();
                }
                configFileInfo = null;
                JsonObject jsonObject = new JsonObject();

                for (int i = 0; i < m_treeList.Count; i++)
                {
                    if (m_treeList[i].HasSelected())
                    {
                        jsonObject.AddArrayValue(m_treeList[i].BuildBundle(m_groupName));
                    }
                }
                JsonObject json = null;

                if (File.Exists(configPath))
                {
                    json = lhJson.Parse(File.ReadAllText(configPath)) as JsonObject;
                    json["manifestFileVersion"] = new JsonNumber(1);
                    json["crc"] = new JsonNumber(lhBundleBuilder.buildParameter.crc);
                    var assetBundleManifest = json["assetBundleManifest"].AsDict();
                    var oldObj = assetBundleManifest["assetBundleInfos"].AsDict();
                    var newObj = ((JsonObject)oldObj);
                    newObj.AddArrayValue(jsonObject);
                    newObj = CheckUnusedFile(configPath, newObj);
                    assetBundleManifest["assetBundleInfos"] = newObj;
                    File.WriteAllText(configPath, lhJson.PrettyPrint(json.ToString()));
                }
                else
                {
                    json = new JsonObject();
                    json["manifestFileVersion"] = new JsonNumber(1);
                    json["crc"] = new JsonNumber(lhBundleBuilder.buildParameter.crc);
                    var assetBundleManifest = new JsonObject();
                    jsonObject = CheckUnusedFile(configPath, jsonObject);
                    assetBundleManifest["assetBundleInfos"] = jsonObject;

                    json["assetBundleManifest"] = assetBundleManifest;
                    File.WriteAllText(configPath, lhJson.PrettyPrint(json.ToString()));
                }
                EditorUtility.DisplayDialog("Information", "Build Success", "Ok");
            }