Skip to content

Commit 0c3d28f

Browse files
committed
update MonoAlphaModifier
1 parent c84f4da commit 0c3d28f

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

Assets/CatCode/AlphaModifiers/MonoAlphaModifier.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace CatCode.AlphaModifiers
77
[ExecuteInEditMode]
88
public class MonoAlphaModifier : MonoBehaviour, IAlphaModifier
99
{
10+
[SerializeField] private bool _updateLinksOnAwake;
1011
[SerializeField] private MonoAlphaModifier _parent;
1112
[SerializeField] private List<MonoAlphaModifier> _children = new();
1213
[Space]
@@ -93,8 +94,11 @@ private void RemoveChild(MonoAlphaModifier alphaModifier)
9394

9495
private void Awake()
9596
{
96-
FindParent();
97-
FindChildren();
97+
if (!Application.isPlaying || _updateLinksOnAwake)
98+
{
99+
FindParent();
100+
FindChildren();
101+
}
98102
}
99103

100104
private void OnDestroy()
@@ -110,14 +114,6 @@ private void OnDestroy()
110114
ListPool<MonoAlphaModifier>.Release(tempChildrenList);
111115
}
112116

113-
114-
115-
protected void Reset()
116-
{
117-
FindParent();
118-
FindChildren();
119-
}
120-
121117
#if UNITY_EDITOR
122118
private void Update()
123119
{
@@ -128,15 +124,18 @@ private void Update()
128124
[ContextMenu("Alpha for this Branch")]
129125
private void GetAllStrategies()
130126
{
127+
FindParent();
128+
FindChildren();
131129
_alphaStrategies = AlphaModifierTools.GetStrategiesFromBranch(gameObject);
132130
}
133131

134132
[ContextMenu("Alpha for this Object")]
135133
private void GetCurrentStrategy()
136134
{
135+
FindParent();
136+
FindChildren();
137137
_alphaStrategies = new[] { AlphaModifierTools.GetAlphaModifierStrategy(gameObject) };
138138
}
139-
140139
#endif
141140
}
142141
}

0 commit comments

Comments
 (0)