void Update() { if (UIParent == null) { return; } if (UIParent.position == oldPosition && UIParent.sizeDelta == oldSize) { return; } if (canvas == null) { canvas = GetTopmostCanvas(UIParent); } if (canvas == null) { return; } oldPosition = UIParent.position; oldSize = UIParent.sizeDelta; UIParent.GetWorldCorners(wc); Vector3 bl, tr; if (canvas.renderMode == RenderMode.ScreenSpaceCamera || canvas.renderMode == RenderMode.WorldSpace) { bl = RectTransformUtility.WorldToScreenPoint(canvas.worldCamera, wc[0]); tr = RectTransformUtility.WorldToScreenPoint(canvas.worldCamera, wc[2]); } else { bl = RectTransformUtility.WorldToScreenPoint(null, wc[0]); tr = RectTransformUtility.WorldToScreenPoint(null, wc[2]); } bl.x /= Screen.width; bl.y /= Screen.height; tr.x /= Screen.width; tr.y /= Screen.height; normalizedScreenRect = new Vector4(bl.x, bl.y, tr.x - bl.x, tr.y - bl.y); if (imagePlaceholder == null) { imagePlaceholder = UIParent.GetComponent <RawImage>(); } if (mapRenderer == null) { mapRenderer = map.GetComponent <Renderer>(); } if (imagePlaceholder != null) { if (Application.isPlaying) { if (imagePlaceholder.enabled) { imagePlaceholder.enabled = false; } } else { if (mapRenderer != null && imagePlaceholder.texture != mapRenderer.sharedMaterial.mainTexture) { imagePlaceholder.texture = mapRenderer.sharedMaterial.mainTexture; } } } }