using System.Collections.Generic; using UnityEngine; public class MaterialLoader { readonly static Dictionary> s_MatDict = new Dictionary>(); // public static Material LoadClothesMaterial(int id, bool isUI, bool isSuit) // { // var _modelResConfig = ModelResConfig.Get(id); // if (_modelResConfig == null) // { // return null; // } // string _assetName = string.Empty; // if (isSuit) // { // if (isUI) // { // _assetName = _modelResConfig.Material_UI_Suit; // } // else // { // _assetName = _modelResConfig.Material_Fight_Suit; // } // } // else // { // if (isUI) // { // _assetName = _modelResConfig.Material_UI_Normal; // } // else // { // _assetName = _modelResConfig.Material_Fight_Normal; // } // } // if (string.IsNullOrEmpty(_assetName)) // { // return null; // } // //Debug.LogFormat("想要加载的材质的名称: {0}", _assetName); // ObjectPool _pool = null; // if (s_MatDict.TryGetValue(_assetName, out _pool)) // { // if (_pool.inactivedCount > 0) // { // //Debug.Log(" |-- 池里有, 从池里取"); // return _pool.Get(); // } // } // string _name = _modelResConfig.ResourcesName; // int _index = _name.IndexOf('/'); // if (_index != -1) // { // _name = _name.Substring(_index + 1); // } // var _parentDirName = string.Empty; // if (_name.Contains("A_Zs")) // { // _parentDirName = "A_Zs"; // } // else if (_name.Contains("A_Fs")) // { // _parentDirName = "A_Fs"; // } // Material _mat = null; // if (AssetSource.mobFromEditor) // { // #if UNITY_EDITOR // string _resourcePath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, // "Gmodels/", // _parentDirName, // "/Materials/", // _assetName, // ".mat"); // _mat = UnityEditor.AssetDatabase.LoadAssetAtPath(_resourcePath); // #endif // } // else // { // string _bundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME, InstanceResourcesLoader.raceSuffix, _name.ToLower()); // AssetInfo _assetInfo = new AssetInfo(_bundleName, _assetName); // _mat = AssetBundleUtility.Instance.Sync_LoadAsset(_assetInfo) as Material; // } // if (_mat == null) // { // Debug.LogErrorFormat("MaterialLoader.Load() => 加载不到资源: {0}", _assetName); // } // return _mat; // } // public static void Release(Material mat) // { // if (!mat) // { // return; // } // var _name = mat.name.Replace(" (Instance)", ""); // //Debug.LogFormat("要释放的材质的名称: {0}, 修改后的名称: {1}", mat.name, _name); // ObjectPool _pool = null; // if (!s_MatDict.TryGetValue(_name, out _pool)) // { // _pool = new ObjectPool(null, null); // s_MatDict.Add(_name, _pool); // } // _pool.Add(mat); // } }