12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using LitJson;
- using ShadowStudio.Model;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- public class IconItem : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
- {
- public static Vector3 ItemPos;
- private ArtHandler handler;
- public ArtInfo info;
- private XRIcon icon;
- private Button icon3DBtn;
- private GameObject ChoiceBack;
- void Start()
- {
- ChoiceBack = transform.Find("Root/ChoiceBack").gameObject;
- }
- void Update()
- {
- timeAllClick = timeAllClick + Time.deltaTime;
- }
- public void Init(ArtInfo artInfo)
- {
- this.info = artInfo;
- icon = transform.Find("Root/UIRoot/XRIcon").GetComponent<XRIcon>();
- icon3DBtn = GetComponent<Button>();
- //icon3DBtn.onClick.AddListener(OnClick);
- handler = ArtInfoMgr.Instance.CreateArtHandler(info);
- var sprite = handler.GetIcon();
- if (sprite)
- {
- icon.icon = sprite as Texture2D;
- icon.AutoSetSprite();
- }
- else
- {
- handler.GetIcon((tex) =>
- {
- sprite = tex;
- if (sprite)
- {
- icon.icon = sprite as Texture2D;
- icon.AutoSetSprite();
- }
- });
- }
- //print(artInfo.ArtName+"--"+sprite);
- }
- private void OnClick()
- {
- }
- private void HeidBack()
- {
- ChoiceBack.SetActive(false);
- }
- private float timeClick;
- private float timeAllClick;
- public void OnPointerDown(PointerEventData eventData)
- {
- timeAllClick = Time.deltaTime;
- timeClick = Time.deltaTime;
- }
- public void OnPointerUp(PointerEventData eventData)
- {
- }
- public void OnPointerClick(PointerEventData eventData)
- {
- if ((timeAllClick - timeClick) < 0.2f)
- {
- IconItem.ItemPos = this.transform.position;
- WSHandler.Room.CreateGood(info.AID,info.ArtId, info.ArtName, UnityUtil.ArtTransferInfo(info), "", ShowViewMgr.Instance.roomId);
- ChoiceBack.SetActive(true);
- Invoke("HeidBack", 0.2f);
- }
- }
- }
|