Esempio n. 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);
    }
Esempio n. 2
0
    /// <summary>
    /// 打包选中模型或者选中节点下的所有模型
    /// </summary>
    /// <param name="objSelected"></param>
    /// <param name="resourceList"></param>
    /// <returns></returns>
    public static bool BuildEditorObject(GameObject objSelected, ref PBData_EditorResourceInfoList resourceList)
    {
        if (objSelected == null)
        {
            return(false);
        }
        List <GameObject> objList = new List <GameObject>();

        GetBuildObject(ref objList, objSelected);
        if (objList == null)
        {
            return(true);
        }
        bool bNoError = true;

        foreach (GameObject obj in objList)
        {
            if (_BuildEditorObject(obj, ref resourceList) == false)
            {
                bNoError = false;
                UnityEngine.Debug.LogError(string.Format("Build Object:{0} Failed", obj == null ? "NULL" : obj.name));
            }
        }
        return(bNoError);
    }
Esempio n. 3
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);
    }
Esempio n. 4
0
    // 打包一个场景中的模型资源
    private static bool _BuildEditorObject(GameObject objInScene, ref PBData_EditorResourceInfoList resourceList)
    {
        if (objInScene == null)
        {
            return(false);
        }
        Object objPrefab = PrefabUtility.GetPrefabParent(objInScene);

        if (objPrefab == null)
        {
            return(false);
        }
        string strKey  = objPrefab.name;
        string strPath = AssetDatabase.GetAssetPath(objPrefab);

        if (resourceList == null)
        {
            resourceList = new PBData_EditorResourceInfoList();
        }
        if (resourceList.resouce_list == null)
        {
            resourceList.resouce_list = new List <PBData_EditorResourceInfo>();
        }

        bool bUpdate = false;

        foreach (PBData_EditorResourceInfo info in resourceList.resouce_list)
        {
            if (info == null)
            {
                continue;
            }
            if (info.key == strKey)
            {
                info.path = strPath;
                bUpdate   = true;
            }
        }
        if (bUpdate == false)
        {
            PBData_EditorResourceInfo newInfo = new PBData_EditorResourceInfo();
            newInfo.key  = strKey;
            newInfo.path = strPath;
            resourceList.resouce_list.Add(newInfo);
        }
        return(true);
    }
Esempio n. 5
0
    /// <summary>
    /// 打包输入场景中的所有模型
    /// </summary>
    /// <param name="objectList"></param>
    /// <param name="resourceList"></param>
    /// <returns></returns>
    public static bool BuildEditorObject(List <ResourceBuilder.CBuildAllObject> objectList, ref PBData_EditorResourceInfoList resourceList)
    {
        if (objectList == null)
        {
            return(false);
        }
        if (resourceList == null)
        {
            resourceList = new PBData_EditorResourceInfoList();
        }
        Int32 nSize = objectList == null ? 0 : objectList.Count;

        bool bNoError = true;

        for (Int32 i = 0; i < nSize; ++i)
        {
            string strUnityScenePath = objectList[i].Path;
            if (EditorApplication.OpenScene(strUnityScenePath) == false)
            {
                UnityEngine.Debug.LogError(string.Format("Open Scene:<{0}> Failed", strUnityScenePath));
                continue;
            }
            EditorApplication.SaveScene(strUnityScenePath);
            List <GameObject> allObjectToPack = new List <GameObject>();
            GetBuildObject(ref allObjectToPack, null);
            foreach (GameObject objToPack in allObjectToPack)
            {
                if (_BuildEditorObject(objToPack, ref resourceList) == false)
                {
                    bNoError = false;
                    UnityEngine.Debug.LogError(string.Format("Build Object:{0} Failed", objToPack == null ? "NULL" : objToPack.name));
                }
            }
        }
        return(bNoError);
    }