Registry Mirror
搜索
Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Files
Expand file tree
main
Breadcrumbs
CodeName.Styling
/
StyleRule.cs
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
38 lines (33 loc) · 1.03 KB
main
Breadcrumbs
CodeName.Styling
/
StyleRule.cs
Copy path
Top
File metadata and controls
Code
Blame
38 lines (33 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace CodeName.Styling
{
[InlineProperty]
[Serializable]
public class StyleRule<T>
{
[ListDrawerSettings(CustomAddFunction = nameof(Inspector_AddSelector))]
[SerializeField] private List<StyleRuleSelector<T>> selectors = new();
public List<StyleRuleSelector<T>> Selectors => selectors;
public T GetValue(IStyleClassNode node)
{
// Selectors at the end of the list override the ones before.
// Only the last selector matters -> Use reverse for loop.
for (var i = selectors.Count - 1; i >= 0; i--)
{
var selector = selectors[i];
if (selector.IsMatch(node))
{
return selector.Value;
}
}
return default;
}
private void Inspector_AddSelector()
{
selectors.Add(new StyleRuleSelector<T>());
}
}
}
You can’t perform that action at this time.