using System; using System.Collections; using System.Collections.Generic; using HK.Tool; using UnityEngine; using UnityEngine.UI; namespace FUJIFILM { public class GenSticker_Upload : GenSticker { private void OnEnable() { btnGen.onClick.RemoveAllListeners(); btnGen.onClick.AddListener(GenS); } private void GenS() { UploadPhotoPage.instance.UploadCallbackAction += Finish; UploadPhotoPage.instance.OpenBeamer(); } private void Finish(List obj) { if (parent == null) { return; } var o = GameObject.Instantiate(this.prefab, parent); Set(o.GetComponent(), obj[0]); o.GetComponent().sizeDelta = GetComponent().sizeDelta; o.SetActive(true); } void Set(Image image, Sprite sprite) { image.sprite = sprite; var f = image.sprite.rect.width < image.sprite.rect.height ? image.sprite.rect.width : image.sprite.rect.height; var parentRect = image.transform.parent.GetComponent(); var parentF = parentRect.rect.width < parentRect.rect.height ? parentRect.rect.width : parentRect.rect.height; var f1 = parentF / f; image.rectTransform.sizeDelta = new Vector2(image.sprite.rect.width * f1, image.sprite.rect.height * f1); } } }