Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MsgLine.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5public class MsgLine : MonoBehaviour
6{
7 public HorizontalLayoutGroup layout;
8
9 public RectTransform rect;
10
11 [NonSerialized]
13
15
16 private void Awake()
17 {
18 rect = this.Rect();
19 }
20
21 public void Append(string s, FontColor col)
22 {
23 UIText uIText = PoolManager.Spawn(prefabs.text, layout);
24 uIText.SetText(s, col);
25 uIText.RebuildLayout();
26 AddElement(uIText);
27 }
28
29 public void Append(Sprite s, bool fitLine = true)
30 {
31 Transform transform = PoolManager.Spawn(prefabs.image, layout);
32 Image componentInChildren = transform.GetComponentInChildren<Image>();
33 componentInChildren.sprite = s;
34 if (fitLine)
35 {
36 RectTransform rectTransform = transform.Rect();
37 rectTransform.sizeDelta = new Vector2(rect.sizeDelta.y, rect.sizeDelta.y);
38 componentInChildren.transform.Rect().sizeDelta = rectTransform.sizeDelta;
39 }
40 AddElement(transform);
41 }
42
43 private void AddElement(Component c)
44 {
45 if (rect.sizeDelta.x > block.box.maxWidth / 3f)
46 {
47 _ = rect.sizeDelta.x + c.Rect().sizeDelta.x;
48 _ = block.box.maxWidth;
49 }
50 }
51
52 private void AddElement(Component c, MsgLine line)
53 {
54 c.transform.SetParent(line.transform, worldPositionStays: false);
55 line.layout.RebuildLayout();
56 }
57
58 public void Reset()
59 {
60 for (int num = base.transform.childCount - 1; num >= 0; num--)
61 {
62 PoolManager.DespawnOrDestroy(base.transform.GetChild(num));
63 }
64 this.RebuildLayout();
65 }
66}
FontColor
Definition: FontColor.cs:2
MsgBox box
Definition: MsgBlock.cs:22
float maxWidth
Definition: MsgBox.cs:66
Prefabs prefabs
Definition: MsgBox.cs:31
void AddElement(Component c)
Definition: MsgLine.cs:43
RectTransform rect
Definition: MsgLine.cs:9
MsgBlock block
Definition: MsgLine.cs:12
void Awake()
Definition: MsgLine.cs:16
MsgBox.Prefabs prefabs
Definition: MsgLine.cs:14
void Append(Sprite s, bool fitLine=true)
Definition: MsgLine.cs:29
void Append(string s, FontColor col)
Definition: MsgLine.cs:21
void Reset()
Definition: MsgLine.cs:58
HorizontalLayoutGroup layout
Definition: MsgLine.cs:7
void AddElement(Component c, MsgLine line)
Definition: MsgLine.cs:52
static void DespawnOrDestroy(Component c)
Definition: PoolManager.cs:158
static Transform Spawn(string id, string path, Transform parent)
Definition: PoolManager.cs:86
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159