// Token: 0x0600077D RID: 1917 RVA: 0x000A2C80 File Offset: 0x000A0E80 public void UnloadMaterial(Material material) { int instanceID = material.GetInstanceID(); if (!this.m_MatMap.ContainsKey(instanceID)) { Debug.LogError("Material memory leak appear"); return; } uint num = this.m_MatMap[instanceID]; ushort key = (ushort)(num >> 16); ushort num2 = (ushort)(num & 65535u); ModelLoader.ModelNode modelNode = this.m_MatList[key]; if (modelNode != null) { ModelLoader.MatNode matNode = modelNode.matNode[(int)num2]; ModelLoader.MatNode matNode2 = matNode; matNode2.refCount -= 1; if (matNode.refCount == 0) { UnityEngine.Object.DestroyImmediate(modelNode.matNode[(int)num2].material, true); modelNode.matNode[(int)num2] = null; this.m_MatMap.Remove(instanceID); } ModelLoader.ModelNode modelNode2 = modelNode; modelNode2.refCount -= 1; if (modelNode.refCount == 0) { this.m_MatList.Remove(key); } Debug.Log("modelCt: " + modelNode.refCount.ToString() + " ,matCt: " + matNode.refCount.ToString()); } }
// 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); }
// Token: 0x0600077E RID: 1918 RVA: 0x000A2D88 File Offset: 0x000A0F88 public void Unload(UnityEngine.Object obj) { GameObject gameObject = obj as GameObject; if (gameObject == null) { return; } if (!gameObject.activeSelf) { gameObject.SetActive(true); } SkinnedMeshRenderer componentInChildren = gameObject.GetComponentInChildren <SkinnedMeshRenderer>(); if (componentInChildren != null) { int instanceID = componentInChildren.sharedMaterial.GetInstanceID(); if (!this.m_MatMap.ContainsKey(instanceID)) { Debug.LogError("Material memory leak appear"); return; } uint num = this.m_MatMap[instanceID]; ushort key = (ushort)(num >> 16); ushort num2 = (ushort)(num & 65535u); ModelLoader.ModelNode modelNode = this.m_MatList[key]; if (modelNode != null) { ModelLoader.MatNode matNode = modelNode.matNode[(int)num2]; ModelLoader.MatNode matNode2 = matNode; matNode2.refCount -= 1; if (matNode.refCount == 0) { UnityEngine.Object.DestroyImmediate(modelNode.matNode[(int)num2].material, true); modelNode.matNode[(int)num2] = null; this.m_MatMap.Remove(instanceID); } ModelLoader.ModelNode modelNode2 = modelNode; modelNode2.refCount -= 1; if (modelNode.refCount == 0) { this.m_MatList.Remove(key); } } } UnityEngine.Object.Destroy(gameObject); }
// Token: 0x0600077B RID: 1915 RVA: 0x000A28C8 File Offset: 0x000A0AC8 public GameObject Load(ushort modelID, AssetBundle ab, ushort texID = 0) { if (modelID <= 0 || ab == null || this.modelDefuse == null) { return(null); } GameObject gameObject = UnityEngine.Object.Instantiate(ab.Load("mwm")) as GameObject; if (gameObject == null) { return(null); } SkinnedMeshRenderer componentInChildren = gameObject.GetComponentInChildren <SkinnedMeshRenderer>(); if (componentInChildren == 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); } componentInChildren.material = matNode.material; ModelLoader.MatNode matNode2 = matNode; matNode2.refCount += 1; ModelLoader.ModelNode modelNode2 = modelNode; modelNode2.refCount += 1; return(gameObject); }