private void PlayAssetProxy(PlayableAssetProxy assetProxy) { if (this == null) { return; } //播放资源 this.director.playableAsset = assetProxy.playableAsset; //绑定 foreach (var genericBind in assetProxy.genericBindList) { this.director.SetGenericBinding(genericBind.key, this.GetBindGameObject(genericBind.name)); } foreach (var refereneceBind in assetProxy.referenceBindList) { this.director.SetReferenceValue(refereneceBind.key, this.GetBindGameObject(refereneceBind.name)); } //播放模式 this.director.extrapolationMode = this.loop ? DirectorWrapMode.Loop : DirectorWrapMode.Hold; //开始播放 this.director.Play(); //指定播放时间 this.director.time = Time.time - startPlayTime; }
public PlayableAssetProxy GetPlayableAssetProxy(string path) { if (!playableProxyDict.ContainsKey(path)) { var assetProxy = new PlayableAssetProxy(path); playableProxyDict.Add(path, assetProxy); } return(playableProxyDict[path]); }
public void Play(string action, bool loop) { if (this.asset == null) { return; } string path = null; foreach (var item in this.asset.list) { if (action == item.name) { path = item.path; } } if (path == null) { return; } this.startPlayTime = Time.time; this.loop = loop; PlayableAssetProxy proxy = PlayableMgr.inst.GetPlayableAssetProxy(path); proxy.readyListener -= PlayAssetProxy; if (proxy.isReady) { this.PlayAssetProxy(proxy); } else { proxy.readyListener += PlayAssetProxy; } }