コード例 #1
0
        public void UpdateFileFromBundle(ref AssetBundle bundle)
        {
            if (bundle == null)
            {
                return;
            }
            for (int i = 0; i < _firstFiles.Count; i++)
            {
                ConfigFileInfo info  = _firstFiles[i];
                string         uname = info.fullPath.ToLower();

                if (bundle.Contains(uname))
                {
                    TextAsset asset = bundle.LoadAsset <TextAsset>(uname);
                    if (asset != null)
                    {
                        info.text = asset.text;
                    }
                }
            }

            for (int i = 0; i < _secondFiles.Count; i++)
            {
                ConfigFileInfo info2 = _secondFiles[i];
                string         uname = info2.fullPath.ToLower();
                if (bundle.Contains(uname))
                {
                    TextAsset asset = bundle.LoadAsset <TextAsset>(uname);
                    if (asset != null)
                    {
                        info2.text = asset.text;
                    }
                }
            }
        }
コード例 #2
0
ファイル: LanguageManager.cs プロジェクト: dfengwji/unity
        public void UpateLanguage(AssetBundle bundle)
        {
            if (bundle == null)
            {
                return;
            }
            string prefix = GetPrefixPath(false);

            if (bundle.Contains(prefix + "popupwin.txt"))
            {
                TextAsset asset = bundle.LoadAsset <TextAsset>(prefix + "popupwin.txt");
                if (asset != null)
                {
                    _popupwinDic = ParseFile(asset);
                }
            }
            if (bundle.Contains(prefix + "exception.txt"))
            {
                TextAsset asset = bundle.LoadAsset <TextAsset>(prefix + "exception.txt");
                if (asset != null)
                {
                    _exceptionDic = ParseFile(asset);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Import the custom GameObject if available.
        /// </summary>
        /// <remarks>
        /// A GameObject which corresponds to <paramref name="modelID"/>
        /// is searched inside mods and eventually imported and returned.
        /// On Development builds is also imported from Resources for easier tests.
        /// </remarks>
        /// <param name="matrix">Matrix with position and rotation of GameObject.</param>
        /// <returns>Returns the imported model or null.</returns>
        static public GameObject ImportCustomGameobject(uint modelID, Transform parent, Matrix4x4 matrix)
        {
            // Check user settings
            if (!DaggerfallUnity.Settings.MeshAndTextureReplacement)
            {
                return(null);
            }

            // Get name
            string modelName = modelID.ToString();

#if DEVELOPMENT_BUILD
            // Import Gameobject from Resources
            string path = "Models/" + modelName + "/";
            if (Resources.Load(path + modelName) != null)
            {
                // Assign the name according to the current season
                if (IsWinter())
                {
                    if (Resources.Load(path + modelName + winterTag) != null)
                    {
                        modelName += winterTag;
                    }
                }

                // Import GameObject
                GameObject go = GameObject.Instantiate(Resources.Load(path + modelName) as GameObject);
                InstantiateCustomModel(go, parent, matrix, modelName);
                return(go);
            }
#endif

            // Get model from mods using load order
            Mod[] mods = ModManager.Instance.GetAllMods(true);
            for (int i = mods.Length; i-- > 0;)
            {
                AssetBundle bundle = mods[i].AssetBundle;
                if (bundle && bundle.Contains(modelName))
                {
                    // Assign the name according to the current season
                    if (IsWinter() && bundle.Contains(modelName + winterTag))
                    {
                        modelName += winterTag;
                    }

                    GameObject go = mods[i].GetAsset <GameObject>(modelName, true);
                    if (go != null)
                    {
                        InstantiateCustomModel(go, parent, matrix, modelName);
                        return(go);
                    }

                    Debug.LogError("Failed to import " + modelName + " from " + mods[i].Title + " as GameObject.");
                }
            }

            return(null);
        }
コード例 #4
0
ファイル: ABResLoader.cs プロジェクト: unityHUI/UnityFrame
 /// <summary>
 /// 加载单个资源
 /// </summary>
 /// <param name="resName">资源名称</param>
 /// <returns></returns>
 public Object LoadSingleRes(string resName)
 {
     if (mAB != null && mAB.Contains(resName))
     {
         return(mAB.LoadAsset(resName));
     }
     Debug.Log("res is not Contain");
     return(null);
 }
コード例 #5
0
    //CAN DELETE, this is the old version that has each thing as an individual TextAsset in the asset bundle which runs too slowly on XB1
    public void pose_bundle_loaded_callback(AssetBundle aBundle)
    {
        //Debug.Log("poses");
        foreach (CharacterIndex e in CharacterIndex.sAllCharacters)
        {
            if (e == CharacterIndex.sGrave)
            {
                continue;
            }
            string txtName = "info_" + e.StringIdentifier;
            if (aBundle.Contains(txtName))
            {
                //Debug.Log ("loaded character info " + txtName);
                mCharacterHelper.Characters[e].CharacterInfo =
                    NUPD.CharacterInformationProcessor.process_character((aBundle.LoadAsset(txtName) as TextAsset).text);

                //kind of a hack.
                //TODO uncomment this when you get new character packages in...
                GameConstants.INDEX_TO_SHORT_NAME[e] = mCharacterHelper.Characters[e].CharacterInfo.ShortName;
                //GameConstants.INDEX_TO_FULL_NAME[e] = mCharacterHelper.Characters[e].CharacterInfo.LongName;
                GameConstants.INDEX_TO_DESCRIPTION[e] = mCharacterHelper.Characters[e].CharacterInfo.Description;
            }
            else
            {
                throw new UnityException("No info found for " + txtName);
                //Debug.Log ("no info found for " + txtName);
                //mCharacterHelper.Characters[e].CharacterInfo = NUPD.CharacterInformation.default_character_info(e);
            }
        }

        //TODO CAN DELETE
        //this is now called inside of ModeNormalPlay.reset_stats_and_difficulties
        //fetus_difficulty_shuffle_hack();

        foreach (CharacterIndex e in CharacterIndex.sAllCharacters)
        {
            //Debug.Log ("loaded pose for " + e.StringIdentifier);
            for (int i = 0; i < 4; i++)
            {
                for (int j = 1; j < 10; j++)                //assuming no mroe than 10 poses per animatino
                {
                    string s = construct_pose_string(e, i, j);
                    if (aBundle.Contains(s))
                    {
                        mPoses[s] = (aBundle.LoadAsset(s) as TextAsset).to_pose();
                    }
                }
            }
        }
        aBundle.Unload(true); //don't need this anymore I don't ithnk...
        mPosesLoaded = true;

        //Debug.Log("end poses");
    }
コード例 #6
0
    /// <summary>
    /// 加载单个资源
    /// </summary>
    /// <param name="resName"></param>
    /// <returns></returns>
    public UnityEngine.Object this[string resName] {
        get {
            if (abRes == null || !abRes.Contains(resName))
            {
                Debug.LogWarning("res not contain " + resName);
                return(null);
            }

            return(abRes.LoadAsset(resName));
        }
    }
コード例 #7
0
    private void InvokePackageCallback(ResLoadResult ret, string PackName, IResourceLoad iLoad)
    {
        bool bSucc = CachePackages.Contains(PackName);

        if (bSucc)
        {
            if (iLoad != null)
            {
                iLoad.ResourceLoadSucc(ret);
            }
        }
        else
        {
            if (iLoad != null)
            {
                iLoad.ResourceLoadFail(ret);
            }
        }

        if (bSucc)
        {
            AssetBundle assetbundle = CachePackages[PackName] as AssetBundle;
            if (RequestTable.Contains(PackName))
            {
                RequestPackageInfo      packinfo    = RequestTable[PackName] as RequestPackageInfo;
                List <RequestAssetInfo> RequestList = packinfo.RequestAssets;
                for (int i = 0; i < RequestList.Count; i++)
                {
                    RequestAssetInfo info = RequestList[i];
                    info.obj = null;
                    if (assetbundle.Contains(info.resPath))
                    {
                        info.obj = assetbundle.LoadAsset(info.resPath);
                    }
                    if (info.obj == null)
                    {
                        string resShort = System.IO.Path.GetFileNameWithoutExtension(info.resPath);
                        if (assetbundle.Contains(resShort))
                        {
                            info.obj = assetbundle.LoadAsset(resShort);
                        }
                    }
                    RequestList[i] = info;
                }
                foreach (RequestAssetInfo info in RequestList)
                {
                    InvokeAssetCallback(info.obj, info.resPath, info.iLoad);
                }
                RequestTable.Remove(PackName);
            }
        }
    }
コード例 #8
0
    /// <summary>
    /// 加载单个资源(索引器)
    /// </summary>
    public UnityEngine.Object this[string assetName]
    {
        get
        {
            if (abRes == null || !abRes.Contains(assetName))
            {
                Debug.LogError("The abRes Not Contains this assetName :" + assetName);
                return(null);
            }

            return(abRes.LoadAsset(assetName));
        }
    }
コード例 #9
0
    // Creates a new Material with an extracted shader
    private static Material tryLoad(string bundleLower, string keyLower, bool mod, string bundleName, string key)
    {
        AssetBundle bundle = mod ? dictMod[bundleLower] : dictDefault[bundleLower];

        if (!bundle.Contains(keyLower))
        {
            throw new CYFException("Shader AssetBundle \"" + bundleName + "\" does not contain shader \"" + key + "\".");
        }

        Shader shade = bundle.LoadAsset(keyLower) as Shader;

        if (shade != null && !shade.isSupported)
        {
            throw new CYFException("The shader \"" + key + "\" is not supported. It might not be suited for your OS, or this might be a problem with the shader itself.");
        }

        Material mat = new Material(shade);

        if (mod)
        {
            materialsMod[bundleLower + keyLower] = mat;
        }
        else
        {
            materialsDefault[bundleLower + keyLower] = mat;
        }
        return(mat);
    }
コード例 #10
0
 /// <summary>
 /// Returns the first asset in the assetbundle that is loaded with the given name, including its file extensions.
 /// </summary>
 /// <param name="name">The name of the asset to look for</param>
 /// <returns>the first asset in the assetbundle that is loaded with the given name</returns>
 public static object GetAsset(string name)
 {
     if (assetBundle.Contains(name))
     {
         object   Asset = null;
         string[] paths = assetBundle.GetAllAssetNames();
         for (int i = 0; i < paths.Length; i++)
         {
             string[] pathParts = paths[i].Split('/');
             string   assetName = pathParts[pathParts.Length - 1];
             if (assetName == name.ToLower())
             {
                 Asset = assetBundle.LoadAsset(paths[i]);
             }
         }
         return(Asset);
     }
     else
     {
         if (hasHelper)
         {
             helper.Log("Asset not found: " + name);
         }
         return(null);
     }
 }
コード例 #11
0
    private IEnumerator Start()
    {
        AssetBundleCreateRequest contentVersionBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, "AssetBundles/Windows/" + assetBundleVersionFileName));

        yield return(contentVersionBundleRequest);

        Debug.Log("Content version: " + assetBundleVersionFileName + " loaded.");

        contentVersionBundle = contentVersionBundleRequest.assetBundle;

        if (contentVersionBundle.Contains("AssetBundleVersion" + currentVersion.ToString("0.0")))
        {
            Debug.Log("AssetBundleVersion" + currentVersion.ToString("0.0") + " found.");

            bundleMap = contentVersionBundle.LoadAsset <AssetBundleVersion>("AssetBundleVersion" + currentVersion.ToString("0.0"));
            if (bundleMap != null)
            {
                Debug.Log("BundleMap loaded.");

                // iterate through bundles referenced by bundleMap and load them
                for (int i = 0; i < bundleMap.bundles.Count; i++)
                {
                    Debug.Log("Bundle: " + bundleMap.bundles[i].key.ToString());
                }
            }
            else
            {
                Debug.LogError("BundleMap failed to load.");
            }
        }
    }
コード例 #12
0
        public static void Init(string assetbundle, string recipejson, bool craftingMode)
        {
            assetBundle = Tools.LoadAssetBundle(assetbundle);
            recipes     = Tools.LoadJsonFile <Items.RecipesConfig>(recipejson);

            foreach (var recipe in recipes.recipes)
            {
                if (recipe.enabled)
                {
                    if (assetBundle.Contains(recipe.item))
                    {
                        var prefab = assetBundle.LoadAsset <GameObject>(recipe.item);
                        PrefabHelper.AddCustomItem(prefab, recipes);
                        PrefabHelper.AddCustomRecipe(prefab, recipes, craftingMode);
                    }
                }
            }
            ObjectDBHelper.OnAfterInit += () =>
            {
                foreach (var rec in recipes.recipes)
                {
                    if (rec.enabled && rec.projectilePrefab != null)
                    {
                        var projectile = Prefab.Cache.GetPrefab <Projectile>(rec.projectilePrefab);
                        if (projectile)
                        {
                            var        prefab           = assetBundle.LoadAsset <GameObject>(rec.item);
                            GameObject projectilePrefab = Prefab.InstantiateClone(projectile.gameObject, rec.projectilePrefabName);
                            prefab.GetComponent <ItemDrop>().m_itemData.m_shared.m_attack.m_attackProjectile = projectilePrefab;
                        }
                    }
                }
            };
        }
コード例 #13
0
ファイル: Mod.cs プロジェクト: ezikialbasix/daggerfall-unity
        /// <summary>
        /// Checks if this mod contains an asset with the given name.
        /// </summary>
        /// <param name="assetName">The name of the asset.</param>
        /// <returns>True if asset is provided by this mod.</returns>
        public bool HasAsset(string assetName)
        {
#if UNITY_EDITOR
            if (IsVirtual)
            {
                return(modInfo.Files.Any(CompareNameWithPath(assetName)));
            }
#endif

            if (assetBundle)
            {
                return(assetBundle.Contains(assetName));
            }

            return(false);
        }
コード例 #14
0
    /// <summary>
    /// Load common lua scripts. lua_common.u includes all managers and game mode base etc....
    /// </summary>
    /// <param name="szFile">file path</param>
    /// <param name="bytes">file contents</param>
    public void LoadCommonLuaScript(string szFile, out byte[] bytes)
    {
        bytes = null;

        AssetBundle bundle = null;

        if (szFile.Contains("Common/"))
        {
            if (static_bundle.ContainsKey(BUNDLE_LUA_COMMON))
            {
                bundle = static_bundle[BUNDLE_LUA_COMMON];
            }
        }
        else if (szFile.Contains("Puremvc/"))
        {
            if (static_bundle.ContainsKey(BUNDLE_LUA_PUREMVC))
            {
                bundle = static_bundle[BUNDLE_LUA_PUREMVC];
            }
        }

        if (bundle != null && string.IsNullOrEmpty(szFile) == false)
        {
            string lua = GameHelper.GetFileName(szFile);
            if (bundle.Contains(lua))
            {
                bytes = (bundle.LoadAsset(lua) as TextAsset).bytes;
            }
        }
    }
コード例 #15
0
 /// <summary>
 /// 名前で指定したアセットが存在するかチェックします。
 /// </summary>
 /// <returns>存在の有無がboolで返されます。</returns>
 /// <param name="bundleName">存在の確認するアセットが含まれているアセットバンドル名を指定します。</param>
 /// <param name="assetName">存在の確認するアセット名を指定します。</param>
 public static bool Contains(string bundleName, string assetName)
 {
     // 初期化済みかどうかチェック
     if (!initialized)
     {
         return(false);
     }
     // アセットバンドルがロードされているか確認
     if (bundleDic == null)
     {
         Debug.LogError("Could not load " + assetName + ". because " + bundleName + " has not loaded.");
         return(false);
     }
     else
     {
         // ロードしたリストに存在するかどうかチェック
         foreach (string name in GetAllAssetBundleName())
         {
             if (bundleName == name)
             {
                 // アセットバンドルをロード
                 AssetBundle bundle = bundleDic[bundleName];
                 // 存在の有無を返す
                 return(bundle.Contains(name));
             }
         }
     }
     Debug.LogError("Could not load " + assetName + ". because " + bundleName + " has not loaded.");
     return(false);
 }
コード例 #16
0
        public GameObject GetModelByName(string name)
        {
            if (!cache.ContainsKey(name))
            {
                //加载bundle,从bundle加载模型

                //UISceneHome.Instance.SetText(Tips.BUNDLEPATH + name);
                GameObject obj = null;
                //StartCoroutine(LoadBundle(Tips.BUNDLEPATH + name, name, obj));
                AssetBundle bundle = LocalAssetManager.Instace.getBundle(Tips.BUNDLEPATH + name);

                if (bundle != null && bundle.Contains(name))
                {
                    obj = GameObject.Instantiate(bundle.LoadAsset(name)) as GameObject;
                    obj.SetActive(false);
                    bundle.Unload(false);//卸载bundle
                }
                else
                {
                    Debug.LogError("没有此模型!!!");
                }
                cache.Add(name, obj);
            }
            return(cache[name]);
        }
コード例 #17
0
ファイル: Mod.cs プロジェクト: jammerlich/daggerfall-unity
        private bool AddAsset(string assetName, LoadedAsset la)
        {
            if (IsAssetLoaded(assetName))
            {
                return(false);
            }
            else if (la.Obj == null || la.T == null)
            {
                return(false);
            }
            else
            {
                if (la.T == typeof(GameObject) && AssetBundle.Contains(ImportedComponentAttribute.MakeFileName(assetName)))
                {
                    ImportedComponentAttribute.Restore(this, la.Obj as GameObject);
                }

                loadedAssets.Add(assetName, la);

                if (this.ModInfo != null && string.IsNullOrEmpty(this.Title) == false)
                {
                    ModManager.OnLoadAsset(this.Title, assetName, la.T);
                }
#if DEBUG
                Debug.Log(string.Format("added asset: {0}", assetName));
#endif
                return(true);
            }
        }
コード例 #18
0
        //从assetbundle中异步加载资源
        private IEnumerator MyLoadAssetsAsync(AssetBundle bundle)
        {
            if (assetName == null)
            {
                bundleRequest = bundle.LoadAllAssetsAsync(assetType);
                yield return(bundleRequest);
            }
            else
            {
                if (!bundle.Contains(assetName))
                {
                    string error = string.Format("未找到名为{0}的文件数据", assetName);
                    Debug.LogError(error);
                }

                bundleRequest = bundle.LoadAssetAsync(assetName, assetType);

                yield return(bundleRequest);
            }

            assets = bundleRequest.allAssets;

            if (assetsLoadingFinishCallBack != null)
            {
                assetsLoadingFinishCallBack();
            }
        }
コード例 #19
0
        public T LoadAsset <T>(string assetName) where T : Object
        {
            if (mAssetBundle == null)
            {
                Debug.LogError("当前资源包为空,无法获取:" + assetName);
                return(null);
            }

            if (!mAssetBundle.Contains(assetName))
            {
                Debug.LogError("当前资源包不包括:" + assetName);
                return(null);
            }

            return(mAssetBundle.LoadAsset(assetName) as T);
        }
コード例 #20
0
ファイル: Mod.cs プロジェクト: jammerlich/daggerfall-unity
        /// <summary>
        /// Will retrieve asset either from LoadedAssets or asset bundle and return it. Will load
        /// asset bundle if necessary.
        /// </summary>
        /// <typeparam name="T">Type of asset</typeparam>
        /// <param name="assetName">name of asset</param>
        /// <param name="loadedBundle">had to load asset bundle</param>
        /// <returns>A reference to the loaded asset or null if not found.</returns>
        private T LoadAssetFromBundle <T>(string assetName, out bool loadedBundle) where T : UnityEngine.Object
        {
            LoadedAsset la = new LoadedAsset();

            loadedBundle = false;

            if (string.IsNullOrEmpty(assetName))
            {
                return(null);
            }
            try
            {
                assetName = ModManager.GetAssetName(assetName);

                if (IsAssetLoaded(assetName))
                {
                    la = loadedAssets[assetName];
                    return(la.Obj as T);
                }

#if UNITY_EDITOR
                if (IsVirtual)
                {
                    la.Obj = LoadAssetFromResources <T>(assetName);
                    if (la.Obj != null)
                    {
                        la.T = la.Obj.GetType();
                        loadedAssets.Add(assetName, la);
                    }
                    return(la.Obj as T);
                }
#endif

                if (AssetBundle == null)
                {
                    loadedBundle = LoadAssetBundle();
                }

                if (AssetBundle.Contains(assetName))
                {
                    la.Obj = AssetBundle.LoadAsset <T>(assetName);

                    if (la.Obj != null)
                    {
                        la.T = la.Obj.GetType();
                        AddAsset(assetName, la);
                    }
                    return(la.Obj as T);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                return(null);
            }
        }
コード例 #21
0
    IEnumerator DownloadAndCache()
    {
        // Wait for the Caching system to be ready
        preloader.Loading();
        isRun = true;
        Debug.Log("isRunningTRUE");
        while (!Caching.ready)
        {
            yield return(null);
        }
        Debug.Log("Caching ready");
        // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
        using (WWW www = WWW.LoadFromCacheOrDownload(BundleFullURL, version))
        {
            Debug.Log("Loading ready");
            if (www.error == null)
            {
                preloader.LoadPercent(www);
            }
            yield return(www);

            if (www.error != null)
            {
                Debug.Log(ABName + " not downloaded. Error" + www.error);
                preloader.CantLoad();
            }
            else
            {
                AssetBundle bundle = www.assetBundle;
                if (AssetName == "" && TextAssetName == "")
                {
                    Debug.Log("Asset name not assigned");
                }
                else
                {
                    Debug.Log("Asset ready");
                    if (bundle.Contains(AssetName))
                    {
                        Instantiate(bundle.LoadAsset(AssetName), gameObject.transform);
                        objectActive = true;
                        Debug.Log("is OBJ");
                        preloader.Loaded();
                    }
                    else
                    {
                        Debug.Log("Check asset name");
                    }
                }
                // Unload the AssetBundles compressed contents to conserve memory
                bundle.Unload(false);
            }
            www.Dispose();
        }
        Debug.Log("isRunningFALSE");
        isRun = false;
        if (onRequestLost)
        {
            OnTrackingLost();
        }
    }
コード例 #22
0
    bool loadAssetAsync(CarpDefineAB checkAsset, AssetBundle assetBundle, System.Type t)
    {
        requestLoads[checkAsset.assetKey] = null;
        if (assetBundle == null)
        {
            errorAssets.Add(checkAsset.assetKey, true);
        }
        else if (checkAsset.assetName.Equals(string.Empty))
        {
            requestLoads[checkAsset.assetKey] = t == null?assetBundle.LoadAllAssetsAsync() : assetBundle.LoadAllAssetsAsync(t);

            errorAssets.Add(checkAsset.assetKey, false);
        }
        else
        {
            bool exist = assetBundle.Contains(checkAsset.assetName);
            if (exist)
            {
                requestLoads[checkAsset.assetKey] = t == null?assetBundle.LoadAssetAsync(checkAsset.assetName) : assetBundle.LoadAssetAsync(checkAsset.assetName, t);
            }
            checkError(!exist, string.Format("资源加载错误:({0}),发生在加载资源内容阶段", checkAsset.assetKey));
            errorAssets.Add(checkAsset.assetKey, !exist);
        }
        return(true);
    }
コード例 #23
0
ファイル: GameResPackage.cs プロジェクト: moto2002/snowbattle
 //加载资源obj
 public UnityEngine.Object LoadObject(string path)
 {
     UnityEngine.Object obj = null;
     if (m_assetbundle != null)
     {
         if (!m_assetbundle.Contains(path))
         {
             Debug.LogWarning("asset bundle load null, path:" + path);
         }
         obj = m_assetbundle.LoadAsset(path);
         if (obj == null)
         {
             Debug.LogWarning("assetBundle is not contains filename:" + path);
         }
     }
     return(obj);
 }
コード例 #24
0
 public bool Contains(string name)
 {
     if (_bundle == null)
     {
         return(false);
     }
     return(_bundle.Contains(name));
 }
コード例 #25
0
 /// <summary>
 /// 获取单个资源
 /// </summary>
 /// <param name="assetName">资源名字</param>
 /// <returns>Obj类型的资源</returns>
 public UnityEngine.Object LoadAsset(string assetName)
 {
     if (assetBundle == null)
     {
         Debug.LogError("当前资源包为空,无法获取该 " + assetName + " 资源");
         return(null);
     }
     else if (!assetBundle.Contains(assetName))
     {
         Debug.LogError("当前资源包里不包括 " + assetName + " 资源");
         return(null);
     }
     else
     {
         return(assetBundle.LoadAsset(assetName));
     }
 }
コード例 #26
0
 /// <summary>
 /// 获取单个资源
 /// </summary>
 /// <param name="assetname">资源名称</param>
 /// <returns>Objcet对象</returns>
 public Object LoadAsset(string assetname)
 {
     if (m_assetBundle == null)
     {
         Debug.LogError("当前资源包为空,无法获取" + assetname + "资源");
         return(null);
     }
     else if (!m_assetBundle.Contains(assetname))
     {
         Debug.LogError("当前资源包里不存在" + assetname + "资源");
         return(null);
     }
     else
     {
         return(m_assetBundle.LoadAsset(assetname));
     }
 }
コード例 #27
0
 /// <summary>
 /// 获取单个资源
 /// </summary>
 /// <param name="assetName">资源名字</param>
 /// <returns> Obj 类型的资源 </returns>
 public Object LoadAsset(string assetName)
 {
     if (assetBundle == null)
     {
         Debug.LogError("当前资源包为空,无法获取" + assetName + "资源");
         return(null);
     }
     else if (!assetBundle.Contains(assetName))
     {
         Debug.LogError("当前资源不包含" + assetName + "资源");
         return(null);
     }
     else
     {
         return(assetBundle.LoadAsset(assetName));
     }
 }
コード例 #28
0
    // Token: 0x0600077C RID: 1916 RVA: 0x000A2AA4 File Offset: 0x000A0CA4
    public Material LoadMaterial(ushort modelID, AssetBundle ab, ushort texID = 0)
    {
        if (modelID <= 0 || ab == null || this.modelDefuse == null)
        {
            return(null);
        }
        ModelLoader.MatNode   matNode   = null;
        ModelLoader.ModelNode modelNode = null;
        bool flag = this.m_MatList.TryGetValue(modelID, out modelNode);

        if (!flag || (flag && modelNode.matNode[(int)texID] == null))
        {
            this.sb.Length = 0;
            this.sb.AppendFormat("m{0:00}", texID);
            if (!ab.Contains(this.sb.ToString()))
            {
                this.sb.Length = 0;
                this.sb.Append("m00");
            }
            Texture2D texture2D = ab.Load(this.sb.ToString(), typeof(Texture2D)) as Texture2D;
            if (texture2D != null)
            {
                Material material = new Material(this.modelDefuse);
                material.mainTexture = texture2D;
                uint value = (uint)((int)modelID << 16 | (int)texID);
                this.m_MatMap.Add(material.GetInstanceID(), value);
                matNode          = new ModelLoader.MatNode();
                matNode.material = material;
                if (!flag)
                {
                    modelNode = new ModelLoader.ModelNode();
                    this.m_MatList.Add(modelID, modelNode);
                }
                modelNode.matNode[(int)texID] = matNode;
            }
        }
        else
        {
            matNode = modelNode.matNode[(int)texID];
        }
        if (matNode == null || (matNode != null && matNode.material == null))
        {
            return(null);
        }
        ModelLoader.MatNode matNode2 = matNode;
        matNode2.refCount += 1;
        ModelLoader.ModelNode modelNode2 = modelNode;
        modelNode2.refCount += 1;
        Debug.Log(string.Concat(new string[]
        {
            modelID.ToString(),
            ": modelCt: ",
            modelNode.refCount.ToString(),
            " ,matCt: ",
            matNode.refCount.ToString()
        }));
        return(matNode.material);
    }
コード例 #29
0
    public static bool SpriteContains(string sprName)
    {
        if (s_emojiBundle != null)
        {
            return(s_emojiBundle.Contains(sprName));
        }

        return(false);
    }
コード例 #30
0
 /// <summary>
 /// 加载当前包中指定资源
 /// </summary>
 /// <returns>The asset.</returns>
 /// <param name="assetName">加载资源名称</param>
 /// <param name="isCache">是否需要缓存</param>
 public UnityEngine.Object LoadAsset(string assetName, bool isCache = false)
 {
     if (!m_CurrentAssetBundle.Contains(assetName))
     {
         Debug.LogWarning(GetType() + "/LoadAsset()/ load asset error! assetName:" + assetName);
         return(null);
     }
     return(LoadResource <UnityEngine.Object>(assetName, isCache));
 }