c# - Create object by drag and drop at runtime in unity -


i have create object dragging button @ run time. have searched lot still can't find solution.

i creating object clicking button using following sample code. have drag , drop.

my code is:

using unityengine; using system.collections;  public class createsphere : monobehaviour {  public void onclick() {     gameobject sphere = gameobject.createprimitive (primitivetype.sphere);     sphere.transform.localscale = new vector3(3.0f, 3.0f, 1.0f) ;     //transform.translate(0, 0, time.deltatime);     sphere.transform.position = new vector3 (4, 0, 0);  } } 

onclick not dragging, click. drag need have drag handlers

using unityengine; using unityengine.gui; using unityengine.eventsystems; using system.collections;  public class createsphere : monobehaviour, ibegindraghandler, idraghandler {      gameobject sphere;      public void onbegindrag(pointereventdata data)     {         // begin dragging logic goes here          sphere = gameobject.createprimitive (primitivetype.sphere);     }      public void ondrag(pointereventdata data)     {         // dragging logic goes here          sphere.transform.localscale = new vector3(3.0f, 3.0f, 1.0f) ;         //transform.translate(0, 0, time.deltatime);         sphere.transform.position = new vector3 (4, 0, 0);     } } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -