52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
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<Sprite> obj)
|
|
{
|
|
if (parent == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var o = GameObject.Instantiate(this.prefab, parent);
|
|
Set(o.GetComponent<Image>(), obj[0]);
|
|
o.GetComponent<RectTransform>().sizeDelta = GetComponent<RectTransform>().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<RectTransform>();
|
|
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);
|
|
}
|
|
}
|
|
} |