private void SetWebView() { int uiFactor = UniWebViewHelper.RunningOnRetinaIOS() ? 2:1; UIRoot mRoot = NGUITools.FindInParents <UIRoot>(gameObject); float ratio = ((float)mRoot.activeHeight / Screen.height) * uiFactor; int width = Mathf.FloorToInt(Screen.width * ratio / uiFactor); int height = Mathf.FloorToInt(Screen.height * ratio / uiFactor); UISliceBackgroundPopup backgroundPopup = gameObject.GetComponentInChildren <UISliceBackgroundPopup>(); int webMarginWidth = Mathf.FloorToInt(width - (backgroundPopup.PopupWidth - 30f)); int webMarginHeight = Mathf.FloorToInt(height - (backgroundPopup.PopupHeight - 30f)); int leftRight = Mathf.FloorToInt(webMarginWidth / (2 * ratio)); int top = Mathf.RoundToInt(((webMarginHeight / 2) + backgroundPopup.buttonClose.GetComponentInChildren <UISprite>().height) / ratio); int bottom = Mathf.RoundToInt(webMarginHeight / (2 * ratio)); webView.insets = new UniWebViewEdgeInsets(top, leftRight, bottom, leftRight); }
public void OnEnable() { currentTarget = (UISliceBackgroundPopup)target; }