-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from SpaceWarpDev/v1.1.1
Fixed audio and localization issue
- Loading branch information
Showing
5 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
SpaceWarp/Patching/LoadingActions/LoadingAddressablesLocalizationsAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using I2.Loc; | ||
using KSP.Game; | ||
using KSP.Game.Flow; | ||
using UnityEngine; | ||
using UnityEngine.AddressableAssets; | ||
|
||
namespace SpaceWarp.Patching.LoadingActions; | ||
|
||
internal sealed class LoadAddressablesLocalizationsAction : FlowAction | ||
{ | ||
public LoadAddressablesLocalizationsAction() : base("Loading localizations from Addressables") | ||
{ | ||
} | ||
|
||
public override void DoAction(Action resolve, Action<string> reject) | ||
{ | ||
try | ||
{ | ||
GameManager.Instance.Game.Assets.LoadByLabel("language_source", | ||
OnLanguageSourceAssetLoaded, delegate(IList<LanguageSourceAsset> languageAssetLocations) | ||
{ | ||
if (languageAssetLocations != null) | ||
{ | ||
Addressables.Release(languageAssetLocations); | ||
} | ||
|
||
resolve(); | ||
}); | ||
} | ||
catch (Exception e) | ||
{ | ||
Debug.LogError(e.ToString()); | ||
reject(null); | ||
} | ||
} | ||
|
||
private static void OnLanguageSourceAssetLoaded(LanguageSourceAsset asset) | ||
{ | ||
if (!asset || LocalizationManager.Sources.Contains(asset.mSource)) | ||
{ | ||
return; | ||
} | ||
|
||
asset.mSource.owner = asset; | ||
LocalizationManager.AddSource(asset.mSource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters