-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtageUguiCgGalleryViewer.cs
131 lines (118 loc) · 3.49 KB
/
UtageUguiCgGalleryViewer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Utage;
[AddComponentMenu("Utage/TemplateUI/CgGalleryViewer")]
public class UtageUguiCgGalleryViewer : UguiView, IPointerClickHandler, IDragHandler, IPointerDownHandler, IEventSystemHandler
{
private int currentIndex;
private AdvCgGalleryData data;
[SerializeField]
private AdvEngine engine;
public UtageUguiGallery gallery;
private bool isEnableClick;
private bool isLoadEnd;
[SerializeField]
private UnityEngine.UI.ScrollRect scrollRect;
private Vector3 startContentPosition;
public AdvUguiLoadGraphicFile texture;
private void Awake()
{
this.texture.OnLoadEnd.AddListener(new UnityAction(this, (IntPtr) this.OnLoadEnd));
}
private void LoadCurrentTexture()
{
this.isLoadEnd = false;
this.isEnableClick = false;
this.ScrollRect.set_enabled(false);
this.ScrollRect.get_content().set_localPosition(this.startContentPosition);
AdvTextureSettingData dataOpened = this.data.GetDataOpened(this.currentIndex);
this.texture.LoadFile(this.Engine.DataManager.SettingDataManager.TextureSetting.LabelToGraphic(dataOpened.Key).Main);
}
private void OnClose()
{
this.ScrollRect.get_content().set_localPosition(this.startContentPosition);
this.texture.ClearFile();
this.gallery.WakeUp();
}
public void OnDrag(PointerEventData eventData)
{
this.isEnableClick = false;
}
private void OnLoadEnd()
{
this.isLoadEnd = true;
this.isEnableClick = false;
this.ScrollRect.set_enabled(true);
}
public void OnPointerClick(PointerEventData eventData)
{
if (this.isEnableClick)
{
this.currentIndex++;
if (this.currentIndex >= this.data.NumOpen)
{
this.Back();
}
else
{
this.LoadCurrentTexture();
}
}
}
public void OnPointerDown(PointerEventData eventData)
{
if (this.isLoadEnd)
{
this.isEnableClick = true;
}
}
public void Open(AdvCgGalleryData data)
{
this.gallery.Sleep();
this.Open();
this.data = data;
this.currentIndex = 0;
this.startContentPosition = this.ScrollRect.get_content().get_localPosition();
this.LoadCurrentTexture();
}
private void Update()
{
if (InputUtil.IsMouseRightButtonDown())
{
this.Back();
}
}
public AdvEngine Engine
{
get
{
if (this.engine == null)
{
}
return (this.engine = Object.FindObjectOfType<AdvEngine>());
}
}
public UnityEngine.UI.ScrollRect ScrollRect
{
get
{
if (this.scrollRect == null)
{
this.scrollRect = base.GetComponent<UnityEngine.UI.ScrollRect>();
if (this.scrollRect == null)
{
this.scrollRect = base.get_gameObject().AddComponent<UnityEngine.UI.ScrollRect>();
this.scrollRect.set_movementType(2);
}
if (this.scrollRect.get_content() == null)
{
this.scrollRect.set_content(this.texture.get_transform() as RectTransform);
}
}
return this.scrollRect;
}
}
}