Drag object in Unity 2D

后端 未结 2 1720

I have looked for an object dragging script for Unity 2D. I have found a good method on the internet, but it seems it\'s just working in Unity 3D. It\'s not good for me as I\'m

2条回答
  •  死守一世寂寞
    2021-02-07 12:22

    You're almost there.

    Change the RequireComponent line in your code to:

    [RequireComponent(typeof(BoxCollider2D))]
    

    And add a BoxCollider2D component to the object to which you add your script. I just tested it and it works fine.

提交回复
热议问题