Example #1
0
        //---------------------------------------------------------------------
        public void LoadIconAsync(string id, string resource_path, string resource_name, GameObject head_icon, Action <Texture> load_callback = null)
        {
            if (MapHeadIconResources.TryGetValue(id, out Texture head_resource))
            {
                if (head_icon != null)
                {
                    head_icon.SetActive(true);
                }

                if (load_callback != null)
                {
                    load_callback(head_resource);
                }
            }
            else
            {
                if (MbAsyncLoadAssets == null)
                {
                    var go = GameObject.Find("Launch");
                    MbAsyncLoadAssets = go.GetComponent <MbAsyncLoadAssets>();
                }

                MbAsyncLoadAssets.WWWLoadTextureAsync(resource_path, load_callback);
            }
        }
Example #2
0
        //---------------------------------------------------------------------
        public LoaderTicket asyncLoadIcon(string id, string resource_path,
                                          string resource_name, GameObject head_icon,
                                          Action <UnityEngine.Object, LoaderTicket> load_callback = null)
        {
            LoaderTicket loader_ticket = null;
            Texture      head_resource = null;

            if (MapHeadIconResources.TryGetValue(id, out head_resource))
            {
                if (head_icon != null)
                {
                    head_icon.SetActive(true);
                    //UiHelper.setActiveState(true, head_icon);
                    //UiHelper.setTexture(head_icon, head_resource);
                }

                if (load_callback != null)
                {
                    load_callback(head_resource, loader_ticket);
                }
            }
            else
            {
                if (MapLoadingIcon.ContainsKey(id))
                {
                    return(loader_ticket);
                }

                MapLoadingIcon[id] = id;
                loader_ticket      = CasinosContext.Instance.AsyncAssetLoadGroup.asyncLoadAsset(
                    resource_path, resource_name, _eAsyncAssetLoadType.WWWRawAsset,
                    (LoaderTicket ticket, string path, UnityEngine.Object obj) =>
                {
                    MapLoadingIcon.Remove(id);
                    if (obj != null)
                    {
                        MapHeadIconResources[id] = (Texture)obj;
                        if (head_icon != null)
                        {
                            head_icon.SetActive(true);
                            //UiHelper.setActiveState(true, head_icon);
                            //UiHelper.setTexture(head_icon, (Texture)obj);
                        }
                    }

                    if (load_callback != null)
                    {
                        load_callback(obj, loader_ticket);
                    }
                });
            }

            return(loader_ticket);
        }