大江湖-逆向篇-资源修复
逆向篇-资源修复
Unity
都可以直接识别,但是 Spine
动画和 Tile Map
地图还存在问题,这个章节我们将对资源问题进行修复,修复完成后游戏即可正常运行添加场景
需要将场景文件添加到编译选项中,否则后续运行点击按钮跳转时会报以下错误信息
|
|
点击 File-> Build Settings
点击 Add Open Scenes
添加到编译选项,此处需要将 Scene/Scenes
下的所有场景都添加进来
修复 spine 动画
打开 Assets\Scene\Scenes\OverHead\Title.unity
场景,出现了一大片红色,这是典型的 shader
出现问题的状态
原因是反编译的 Assets\Shader\SpineSkeleton.shader
语法不正确,可以直接将其替换成官方 Spine
的 shader
文件,路径在 spine-runtimes-spine-libgdx-3.8.55.1\spine-unity\Assets\Spine\Runtime\spine-unity\Shaders\SpineSkeleton.shader
替换完成后可以正常识别 shader
信息了,但是还有一些问题,出现了白边
在官网 Premultiplied Alpha Guide 和 spine-unity Runtime Documentation 中有进行解释
Images with transparency are commonly stored in one of two ways:Straight Alpha and Premultiply Alpha
- Straight Alpha is straightforward. It’s commonly used for “everyday” stuff like print and graphic design and on webpages.
- Premultiply Alpha (PMA) is specialized, can render a bit faster, and it has other properties that are beneficial for graphics in games and for VFX compositing.
For each of these ways of storing, there’s a corresponding way of rendering. Straight alpha blending and PMA blending.
In most Spine runtimes, PMA rendering is recommended. Some runtimes give you a choice, others don’t.
Unfortunately, this piece of information (whether you saved Straight or PMA) is not stored in the image file itself. So your game engine or program cannot tell whether your image was saved as Straight Alpha or Premultiply Alpha without your intervention. You have to make sure of this yourself:
Straight Alpha images need to be rendered as Straight Alpha. Premultiplied Alpha images need to be rendered as Premultiply Alpha.
此处勾选 Straight Alpha Texure
这两个参数,勾选后就可以正常显示了
点击运行,可以正常显示动画了
同理,还有 CGPlayer
场景、Assets\Resources\prefabs
等 spine
动画,也需要进行同样的设置
如主角角色 Assets\Resources\prefabs\Protagonist.prefab
,需要修改 body_top
、body_left
、body_back
的动画
Tile Map 地图修复
打开 Assets\Scene\Scenes\Demo01\Field\Field_YangTaiFuMiao.unity
,这是第一幕的杨太傅庙的地图,发现地图没有正确加载,可能是资源提取过程中丢失了
SuperTiled2Unity
插件会直接将 tile map editor
的 tmx
源文件导入到 unity
中,我们可以自己手动制作一个地图导入进来
Tiled 是一个开源的瓦片地图编辑工具,可以从官网 tiled map editor 下载,此处下载了 1.4.2 版本
使用工具绘制地图,所有图片均在 Assets\Texture2D
目录中
庙外地图stage-101-yangtaifumiao.tmx
破庙内部地图 stage-101-yangtaifumiao-1H.tmx
战斗地图
BattleField-yangtaifumiao-1H.tmx
创建 Assets\Maps
目录,将 tmx
和图片 +tsx
文件拷贝进来
此时 Unity
会提示正在导入
Unity
中可以看到对应的地图信息
信息中修改 Pixels Per Unit
值为 1,并点击 Apply
我们将文件拖到对应场景 Assets\Scene\Scenes\Demo01\Field\Field_YangTaiFuMiao.unity
中,可以看到地图已经可以正确加载了
点击 Camera
,设置 Map
的值为新的 stage
对象
其它地图使用类似的方式操作
修复完成
以上两个问题修复完成后,游戏已经可以正常运行了
我们还可以导出 apk
文件,运行到 android
手机上,游戏已经适配过手机了,界面展示都很正常