1
\$\begingroup\$

This question might sound a bit stupid and I'm sure there is a simple solution for this .. I'm just not finding it:

Actually all I want to do is attach the MeshRenderer Component of this Object MeshRenderer Component of Object B

to a variable of a script on another Object like Script Component of Object A

Problem: As soon as you click on the Capsule Object ofcourse the Inspector changes to this Object and I cannot drag in a component to the previous selected Object anymore.

I know there are a lot alternatives like linkin only the GameObject e.g. as MeshObject and later in code refer to MeshObject.GetComponent<MeshRenderer> but I wondered if this can be done directly, too.

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

I'm glad you solved your problem!

Two other solutions you can use:

  1. If the component you want to assign is the only one of its type on its GameObject:

    • Select the object with your recipient script (Custom Network Transform in this case)

    • In the hierarchy view, click and drag the GameObject with the component you want to assign, dropping it on the recipient field.

    • Unity will automatically select the first Component on the dragged object that matches the type of the field.

  2. If there are multiple components of the same type on the source object, and you want to select a specific one:

    • Right click on the tab at the top of the inspector and choose Add Tab -> Inspector

    • Now you have two inspector tabs! Drag one out / dock it elsewhere so you can see both inspectors at once.

    • Select your source object, and both inspectors will show you its components

    • At the top-right of the inspector, you'll see a little lock icon. Click this on one of the inspectors to change it to its locked state.

    • Now select your recipient object. The unlocked inspector will update to show its components, while the locked inspector keeps showing the source object's components.

    • Now you can drag components / references between the two objects.

\$\endgroup\$
1
  • \$\begingroup\$ Hey nice! I didn't know both of your suggestions. Especially the first one is exactly what I was struggling with. \$\endgroup\$
    – derHugo
    Nov 7, 2017 at 16:33
1
\$\begingroup\$

Ok never mind just found it.

Click on the little circle next to the variable - it allows you to browse through all type-matching elements that exist in your scene/assets.

On this way I also learned that it makes sence to give also MeshObjects reasonable names ;)

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .