コード例 #1
0
        public Object Load(ulong pathHash, System.Type type)
        {
            ResourceData resourceData = _GetResourceData(pathHash);

            if (resourceData != null)
            {
                Log.Assert(resourceData.type == type);
                resourceData.AddRef();
                return(resourceData.asset);
            }

            Object asset = null;

            if (ResourceMainfest.IsAssetBundleResource(pathHash))
            {
                AssetBundle assetBundle = AssetBundleManager.Instance.Load(pathHash);
                string      name        = ResourceMainfest.GetPathName(pathHash);
                if (assetBundle != null && !string.IsNullOrEmpty(name))
                {
                    asset = assetBundle.LoadAsset(name, type);
                }
                AssetBundleManager.Instance.Unload(pathHash);
            }

            if (asset == null)
            {
                string path = ResourceMainfest.GetHashPath(pathHash);
                if (!string.IsNullOrEmpty(path))
                {
                    asset = Resources.Load(path, type);
                }
            }

            if (asset != null)
            {
                resourceData = new ResourceData(pathHash, type, asset);
                resourceData.AddRef();
                _AddResourceData(resourceData);
            }

            return(asset);
        }
コード例 #2
0
        public override bool TryLoad()
        {
            if (ResourceMainfest.IsAssetBundleResource(Id))
            {
                m_assetBundle = AssetBundleManager.Instance.Load(Id);
            }

            if (m_assetBundle != null)
            {
                string name = ResourceMainfest.GetPathName(Id);
                if (!string.IsNullOrEmpty(name))
                {
                    m_assetBundleRequest = m_assetBundle.LoadAssetAsync(name, m_type);
                    if (m_assetBundleRequest != null)
                    {
                        m_assetBundleRequest.priority = m_priority;
                    }
                }
                if (m_assetBundleRequest == null)
                {
                    return(false);
                }
            }
            else
            {
                string path = ResourceMainfest.GetHashPath(Id);
                if (!string.IsNullOrEmpty(path))
                {
                    m_resourceRequest = Resources.LoadAsync(path, m_type);
                    if (m_resourceRequest != null)
                    {
                        m_resourceRequest.priority = m_priority;
                    }
                }
                if (m_resourceRequest == null)
                {
                    return(false);
                }
            }

            return(base.TryLoad());
        }