public Stream LoadAsSteam(string filePath)
    {
        TextAsset textAsset = ResourcesWrapper.Load <TextAsset>(filePath);

        if (textAsset == null)
        {
            return(null);
        }

        return(new MemoryStream(textAsset.bytes));
    }
    public SecurityElement LoadAsXML(string filePath)
    {
        TextAsset textAsset = ResourcesWrapper.Load <TextAsset>(filePath);

        if (textAsset == null)
        {
            return(null);
        }

        SecurityParser xmlParser = new SecurityParser();

        xmlParser.LoadXml(textAsset.text);

        return(xmlParser.ToXml());
    }
Пример #3
0
    public Object LoadAsset(string assetName, bool noCache)
    {
#if ENABLE_RESOURCE_MANAGER_METRICS
        totalLoadCount++;
#endif

        // Convert to lowercase name
        //assetName = WeihuaGames.PathUtility.UnifyPath(assetName);

        // Check if Need load from cache
        //        if (ConfigDatabase.DefaultCfg.ClientManifest != null)
        //        {
        //            ClientManifest.FileInfo fileInfo = ConfigDatabase.DefaultCfg.ClientManifest.GetFileByName(assetName);
        //            if (fileInfo != null)
        //            {
        //#if ENABLE_RESOURCE_MANAGER_METRICS
        //				assetBundleLoadCount++;
        //#endif

        //                // Try to load from resource cache
        //                ResourceCache resCache = ResourceCache.Instance;
        //                if (resCache != null && resCache.Contains(assetName))
        //                {
        //                    return resCache.GetAsset(assetName);
        //                }

        //                // Load from asset bundle and add to resource cache
        //                string abPath = GetLocalFilePath(fileInfo.fileName);
        //#if ENABLE_RESOURCE_MANAGER_LOG
        //				Debug.Log("[ResourceManager] Load asset from AB : " + abPath);
        //#endif

        //                AssetBundle ab = AssetBundle.LoadFromFile(abPath);
        //                if (ab == null)
        //                {
        //                    Debug.LogError("Load AB failed : " + abPath);
        //                    return null;
        //                }

        //                // Load object from AB
        //                Object obj = ab.mainAsset;
        //                ab.Unload(false);
        //                ab = null;

        //                // Add to resource cache
        //                if (resCache != null && noCache == false)
        //                {
        //                    resCache.AddAsset(assetName, obj);
        //                    return resCache.GetAsset(assetName);
        //                }
        //                else
        //                {
        //                    return obj;
        //                }
        //            }



#if ENABLE_RESOURCE_MANAGER_METRICS
        resourceLoadCount++;
#endif

        // Load from resources folder
        return(ResourcesWrapper.Load(assetName));
    }