cocos2d unity3d 获取访问文件列表(一)

来源:互联网 发布:在线编程怎么用 编辑:程序博客网 时间:2024/04/30 00:03

第一次写博客,饮水思源,回馈大家。

 在手游制作工程中有时候需要知道游戏加载的资源。

针对cocos2d

  1. 修改cocos2d-x引擎读取资源函数,记录所有操作到log文件中。

步骤如下,在函数:


std::stringCCFileUtils::fullPathForFilename(constchar* pszFileName)

中添加如下代码

   if (cacheIter !=m_fullPathCache.end())

   {

       //CCLOG("Return full path from cache: %s",cacheIter->second.c_str());

       return cacheIter->second;

    }

//以下红色代码是添加部分

   std::stringlowerCase2(pszFileName);

   if(std::string::npos != lowerCase2.find(".png")||

       std::string::npos != lowerCase2.find(".mp3")||

       std::string::npos != lowerCase2.find(".plist")){

       SGSLOGW(pszFileName);

       CCLOG("---%s", pszFileName);

}

  1. 游戏运行之后会把使用的全部资源记录到log文件中,编写一个脚本把不在log文件中的资源全部删除。

  2. 最后查漏补缺



1 0
原创粉丝点击