Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
InnerOutline.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.UI;
4
5[AddComponentMenu("UI/ToJ Effects/Inner Outline", 20)]
6[DisallowMultipleComponent]
7[RequireComponent(typeof(Text))]
8public class InnerOutline : BaseMeshEffect, IMaterialModifier
9{
10 public enum ColorMode
11 {
15 }
16
17 [SerializeField]
19
20 [SerializeField]
21 public Color m_OutlineColor = Color.black;
22
23 [SerializeField]
24 private float m_OutlineThickness = 1f;
25
27
29
30 private List<UIVertex> m_Verts = new List<UIVertex>();
31
33 {
34 get
35 {
36 return m_ColorMode;
37 }
38 set
39 {
40 m_ColorMode = value;
41 if (base.graphic != null)
42 {
43 base.graphic.SetVerticesDirty();
44 }
45 }
46 }
47
49 {
50 get
51 {
52 return m_OutlineColor;
53 }
54 set
55 {
56 m_OutlineColor = value;
57 if (base.graphic != null)
58 {
59 base.graphic.SetVerticesDirty();
60 }
61 }
62 }
63
64 public float outlineThickness
65 {
66 get
67 {
68 return m_OutlineThickness;
69 }
70 set
71 {
72 m_OutlineThickness = value;
73 if (base.graphic != null)
74 {
75 base.graphic.SetVerticesDirty();
76 }
77 }
78 }
79
80 protected InnerOutline()
81 {
82 }
83
84 protected override void Start()
85 {
86 if (base.graphic != null)
87 {
88 base.graphic.SetMaterialDirty();
89 }
90 }
91
92 public override void ModifyMesh(VertexHelper vh)
93 {
94 if (!IsActive())
95 {
96 return;
97 }
98 vh.GetUIVertexStream(m_Verts);
99 int count = m_Verts.Count;
100 for (int i = 0; i < count; i++)
101 {
102 UIVertex value = m_Verts[i];
103 if (value.uv1 == Vector4.zero)
104 {
105 value.uv1 = new Vector2(1f, 1f);
106 }
107 m_Verts[i] = value;
108 }
109 vh.Clear();
110 vh.AddUIVertexTriangleStream(m_Verts);
111 }
112
113 private void Update()
114 {
115 if (m_NeedsToSetMaterialDirty && base.graphic != null)
116 {
117 base.graphic.SetMaterialDirty();
118 }
119 }
120
121 public virtual Material GetModifiedMaterial(Material baseMaterial)
122 {
123 if (!IsActive())
124 {
125 return baseMaterial;
126 }
127 if (baseMaterial.shader != Shader.Find("Text Effects/Fancy Text"))
128 {
129 Debug.Log("\"" + base.gameObject.name + "\" doesn't have the \"Fancy Text\" shader applied. Please use it if you are using the \"Inner Outline\" effect.");
130 return baseMaterial;
131 }
132 if (m_ModifiedMaterial == null)
133 {
134 m_ModifiedMaterial = new Material(baseMaterial);
135 }
136 m_ModifiedMaterial.CopyPropertiesFromMaterial(baseMaterial);
137 m_ModifiedMaterial.name = baseMaterial.name + " with IO";
138 m_ModifiedMaterial.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
139 m_ModifiedMaterial.shaderKeywords = baseMaterial.shaderKeywords;
140 m_ModifiedMaterial.CopyPropertiesFromMaterial(baseMaterial);
141 m_ModifiedMaterial.EnableKeyword("_USEOUTLINE_ON");
142 m_ModifiedMaterial.SetColor("_OutlineColor", outlineColor);
143 m_ModifiedMaterial.SetFloat("_OutlineThickness", outlineThickness / 250f);
144 m_ModifiedMaterial.SetInt("_OutlineColorMode", (int)colorMode);
146 return m_ModifiedMaterial;
147 }
148}
override void Start()
Definition: InnerOutline.cs:84
bool m_NeedsToSetMaterialDirty
Definition: InnerOutline.cs:26
override void ModifyMesh(VertexHelper vh)
Definition: InnerOutline.cs:92
float outlineThickness
Definition: InnerOutline.cs:65
Color outlineColor
Definition: InnerOutline.cs:49
virtual Material GetModifiedMaterial(Material baseMaterial)
Color m_OutlineColor
Definition: InnerOutline.cs:21
List< UIVertex > m_Verts
Definition: InnerOutline.cs:30
Material m_ModifiedMaterial
Definition: InnerOutline.cs:28
ColorMode colorMode
Definition: InnerOutline.cs:33
ColorMode m_ColorMode
Definition: InnerOutline.cs:18
float m_OutlineThickness
Definition: InnerOutline.cs:24