Ejemplo n.º 1
0
    public static PBData_ResourceConfigInfo GetConfigTreeLeaf(string strKey, PBData_ResourceConfigTree rConfigTree)
    {
        if (rConfigTree == null)
        {
            return(null);
        }
        if (rConfigTree.config_list == null)
        {
            return(null);
        }
        Int32 nSize = rConfigTree.config_list.Count;

        for (Int32 i = 0; i < nSize; ++i)
        {
            PBData_ResourceConfigInfo tmpInfo = rConfigTree.config_list[i];
            if (tmpInfo == null)
            {
                continue;
            }
            if (tmpInfo.key == strKey)
            {
                return(tmpInfo);
            }
        }
        return(null);
    }
Ejemplo n.º 2
0
    public static bool AddOrUpdateResourceConfigTree(PBData_ResourceConfigInfo info, ref PBData_ResourceConfigTree rConfigTree)
    {
        if (rConfigTree == null || info == null)
        {
            return(false);
        }
        if (rConfigTree.config_list == null)
        {
            rConfigTree.config_list = new List <PBData_ResourceConfigInfo>();
        }
        bool  bUpdate = false;
        Int32 nSize   = rConfigTree.config_list.Count;

        for (Int32 i = 0; i < nSize; ++i)
        {
            PBData_ResourceConfigInfo tmpInfo = rConfigTree.config_list[i];
            if (tmpInfo == null)
            {
                continue;
            }
            if (tmpInfo.key == info.key)
            {
                rConfigTree.config_list[i] = info;
                bUpdate = true;
            }
        }
        if (bUpdate == false)
        {
            rConfigTree.config_list.Add(info);
        }
        return(true);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 保存配置树
    /// </summary>
    /// <param name="tType"></param>
    /// <param name="pbData"></param>
    /// <returns></returns>
    static bool SaveConfigTree(TResourceBuildType tType, PBData_ResourceConfigTree pbData)
    {
        bool bRet = false;

        switch (tType)
        {
        case TResourceBuildType.enAssetBuild:
        {
        }
        break;

        case TResourceBuildType.enEditorBuild:
        {
            string strXML    = GameUtil.WriteToXmlString(pbData);
            byte[] dataArray = PackageSetting.cTextFileEncoding.GetBytes(strXML);
            bRet = GameEditorUtil.TextResourceSaveAtPath(PackageSetting.sEditorConfigTreeName, dataArray);
        }
        break;

        case TResourceBuildType.enResourceBuild:
        {
        }
        break;
        }
        return(bRet);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 获取配置树
    /// </summary>
    /// <param name="tType"></param>
    /// <returns></returns>
    static PBData_ResourceConfigTree GetBuildConfigTree(TResourceBuildType tType)
    {
        PBData_ResourceConfigTree configTree = null;

        switch (tType)
        {
        case TResourceBuildType.enAssetBuild:
            break;

        case TResourceBuildType.enEditorBuild:
        {
            string strConfigXML = GameEditorUtil.TextResourceLoadAtPath(PackageSetting.sEditorConfigTreeName);
            if (string.IsNullOrEmpty(strConfigXML) == false)
            {
                configTree = GameUtil.ReadFromXmlString <PBData_ResourceConfigTree>(strConfigXML);
            }
        }
        break;

        case TResourceBuildType.enResourceBuild:
            break;

        default:
            break;
        }
        return(configTree);
    }
Ejemplo n.º 5
0
    static bool BuildTextEditor()
    {
        // 获取BuildAll.config
        if (sBuildAllConfig == null)
        {
            UnityEngine.Debug.LogError("Load BuildAll.config Failed");
            return(false);
        }

        // 获取配置树, 如果没有则增加
        PBData_ResourceConfigTree configTree = GetBuildConfigTree(TResourceBuildType.enEditorBuild);

        if (configTree == null)
        {
            UnityEngine.Debug.LogError("Get Config Tree Failed");
            return(false);
        }
        PBData_ResourceConfigInfo textConfigInfo = ResourceConfigTree.GetConfigTreeLeaf(PackageSetting.sConfigTreeTextKey, configTree);

        if (textConfigInfo == null)
        {
            textConfigInfo      = new PBData_ResourceConfigInfo();
            textConfigInfo.key  = PackageSetting.sConfigTreeTextKey;
            textConfigInfo.path = GetConfigTreeLeafPath(TResourceBuildType.enEditorBuild, PackageSetting.sConfigTreeTextKey);
            ResourceConfigTree.AddOrUpdateResourceConfigTree(textConfigInfo, ref configTree);
        }
        // todo build Text
        PBData_EditorResourceInfoList resourceInfoList = new PBData_EditorResourceInfoList();

        GameUtil.SaveToXmlFile(resourceInfoList, textConfigInfo.path);
        SaveConfigTree(TResourceBuildType.enEditorBuild, configTree);

        return(true);
    }
Ejemplo n.º 6
0
    static bool BuildObjectEditor()
    {
        // 获取BuildAll.config
        if (sBuildAllConfig == null)
        {
            UnityEngine.Debug.LogError("Load BuildAll.config Failed");
            return(false);
        }

        // 获取配置树, 如果没有则增加
        PBData_ResourceConfigTree configTree = GetBuildConfigTree(TResourceBuildType.enEditorBuild);

        if (configTree == null)
        {
            UnityEngine.Debug.LogError("Get Config Tree Failed");
            return(false);
        }
        PBData_ResourceConfigInfo objectConfigInfo = ResourceConfigTree.GetConfigTreeLeaf(PackageSetting.sConfigTreeObjectKey, configTree);

        if (objectConfigInfo == null)
        {
            objectConfigInfo      = new PBData_ResourceConfigInfo();
            objectConfigInfo.key  = PackageSetting.sConfigTreeObjectKey;
            objectConfigInfo.path = GetConfigTreeLeafPath(TResourceBuildType.enEditorBuild, PackageSetting.sConfigTreeObjectKey);
            ResourceConfigTree.AddOrUpdateResourceConfigTree(objectConfigInfo, ref configTree);
        }

        // 读取Object资源已有配置
        PBData_EditorResourceInfoList resourceInfoList = null;
        string strXML = GameEditorUtil.TextResourceLoadAtPath(objectConfigInfo.path);

        if (string.IsNullOrEmpty(strXML) == false)
        {
            resourceInfoList = GameUtil.ReadFromXmlString <PBData_EditorResourceInfoList>(strXML);
        }
        // 单个打包还是所有打包
        GameObject selectObj = Selection.activeGameObject;
        bool       bBuildRet = false;

        if (selectObj == null)
        {
            bBuildRet = ObjectResourceBuilder.BuildEditorObject(sBuildAllConfig.ObjectList, ref resourceInfoList);
        }
        else
        {
            bBuildRet = ObjectResourceBuilder.BuildEditorObject(selectObj, ref resourceInfoList);
        }
        if (bBuildRet == false)
        {
            UnityEngine.Debug.LogError("Build Object Failed");
            return(false);
        }

        GameUtil.SaveToXmlFile(resourceInfoList, objectConfigInfo.path);
        SaveConfigTree(TResourceBuildType.enEditorBuild, configTree);

        return(bBuildRet);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 创建空的BuildAll文件
    /// </summary>
    static void CreateEmptyEditorConfigTree()
    {
        PBData_ResourceConfigTree pbData = new PBData_ResourceConfigTree();

        pbData.config_list = new global::System.Collections.Generic.List <PBData_ResourceConfigInfo>();
        string strFilePath = PackageSetting.sEditorConfigTreeName;

        if (File.Exists(strFilePath) == true)
        {
            GameEditorUtil.ShowMessageBox(" config_tree.xml文件已经存在,继续生成会覆盖原文件,要继续吗? ", "警告",
                                          () =>
            {
                GameUtil.SaveToXmlFile(pbData, strFilePath);
                GameEditorUtil.ShowMessageBox("生成成功");
            });
            return;
        }
        GameUtil.SaveToXmlFile(pbData, strFilePath);
        GameEditorUtil.ShowMessageBox("生成成功");
    }