Advertisemen
Hello guys, today I am going to show you how to make click on individual object and drag it to wherever you want in unity 3d in a very simple way.
I hope that all you guys know basic of unity 3d.
Let's get started, first of all create plane from GameObject > Plane to use as background so we can our objects when we are dragging it and change its colour to whatever you want but make sure it is different then other objects.
Ok lets create cube in the scene from GameObject > Cube so we can drag it around the scene. And if you want change the colour.
ps://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR3mb2cjtFHwmC1l6i1ehibt-PuDqf3R6Nu7gtPt4DDsNv_WyepkFddxDgBbdlvjKazrn-UzEghnVWCmKLEJH_X8w4HVV6RNtQ2nI8kkce55cdnKuq-v0WtzeN0VTqM6GKa_8EpkbCQCUH/s1600/Screen+Shot+2013-11-23+at+1.37.02+pm.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;">
Now create one C# script from project panel, create > C# script and open with monodevelop or whatever script editor you are using. Then type the following.
wallaaa, now you can drag and move around your object wherever you want. If want to see that you can drag individually or not just create another cube and attach the script and hit play. And enjoy your drag and drop.......

After that attach the script to the cube we created before and hit play.
wallaaa, now you can drag and move around your object wherever you want. If want to see that you can drag individually or not just create another cube and attach the script and hit play. And enjoy your drag and drop.......
Advertisemen
Tidak ada komentar:
Posting Komentar