Skip to content

Commit

Permalink
⭐[update] RainbowAssets
Browse files Browse the repository at this point in the history
Signed-off-by: xinansky <[email protected]>
  • Loading branch information
xinansky committed Oct 26, 2023
1 parent 7d257fc commit 08046a2
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 30 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -1720354355, guid: d6a73fd01763dc74986b8acf577ee60b, type: 3}
m_Name: RainbowFoldersRuleset
m_Name: ProjectRuleset
m_EditorClassIdentifier:
Rules:
- Type: 0
Expand Down
File renamed without changes
6 changes: 0 additions & 6 deletions Resources/RainbowAssets/Editor/NOTICES.txt

This file was deleted.

7 changes: 0 additions & 7 deletions Resources/RainbowAssets/Editor/NOTICES.txt.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,62 @@ public static ProjectRuleset Instance
{
if (_instance is null)
{
if (paths is null)
try
{
paths = new List<string>();
foreach (var guid in AssetDatabase.FindAssets($"t:{nameof(ProjectRuleset)}",
new string[] { "Packages", "Assets" }))
if (paths is null)
{
paths.Add(AssetDatabase.GUIDToAssetPath(guid));
paths = new List<string>();
foreach (var guid in AssetDatabase.FindAssets($"t:{nameof(ProjectRuleset)}",
new string[] { "Packages", "Assets" }))
{
paths.Add(AssetDatabase.GUIDToAssetPath(guid));
}
}

foreach (var expr in paths)
{
_instance = AssetDatabase.LoadAssetAtPath<ProjectRuleset>(expr);
if (_instance is null) continue;
_instance.UpdateOrdinals();
OnRulesetChange =
(Action)Delegate.Combine(OnRulesetChange, new Action(_instance.UpdateOrdinals));
_instance.UpdateDictionaries();
OnRulesetChange =
(Action)Delegate.Combine(OnRulesetChange, new Action(_instance.UpdateDictionaries));
return _instance;
}
}
catch (Exception e)
{
// ignored
}
}

foreach (var expr in paths)
if (_instance is null)
{
try
{
_instance = Resources.Load<ProjectRuleset>(
$"Editor/RainbowFoldersRuleset/{nameof(ProjectRuleset)}");
}
catch (Exception e)
{
_instance = AssetDatabase.LoadAssetAtPath<ProjectRuleset>(expr);
if (_instance is null) continue;
_instance.UpdateOrdinals();
OnRulesetChange =
(Action)Delegate.Combine(OnRulesetChange, new Action(_instance.UpdateOrdinals));
_instance.UpdateDictionaries();
OnRulesetChange =
(Action)Delegate.Combine(OnRulesetChange, new Action(_instance.UpdateDictionaries));
return _instance;
// ignored
}
}

if (_instance is null)
{
_instance = CreateInstance<ProjectRuleset>();
AssetDatabase.CreateAsset(_instance, $"Assets/Editor/Gen/Settings/{nameof(ProjectRuleset)}.asset");
try
{
AssetDatabase.CreateAsset(_instance,
$"Assets/Editor/Gen/Settings/{nameof(ProjectRuleset)}.asset");
}
catch (Exception e)
{
// ignored
}
}

return _instance;
Expand Down

0 comments on commit 08046a2

Please sign in to comment.