using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XRTool.Util;
using XRTool.WorldUI;
namespace ShadowStudio.Model
{
///
/// 图片组件
///
public class PictureComponent : UIComponent
{
private XRIcon xrIcon;
///
/// 图片
///
public XRIcon XrIcon
{
get
{
if (!xrIcon)
{
xrIcon = GetComponent();
}
return xrIcon;
}
}
///
/// 设置组件
///
///
///
///
public override void SetContainer(ArtContainerHandler artContainer, UnityEngine.Object art, ArtInfo info)
{
base.SetContainer(artContainer, art, info);
print(art);
if (art is Texture2D || art is Sprite||art is Texture)
{
Sprite sprite = null;
if (art is Sprite)
{
sprite = art as Sprite;
}
Texture2D img = art as Texture2D;
Vector2 size = Vector2.zero;
if (img)
{
size.x = img.width;
size.y = img.height;
}
if (sprite)
{
size.x = sprite.texture.width;
size.y = sprite.texture.height;
}
while (size.magnitude > 2000)
{
size /= 2;
}
while (size.magnitude < 100)
{
size *= 2;
}
if (DlgContainer && DlgContainer.Dlg)
{
DlgContainer.Dlg.DlgTrans.sizeDelta = size;
DlgContainer.Dlg.SetScale(size, 1);
if (DlgContainer.Transfer && DlgContainer.Transfer.IsInit)
{
DlgContainer.Transfer.RemoveBound();
//DlgContainer.Transfer.RemoveBound();
TimerMgr.Instance.CreateTimer(() => { DlgContainer.Transfer.IsDragEnable = false; }, 0);
}
//TimerMgr.Instance.CreateTimer(() =>
//{
// DlgContainer.Transfer.RemoveBound();
//}, 0);
//TimerMgr.Instance.CreateTimer(() =>
//{
// DlgContainer.Transfer.IsDragEnable = false;
//}, 0.01f);
//DlgContainer.Transfer.RemoveBound();
//TimerMgr.Instance.CreateTimer(() => { DlgContainer.Transfer.IsDragEnable = false; }, 0.01f);
}
if (XrIcon)
{
XrIcon.rectTransform.offsetMax = Vector2.zero;
XrIcon.rectTransform.offsetMin = Vector2.zero;
if (sprite)
{
XrIcon.AutoSetSprite(sprite);
}
else if (img)
{
XrIcon.AutoSetSprite(img);
}
}
}
}
}
}