// registered with UIWidget.onChange in OnEnable() method
void OnDimensionsChanged() {
// this is an attempt to sort out problems with the window not being
// visible for various reasons:
// - resolution changes, the we restore the window to place not visible
// - or upgrade problems (like making min size bigger than currently
// saved prefs
Bounds contentBounds = GetContentRectBounds(selectorWindow);
uiPanel.ConstrainTargetToBounds(selectorWindow.transform, ref contentBounds, true);
this.SaveToPrefs();
}
// copied from UIDragObject.UpdateBounds()
public Bounds GetContentRectBounds(UIRect content){
Matrix4x4 toLocal = uiPanel.transform.worldToLocalMatrix;
Vector3[] corners = content.worldCorners;
for (int i = 0; i < 4; ++i) corners[i] = toLocal.MultiplyPoint3x4(corners[i]);
Bounds mBounds
= new Bounds
(corners
[0], Vector3
.zero); for (int i = 1; i < 4; ++i) mBounds.Encapsulate(corners[i]);
return mBounds;
}