Moving UI Element with Code not working


I’m currently attempting to move a UI element via code, however it refuses to actually move. Basically, I have a set of ui elements that appear to indicate parts of a queue. Each of these is basically an image with another fill image to show the progress of the item in the queue. Once the first is finished, it should destroy itself and then all the other items will move over a spot, so they don’t just get farther and farther away over time.

However, they won’t move. I’ve tried everything from a simple transform.position change, to using anchoredPosition and the position of the recttransform. but to no avail. I honestly am so lost as to why this doesn’t work, as I was able to move them in a different area of code with no issue. Through debugging I’ve determined that the function this movement is in is getting run, but the movement never happens.

This is the code for the movement itself:

public void moveBack() {

		Debug.Log("when ur code dont work like it used to");
		gameObject.transform.position = new Vector3 (gameObject.transform.position.x - 33, gameObject.transform.position.y, gameObject.transform.position.z);


This debug.log works, and I get the message in the console from it. This is called as a part of this during Update():

if (Queue.Count > 0 && offset == true) {

				foreach (GameObject q in Queue) {

					q.GetComponent<shipBuildController>().moveBack ();


				Queue.Remove (Queue [0]);
				offset = false;


But that movement that’s supposed to happen never happens. Any help would be much appreciated, as this has completely stumped me.

Well, I figured out my issue. Turns out I was trying to add the prefab to the queue, rather than the clones, so it wasn’t doing anything to the clones…