コード例 #1
0
        public bool RegisterRequestSet(string label, ResourceRequestSet resourceSet)
        {
            if (_dictRequestSet.ContainsKey(label) == true)
            {
                return(false);
            }

            foreach (var requestItem in resourceSet.GetList())
            {
                BaseLoader loader = null;
                if (_dictLoader.ContainsKey(requestItem.url) == true)
                {
                    continue;
                }

                ResourceItem resourceItem = null;
                switch (requestItem.type)
                {
                case ResourceType.Asset:
                    if (_dictResourceAsset.TryGetValue(requestItem.url, out resourceItem) == false)
                    {
                        loader = BaseLoader.Init <AssetLoader> (requestItem.url);
                    }
                    break;

                case ResourceType.AssetBundle:
                    if (_dictResourceAssetBundle.TryGetValue(requestItem.url, out resourceItem) == false)
                    {
                        loader = BaseLoader.Init <AssetBundleLoader> (requestItem.url);
                    }
                    break;

                case ResourceType.Texture:
                    if (_dictResourceTexture.TryGetValue(requestItem.url, out resourceItem) == false)
                    {
                        loader = BaseLoader.Init <TextureLoader> (requestItem.url);
                    }
                    break;

                default:
                    Debug.LogErrorFormat("{0} {1} NotFound {2}", typeof(ResourceManager).Name, MethodBase.GetCurrentMethod().Name, requestItem.type);
                    break;
                }

                if (resourceItem != null)
                {
                    resourceItem.IncRef();
                }
                if (loader != null)
                {
                    _dictLoader.Add(requestItem.url, loader);
                }
            }
            _dictRequestSet.Add(label, resourceSet);
            return(true);
        }
コード例 #2
0
 public override void OnSceneVisible()
 {
     Debug.Log ("OnSceneVisible_B");
     resourceRequestSet = new ResourceRequestSet ();
     for (var i=0; i<100; i++)
     {
         resourceRequestSet.Add (
             string.Format ("http://pictogram-free.com/thumbnail/s_{0}.png", (i+1).ToString ("000")),
             ResourceType.Texture);
     }
     ResourceManager.Instance.RegisterRequestSet (
         RequestResourceLabel,
         resourceRequestSet);
 }
コード例 #3
0
    public override void OnSceneInvisible()
    {
        Debug.Log ("OnSceneInvisible_B");
        ResourceManager.Instance.UnregisterRequestSet (RequestResourceLabel);
        listShowedResourceName.Clear ();

        foreach (Transform trans in _layout.transform)
        {
            if (trans.gameObject.activeSelf == true)
                Object.Destroy (trans.gameObject);
        }

        resourceRequestSet = null;
    }
コード例 #4
0
        public bool UnregisterRequestSet(string label)
        {
            ResourceRequestSet requestSet = null;

            if (_dictRequestSet.TryGetValue(label, out requestSet) == false)
            {
                return(false);
            }

            requestSet.Stop();

            foreach (var request in requestSet.GetList())
            {
                switch (request.type)
                {
                case ResourceType.Asset:
                    RemoveAsset(request.url);
                    break;

                case ResourceType.AssetBundle:
                    RemoveAssetBundle(request.url);
                    foreach (var dependency in assetBundleManifest.GetDirectDependencies(request.url))
                    {
                        RemoveAssetBundle(dependency);
                    }
                    break;

                case ResourceType.Texture:
                    RemoveTexture(request.url);
                    break;

                default:
                    Debug.LogErrorFormat("{0} {1} NotFound {2}", typeof(ResourceManager).Name, MethodBase.GetCurrentMethod().Name, request.type);
                    break;
                }
            }

            _dictRequestSet.Remove(label);
            Resources.UnloadUnusedAssets();
            return(true);
        }