Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerImage.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3
4public class LayerImage : ELayer
5{
6 public Image image;
7
8 public Vector2 margin;
9
10 private float zoom = 1f;
11
12 public void SetImage(Sprite sprite)
13 {
14 image.sprite = sprite;
15 image.SetNativeSize();
16 float num = ((float)Screen.height - margin.y) / ELayer.core.uiScale;
17 RectTransform rectTransform = image.rectTransform;
18 float num2 = rectTransform.sizeDelta.y;
19 if (num2 > num)
20 {
21 num2 = num;
22 }
23 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, num2);
24 Zoom(0f);
25 }
26
27 public override void OnUpdateInput()
28 {
29 if (EInput.wheel != 0)
30 {
31 Zoom((EInput.wheel > 0) ? 0.25f : (-0.25f));
32 }
34 {
35 image.SetNativeSize();
36 zoom = 1f;
37 Zoom(0f);
38 }
39 }
40
41 public void Zoom(float a)
42 {
43 zoom += a;
44 if (zoom < 0.5f)
45 {
46 zoom = 0.5f;
47 }
48 if (zoom > 2f)
49 {
50 zoom = 2f;
51 }
52 image.rectTransform.localScale = new Vector3(zoom, zoom, zoom);
53 }
54
55 public override void OnKill()
56 {
57 EInput.Consume(2);
58 }
59}
bool clicked
Definition: ButtonState.cs:37
override float uiScale
Definition: Core.cs:95
Definition: EInput.cs:8
static int wheel
Definition: EInput.cs:289
static ButtonState middleMouse
Definition: EInput.cs:353
static void Consume(int _skipFrame)
Definition: EInput.cs:656
Definition: ELayer.cs:4
static Core core
Definition: ELayer.cs:7
Image image
Definition: LayerImage.cs:6
override void OnKill()
Definition: LayerImage.cs:55
float zoom
Definition: LayerImage.cs:10
override void OnUpdateInput()
Definition: LayerImage.cs:27
void Zoom(float a)
Definition: LayerImage.cs:41
Vector2 margin
Definition: LayerImage.cs:8
void SetImage(Sprite sprite)
Definition: LayerImage.cs:12