I am instantiating objects when I press ui-buttons. I want to move them around until as I click again, but unfortunalty because of pressing the ui-button it releases it instantly. Even if I set a bool flag to check on the next Frame it dont work.
void Update () {
if(currentObj)
MoveObject();
}
void MoveObject(){
//Movement
currentObj.position = Input.mousePosition;
if(instantiated){ //Check on next frame to avoid instant placing
if(Input.GetMouseButtonDown(0))
currentObj = null;//Release it
} else
instantiated = true;
}
public void InstantiateObj(string obj){
instantiated = false;
currentObj = Instantiate(Resources.Load(obj), Vector3.zero, Quaternion.identity) as Transform;
}