OnPostprocessModel and GameObject.Find()

I have two objects:

  • objectA.FBX loaded in a scene as objectA
  • objectB.FBX loaded in a scene as objectB

I created a post processor for objectA to automatically link the objectB to a custom script created and linked to objectA

	void OnPostprocessModel (GameObject gameObject) {
		if (gameObject.transform.name == "objectA") {
			MyScript myScript = gameObject.AddComponent<MyScript>();
			myScript.property1 = GameObject.Find("objectB");
		}
	}

When running the debugger, I can see that property1 is correctly assigned to the objectB instance after re-importing objectA but nothing is assigned in the Unity Inspector value named “Property1”: None (Game Object).

Why the value is not stored by the Inspector ?

Are you setting the object as dirty? http://docs.unity3d.com/Documentation/ScriptReference/EditorUtility.SetDirty.html