I have an existing menu that I want to move where the user clicked.
I have search the forums, and found some articles, but I can't seem to make any sense out of them.
Here is the code that is triggered when the user clicks. The TerrainConditionDropDown is a GameObject with the UISprite script.
public GameObject TerrainConditionDropDown;
Vector3 worldClickPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
TerrainConditionDropDown.transform.localPosition = TerrainConditionDropDown.transform.parent.InverseTransformPoint(worldClickPos);
By manually moving the TerrainConditionDropDown to a desired spot, the transform displayed in the inspector is (184,357,-4). When I click on the same desired spot, the above code is triggered, and the transform becomes (-4684, 674, -10799).
Multiple forum posts lead to this code fixing the problem, but I don't know what type of object widget represents.
widget.transform.localPosition = widget.transform.parent.InverseTransformPoint(worldPos);
Thanks