WuhuIslandTesting/Library/PackageCache/com.unity.addressables@1.21.12/Tests/Editor/DocExampleCode/CustomDataBuilder.cs
2025-01-07 02:06:59 +01:00

32 lines
1.1 KiB
C#

namespace AddressableAssets.DocExampleCode
{
#region doc_SetCustomBuilder
#if UNITY_EDITOR
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Build;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
internal class CustomDataBuilder
{
public static void SetCustomDataBuilder(IDataBuilder builder)
{
AddressableAssetSettings settings
= AddressableAssetSettingsDefaultObject.Settings;
int index = settings.DataBuilders.IndexOf((ScriptableObject)builder);
if (index > 0)
settings.ActivePlayerDataBuilderIndex = index;
else if (AddressableAssetSettingsDefaultObject.Settings.AddDataBuilder(builder))
settings.ActivePlayerDataBuilderIndex
= AddressableAssetSettingsDefaultObject.Settings.DataBuilders.Count - 1;
else
Debug.LogWarning($"{builder} could not be found " +
$"or added to the list of DataBuilders");
}
}
#endif
#endregion
}