Ejemplo n.º 1
0
    static void MenuBuildObjectAsset()
    {
        SetBuilderRunningTimeSettings(TSysRunningType.enRelease);
        bool bRet = BuildObjectAsset();

        GameEditorUtil.ShowMessageBox(bRet ? "成功" : "失败");
    }
Ejemplo n.º 2
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.º 3
0
    static void MenuBuildTextEditor()
    {
        SetBuilderRunningTimeSettings(TSysRunningType.enEditor);
        bool bRet = BuildTextEditor();

        GameEditorUtil.ShowMessageBox(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
    // 获取所有objParent下(包含)需要打包的资源节点
    private static void GetBuildObject(ref List <GameObject> rOutGoList, GameObject objParent = null)
    {
        if (rOutGoList == null)
        {
            rOutGoList = new List <GameObject>();
        }
        if (objParent == null)
        {
            List <GameObject> objTop = GameEditorUtil.GetALLTopGameObjectInScene();
            foreach (GameObject go in objTop)
            {
                GetBuildObject(ref rOutGoList, go);
            }
            return;
        }

        if (PrefabUtility.GetPrefabParent(objParent) == null)
        {
            Int32 nChildCount = objParent.transform.childCount;
            for (Int32 i = 0; i < nChildCount; ++i)
            {
                Transform transChild = objParent.transform.GetChild(i);
                if (transChild == null || transChild.gameObject == null)
                {
                    continue;
                }
                GetBuildObject(ref rOutGoList, transChild.gameObject);
            }
        }
        else
        {
            rOutGoList.Add(objParent);
        }
    }
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
    // 获取打包场景配置
    static CBuildAllConfig GetBuildConfigAll()
    {
        if (File.Exists(sStrBuildSceneConfig) == false)
        {
            return(null);
        }
        string strConfig = GameEditorUtil.TextResourceLoadAtPath(sStrBuildSceneConfig);

        if (string.IsNullOrEmpty(strConfig))
        {
            return(null);
        }
        CBuildAllConfig buildConfig = GameUtil.ReadFromXmlString <CBuildAllConfig>(strConfig);

        return(buildConfig);
    }
Ejemplo n.º 8
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("生成成功");
    }