Resources.load returns null

I’ve searched many other similar questions but none of the solutions to those helped me…

The problem is when i use Resources.load(“myResource”); it always returns null.

The code(C#):

public class Fuser : MonoBehaviour {

	public Mesh a;
	public Mesh b;
	public GameObject t;
	void Start () {
		a = Resources.Load("floor", typeof(Mesh)) as Mesh;
		b = Resources.Load("floor") as Mesh;
		//a.CombineMeshes(b);
		
		//MeshFilter[] meshFilters = GetComponentsInChildren(MeshFilter);
	    CombineInstance[] combine = new CombineInstance[2];
	    //for ( i = 0; i < 2; i++){
	        combine[0].mesh = a;
	        combine[0].transform = new Matrix4x4();
			combine[0].mesh = b;
			Matrix4x4 m = new Matrix4x4();
			m.SetTRS(new Vector3(0,2,0), Quaternion.identity, Vector3.up);
	        combine[0].transform = m;//new Vector3(0,2,0);//a.transform.localToWorldMatrix;
	        //meshFilters*.gameObject.active = false;*
  •  //}*
    
  •  t.GetComponent<MeshFilter>().mesh = new Mesh();*
    
  •  t.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);*
    
  •  //transform.gameObject.active = true;*
    
  • }*

  • // Update is called once per frame*

  • void Update () {*

  • }*
    }
    And the project structure:
    [6902-sem+título.png|6902]*

I have tried many different ways and names but none seems to work… I don’t know what i am doing wrong…

When meshes are imported into Unity, a game object is added for the root object and then one for each sub-mesh. In your case you are attempting to access the container object as opposed to the mesh.

You can use the following method to access the mesh(es) in your asset:

using System.Linq;

...

GameObject floorModel = Resources.Load(
    "floor", typeof(GameObject)
) as GameObject;

MeshFilter[] meshFilters =
    (MeshFilter[])floorModel.GetComponentsInChildren(
        typeof(MeshFilter)
    );

Mesh[] meshes = (Mesh[])meshFilters.Select(
    filter => filter.sharedMesh
);