예제 #1
0
        private IEnumerator loadDecorationPrefab(DecorationRenderParams param)
        {
            AssetRequest <GameObject> decorationRequest;

            try
            {
                decorationRequest = Content.LoadAsync(param.Definition.Prefab);
            }
            catch (Exception)
            {
                Log.LogErrorFormatted(this, "Could not load decoration prefab {0} with prefab key {1}", param.Definition.Name, param.Definition.Prefab.Key);
                yield break;
            }
            if (decorationRequest == null)
            {
                Log.LogErrorFormatted(this, "Something went wrong loading decoration {0}.", param.Definition.Prefab);
                yield break;
            }
            yield return(decorationRequest);

            GameObject decorationGameObject = UnityEngine.Object.Instantiate(decorationRequest.Asset);

            LightCullingMaskHelper.SetLayerIncludingChildren(decorationGameObject.transform, "IconRender");
            yield return(loadDecorationRenderData(param, decorationGameObject));
        }
예제 #2
0
        public void RequestImage(long id, DecorationDefinition definition, RequestImageCallback callback, Color backgroundColor)
        {
            string        hashedName    = getHashedName(id);
            CallbackToken callbackToken = default(CallbackToken);

            callbackToken.Id           = id;
            callbackToken.DefinitionId = definition.Id;
            DecorationRenderParams decorationRenderParams = new DecorationRenderParams();

            decorationRenderParams.CallbackToken   = callbackToken;
            decorationRenderParams.Definition      = definition;
            decorationRenderParams.BackgroundColor = backgroundColor;
            decorationRenderParams.ImageHash       = hashedName;
            DecorationRenderParams renderParams = decorationRenderParams;

            if (RequestImage(renderParams, callback))
            {
                loadedItemCount++;
                if (loadedItemCount >= 30)
                {
                    Resources.UnloadUnusedAssets();
                    loadedItemCount = 0;
                }
            }
        }
예제 #3
0
        private IEnumerator loadDecorationRenderData(DecorationRenderParams param, GameObject decorationGameObject)
        {
            AssetRequest <DecorationRenderData> renderDataRequest = null;

            try
            {
                renderDataRequest = Content.LoadAsync(param.Definition.RenderData);
            }
            catch (Exception)
            {
                Log.LogErrorFormatted(this, "Could not load the render data for decation {0} with key {1}", param.Definition.Name, param.Definition.RenderData.Key);
            }
            if (renderDataRequest == null)
            {
                Log.LogErrorFormatted(this, "Something went wrong loading render data {0}.", param.Definition.RenderData);
                UnityEngine.Object.Destroy(decorationGameObject);
            }
            else
            {
                yield return(renderDataRequest);

                DecorationRenderData decorationRenderData = renderDataRequest.Asset;
                yield return(renderToTexture(param, decorationGameObject, decorationRenderData));
            }
        }
예제 #4
0
        protected override IEnumerator processRequest(RenderParams renderParam)
        {
            DecorationRenderParams param = renderParam as DecorationRenderParams;
            DecorationDefinition   decorationDefinition = null;

            if (!decorationList.TryGetValue(param.Definition.Id, out decorationDefinition))
            {
                Log.LogErrorFormatted(this, "Unable to locate decoration {0} in decoration definitions with id {1}.", param.Definition.Name, param.Definition.Id);
            }
            else
            {
                yield return(loadDecorationPrefab(param));
            }
        }