Bug: Cannot select Rigidbody2D prefab for public class (C#)

Hi,

I believe there is a bug in Unity at the moment. I’m using version 4.3.1f.

At the moment it is not possible to select any Prefab with Rigidbody2D applied to it, through the editor, when you are trying to link the object to a public class in a script.

To elaborate; I have a C# script with a public class:

public Rigidbody2D nameofobject;

I have a prefab within Unity which I want to use. In the Inspector panel I locate the script component, click on the small circle to see the list of valid Rigidbody2D items that can be applied and the editor is empty.

I downloaded the example 2D platformer project from Unity and the same issue exists. If you open up the Gun and go to the field where they have the rocket assigned to the gun as a Rigidbody2D prefab. Clicking on that will show an empty editor window and if you select None, then you cannot reassign the prefab to the script component. It doesn’t work.

To show you what I mean:

Either I am doing something wrong with the class call, which I doubt since it’s exactly the same as in the example from Unity, or it would seem this is bugged. If anyone could confirm this, that would be great.

I think this was working in 4.3 as I was previously able to assign the prefab. After upgrading to 4.3.1f I started getting a “Object reference not set to an instance of an object”, which was strange since the prefab would appear in the scene when Instantiated. I changed the class to gameObject, which worked, but changing back to Rigidbody2D I was no longer able to select any prefabs.

Sorry if this is something trivial on my end. Thanks.

I’m just getting into Unity/C# because of the new 2D stuff and this is also confusing the hell outta me. Trying to set up my own prefab bullets (based on the rockets) but cant link the reference variable in the same way as the demo.

I can make bombs fire from the gun with GameObject vars and then casting (GameObject)Instantiate when I make one.
But I cant link to the " rocket/bullet(Rigidbody 2D) " like the demo :face_with_spiral_eyes:

The only way around this that I’ve found is to go into the C# script in which you are Instantiating the projectile, setting the public variable to a gameObject. Then in the editor, to to the inspector and find the script component. You will be able to select the Rigidbody2D prefab as a normal gameObject. Then go back into the script and change the public variable back to a Rigidbody2D. The prefab will remain selected and then your reference to the Rigidbody2D will work.

I still have the same problem. The above mentioned solutions don’t work. In fact, when I unlink the rocket RigidBody 2D from the gun, I can’t relink them in the demo project itself.