Example #1
0
        public void CreateStage(ConfigDataStage configDataStage, IAssetProvider assetProvider)
        {
            var stagePrefab = assetProvider.GetAsset <GameObject>(configDataStage.Prefab);
            var go          = GameObject.Instantiate(stagePrefab);

            go.transform.SetParent(StageRoot.transform, false);
        }
Example #2
0
        public void Play(string soundName, float delay = 0, float volume = 1, SoundChannel.SoundChannelType channel = SoundChannel.SoundChannelType.Default)
        {
            AudioClip clip = null;

            if (m_cache.ContainsKey(soundName))
            {
                clip = m_cache[soundName];
            }
            else
            {
                clip = m_assetProvider.GetAsset <AudioClip>("Sound/" + soundName);
                if (clip != null)
                {
                    m_cache.Add(soundName, clip);
                }
                else
                {
                    Debug.LogError("can't load audioClip: " + soundName);
                }
            }
            if (clip == null)
            {
                return;
            }
            m_soundChannelDic[channel].Play(clip, volume, delay);
        }
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var assetPath = request.GetRouteData().Values["assetPath"].ToString();
            var rootUrl   = DefaultRootUrlResolver(request);

            try
            {
                var webAsset = _Provider.GetAsset(rootUrl, assetPath);
                var content  = ContentFor(webAsset);
                return(TaskFor(new HttpResponseMessage {
                    Content = content
                }));
            }
            catch (AssetNotFound ex)
            {
                return(TaskFor(request.CreateErrorResponse(HttpStatusCode.NotFound, ex)));
            }
        }
        protected override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            IAssetProvider swaggerUiProvider = this._config.GetSwaggerUiProvider();
            string         rootUrl           = this._config.GetRootUrl(request);
            string         assetPath         = HttpRequestMessageExtensions.GetRouteData(request).get_Values()["assetPath"].ToString();

            try
            {
                HttpContent httpContent = this.ContentFor(swaggerUiProvider.GetAsset(rootUrl, assetPath));
                return(this.TaskFor(new HttpResponseMessage()
                {
                    Content = httpContent,
                    RequestMessage = request
                }));
            }
            catch (AssetNotFound ex)
            {
                return(this.TaskFor(HttpRequestMessageExtensions.CreateErrorResponse(request, HttpStatusCode.NotFound, (Exception)ex)));
            }
        }
Example #5
0
 public T GetAsset <T>(string path) where T : UnityEngine.Object
 {
     return(m_assetProvider.GetAsset <T>(path));
 }
Example #6
0
 public static UAsset LoadAsset(string assetPath)
 {
     return(_assetProvider.GetAsset(assetPath));
 }