SetAnchor should be immediate. Going through the order of calls, calling SetAnchor calls UpdateAnchors, which in turn calls OnAnchor, which is what calculates the widget's position, width and height.
UIWidget.worldCorners then uses those values, adjusting them by the widget's transform.
The only issue I see with your call is you're passing -18, -18, 18, 18 -- which I'm guessing are supposed to be absolute values... yet the function expects relative values instead (ie -1 to 1 range!)
I just tried this simple test:
1. New scene, ALT+SHIFT+S to make a sprite.
2. Game Object -> 3D Object -> Cube.
3. Attached this script to the cube and set the sprite reference on it:
using UnityEngine;
using TNet;
public class Test2 : MonoBehaviour
{
public UIWidget widget;
void Update ()
{
if (Input.GetKeyDown(KeyCode.S))
{
widget.SetAnchor(gameObject, 0f, -18, 0f, -18, 0f, 18, 0f, 18);
var corners = widget.worldCorners;
var cam = UICamera.FindCameraForLayer(widget.gameObject.layer);
var v0 = cam.cachedCamera.WorldToScreenPoint(corners[0]);
var v1 = cam.cachedCamera.WorldToScreenPoint(corners[2]);
Debug.Log(v0 + " " + v1);
}
}
}
4. Play, hit "S", see values show up correctly immediately, and the sprite gets positioned right in the middle of the cube.