Skip to content

Commit

Permalink
chore: improve text readability
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Oct 3, 2022
1 parent 249389a commit b703d5f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Editor/AddressableImportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public void CleanEmptyGroup()
}

/// <summary>
/// Create AddressableImportSettings and Add it to AddressableImportSettingsList
/// Create AddressableImportSettings and add it to AddressableImportSettingsList
/// </summary>
[MenuItem("Assets/Create/Addressables/Import Settings", false, 50)]
public static void CreateAsset()
{
string directoryPath = "Assets/";
string fileName = "AddressableImportSettings.asset";

foreach(var obj in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets))
{
var assetPath = AssetDatabase.GetAssetPath(obj);
Expand All @@ -81,6 +81,7 @@ public static void CreateAsset()
AddressableImportSettings settings = ScriptableObject.CreateInstance<AddressableImportSettings>();
var filePath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(directoryPath, fileName));
AssetDatabase.CreateAsset(settings, filePath);
Debug.LogFormat("Created AddressableImportSettings at path: {0}", filePath);

if (!AddressableImportSettingsList.Instance.SettingList.Contains(settings))
{
Expand Down
17 changes: 9 additions & 8 deletions Editor/AddressableImportSettingsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ public class AddressableImportSettingsList : ScriptableObject
public const string kDefaultPath = "Assets/AddressableAssetsData/AddressableImportSettingsList.asset";
public List<AddressableImportSettings> SettingList;
public List<AddressableImportSettings> EnabledSettingsList => SettingList.Where((s) => s?.rulesEnabled == true).ToList();

public static AddressableImportSettingsList Instance
{
get
{
AddressableImportSettingsList so;

// Try to locate settings from EditorBuildSettings
if (EditorBuildSettings.TryGetConfigObject(kConfigObjectName, out so))
// Try to locate settings list from EditorBuildSettings
EditorBuildSettings.TryGetConfigObject(kConfigObjectName, out so);
if (so != null)
{
return so;
}
// Try to locate settings from default path
// Try to locate settings list from the default path
so = AssetDatabase.LoadAssetAtPath<AddressableImportSettingsList>(kDefaultPath);
if (so != null)
{
EditorBuildSettings.AddConfigObject(kConfigObjectName, so, true);
return so;
}
// Try to locate settings from AssetDatabase
// Try to locate settings list from AssetDatabase
var guidList = AssetDatabase.FindAssets($"t:{nameof(AddressableImportSettingsList)}");
if (guidList.Length > 0)
{
Expand All @@ -40,7 +41,7 @@ public static AddressableImportSettingsList Instance
return so;
}

// If AddressableImportSettingsList doesn't exist but AddressableImportSettings exists. create automatically.
// If AddressableImportSettingsList doesn't exist but AddressableImportSettings exists, create the list.
var importSettingsGuidList = AssetDatabase.FindAssets($"t:{nameof(AddressableImportSettings)}");
if (importSettingsGuidList.Length > 0)
{
Expand All @@ -49,7 +50,7 @@ public static AddressableImportSettingsList Instance
asset.SettingList = settingList;
var path = Path.Combine(Path.GetDirectoryName(AssetDatabase.GUIDToAssetPath(importSettingsGuidList[0])),
nameof(AddressableImportSettingsList) + ".asset");
Debug.LogFormat("AddressableImportSettingsList doesn't exist. so it is created automatically. path : {0}", path);
Debug.LogFormat("Created AddressableImportSettingsList at path: {0}", path);
AssetDatabase.CreateAsset(asset, path);
AssetDatabase.SaveAssets();
so = asset;
Expand Down Expand Up @@ -77,7 +78,7 @@ public bool RemoveMissingImportSettings()
}

[ButtonMethod]
public void Reset()
public void RebuildSettingsList()
{
var importSettingsGuidList = AssetDatabase.FindAssets($"t:{nameof(AddressableImportSettings)}");
SettingList = importSettingsGuidList.Select((guid) => AssetDatabase.LoadAssetAtPath<AddressableImportSettings>(AssetDatabase.GUIDToAssetPath(guid))).ToList();
Expand Down
2 changes: 1 addition & 1 deletion Editor/AddressableImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse
{
if (IsAssetIgnored(deletedAsset))
continue;

foreach (var importSettings in hasRuleSettingsList)
{
if (TryGetMatchedRule(deletedAsset, importSettings, out var matchedRule))
Expand Down
3 changes: 1 addition & 2 deletions Editor/Helper/AddressableImportSettingsEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <summary>
/// ButtonMethodAttribute,
/// modified from https://github.com/Deadcows/MyBox/blob/master/Attributes/ButtonMethodAttribute.cs
/// AddressableImportSettingsEditor
/// </summary>
namespace UnityAddressableImporter.Helper.Internal
{
Expand Down
3 changes: 1 addition & 2 deletions Editor/Helper/AddressableImportSettingsListEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <summary>
/// ButtonMethodAttribute,
/// modified from https://github.com/Deadcows/MyBox/blob/master/Attributes/ButtonMethodAttribute.cs
/// AddressableImportSettingsListEditor
/// </summary>
namespace UnityAddressableImporter.Helper.Internal
{
Expand Down
3 changes: 1 addition & 2 deletions Editor/Helper/ScriptableObjectEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <summary>
/// ButtonMethodAttribute,
/// modified from https://github.com/Deadcows/MyBox/blob/master/Attributes/ButtonMethodAttribute.cs
/// ScriptableObjectEditor
/// </summary>
namespace UnityAddressableImporter.Helper.Internal
{
Expand Down

0 comments on commit b703d5f

Please sign in to comment.