现象:
playableasset retuned a null playably on instantiate
使用AB包的形式加载场景,携带有TimeLine的功能无法播放
工程分析:
场景A:
只有下载AB包和加载场景功能
场景B:
具体功能场景,有TimeLine组件
原因分析:
由于Unity有代码裁剪功能,
当打包时,你的C#脚本或Unity的功能未使用
则打包时这些Dll库或脚本将不会被携带到APP中
解决方案:
使用link.xml
这是link.xml的介绍
新建一个link.xml文件,放入到Assets任意目录下。
这个类名不好用。。。
<type fullname="UnityEngine.Playables.PlayableAsset" preserve="all"/>
<type fullname="UnityEngine.Playables.PlayableBehaviour" preserve="all"/>
<type fullname="UnityEngine.Playables.PlayableDirector" preserve="all"/>
将以下内容填入,剩余的根据自己工程删减或增加
<assembly fullname="UnityEngine.Timeline">
<namespace fullname="UnityEngine.Timeline" preserve="all"/>
</assembly>
<linker>
<assembly fullname="UnityEngine.UI" preserve="all"/>
<assembly fullname="UnityEngine.CoreModule" preserve="all">
<type fullname="UnityEngine.SpriteRenderer" preserve="all"/>
<type fullname="UnityEngine.Playables.PlayableAsset" preserve="all"/>
<type fullname="UnityEngine.Playables.PlayableBehaviour" preserve="all"/>
<type fullname="UnityEngine.Playables.PlayableDirector" preserve="all"/>
</assembly>
<assembly fullname="UnityEngine.Timeline">
<namespace fullname="UnityEngine.Timeline" preserve="all"/>
</assembly>
<assembly fullname="UnityEngine.PhysicsModule" preserve="all"/>
<assembly fullname="UnityEngine.DirectorModule" preserve="all"/>
<assembly fullname="UnityEngine.AnimationModule" preserve="all"/>
<assembly fullname="UnityEngine.AudioModule" preserve="all"/>
<assembly fullname="UnityEngine.TerrainPhysicsModule" preserve="all"/>
<assembly fullname="UnityEngine.WindModule" preserve="all"/>
<assembly fullname="UnityEngine.DirectorModule" preserve="all"/>
<assembly fullname="UnityEngine.Video" preserve="all"/>
<assembly fullname="UnityEngine.VideoModule" preserve="all">
<type fullname="UnityEngine.Video.VideoPlayer" preserve="all"/>
<type fullname="UnityEngine.Video.VideoClip" preserve="all"/>
</assembly>
<assembly fullname="Vuforia.UnityExtensions" preserve="all"/>
<assembly fullname="VuforiaScripts" preserve="all"/>
<assembly fullname="Unity.RenderPipelines.Universal.Runtime" preserve="all"/>
<assembly fullname="Assembly-CSharp" preserve="all"/>
</linker>