Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question how to drag and drop a specific component?

Discussion in 'Editor & General Support' started by mellowVtuber, Mar 4, 2021.

  1. mellowVtuber

    mellowVtuber

    Joined:
    Feb 15, 2021
    Posts:
    27
    i have a public field in my script for Component. and in the editor i want to set it to a component on another gameobject. can i do this?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,888
    Edit - Update 11/7/23 as of recent Unity versions you can now right click on any GameObject and select "Properties" from the context menu to get a permanent inspector window just for that specific object, which is a lot easier than the process outlined below.

    Yep you can do this.

    A little preparation. First, click the padlock in the top right of the inspector to lock it showing the script you want to add your component to. Then right click the tab and select Add Tab -> Inspector.

    upload_2021-3-4_21-13-20.png

    This will open a second inspector window, which can separately be unlocked and dragged to a different part of your screen. Now find and select the GameObject containing the component you want to drag from the hierarchy. Finally you can directly drag the component by its title bar from one inspector window into the slot on the first locked window
     
    Last edited: Nov 7, 2023
  3. mellowVtuber

    mellowVtuber

    Joined:
    Feb 15, 2021
    Posts:
    27
    thanks