Hello there, i want to create a field in a custom inspector where i can assign a rigidbody but i get an error in this code:
public override void OnInspectorGUI() {
base.OnInspectorGUI();
var myScript = target as Grabable;
if(myScript.grabType == Grabable.GRAB_TYPE.FORCE) {
myScript.connectedRigidBody = EditorGUILayout.ObjectField("Connected Rigidbody",
myScript.connectedRigidBody, typeof(Rigidbody), true);
}
}
Error: “Cannot convert type UnityEngine.Object to UnityEngine.Rigidbody - are you missing a cast?”
How can i actually assign a rigidbody there? Casting the Rigidbody into a UnityEngine.Object is redundant (says Unity),
Greets