How to get a real time position of an instantiated object?

For example, I have a RectTransform UI element moving about the screen. Inside its script, there is a position condition to trigger an event at a certain position. How do I do that inside the script?

Hello.

Its simple, when you instantiate an object, you can simply instantiate it, or Instantiate at same time you store that object as a variable, so you can “manipulate” that object. Like this:

GameObject InstantiatedObject;
GameObject PrefabToInstantiate;

InstantiatedObject = Instantiate(PrefabToInstantiate, position, rotation);

Now, you have the instantiated object stored as InstantiatedObject variable, so you can just check its position, change it, or do anything you want like any other gameobject. As its a CAnvas element, it does not have transform, it have RectTransfrom, so read the manual about this component for more information. The position is the anchoredPosition value, you can check it like this:

if (InstantiatedObject.GetComponent<RectTransform>().anchoredPosition.x >= 3.2f)
{
something
}

Bye!