Code is not working

My code look like :

public void Assign(){
		inv = GameObject.Find ("Inventory").GetComponent<InventorySystem> ();
		uimanager = GameObject.Find ("GameUIManager").GetComponent<GameUIManager> ();
		if (!inv.equipment *.itemName.Equals("")) {*

_ print (inv.equipment .itemName);_
_ item = inv.equipment ;
* GetComponent ().sprite = item.itemIcon;
}
}*_

And when i call Assign() it tells that inv is not assignet in if (inv.equipment .itemName != “”) and if i go to inspector it is really not asigned, but it should be becouse it is beeing assigned before if. What wrong with it?

GameObject.Find doesn’t guarantee that it will return something. Neither does GetComponent. If there isn’t a GameObject with the name of “Inventory” in your scene, GameObject.Find will return null.

Because you don’t get an error on that line, I’m guessing that there is a GameObject called “Inventory” but that it doesn’t have a Component of type InventorySystem. The same problem could present itself with GameUIManager. I’d double check that these exist in your scene first.