public void Generate() { Cleanup(); Initialize(); name = GuideData.Name; // guide hand. guideHandeController = Instantiate(Resources.Load <GameObject>(GuideHand), guideInstance.transform, false).GetComponent <GuideHandController>(); guideHandeController.Data = GuideData.Hand; guideHandeController.FlushDataToUI(); guideHandeController.Animate(); // guide window. guideWindow = Instantiate(Resources.Load <GameObject>(GuideWindow), guideInstance.transform, false).GetComponent <GuideWindowController>(); guideWindow.Data = GuideData.Window; guideWindow.FlushDataToUI(); // guide items. GuideData.ItemList.ForEach(item => { var rect = Instantiate(Resources.Load <GameObject>(GuideImage), guideInstance.transform, false).GetComponent <RectTransform>(); rect.anchorMin = new Vector2(item.AnchorMin.X, item.AnchorMin.Y); rect.anchorMax = new Vector2(item.AnchorMax.X, item.AnchorMax.Y); rect.pivot = new Vector2(item.Pivot.X, item.Pivot.Y); rect.anchoredPosition = new Vector3(item.AnchorPosition.X, item.AnchorPosition.Y, item.AnchorPosition.Z); rect.sizeDelta = new Vector3(item.Size.X, item.Size.Y, item.Size.Z); rect.name = item.ObjectName; // normalize rect into normal space. var rectNormal = Instantiate(Resources.Load <GameObject>(GuideImage), guideInstance.transform, false).GetComponent <RectTransform>(); rectNormal.sizeDelta = rect.sizeDelta; rectNormal.localPosition = rect.localPosition; item.AnchorMin = item.AnchorMax = item.Pivot = new Position(0.5f, 0.5f, 0); item.AnchorPosition = new Position(rectNormal.anchoredPosition.x, rectNormal.anchoredPosition.y, 0); item.Size = new Position(rectNormal.sizeDelta.x, rectNormal.sizeDelta.y, 0); rect.gameObject.SetActive(false); rectNormal.gameObject.SetActive(false); }); CleanupMask(); var mask0 = Instantiate(Resources.Load <RectTransform>(GuideMask), maskContainer).GetComponent <RectTransform>(); mask0.anchoredPosition = Vector2.zero; mask0.name = mask0.name + "_0"; mask0.sizeDelta = maskContainer.GetComponent <RectTransform>().rect.size; GenerateMask(mask0); }
void Initialize() { imageContainer = transform.Find("ImageContainer"); ImageList.Clear(); for (var i = 0; i < imageContainer.childCount; ++i) { ImageList.Add(imageContainer.GetChild(i).GetComponent <RectTransform>()); } guideMaskContainer = transform.Find("GuideMask"); guideHandController = transform.Find("GuideHand").GetComponent <GuideHandController>(); guideImage = transform.Find("GuideImage"); guideWindow = transform.Find("GuideWindow").GetComponent <GuideWindowController>(); }