37 lines
851 B
C#
37 lines
851 B
C#
|
using System;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace FUJIFILM
|
|||
|
{
|
|||
|
public class GenSticker : MonoBehaviour
|
|||
|
{
|
|||
|
public Transform parent;
|
|||
|
public GameObject prefab;
|
|||
|
public Button btnGen;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
btnGen = GetComponent<Button>();
|
|||
|
Init();
|
|||
|
}
|
|||
|
|
|||
|
public virtual void Init()
|
|||
|
{
|
|||
|
btnGen.onClick.AddListener(Gen);
|
|||
|
}
|
|||
|
|
|||
|
private void Gen()
|
|||
|
{
|
|||
|
if (parent == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var o = GameObject.Instantiate(this.prefab, parent);
|
|||
|
o.GetComponent<Image>().sprite = GetComponent<Image>().sprite;
|
|||
|
o.GetComponent<RectTransform>().sizeDelta = GetComponent<RectTransform>().sizeDelta;
|
|||
|
o.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|