public static void resetShardAssets(UnityEngine.Object obj) { CLSharedAssets sharedAsset = null; CLRoleAvata avata = null; if (obj != null && obj is GameObject) { // 没搞明白,执行到这里时,textureMgr已经为null了,因此再取一次 sharedAsset = ((GameObject)obj).GetComponent <CLSharedAssets> (); avata = ((GameObject)obj).GetComponent <CLRoleAvata> (); UIFont font = ((GameObject)obj).GetComponent <UIFont> (); if (font != null) { if (!string.IsNullOrEmpty(font.atlasName)) { font.atlas = CLUIInit.self.getAtlasByName(font.atlasName); if (font.atlas) { font.material = font.atlas.spriteMaterial; } } } } else if (obj != null && obj is Material) { CLMaterialPool.resetTexRef(ECLEditorUtl.getAssetName4Upgrade(obj), (Material)obj, null, null); sharedAsset = null; } else { sharedAsset = null; } bool isRefresh = false; if (avata != null) { avata.setDefaultMaterial(); isRefresh = true; } if (sharedAsset != null) { sharedAsset.reset(); sharedAsset.resetAssets(); isRefresh = true; } if (isRefresh && obj is GameObject) { //string path = AssetDatabase.GetAssetPath (obj); //EditorUtility.SetDirty (obj); //AssetDatabase.WriteImportSettingsIfDirty (path); //AssetDatabase.ImportAsset (path); PrefabUtility.SavePrefabAsset(obj as GameObject); } }
public static void cleanShardAssets(UnityEngine.Object obj) { CLSharedAssets sharedAsset = null; CLRoleAvata avata = null; if (obj is GameObject) { sharedAsset = ((GameObject)obj).GetComponent <CLSharedAssets> (); avata = ((GameObject)obj).GetComponent <CLRoleAvata> (); if (AssetDatabase.GetAssetPath(obj).Contains("/other/model/")) { ECLEditorUtl.cleanModleMaterials(AssetDatabase.GetAssetPath(obj)); } UIFont font = ((GameObject)obj).GetComponent <UIFont> (); if (font != null) { string spName = font.spriteName; font.atlas = null; font.material = null; font.spriteName = spName; } } else if (obj is Material) { CLMaterialPool.cleanTexRef(ECLEditorUtl.getAssetName4Upgrade(obj), (Material)obj); sharedAsset = null; } else { sharedAsset = null; } bool isRefresh = false; if (avata != null) { avata.cleanMaterial(); isRefresh = true; } if (sharedAsset != null) { sharedAsset.cleanRefAssets(); isRefresh = true; } if (isRefresh && obj is GameObject) { // AssetDatabase.Refresh (); //string path = AssetDatabase.GetAssetPath (obj); //EditorUtility.SetDirty (obj); //AssetDatabase.WriteImportSettingsIfDirty (path); //AssetDatabase.ImportAsset (path); PrefabUtility.SavePrefabAsset(obj as GameObject); } }