IEnumerator ShowPictureSub(string path, bool assignPosition, Vector2 position, float scale, bool autoMatch) { Image image; if (_picture == null) { var go = new GameObject(); go.name = "Picture"; image = go.AddComponent <Image>(); _picture = go.transform as RectTransform; _picture.SetParent(SwitchTransform); _picture.localScale = Vector3.one; } else { image = _picture.GetComponent <Image>(); } if (assignPosition) { _picture.gameObject.SetActive(false); yield return(null); Sprite sprite = ResourceLoadUtils.Load <Sprite>(Path.Combine("Framework/Core/Tutorial/Display", path)); image.sprite = sprite; Vector2 spriteSize = new Vector2(sprite.texture.width * scale, sprite.texture.height * scale); if (autoMatch) { var oldSize = spriteSize; spriteSize = UIUtils.CalculateAutoMatchedSize(spriteSize); var anchorX = Mathf.Clamp01((position.x + spriteSize.x * .5f) / spriteSize.x); var adjust = UIUtils.CalculateAutoMatchedDeltaX() - (spriteSize.x - oldSize.x) * .5f; position.x -= (1f - anchorX * 2f) * adjust; } UIUtils.SetScreenPosition(ref _picture, GetCanvas(), position); _picture.sizeDelta = spriteSize; } _picture.gameObject.SetActive(true); EnableParentCanvasRaycaster(_picture); }