public void Setup(Displayable newData) { displayableData = newData; name = displayableData.name; imageRect.SetPivotAndAnchors(new Vector2(0.5f, 0.5f)); imageRect.SetSize(newData.canvasSize); var spriteMappers = displayableData.spriteMappers; foreach (var spriteMap in spriteMappers) { var imageInstance = new GameObject(spriteMap.sprite.name).AddComponent <Image>(); imageInstance.transform.SetParent(transform); imageInstance.transform.localScale = Vector3.one; imageInstance.sprite = spriteMap.sprite; // LEFT TOP imageInstance.rectTransform.SetPivot(PivotPresets.TopLeft); imageInstance.rectTransform.SetAnchor(AnchorPresets.BottomLeft, spriteMap.pos.x + displayableData.offset.x, displayableData.canvasSize.y - spriteMap.pos.y + displayableData.offset.y); imageInstance.rectTransform.SetSize(spriteMap.size); childRects.Add(imageInstance.rectTransform); // 마지막으로, 홀더의 크기에 자동 스트레치 되도록 변경 //imageInstance.rectTransform.SetAnchor(AnchorPresets.StretchAll); //imageInstance.anchor } }
public void Show(Displayable displayable) { // 만약 이미 같은 이름의 디스플레이어블이 그려져 있다면 if (images.ContainsKey(displayable.name)) { ReplaceImage(displayable); } else // 같은 이름의 디스플레이어블이 없다면 { AddImage(displayable); } }
private void ReplaceImage(Displayable displayable) { // prevImage is not inserted into images list. var prevImage = Instantiate(images[displayable.name], displayablesHolder); prevImage.name += "_prev"; // Replace sprite in existing image component. images[displayable.name].sprite = displayable.mergedSprite; StartCoroutine("DissolveOutAndDestroy", prevImage); StartCoroutine("DissolveIn", images[displayable.name]); }
private void ReplaceImage(Displayable displayable) { // prevImage is not inserted into images list. var prevImage = Instantiate(displayableImages[displayable.tag], displayablesHolder); prevImage.name += "_prev"; //prevImage.transform.position = images[displayable.tag].transform.position; // Replace sprite in existing image component. displayableImages[displayable.tag].ChangeDisplayable(displayable); StartCoroutine(DissolveOutAndDestroy(prevImage, null)); StartCoroutine(DissolveIn(displayableImages[displayable.tag])); }
public virtual void Show(Displayable displayable) { if (displayable == null) { Debug.LogError("Show Displayable Error: Null displayable"); } else { // 만약 이미 같은 이름의 디스플레이어블이 그려져 있다면 if (displayableImages.ContainsKey(displayable.tag)) ReplaceImage(displayable); else // 같은 이름의 디스플레이어블이 없다면 AddImage(displayable); } }
public void ChangeDisplayable(Displayable newData) { // Clear while (childRects.Count > 0) { var childRect = childRects[0]; childRects.RemoveAt(0); Destroy(childRect.gameObject); } Setup(newData); //size = oldSize; }
private void AddImage(Displayable displayable) { var displayableImage = Instantiate(displayableImagePrefab); displayableImage.transform.SetParent(displayablesHolder); displayableImage.transform.localScale = Vector3.one; displayableImage.Setup(displayable); displayableImages.Add(displayable.tag, displayableImage); UpdateDisplayablePivot(displayable.tag, PivotPresets.MiddleCenter); UpdateDisplayableAnchor(displayable.tag, AnchorPresets.MiddleCenter); UpdateDisplayablePosition(displayable.tag, Vector2.zero); StartCoroutine("DissolveIn", displayableImage); }
private void AddImage(Displayable displayable) { var image = new GameObject(displayable.name).AddComponent <Image>(); image.sprite = displayable.mergedSprite; image.transform.SetParent(displayablesHolder); image.transform.localScale = Vector3.one; image.rectTransform.SetSize(displayable.size); image.rectTransform.anchoredPosition = Vector2.zero; image.preserveAspect = true; images.Add(displayable.name, image); StartCoroutine("DissolveIn", image); }
public VNShow(Displayable displayable_) { displayable = displayable_; }
public VNBackground(Displayable displayable_) { displayable = displayable_; }