public static ModelObjectInfo Create(GameObject gobj)
        {
            MeshFilter          meshfilter       = gobj.GetComponent <MeshFilter>();
            SkinnedMeshRenderer skin_mesh_render = gobj.GetComponent <SkinnedMeshRenderer>();

            if (meshfilter == null && skin_mesh_render == null)
            {
                return(null);
            }

            ModelObjectInfo obj = new ModelObjectInfo();

            obj.tex_info_list = new List <TextureInfo>();
            if (skin_mesh_render != null)
            {
                obj.mesh_info.mesh    = skin_mesh_render.sharedMesh;
                obj.material_info.mat = skin_mesh_render.sharedMaterial;
            }
            else if (meshfilter != null)
            {
                obj.mesh_info.mesh = meshfilter.sharedMesh;
                MeshRenderer mesh_render = gobj.GetComponent <MeshRenderer>();
                if (mesh_render != null)
                {
                    obj.material_info.mat = mesh_render.sharedMaterial;
                }
            }

            if (obj.mesh_info.mesh != null)
            {
                obj.mesh_info.mesh_tris = obj.mesh_info.mesh.triangles.Length / 3;
                obj.mesh_info.mesh_size = (int)UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(obj.mesh_info.mesh);
            }

            if (obj.material_info.mat != null)
            {
                Texture[] tex_arr = EditorCommonTools.GetContainMaterialTextures(obj.material_info.mat);
                for (int i = 0; i < tex_arr.Length; i++)
                {
                    Texture     tex      = tex_arr[i];
                    TextureInfo tex_info = new TextureInfo();
                    tex_info.Init(tex);
                    obj.tex_info_list.Add(tex_info);
                }

                if (tex_arr.Length > 0)
                {
                    obj.material_info.has_tex = true;
                }
            }

            return(obj);
        }
        void RecursiveFind(GameObject gobj)
        {
            ParticleObjectInfo poi = ParticleObjectInfo.Create(gobj);
            ModelObjectInfo    moi = ModelObjectInfo.Create(gobj);

            if (poi != null)
            {
                single_particle_list.Add(poi);
                AddToList(poi.tex_info_list, poi.mesh_info, poi.material_info);
            }

            if (moi != null)
            {
                single_model_list.Add(moi);
                AddToList(moi.tex_info_list, moi.mesh_info, moi.material_info);
            }

            Transform tobj = gobj.transform;

            for (int i = 0; i < tobj.childCount; i++)
            {
                RecursiveFind(tobj.GetChild(i).gameObject);
            }
        }
Ejemplo n.º 3
0
 protected bool Equals(ModelObjectInfo other)
 {
     return(string.Equals(ObjectName, other.ObjectName) && string.Equals(MaterialName, other.MaterialName));
 }