public ResCheckResult Check(ResCheckerCallBack callbacker) { List <string> errMsg = new List <string>(); //检查模型文件 var models = GetCharaterModel(CatalogueConfig.CharactersDir); callbacker.BeginCheck(this.Name(), models.Count); for (int i = 0; i < models.Count; i++) { var model = models[i]; var prefab = AssetDatabase.LoadAssetAtPath(model, typeof(GameObject)) as GameObject; if (prefab != null) { var go = GameObject.Instantiate(prefab) as GameObject; go.name = prefab.name; bool hasBones = HasBones(go.transform, ref errMsg); CheckCharatersName(go.name, ref errMsg); CheckRootBoneName(go.transform, ref errMsg); CheckCharatersMesh(go.transform, ref errMsg); CheckModelMaterial(go.transform, ref errMsg); GameObject.DestroyImmediate(go); callbacker.OnCheckProgress(string.Format("Checking{0}", model), i, models.Count); } } callbacker.OnCheckEnd(); //检查动画文件 var anims = GetCharacterAnim(CatalogueConfig.CharactersDir); callbacker.BeginCheck(this.Name(), anims.Count); for (int i = 0; i < anims.Count; i++) { var anim = anims[i]; var prefab = AssetDatabase.LoadAssetAtPath(anim, typeof(GameObject)) as GameObject; if (prefab != null) { var go = GameObject.Instantiate(prefab) as GameObject; go.name = prefab.name; CheckAnimMesh(go.transform, ref errMsg); GameObject.DestroyImmediate(go); callbacker.OnCheckProgress(string.Format("Checking{0}", anim), i, anims.Count); } } callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), errMsg)); }
public ResCheckResult Check(ResCheckerCallBack callbacker) { callbacker.BeginCheck(this.Name(), 1); var error = new List <string>(); GetFileFromDir("*.tga", "tga", ref error); GetFileFromDir("*.png", "png", ref error); GetFileFromDir("*.jpg", "jpg", ref error); GetFileFromDir("*.gif", "gif", ref error); GetFileFromDir("*.mat", "mat", ref error); GetFileFromDir("*.shader", "shader", ref error); callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), error)); }
public ResCheckResult Check(ResCheckerCallBack callbacker) { List <string> errorMsg = new List <string>(); var prefabs = Directory.GetFiles("Assets/Bundles/Player/", "*.prefab", SearchOption.AllDirectories).ToList <string>(); callbacker.BeginCheck(this.Name(), prefabs.Count); for (int i = 0; i < prefabs.Count; i++) { var p = prefabs[i]; var prefab = AssetDatabase.LoadAssetAtPath(p, typeof(GameObject)) as GameObject; if (prefab != null) { CheckCharatersGenericPoolLogic(prefab.transform, ref errorMsg); callbacker.OnCheckProgress(string.Format("Checking{0}", prefab), i, prefabs.Count); } } callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), errorMsg)); }
public ResCheckResult Check(ResCheckerCallBack callbacker) { var prefabs = GetAllPrefab(CatalogueConfig.UIPrefabPath); callbacker.BeginCheck(this.Name(), prefabs.Count); var error = new List <string>(); for (int i = 0; i < prefabs.Count; i++) { var prefab = prefabs[i]; var goPrefab = AssetDatabase.LoadAssetAtPath(prefab, typeof(GameObject)) as GameObject; if (goPrefab != null) { CheckPrefabAtlasTextureDepth(goPrefab, ref error); //GameObject.DestroyImmediate(goPrefab); callbacker.OnCheckProgress(string.Format("Checking{0}", prefab), i, prefabs.Count); } } callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), error)); }
public ResCheckResult Check(ResCheckerCallBack callbacker) { var prefabs = GetAllPrefab(s_PrefabDir); callbacker.BeginCheck(this.Name(), prefabs.Count); var error = new List <string>(); for (int i = 0; i < prefabs.Count; i++) { var prefab = prefabs[i]; var goPrefab = AssetDatabase.LoadAssetAtPath(prefab, typeof(GameObject)) as GameObject; if (goPrefab != null) { var skinnedMeshs = goPrefab.GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (var skinnedmesh in skinnedMeshs) { foreach (var mat in skinnedmesh.sharedMaterials) { if (mat == null) { error.Add(string.Format("prefab名字:{0}有材质丢失在:{1}节点", goPrefab.name, skinnedmesh.gameObject.name)); } } } var meshRenderers = goPrefab.GetComponentsInChildren <MeshRenderer>(); foreach (var meshRenderer in meshRenderers) { if (meshRenderer == null) { error.Add(string.Format("prefab名字:{0}有mesh丢失在", goPrefab.name)); continue; } foreach (var mat in meshRenderer.sharedMaterials) { if (mat == null) { error.Add(string.Format("prefab名字:{0}有材质丢失在:{1}节点", goPrefab.name, meshRenderer.gameObject.name)); } } } var particleSystems = goPrefab.GetComponentsInChildren <Renderer>(); foreach (var particleSystem in particleSystems) { if (particleSystem == null) { error.Add(string.Format("粒子名字:{0}有Renderer丢失在", goPrefab.name)); continue; } if (!particleSystem.enabled) { continue; } int missNum = 0; foreach (var mat in particleSystem.sharedMaterials) { if (mat != null) { continue; } if (mat == null) { missNum++; } } if (missNum >= particleSystem.sharedMaterials.Length) { error.Add(string.Format("粒子名字:{0}有材质丢失在:{1}节点", goPrefab.name, particleSystem.gameObject.name)); } } //GameObject.DestroyImmediate(goPrefab); callbacker.OnCheckProgress(string.Format("Checking{0}", prefab), i, prefabs.Count); } } callbacker.OnCheckEnd(); var fbxs = GetAllFbx(s_PrefabDir); callbacker.BeginCheck(this.Name(), fbxs.Count); for (int i = 0; i < fbxs.Count; i++) { var fbx = fbxs[i]; var goPrefab = AssetDatabase.LoadAssetAtPath(fbx, typeof(GameObject)) as GameObject; if (goPrefab != null) { var skinnedMeshs = goPrefab.GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (var skinnedmesh in skinnedMeshs) { foreach (var mat in skinnedmesh.sharedMaterials) { if (mat == null) { error.Add(string.Format("fbx名字:{0}有材质丢失在:{1}节点", goPrefab.name, skinnedmesh.gameObject.name)); } } } var meshRenderers = goPrefab.GetComponentsInChildren <MeshRenderer>(); foreach (var meshRenderer in meshRenderers) { if (meshRenderer == null) { error.Add(string.Format("fbx名字:{0}有mesh丢失在", goPrefab.name)); continue; } foreach (var mat in meshRenderer.sharedMaterials) { if (mat == null) { error.Add(string.Format("fbx名字:{0}有材质丢失在:{1}节点", goPrefab.name, meshRenderer.gameObject.name)); } } } var particleSystems = goPrefab.GetComponentsInChildren <Renderer>(); foreach (var particleSystem in particleSystems) { if (particleSystem == null) { error.Add(string.Format("粒子名字:{0}有Renderer丢失在", goPrefab.name)); continue; } if (!particleSystem.enabled) { continue; } int missNum = 0; foreach (var mat in particleSystem.sharedMaterials) { if (mat != null) { continue; } if (mat == null) { missNum++; } } if (missNum >= particleSystem.sharedMaterials.Length) { error.Add(string.Format("粒子名字:{0}有材质丢失在:{1}节点", goPrefab.name, particleSystem.gameObject.name)); } } //GameObject.DestroyImmediate(goPrefab); callbacker.OnCheckProgress(string.Format("Checking{0}", fbx), i, fbxs.Count); } } callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), error)); }
public ResCheckResult Check(ResCheckerCallBack callbacker) { var prefabs = Directory.GetFiles(CatalogueConfig.UIPrefabPath, "*.prefab", SearchOption.AllDirectories).ToList <string>(); callbacker.BeginCheck(this.Name(), prefabs.Count); List <string> wrongs = new List <string>(); for (int i = 0; i < prefabs.Count; i++) { var p = prefabs[i]; var prefab = AssetDatabase.LoadAssetAtPath(p, typeof(GameObject)) as GameObject; if (prefab != null) { var rigids = prefab.GetComponentsInChildren <Rigidbody>(); if (rigids != null && rigids.Length > 0) { foreach (var rigid in rigids) { wrongs.Add(string.Format("{0}的{1}节点不应该包含Rigidbody组件!", prefab.name, rigid.gameObject.name)); } } var fonts = prefab.GetComponentsInChildren <UILabel>(); if (fonts != null && fonts.Length > 0) { foreach (var font in fonts) { if (font.trueTypeFont == null) { wrongs.Add(string.Format("{0}的{1}节点有字体丢失!", prefab.name, font.gameObject.name)); } } } var components = prefab.GetComponentsInChildren <Component>(true); foreach (var c in components) { if (c == null) { wrongs.Add(string.Format("prefab名字:{0}有脚本丢失!", prefab.name)); } } //font check if (prefab.GetComponent <UIPanel>() == null) { continue; } UILabel[] labels = prefab.transform.GetComponentsInChildren <UILabel>(true); foreach (var label in labels) { if (label.fontStyle != FontStyle.Normal) { wrongs.Add(string.Format("{0}的{1}节点字体fontStyle错误", prefab.name, label.gameObject.name)); } if (label.effectStyle != UILabel.Effect.None && label.effectDistance.x != 2 && label.effectDistance.x != 3) { wrongs.Add(string.Format("{0}的{1}节点字体effectDistance错误", prefab.name, label.gameObject.name)); } } //btn check UIButton[] btns = prefab.transform.GetComponentsInChildren <UIButton>(true); foreach (var btn in btns) { if (btn.hover != Color.white || btn.pressed != Color.white) { wrongs.Add(string.Format("{0}的{1}节点按钮的hover pressed的状态错误", prefab.name, btn.gameObject.name)); } if (btn.GetComponent <UIButtonScale>() == null) { wrongs.Add(string.Format("{0}的{1}节点按钮没有UIButtonScale组件", prefab.name, btn.gameObject.name)); } } callbacker.OnCheckProgress(string.Format("Checking{0}", p), i, prefabs.Count); } } callbacker.OnCheckEnd(); return(new ResCheckResult(Name(), wrongs)); }