void LoadGuideData() { guideHandController.Data = data.Hand; guideHandController.FlushDataToUI(); guideWindow.Data = data.Window; guideWindow.FlushDataToUI(); CleanupImage(); ImageList.Clear(); ImageList.AddRange(data.ItemList.Select(item => { var rect = Instantiate(guideImage.gameObject, imageContainer).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; return(rect); })); ConditionList.Clear(); ConditionList.AddRange(data.ConditionList); }
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); }