1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System.Collections.Generic;
using UnityEngine;
 
public class MaterialLoader
{
    readonly static Dictionary<string, ObjectPool<Material>> s_MatDict = new Dictionary<string, ObjectPool<Material>>();
 
//     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<Material> _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<Material>(_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<Material> _pool = null;
 
//         if (!s_MatDict.TryGetValue(_name, out _pool))
//         {
//             _pool = new ObjectPool<Material>(null, null);
//             s_MatDict.Add(_name, _pool);
//         }
 
//         _pool.Add(mat);
//     }
}