//
    public IEnumerable DoCheckSkinMeshRendererCoroutine(string prefabName, GameObject scenePrefab)
    {
        List <string>    errorList_MaterialMissing       = new List <string>();
        HashSet <string> errorSet_MaterialMissing        = new HashSet <string>();
        List <string>    errorList_MaterialShaderMissing = new List <string>();
        HashSet <string> errorSet_MaterialShaderMissing  = new HashSet <string>();
        List <string>    errorList_MaterialShaderError   = new List <string>();
        HashSet <string> errorSet_MaterialShaderError    = new HashSet <string>();
        List <string>    errorList_TextureLarge          = new List <string>();
        HashSet <string> errorSet_TextureLarge           = new HashSet <string>();
        List <string>    errorList_TextureNPT            = new List <string>();
        HashSet <string> errorSet_TextureNPT             = new HashSet <string>();
        List <string>    errorList_TextureNull           = new List <string>();
        //HashSet<string> errorSet_TextureNull = new HashSet<string>();

        List <GameObject> rendererList = new List <GameObject>();

        CUnityUtil.FindChildLeaf(typeof(SkinnedMeshRenderer), typeof(MeshRenderer), scenePrefab, rendererList);

        //检查每个包含MeshRenderer的go
        foreach (var go in rendererList)
        {
            Material[]          materials;
            SkinnedMeshRenderer renderer = go.GetComponent <SkinnedMeshRenderer>();
            if (renderer != null)
            {
                materials = renderer.sharedMaterials == null ? renderer.materials : renderer.sharedMaterials;
            }
            else
            {
                MeshRenderer meshRenderer = go.GetComponent <MeshRenderer>();
                materials = meshRenderer.sharedMaterials == null ? meshRenderer.materials : meshRenderer.sharedMaterials;
            }

            //检查
            for (int i = 0; i < materials.Length; ++i)
            {
                Material mat = materials[i];

                if (IsPlayerPart(prefabName, go.name))
                {
                    if (mat != null)
                    {
                        _ErrorString += string.Format("{0} player部位的material必须为null! 组件名: {1}", prefabName, go.name);
                    }
                    continue;
                }

                if (mat == null)
                {
                    string strMsg = string.Format("{0} material丢失! 组件名: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialMissing.Contains(strMsg))
                    {
                        errorSet_MaterialMissing.Add(strMsg);
                        errorList_MaterialMissing.Add(strMsg);
                    }
                    continue;
                }
                Shader shader = mat.shader;
                if (shader == null)
                {
                    string strMsg = string.Format("{0} material shader 丢失! 组件名: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                    {
                        errorSet_MaterialShaderMissing.Add(mat.name);
                        errorList_MaterialShaderMissing.Add(strMsg);
                    }
                    continue;
                }

                if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                {
                    string strMsg = string.Format("{0} material shader 错误! 组件名: {1} 材质: {2}, shader名称: {3}\n", prefabName, go.name, i, shader.name);
                    if (!errorSet_MaterialShaderError.Contains(mat.name))
                    {
                        errorSet_MaterialShaderError.Add(mat.name);
                        errorList_MaterialShaderError.Add(strMsg);
                    }

                    continue;
                }

#if UNITY_EDITOR
                for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                {
                    if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                        Texture tex          = mat.GetTexture(propertyName);

                        if (tex != null)
                        {
                            if (tex.width > TextureLimit || tex.height > TextureLimit)
                            {
                                string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! 组件名: {2} 材质: {3} 宽高: {4} {5} 贴图: {6} \n", prefabName, TextureLimit, go.name, i, tex.width, tex.height, tex.name);

                                //排除允许过大贴图的一些目录
                                bool bSpecial = prefabName.Contains("/Boss/") ||
                                                prefabName.Contains("/Fashion/") ||
                                                (prefabName.Contains("/Outward/") && prefabName.Contains("/equipment/")) ||
                                                prefabName.Contains("/Ride/") ||
                                                prefabName.Contains("/wing/") ||
                                                prefabName.Contains("_create_");

                                if (!bSpecial)
                                {
                                    AddToTextureInfoList(LargeTextureList, prefabName, go.name, tex.name, tex.width, tex.height);

                                    if (!errorSet_TextureLarge.Contains(tex.name))
                                    {
                                        errorSet_TextureLarge.Add(tex.name);
                                        errorList_TextureLarge.Add(strMsg);
                                    }
                                }
                            }

                            if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                            {
                                string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! 组件名: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, i, tex.width, tex.height, tex.name);

                                AddToTextureInfoList(NoStandardTextureList, prefabName, go.name, tex.name, tex.width, tex.height);

                                if (!errorSet_TextureNPT.Contains(tex.name))
                                {
                                    errorSet_TextureNPT.Add(tex.name);
                                    errorList_TextureNPT.Add(strMsg);
                                }
                            }
                        }
                        else
                        {
//                             if (false) //(propertyName == "_MainTex")
//                             {
//                                 string strMsg = string.Format("{0} 贴图为空! 组件名: {1} 材质: {2} 贴图: {3}\n", prefabName, go.name, i, propertyName);
//                                 if (!errorSet_TextureNull.Contains(strMsg))
//                                 {
//                                     errorSet_TextureNull.Add(strMsg);
//                                     errorList_TextureNull.Add(strMsg);
//                                 }
//                             }
                        }
                    }
                }
#endif
            }
        }

        //输出错误信息
        foreach (var str in errorList_MaterialMissing)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_MaterialShaderMissing)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_MaterialShaderError)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureLarge)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureNPT)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureNull)
        {
            _ErrorString += str;
        }

        yield return(null);
    }
Beispiel #2
0
    //
    public IEnumerable DoCheckParticleSystemCoroutine(string prefabName, GameObject sfxPrefab)
    {
        List <string>    errorList_MaterialMissing       = new List <string>();
        HashSet <string> errorSet_MaterialMissing        = new HashSet <string>();
        List <string>    errorList_MaterialShaderMissing = new List <string>();
        HashSet <string> errorSet_MaterialShaderMissing  = new HashSet <string>();
        List <string>    errorList_MaterialShaderError   = new List <string>();
        HashSet <string> errorSet_MaterialShaderError    = new HashSet <string>();
        List <string>    errorList_TextureLarge          = new List <string>();
        HashSet <string> errorSet_TextureLarge           = new HashSet <string>();
        List <string>    errorList_TextureNPT            = new List <string>();
        HashSet <string> errorSet_TextureNPT             = new HashSet <string>();
        List <string>    errorList_TextureNull           = new List <string>();
        //HashSet<string> errorSet_TextureNull = new HashSet<string>();

        List <GameObject> rendererList = new List <GameObject>();

        CUnityUtil.FindChildLeaf(typeof(ParticleSystem), typeof(MeshRenderer), sfxPrefab, rendererList);

        foreach (var go in rendererList)
        {
            Material[]     materials = null;
            ParticleSystem ps        = go.GetComponent <ParticleSystem>();
            if (ps != null)
            {
                ParticleSystemRenderer renderer = ps.GetComponent <ParticleSystemRenderer>();
                if (renderer != null && renderer.enabled)
                {
                    materials = renderer.sharedMaterials == null ? renderer.materials : renderer.sharedMaterials;
                }
            }
            else
            {
                MeshRenderer renderer = go.GetComponent <MeshRenderer>();
                if (renderer != null && renderer.enabled)
                {
                    materials = renderer.sharedMaterials == null ? renderer.materials : renderer.sharedMaterials;
                }
            }

            if (materials == null)
            {
                continue;
            }

            //检查
            for (int i = 0; i < materials.Length; ++i)
            {
                Material mat = materials[i];
                if (mat == null)
                {
                    if (i == 0)
                    {
                        string strMsg = string.Format("{0} material丢失! prefab: {1}\n", prefabName, go.name);
                        if (!errorSet_MaterialMissing.Contains(strMsg))
                        {
                            errorSet_MaterialMissing.Add(strMsg);
                            errorList_MaterialMissing.Add(strMsg);
                        }
                    }
                    continue;
                }
                Shader shader = mat.shader;
                if (shader == null)
                {
                    string strMsg = string.Format("{0} material shader 丢失! prefab: {1}\n", prefabName, go.name);
                    if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                    {
                        errorSet_MaterialShaderMissing.Add(mat.name);
                        errorList_MaterialShaderMissing.Add(strMsg);
                    }
                    continue;
                }

                if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                {
                    string strMsg = string.Format("{0} material shader 错误! prefab: {1} shader名称: {2}\n", prefabName, go.name, shader.name);
                    if (!errorSet_MaterialShaderError.Contains(mat.name))
                    {
                        errorSet_MaterialShaderError.Add(mat.name);
                        errorList_MaterialShaderError.Add(strMsg);
                    }

                    continue;
                }

#if UNITY_EDITOR
                for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                {
                    if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                        Texture tex          = mat.GetTexture(propertyName);

                        if (tex != null)
                        {
                            if (tex.width > TextureLimit || tex.height > TextureLimit)
                            {
                                string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! prefab: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, TextureLimit, go.name, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureLarge.Contains(tex.name))
                                {
                                    errorSet_TextureLarge.Add(tex.name);
                                    errorList_TextureLarge.Add(strMsg);
                                }
                            }

                            if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                            {
                                string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! prefab: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, innerIndex, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureNPT.Contains(tex.name))
                                {
                                    errorSet_TextureNPT.Add(tex.name);
                                    errorList_TextureNPT.Add(strMsg);
                                }
                            }
                        }
                        else
                        {
//                             if (false) //(propertyName == "_MainTex")
//                             {
//                                 string strMsg = string.Format("{0} 贴图为空! prefab: {1} 贴图: {3}\n", prefabName, go.name, propertyName);
//                                 if (!errorSet_TextureNull.Contains(strMsg))
//                                 {
//                                     errorSet_TextureNull.Add(strMsg);
//                                     errorList_TextureNull.Add(strMsg);
//                                 }
//                             }
                        }
                    }
                }
#endif
            }
        }


        foreach (var go in rendererList)
        {
            Material[]     materials = null;
            ParticleSystem ps        = go.GetComponent <ParticleSystem>();
            if (ps == null || ps.shape.shapeType != ParticleSystemShapeType.MeshRenderer)
            {
                continue;
            }

            if (ps.shape.meshRenderer != null)
            {
                materials = ps.shape.meshRenderer.sharedMaterials == null ? ps.shape.meshRenderer.materials : ps.shape.meshRenderer.sharedMaterials;
            }

            if (materials == null)
            {
                continue;
            }

            //检查
            for (int i = 0; i < materials.Length; ++i)
            {
                Material mat = materials[i];
                if (mat == null)
                {
                    if (i == 0)
                    {
                        string strMsg = string.Format("{0} ParticleSystem.shape.meshRenderer material丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                        if (!errorSet_MaterialMissing.Contains(strMsg))
                        {
                            errorSet_MaterialMissing.Add(strMsg);
                            errorList_MaterialMissing.Add(strMsg);
                        }
                    }
                    continue;
                }
                Shader shader = mat.shader;
                if (shader == null)
                {
                    string strMsg = string.Format("{0} ParticleSystem.shape.meshRenderer material shader 丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                    {
                        errorSet_MaterialShaderMissing.Add(mat.name);
                        errorList_MaterialShaderMissing.Add(strMsg);
                    }
                    continue;
                }

                if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                {
                    string strMsg = string.Format("{0} ParticleSystem.shape.meshRenderer material shader 错误! prefab: {1} 材质: {2}, shader名称: {3}\n", prefabName, go.name, i, shader.name);
                    if (!errorSet_MaterialShaderError.Contains(mat.name))
                    {
                        errorSet_MaterialShaderError.Add(mat.name);
                        errorList_MaterialShaderError.Add(strMsg);
                    }

                    continue;
                }

#if UNITY_EDITOR
                for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                {
                    if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                        Texture tex          = mat.GetTexture(propertyName);

                        if (tex != null)
                        {
                            if (tex.width > TextureLimit || tex.height > TextureLimit)
                            {
                                string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! prefab: {2} 材质: {3} 宽高: {4} {5} 贴图: {6} \n", prefabName, TextureLimit, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureLarge.Contains(tex.name))
                                {
                                    errorSet_TextureLarge.Add(tex.name);
                                    errorList_TextureLarge.Add(strMsg);
                                }
                            }

                            if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                            {
                                string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! prefab: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureNPT.Contains(tex.name))
                                {
                                    errorSet_TextureNPT.Add(tex.name);
                                    errorList_TextureNPT.Add(strMsg);
                                }
                            }
                        }
                        else
                        {
//                             if (false) //(propertyName == "_MainTex")
//                             {
//                                 string strMsg = string.Format("{0} 贴图为空! prefab: {1} 材质: {2} 贴图: {3}\n", prefabName, go.name, i, propertyName);
//                                 if (!errorSet_TextureNull.Contains(strMsg))
//                                 {
//                                     errorSet_TextureNull.Add(strMsg);
//                                     errorList_TextureNull.Add(strMsg);
//                                 }
//                             }
                        }
                    }
                }
#endif
            }
        }

        foreach (var go in rendererList)
        {
            Material[]     materials = null;
            ParticleSystem ps        = go.GetComponent <ParticleSystem>();
            if (ps == null || ps.shape.shapeType != ParticleSystemShapeType.SkinnedMeshRenderer)
            {
                continue;
            }

            if (ps.shape.skinnedMeshRenderer != null)
            {
                materials = ps.shape.skinnedMeshRenderer.sharedMaterials == null ? ps.shape.skinnedMeshRenderer.materials : ps.shape.skinnedMeshRenderer.sharedMaterials;
            }

            if (materials == null)
            {
                continue;
            }

            //检查
            for (int i = 0; i < materials.Length; ++i)
            {
                Material mat = materials[i];
                if (mat == null)
                {
                    if (i == 0)
                    {
                        string strMsg = string.Format("{0} ParticleSystem.shape.skinnedMeshRenderer material丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                        if (!errorSet_MaterialMissing.Contains(strMsg))
                        {
                            errorSet_MaterialMissing.Add(strMsg);
                            errorList_MaterialMissing.Add(strMsg);
                        }
                    }
                    continue;
                }
                Shader shader = mat.shader;
                if (shader == null)
                {
                    string strMsg = string.Format("{0} ParticleSystem.shape.skinnedMeshRenderer material shader 丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                    {
                        errorSet_MaterialShaderMissing.Add(mat.name);
                        errorList_MaterialShaderMissing.Add(strMsg);
                    }
                    continue;
                }

                if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                {
                    string strMsg = string.Format("{0} ParticleSystem.shape.skinnedMeshRenderer material shader 错误! prefab: {1} 材质: {2}, shader名称: {3}\n", prefabName, go.name, i, shader.name);
                    if (!errorSet_MaterialShaderError.Contains(mat.name))
                    {
                        errorSet_MaterialShaderError.Add(mat.name);
                        errorList_MaterialShaderError.Add(strMsg);
                    }

                    continue;
                }

#if UNITY_EDITOR
                for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                {
                    if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                        Texture tex          = mat.GetTexture(propertyName);

                        if (tex != null)
                        {
                            if (tex.width > TextureLimit || tex.height > TextureLimit)
                            {
                                string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! prefab: {2} 材质: {3} 宽高: {4} {5} 贴图: {6} \n", prefabName, TextureLimit, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureLarge.Contains(tex.name))
                                {
                                    errorSet_TextureLarge.Add(tex.name);
                                    errorList_TextureLarge.Add(strMsg);
                                }
                            }

                            if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                            {
                                string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! prefab: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureNPT.Contains(tex.name))
                                {
                                    errorSet_TextureNPT.Add(tex.name);
                                    errorList_TextureNPT.Add(strMsg);
                                }
                            }
                        }
                        else
                        {
//                             if (false) //(propertyName == "_MainTex")
//                             {
//                                 string strMsg = string.Format("{0} 贴图为空! prefab: {1} 材质: {2} 贴图: {3}\n", prefabName, go.name, i, propertyName);
//                                 if (!errorSet_TextureNull.Contains(strMsg))
//                                 {
//                                     errorSet_TextureNull.Add(strMsg);
//                                     errorList_TextureNull.Add(strMsg);
//                                 }
//                             }
                        }
                    }
                }
#endif
            }
        }

        //输出错误信息
        foreach (var str in errorList_MaterialMissing)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_MaterialShaderMissing)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_MaterialShaderError)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureLarge)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureNPT)
        {
            _ErrorString += str;
        }

        foreach (var str in errorList_TextureNull)
        {
            _ErrorString += str;
        }

        yield return(null);
    }
Beispiel #3
0
    private IEnumerable DoCheckMeshRendererCoroutine(string prefabName, SceneConfig config)
    {
        string shortName = System.IO.Path.GetFileNameWithoutExtension(prefabName);

        List <string>    errorList_MaterialMissing       = new List <string>();
        HashSet <string> errorSet_MaterialMissing        = new HashSet <string>();
        List <string>    errorList_MaterialShaderMissing = new List <string>();
        HashSet <string> errorSet_MaterialShaderMissing  = new HashSet <string>();
        List <string>    errorList_MaterialShaderError   = new List <string>();
        HashSet <string> errorSet_MaterialShaderError    = new HashSet <string>();
        List <string>    errorList_TextureLarge          = new List <string>();
        HashSet <string> errorSet_TextureLarge           = new HashSet <string>();
        List <string>    errorList_TextureNPT            = new List <string>();
        HashSet <string> errorSet_TextureNPT             = new HashSet <string>();
        List <string>    errorList_TextureNull           = new List <string>();
        //HashSet<string> errorSet_TextureNull = new HashSet<string>();

        Transform blockRootTran = config.transform.Find("BlockObjects");

        if (null == blockRootTran)
        {
            blockRootTran = config.transform;
        }

        int count = 0;
        int total = config._BlockPositionList.Count;

        foreach (SceneConfig.CPositionSetting currentPos in config._BlockPositionList)
        {
            ++count;

            string blockName = System.IO.Path.GetFileName(currentPos._BlockName);
            GameDataCheckMan.Instance.SetDesc(string.Format("{0} 检查Obj: {1}", shortName, blockName));
            GameDataCheckMan.Instance.SetPartProgress((float)count / total);
            yield return(null);

            var asset = AssetBundleCheck.Instance.LoadAsset(currentPos._BlockName);
            if (asset == null)
            {
                AddErrorStringFormat(shortName, "terrain加载Object错误: {0}\n", currentPos._BlockName);
                continue;
            }

            //创建
            //TextLogger.Instance.WriteLine(string.Format("Checking Scene Object: {0}", currentPos._BlockName));
            var obj = GameObject.Instantiate(asset) as GameObject;
            obj.transform.parent = blockRootTran;

            List <GameObject> rendererList = new List <GameObject>();
            CUnityUtil.FindChildLeaf(typeof(MeshRenderer), obj, rendererList);

            //检查每个包含MeshRenderer的go
            foreach (var go in rendererList)
            {
                MeshRenderer renderer  = go.GetComponent <MeshRenderer>();
                Material[]   materials = renderer.sharedMaterials == null ? renderer.materials : renderer.sharedMaterials;

                //检查
                for (int i = 0; i < materials.Length; ++i)
                {
                    Material mat = materials[i];
                    if (mat == null)
                    {
                        string strMsg = string.Format("{0} material丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                        if (!errorSet_MaterialMissing.Contains(strMsg))
                        {
                            errorSet_MaterialMissing.Add(strMsg);
                            errorList_MaterialMissing.Add(strMsg);
                        }
                        continue;
                    }

                    Shader shader = mat.shader;
                    if (shader == null)
                    {
                        string strMsg = string.Format("{0} material shader 丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                        if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                        {
                            errorSet_MaterialShaderMissing.Add(mat.name);
                            errorList_MaterialShaderMissing.Add(strMsg);
                        }
                        continue;
                    }

                    if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                    {
                        string strMsg = string.Format("{0} material shader 错误! prefab: {1} 材质: {2}, shader名称: {3}\n", prefabName, go.name, i, shader.name);
                        if (!errorSet_MaterialShaderError.Contains(mat.name))
                        {
                            errorSet_MaterialShaderError.Add(mat.name);
                            errorList_MaterialShaderError.Add(strMsg);
                        }

                        continue;
                    }

#if UNITY_EDITOR
                    for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                    {
                        if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                        {
                            string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                            Texture tex          = mat.GetTexture(propertyName);

                            if (tex != null)
                            {
                                if (tex.width > TextureLimit || tex.height > TextureLimit)
                                {
                                    string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! prefab: {2} 材质: {3} 宽高: {4} {5} 贴图: {6} \n", prefabName, TextureLimit, go.name, i, tex.width, tex.height, tex.name);
                                    if (!errorSet_TextureLarge.Contains(tex.name))
                                    {
                                        errorSet_TextureLarge.Add(tex.name);
                                        errorList_TextureLarge.Add(strMsg);
                                    }
                                }

                                if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                                {
                                    string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! prefab: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, i, tex.width, tex.height, tex.name);
                                    if (!errorSet_TextureNPT.Contains(tex.name))
                                    {
                                        errorSet_TextureNPT.Add(tex.name);
                                        errorList_TextureNPT.Add(strMsg);
                                    }
                                }
                            }
                            else
                            {
//                                 if (false) //(propertyName == "_MainTex")
//                                 {
//                                     string strMsg = string.Format("{0} 贴图为空! prefab: {1} 材质: {2} 贴图: {3}\n", prefabName, go.name, i, propertyName);
//                                     if (!errorSet_TextureNull.Contains(strMsg))
//                                     {
//                                         errorSet_TextureNull.Add(strMsg);
//                                         errorList_TextureNull.Add(strMsg);
//                                     }
//                                 }
                            }
                        }
                    }
#endif
                }
            }

            GameObject.DestroyImmediate(obj);
        }

        //输出错误信息
        foreach (var str in errorList_MaterialMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderError)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureLarge)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureNPT)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureNull)
        {
            AddErrorString(shortName, str);
        }

        yield return(null);
    }
Beispiel #4
0
    IEnumerable DoCheckMeshRendererCoroutine(string prefabName, GameObject scenePrefab)
    {
        string shortName = System.IO.Path.GetFileNameWithoutExtension(prefabName);

        List <string>    errorList_MaterialMissing       = new List <string>();
        HashSet <string> errorSet_MaterialMissing        = new HashSet <string>();
        List <string>    errorList_MaterialShaderMissing = new List <string>();
        HashSet <string> errorSet_MaterialShaderMissing  = new HashSet <string>();
        List <string>    errorList_MaterialShaderError   = new List <string>();
        HashSet <string> errorSet_MaterialShaderError    = new HashSet <string>();
        List <string>    errorList_TextureLarge          = new List <string>();
        HashSet <string> errorSet_TextureLarge           = new HashSet <string>();
        List <string>    errorList_TextureNPT            = new List <string>();
        HashSet <string> errorSet_TextureNPT             = new HashSet <string>();
        List <string>    errorList_TextureNull           = new List <string>();
        //HashSet<string> errorSet_TextureNull = new HashSet<string>();

        List <GameObject> rendererList = new List <GameObject>();

        CUnityUtil.FindChildLeaf(typeof(MeshRenderer), scenePrefab, rendererList);

        //检查每个包含MeshRenderer的go
        foreach (var go in rendererList)
        {
            MeshRenderer renderer  = go.GetComponent <MeshRenderer>();
            Material[]   materials = renderer.sharedMaterials == null ? renderer.materials : renderer.sharedMaterials;

            //检查
            for (int i = 0; i < materials.Length; ++i)
            {
                Material mat = materials[i];
                if (mat == null)
                {
                    string strMsg = string.Format("{0} material丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialMissing.Contains(strMsg))
                    {
                        errorSet_MaterialMissing.Add(strMsg);
                        errorList_MaterialMissing.Add(strMsg);
                    }
                    continue;
                }
                Shader shader = mat.shader;
                if (shader == null)
                {
                    string strMsg = string.Format("{0} material shader 丢失! prefab: {1} 材质: {2}\n", prefabName, go.name, i);
                    if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                    {
                        errorSet_MaterialShaderMissing.Add(mat.name);
                        errorList_MaterialShaderMissing.Add(strMsg);
                    }
                    continue;
                }

                if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                {
                    string strMsg = string.Format("{0} material shader 错误! prefab: {1} 材质: {2}, shader名称: {3}\n", prefabName, go.name, i, shader.name);
                    if (!errorSet_MaterialShaderError.Contains(mat.name))
                    {
                        errorSet_MaterialShaderError.Add(mat.name);
                        errorList_MaterialShaderError.Add(strMsg);
                    }

                    continue;
                }

#if UNITY_EDITOR
                for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                {
                    if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                        Texture tex          = mat.GetTexture(propertyName);

                        if (tex != null)
                        {
                            if (tex.width > TextureLimit || tex.height > TextureLimit)
                            {
                                string strMsg = string.Format("{0} 贴图大小大于{1},建议缩小! prefab: {2} 材质: {3} 宽高: {4} {5} 贴图: {6} \n", prefabName, TextureLimit, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureLarge.Contains(tex.name))
                                {
                                    errorSet_TextureLarge.Add(tex.name);
                                    errorList_TextureLarge.Add(strMsg);
                                }
                            }

                            if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                            {
                                string strMsg = string.Format("{0} 贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! prefab: {1} 材质: {2} 宽高: {3} {4} 贴图: {5} \n", prefabName, go.name, i, tex.width, tex.height, tex.name);
                                if (!errorSet_TextureNPT.Contains(tex.name))
                                {
                                    errorSet_TextureNPT.Add(tex.name);
                                    errorList_TextureNPT.Add(strMsg);
                                }
                            }
                        }
                        else
                        {
//                             if (false) //if (propertyName == "_MainTex")
//                             {
//                                 string strMsg = string.Format("{0} 贴图为空! prefab: {1} 材质: {2} 贴图: {3}\n", prefabName, go.name, i, propertyName);
//                                 if (!errorSet_TextureNull.Contains(strMsg))
//                                 {
//                                     errorSet_TextureNull.Add(strMsg);
//                                     errorList_TextureNull.Add(strMsg);
//                                 }
//                             }
                        }
                    }
                }
#endif
            }
        }

        //输出错误信息
        foreach (var str in errorList_MaterialMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderError)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureLarge)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureNPT)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureNull)
        {
            AddErrorString(shortName, str);
        }

        yield return(null);
    }
Beispiel #5
0
    private IEnumerable DoCheckSceneConfig(string prefabName, SceneConfig config)
    {
        string shortName = System.IO.Path.GetFileNameWithoutExtension(prefabName);

        List <string>    errorList_MaterialMissing       = new List <string>();
        HashSet <string> errorSet_MaterialMissing        = new HashSet <string>();
        List <string>    errorList_MaterialShaderMissing = new List <string>();
        HashSet <string> errorSet_MaterialShaderMissing  = new HashSet <string>();
        List <string>    errorList_MaterialShaderError   = new List <string>();
        HashSet <string> errorSet_MaterialShaderError    = new HashSet <string>();
        List <string>    errorList_TextureLarge          = new List <string>();
        HashSet <string> errorSet_TextureLarge           = new HashSet <string>();
        List <string>    errorList_TextureNPT            = new List <string>();
        HashSet <string> errorSet_TextureNPT             = new HashSet <string>();

        int count = 0;
        int total = config._RegionIdGroup.Count;

        for (int regionId = 0; regionId < config._RegionIdGroup.Count; ++regionId)
        {
            var regionConfig = config._RegionIdGroup[regionId];

            ++count;

            GameDataCheckMan.Instance.SetDesc(string.Format("{0} 检查Region Config: {1}", shortName, regionId));
            GameDataCheckMan.Instance.SetPartProgress((float)count / total);
            yield return(null);

            int[] idArray = new int[] { regionConfig.DayID, regionConfig.DuskID, regionConfig.MorningID, regionConfig.NightID };

            foreach (int id in idArray)
            {
                var data = GetEffectByID(id);
                if (data == null)
                {
                    continue;
                }

                var cubeMap = AssetBundleCheck.Instance.LoadAsset(data._SkyConifg._CubeMapPath) as Cubemap;
                if (cubeMap == null)
                {
                    if (!string.IsNullOrEmpty(data._SkyConifg._CubeMapPath))
                    {
                        AddErrorStringFormat(shortName, "{0} sceneConfig 的SKYBOX cubemap加载失败, 区域Id: {1}, CubeMapPath: {2}\n", prefabName, regionId, data._SkyConifg._CubeMapPath);
                    }
                }
                else
                {
                    var tex = cubeMap;
                    if (tex.width > TextureLimit || tex.height > TextureLimit)
                    {
                        string strMsg = string.Format("{0} 的SKYBOX CubeMap贴图大小大于{1},建议缩小! 宽高: {2} {3} 贴图: {4} \n", prefabName, TextureLimit, tex.width, tex.height, tex.name);
                        if (!errorSet_TextureLarge.Contains(tex.name))
                        {
                            errorSet_TextureLarge.Add(tex.name);
                            errorList_TextureLarge.Add(strMsg);
                        }
                    }

                    if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                    {
                        string strMsg = string.Format("{0} 的SKYBOX CubeMap贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! 宽高: {1} {2} 贴图: {3} \n", prefabName, tex.width, tex.height, tex.name);
                        if (!errorSet_TextureNPT.Contains(tex.name))
                        {
                            errorSet_TextureNPT.Add(tex.name);
                            errorList_TextureNPT.Add(strMsg);
                        }
                    }
                }

                var asset = AssetBundleCheck.Instance.LoadAsset(data._SkyBoxMatPath);
                if (asset != null)
                {
                    Material mat = GameObject.Instantiate(asset) as Material;
                    if (mat == null)
                    {
                        string strMsg = string.Format("{0} 的SKYBOX material丢失! 材质: {1}\n", prefabName, data._SkyBoxMatPath);
                        if (!errorSet_MaterialMissing.Contains(strMsg))
                        {
                            errorSet_MaterialMissing.Add(strMsg);
                            errorList_MaterialMissing.Add(strMsg);
                        }
                        continue;
                    }

                    Shader shader = mat.shader;
                    if (shader == null)
                    {
                        string strMsg = string.Format("{0} 的SKYBOX material shader 丢失! 材质: {1}\n", prefabName, data._SkyBoxMatPath);
                        if (!errorSet_MaterialShaderMissing.Contains(mat.name))
                        {
                            errorSet_MaterialShaderMissing.Add(mat.name);
                            errorList_MaterialShaderMissing.Add(strMsg);
                        }
                        continue;
                    }

                    if ((!shader.name.Contains("Standard")) && (shader.name.Contains("ErrorShader")))
                    {
                        string strMsg = string.Format("{0} 的SKYBOX material shader 错误! 材质: {1}, shader名称: {2}\n", prefabName, data._SkyBoxMatPath, shader.name);
                        if (!errorSet_MaterialShaderError.Contains(mat.name))
                        {
                            errorSet_MaterialShaderError.Add(mat.name);
                            errorList_MaterialShaderError.Add(strMsg);
                        }

                        continue;
                    }

#if UNITY_EDITOR
                    for (int innerIndex = 0; innerIndex < UnityEditor.ShaderUtil.GetPropertyCount(shader); ++innerIndex)
                    {
                        if (UnityEditor.ShaderUtil.GetPropertyType(shader, innerIndex) == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv)
                        {
                            string  propertyName = UnityEditor.ShaderUtil.GetPropertyName(shader, innerIndex);
                            Texture tex          = mat.GetTexture(propertyName);

                            if (tex != null)
                            {
                                if (tex.width > TextureLimit || tex.height > TextureLimit)
                                {
                                    string strMsg = string.Format("{0} 的SKYBOX贴图大小大于{1},建议缩小! 宽高: {2} {3} 贴图: {4} \n", prefabName, TextureLimit, tex.width, tex.height, tex.name);
                                    if (!errorSet_TextureLarge.Contains(tex.name))
                                    {
                                        errorSet_TextureLarge.Add(tex.name);
                                        errorList_TextureLarge.Add(strMsg);
                                    }
                                }

                                if (tex.width != tex.height || !GameDataCheckMan.IsPOT((uint)tex.width))
                                {
                                    string strMsg = string.Format("{0} 的SKYBOX贴图长宽不相等或不是2的n次幂,无法压缩,建议修改! 宽高: {1} {2} 贴图: {3} \n", prefabName, tex.width, tex.height, tex.name);
                                    if (!errorSet_TextureNPT.Contains(tex.name))
                                    {
                                        errorSet_TextureNPT.Add(tex.name);
                                        errorList_TextureNPT.Add(strMsg);
                                    }
                                }
                            }
                        }
                    }
#endif
                }
            }
        }

        //输出错误信息
        foreach (var str in errorList_MaterialMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderMissing)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_MaterialShaderError)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureLarge)
        {
            AddErrorString(shortName, str);
        }

        foreach (var str in errorList_TextureNPT)
        {
            AddErrorString(shortName, str);
        }

        yield return(null);
    }