Beispiel #1
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);
    }
Beispiel #2
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);
    }