Exemple #1
0
        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;
        }
Exemple #2
0
 public PlayableAssetProxy GetPlayableAssetProxy(string path)
 {
     if (!playableProxyDict.ContainsKey(path))
     {
         var assetProxy = new PlayableAssetProxy(path);
         playableProxyDict.Add(path, assetProxy);
     }
     return(playableProxyDict[path]);
 }
Exemple #3
0
        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;
            }
        }