Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Added a crutch for webGL
Browse files Browse the repository at this point in the history
  • Loading branch information
ShutovKS committed Jan 4, 2024
1 parent 045cdc7 commit 92600fc
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 102 deletions.
45 changes: 42 additions & 3 deletions src/Visual novel/Assets/_Project/Scenes/0.Bootstrap.unity
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,41 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &786270577 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 109254, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
m_PrefabInstance: {fileID: 1155182340}
m_PrefabAsset: {fileID: 0}
--- !u!114 &786270582
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 786270577}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
m_CursorLockBehavior: 0
--- !u!1001 &1155182340
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -416,10 +451,14 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -18
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 11492840, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 109254, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
insertIndex: -1
addedObject: {fileID: 786270582}
m_SourcePrefab: {fileID: 100100000, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
--- !u!1 &1611659631
GameObject:
Expand Down Expand Up @@ -459,7 +498,7 @@ Transform:
m_GameObject: {fileID: 1611659631}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 79.3, y: 159.35703, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Infrastructure.ScenesManagers.Bootstrap
{
public class Bootstrap : MonoBehaviour, ICoroutineRunner
{
private void Awake()
private void Start()
{
ServicesInitialize();
GameLoading();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,104 @@

using System;
using System.Threading.Tasks;
using Data.Dynamic;
using Infrastructure.Services;
using Infrastructure.Services.LocalisationDataLoad;
using Infrastructure.Services.LocalizationUI;
using Infrastructure.Services.SaveLoadData;
using Infrastructure.Services.UIFactory;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

#endregion

namespace Infrastructure.ScenesManagers.Loading
{
public class Loading : MonoBehaviour
{
private string _language = "";
private ILocalisationDataLoadService _localisationDataLoad;
private ILocalizerUI _localizerUI;
private IUIFactoryService _uiFactory;
private IUIFactoryInfoService _uiFactoryInfo;

private async void Start()
{
InitializedServices();
await CreatedUI();
RegisterLocalizableUI();
await LoadData();
LocalisationUI();
StartGame();
}

private void InitializedServices()
{
_localisationDataLoad = ServicesContainer.GetService<ILocalisationDataLoadService>();
_uiFactoryInfo = ServicesContainer.GetService<IUIFactoryInfoService>();
_uiFactory = ServicesContainer.GetService<IUIFactoryService>();
_localizerUI = ServicesContainer.GetService<ILocalizerUI>();
}

private async Task CreatedUI()
{
await _uiFactory.CreatedBackgroundScreen();
_uiFactoryInfo.BackgroundUI.SetBackgroundColor(Color.black);

await _uiFactory.CreatedChooseLanguageScreen();
_uiFactoryInfo.ChooseLanguageUI.SetActivePanel(true);

await _uiFactory.CreatedDialogueScreen();
_uiFactoryInfo.DialogueUI.SetActivePanel(false);

await _uiFactory.CreatedMainMenuScreen();
_uiFactoryInfo.MainMenuUI.SetActivePanel(false);

await _uiFactory.CreatedConfirmationScreen();
_uiFactoryInfo.ConfirmationUI.SetActivePanel(false);

await _uiFactory.CreatedSaveLoadScreen();
_uiFactoryInfo.SaveLoadUI.SetActivePanel(false);

await _uiFactory.CreatedLastWordsScreen();
_uiFactoryInfo.LastWordsUI.SetActivePanel(false);
}

private void RegisterLocalizableUI()
{
_localizerUI.Register(_uiFactoryInfo.DialogueUI);
_localizerUI.Register(_uiFactoryInfo.MainMenuUI);
_localizerUI.Register(_uiFactoryInfo.ConfirmationUI);
_localizerUI.Register(_uiFactoryInfo.SaveLoadUI);
}

private async Task LoadData()
{
var localizationsInfo = _localisationDataLoad.GetLocalizationsInfo();
var addLanguageInScrollView = new Action<string, UnityAction>(
_uiFactoryInfo.ChooseLanguageUI.ScrollViewLanguages.AddLanguageInScrollView);

foreach (var localizationInfo in localizationsInfo)
{
addLanguageInScrollView.Invoke(
localizationInfo.Language,
() => _language = localizationInfo.Language);
}

await Task.Run(
() =>
{
while (_language == "")
{
}
});

_localisationDataLoad.Load(_language);
}

private void LocalisationUI()
{
var uiLocalisation = _localisationDataLoad.GetUILocalisation();
_localizerUI.Localize(uiLocalisation);
}

private void StartGame()
{
SceneManager.LoadScene("2.Meta");
_uiFactoryInfo.ChooseLanguageUI.SetActivePanel(false);
}
}
public class Loading : MonoBehaviour
{
private string _language = "";
private ILocalisationDataLoadService _localisationDataLoad;
private ILocalizerUI _localizerUI;
private IUIFactoryService _uiFactory;
private IUIFactoryInfoService _uiFactoryInfo;

private async void Start()
{
InitializedServices();
await CreatedUI();
RegisterLocalizableUI();
LoadData(() =>
{
LocalisationUI();
StartGame();
});
}

private void InitializedServices()
{
_localisationDataLoad = ServicesContainer.GetService<ILocalisationDataLoadService>();
_uiFactoryInfo = ServicesContainer.GetService<IUIFactoryInfoService>();
_uiFactory = ServicesContainer.GetService<IUIFactoryService>();
_localizerUI = ServicesContainer.GetService<ILocalizerUI>();
}

private async Task CreatedUI()
{
await _uiFactory.CreatedBackgroundScreen();
_uiFactoryInfo.BackgroundUI.SetBackgroundColor(Color.black);

await _uiFactory.CreatedChooseLanguageScreen();
_uiFactoryInfo.ChooseLanguageUI.SetActivePanel(true);

await _uiFactory.CreatedDialogueScreen();
_uiFactoryInfo.DialogueUI.SetActivePanel(false);

await _uiFactory.CreatedMainMenuScreen();
_uiFactoryInfo.MainMenuUI.SetActivePanel(false);

await _uiFactory.CreatedConfirmationScreen();
_uiFactoryInfo.ConfirmationUI.SetActivePanel(false);

await _uiFactory.CreatedSaveLoadScreen();
_uiFactoryInfo.SaveLoadUI.SetActivePanel(false);

await _uiFactory.CreatedLastWordsScreen();
_uiFactoryInfo.LastWordsUI.SetActivePanel(false);
}

private void RegisterLocalizableUI()
{
_localizerUI.Register(_uiFactoryInfo.DialogueUI);
_localizerUI.Register(_uiFactoryInfo.MainMenuUI);
_localizerUI.Register(_uiFactoryInfo.ConfirmationUI);
_localizerUI.Register(_uiFactoryInfo.SaveLoadUI);
}

private void LoadData(Action onCompleted)
{
var localizationsInfo = _localisationDataLoad.GetLocalizationsInfo();

foreach (var localizationInfo in localizationsInfo)
{
_uiFactoryInfo.ChooseLanguageUI.ScrollViewLanguages.AddLanguageInScrollView(
localizationInfo.Language,
() =>
{
_language = localizationInfo.Language;
_localisationDataLoad.Load(_language);
onCompleted?.Invoke();
});
}
}

private void LocalisationUI()
{
var uiLocalisation = _localisationDataLoad.GetUILocalisation();
_localizerUI.Localize(uiLocalisation);
}

private void StartGame()
{
SceneManager.LoadScene("2.Meta");
_uiFactoryInfo.ChooseLanguageUI.SetActivePanel(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Meta : MonoBehaviour
private IUIFactoryInfoService _uiFactoryInfo;
private ISoundsService _soundsService;

private void Awake()
private void Start()
{
InitializedServices();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public class ButtonsUI : MonoBehaviour
[SerializeField] private TextMeshProUGUI _startGameButtonText;
[SerializeField] private TextMeshProUGUI _exitButtonText;

private void Awake()
{
#if UNITY_WEBGL
_exitButton.gameObject.SetActive(false);
#endif
}

public void RegisterLoadGameButtonCallback(UnityAction action)
{
_loadGameButton.RegisterNewCallback(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region

using System;
using Data.Localization.UILocalisation;
using Infrastructure.Services.LocalizationUI;
using UnityEngine;
Expand Down

0 comments on commit 92600fc

Please sign in to comment.