Skip to content

Commit 1b5856e

Browse files
authored
Merge pull request #21 from tsgcpp/feature/editor_performance_improvement
Fix and improve StringTableCollectionBundleEditor
2 parents 745ae9c + 0c37649 commit 1b5856e

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

Assets/Plugins/LocalizationExtension/Editor/AssetTool/AssetFinding.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static IReadOnlyList<T> FindAssetsInFolders<T>(IReadOnlyList<DefaultAsset
1616
}
1717

1818
var folderPathList = folders
19+
.Where(folder => folder != null)
1920
.Select(AssetDatabase.GetAssetPath)
2021
.Where(path => !string.IsNullOrEmpty(path))
2122
.Where(path => Directory.Exists(path))

Assets/Plugins/LocalizationExtension/Editor/Google/StringTableCollection/StringTableCollectionBundle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class StringTableCollectionBundle : ScriptableObject, ITargetFolde
1818

1919
[Tooltip("The folders to search for StringTableCollection assets.")]
2020
[SerializeField] private List<DefaultAsset> _targetFolders;
21-
public IReadOnlyList<DefaultAsset> TargetFolders => _targetFolders;
21+
public IReadOnlyList<DefaultAsset> TargetFolders => _targetFolders ??= new List<DefaultAsset>();
2222

2323
[Tooltip("Sleep seconds per requests for cool time.")]
2424
[Min(0f)]

Assets/Plugins/LocalizationExtension/Editor/Google/StringTableCollection/StringTableCollectionBundleEditor.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using UnityEngine;
45
using UnityEditor;
@@ -14,16 +15,19 @@ public sealed class StringTableCollectionBundleEditor : UnityEditor.Editor
1415

1516
public override void OnInspectorGUI()
1617
{
17-
DrawDefaultInspector();
18-
EditorGUILayout.Space(16);
18+
using (var changeCheck = new EditorGUI.ChangeCheckScope())
19+
{
20+
DrawDefaultInspector();
21+
EditorGUILayout.Space(16);
1922

20-
DrawToolsWithSheetsServiceProvider();
21-
EditorGUILayout.Space(8);
23+
DrawToolsWithSheetsServiceProvider();
24+
EditorGUILayout.Space(8);
2225

23-
DrawToolsWithServiceAccount();
24-
EditorGUILayout.Space(8);
26+
DrawToolsWithServiceAccount();
27+
EditorGUILayout.Space(8);
2528

26-
DrawStringTableCollections();
29+
DrawStringTableCollections(changeCheck.changed);
30+
}
2731
}
2832

2933
private void DrawToolsWithSheetsServiceProvider()
@@ -59,8 +63,9 @@ private void DrawToolsWithServiceAccount()
5963
}
6064

6165
private bool _showStringTableCollections = true;
66+
private IReadOnlyList<StringTableCollection> _stringTableCollectionsCache = new List<StringTableCollection>();
6267

63-
private void DrawStringTableCollections()
68+
private void DrawStringTableCollections(bool guiChanged)
6469
{
6570
var foldoutStyle = new GUIStyle(EditorStyles.foldout)
6671
{
@@ -70,9 +75,15 @@ private void DrawStringTableCollections()
7075
_showStringTableCollections = EditorGUILayout.Foldout(_showStringTableCollections, "Target \"StringTableCollection\"s", foldoutStyle);
7176
if (!_showStringTableCollections)
7277
{
78+
_stringTableCollectionsCache = null;
7379
return;
7480
}
7581

82+
if (_stringTableCollectionsCache == null || guiChanged)
83+
{
84+
_stringTableCollectionsCache = Bundle.StringTableCollections;
85+
}
86+
7687
var stringTableCollections = Bundle.StringTableCollections;
7788
using var h = new EditorGUILayout.VerticalScope(GUI.skin.box);
7889
using var g = new EditorGUI.DisabledGroupScope(true);

0 commit comments

Comments
 (0)