- Home /
Press button on canvas to transform prefab clone?
I have a button on my canvas that I set to the following method on a prefab:
public void PressRight ()
{
transform.position += new Vector3(1, 0, 0);
print("lines");
if (isValidPosition())
GridUpdate();
else
transform.position += new Vector3(-1, 0, 0);
}
However the instantiated clones do not transform. "lines" is printed to the console but the object does not move. Anyone have any ideas as to why?
Comment
What does isValidPosition() return? If it's false, it will execute a movement of -1 along the X - so it would appear there is no movement. (+1 - 1 = 0)
Also, depends on the scale of your scene - moving an object 1 unit might be insignificant.
It returns true. The scale is rather small so it would be shown. This methods work when I use it with arrow keys from a separate part of the script but not on canvas buttons, so I'm confused as to why it works one place but not the other.