Firstborn/Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Editor/Settings/InputSettingsBuildProvider.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

53 lines
1.9 KiB
C#

#if UNITY_EDITOR
using System.Linq;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine.InputSystem.Utilities;
namespace UnityEngine.InputSystem.Editor
{
internal class InputSettingsBuildProvider : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
if (InputSystem.settings == null)
return;
// If we operate on temporary object instead of input setting asset,
// adding temporary asset would result in preloadedAssets containing null object "{fileID: 0}".
// Hence we ignore adding temporary objects to preloaded assets.
if (!EditorUtility.IsPersistent(InputSystem.settings))
return;
// Add InputSettings object assets, if it's not in there already.
var preloadedAssets = PlayerSettings.GetPreloadedAssets();
if (!preloadedAssets.Contains(InputSystem.settings))
{
ArrayHelpers.Append(ref preloadedAssets, InputSystem.settings);
PlayerSettings.SetPreloadedAssets(preloadedAssets);
}
}
public void OnPostprocessBuild(BuildReport report)
{
// Revert back to original state by removing all input settings from preloaded assets.
var preloadedAssets = PlayerSettings.GetPreloadedAssets();
while (preloadedAssets != null && preloadedAssets.Length > 0)
{
var index = preloadedAssets.IndexOf(x => x is InputSettings);
if (index != -1)
{
ArrayHelpers.EraseAt(ref preloadedAssets, index);
PlayerSettings.SetPreloadedAssets(preloadedAssets);
}
else
break;
}
}
}
}
#endif // UNITY_EDITOR