기능 검색 기능
This commit is contained in:
@@ -20,6 +20,11 @@ MonoBehaviour:
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: b7e3230909563f049a2b6af27abfd127
|
||||
m_Address: Assets/Localization/Command Shared Data.asset
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
m_ReadOnly: 1
|
||||
m_Settings: {fileID: 11400000, guid: 83e6752692450684b9f53bc4f2d5b557, type: 2}
|
||||
m_SchemaSet:
|
||||
|
||||
@@ -15,6 +15,12 @@ MonoBehaviour:
|
||||
m_GroupName: Localization-String-Tables-English (en)
|
||||
m_GUID: 951c18d3ec70b47479f4f6d6a7a8eb1a
|
||||
m_SerializeEntries:
|
||||
- m_GUID: 1955c6890fde8db43a0ef004936c7c11
|
||||
m_Address: Command_en
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels:
|
||||
- Locale-en
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: f52bf8a6af5d1e746847c94650c2884e
|
||||
m_Address: UI_en
|
||||
m_ReadOnly: 1
|
||||
|
||||
@@ -22,6 +22,12 @@ MonoBehaviour:
|
||||
- Locale-ko-KR
|
||||
- Preload
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 74777a03b717f644492a404f64de1dc4
|
||||
m_Address: Command_ko-KR
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels:
|
||||
- Locale-ko-KR
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
m_ReadOnly: 1
|
||||
m_Settings: {fileID: 11400000, guid: 83e6752692450684b9f53bc4f2d5b557, type: 2}
|
||||
m_SchemaSet:
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<linker>
|
||||
<assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
|
||||
<type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
|
||||
</assembly>
|
||||
<assembly fullname="Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<type fullname="UnityEngine.Localization.Locale" preserve="all" />
|
||||
<type fullname="UnityEngine.Localization.Tables.SharedTableData" preserve="all" />
|
||||
<type fullname="UnityEngine.Localization.Tables.StringTable" preserve="all" />
|
||||
<type fullname="UnityEngine.Localization.Metadata.MetadataCollection" preserve="nothing" serialized="true" />
|
||||
<type fullname="UnityEngine.Localization.Tables.DistributedUIDGenerator" preserve="nothing" serialized="true" />
|
||||
<type fullname="UnityEngine.Localization.Tables.SharedTableData/SharedTableEntry" preserve="nothing" serialized="true" />
|
||||
<type fullname="UnityEngine.Localization.LocaleIdentifier" preserve="nothing" serialized="true" />
|
||||
<type fullname="UnityEngine.Localization.Tables.TableEntryData" preserve="nothing" serialized="true" />
|
||||
</assembly>
|
||||
<assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
|
||||
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
|
||||
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
|
||||
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
|
||||
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.SceneProvider" preserve="all" />
|
||||
</assembly>
|
||||
<assembly fullname="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<type fullname="UnityEngine.Object" preserve="all" />
|
||||
</assembly>
|
||||
</linker>
|
||||
40
Assets/Localization/Command Shared Data.asset
Normal file
40
Assets/Localization/Command Shared Data.asset
Normal file
@@ -0,0 +1,40 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5b11a58205ec3474ca216360e9fa74a8, type: 3}
|
||||
m_Name: Command Shared Data
|
||||
m_EditorClassIdentifier:
|
||||
m_TableCollectionName: Command
|
||||
m_TableCollectionNameGuidString: b7e3230909563f049a2b6af27abfd127
|
||||
m_Entries:
|
||||
- m_Id: 60647641088
|
||||
m_Key: Move Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 267707846656
|
||||
m_Key: Rotate Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 362574614528
|
||||
m_Key: Scale Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_KeyGenerator:
|
||||
rid: 8091366906044088603
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
- rid: 8091366906044088603
|
||||
type: {class: DistributedUIDGenerator, ns: UnityEngine.Localization.Tables, asm: Unity.Localization}
|
||||
data:
|
||||
m_CustomEpoch: 1750139113319
|
||||
@@ -1,7 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4159b5f02693b614e9328aa0940643ef
|
||||
TextScriptImporter:
|
||||
guid: b7e3230909563f049a2b6af27abfd127
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/Localization/Command.asset
Normal file
23
Assets/Localization/Command.asset
Normal file
@@ -0,0 +1,23 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5be51871efa6c3e4eae1703925c8f5ac, type: 3}
|
||||
m_Name: Command
|
||||
m_EditorClassIdentifier:
|
||||
m_SharedTableData: {fileID: 11400000, guid: b7e3230909563f049a2b6af27abfd127, type: 2}
|
||||
m_Tables:
|
||||
- {fileID: 11400000, guid: 1955c6890fde8db43a0ef004936c7c11, type: 2}
|
||||
- {fileID: 11400000, guid: 74777a03b717f644492a404f64de1dc4, type: 2}
|
||||
m_Extensions: []
|
||||
m_Group: String Table
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
8
Assets/Localization/Command.asset.meta
Normal file
8
Assets/Localization/Command.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1a101415eb4f2f4f8b1c92d797e7ab6
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Localization/Command_en.asset
Normal file
35
Assets/Localization/Command_en.asset
Normal file
@@ -0,0 +1,35 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e9620f8c34305754d8cc9a7e49e852d9, type: 3}
|
||||
m_Name: Command_en
|
||||
m_EditorClassIdentifier:
|
||||
m_LocaleId:
|
||||
m_Code: en
|
||||
m_SharedData: {fileID: 11400000, guid: b7e3230909563f049a2b6af27abfd127, type: 2}
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_TableData:
|
||||
- m_Id: 60647641088
|
||||
m_Localized: Move Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 267707846656
|
||||
m_Localized: Rotate Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 362574614528
|
||||
m_Localized: Scale Gizmo
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
8
Assets/Localization/Command_en.asset.meta
Normal file
8
Assets/Localization/Command_en.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1955c6890fde8db43a0ef004936c7c11
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Localization/Command_ko-KR.asset
Normal file
35
Assets/Localization/Command_ko-KR.asset
Normal file
@@ -0,0 +1,35 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e9620f8c34305754d8cc9a7e49e852d9, type: 3}
|
||||
m_Name: Command_ko-KR
|
||||
m_EditorClassIdentifier:
|
||||
m_LocaleId:
|
||||
m_Code: ko-KR
|
||||
m_SharedData: {fileID: 11400000, guid: b7e3230909563f049a2b6af27abfd127, type: 2}
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_TableData:
|
||||
- m_Id: 60647641088
|
||||
m_Localized: "\uC774\uB3D9 \uAE30\uC9C0\uBAA8"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 267707846656
|
||||
m_Localized: "\uD68C\uC804 \uAE30\uC9C0\uBAA8"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 362574614528
|
||||
m_Localized: "\uC2A4\uCF00\uC77C \uAE30\uC9C0\uBAA8"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
8
Assets/Localization/Command_ko-KR.asset.meta
Normal file
8
Assets/Localization/Command_ko-KR.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74777a03b717f644492a404f64de1dc4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ad2e6fcfec6626429b52e881c7016ab
|
||||
guid: 1240afe07db3b6342bcc2af67d0690e9
|
||||
@@ -1846,8 +1846,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -120.805725, y: -37.5}
|
||||
m_SizeDelta: {x: -241.6115, y: 75}
|
||||
m_AnchoredPosition: {x: -144.62958, y: -37.5}
|
||||
m_SizeDelta: {x: -289.2593, y: 75}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8171169114298900524
|
||||
CanvasRenderer:
|
||||
@@ -5925,7 +5925,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 126.6, y: -30}
|
||||
m_AnchoredPosition: {x: 126.6001, y: -30}
|
||||
m_SizeDelta: {x: 100, y: 40}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &515710422415407702
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,10 +10,10 @@ namespace Studio.Command
|
||||
{
|
||||
public ActivateMoveGizmoCommand()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
|
||||
public string id { get => "Move Gizmo"; set => throw new System.NotImplementedException(); }
|
||||
|
||||
public bool CanExecute()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Studio.Command
|
||||
{
|
||||
public class ActivateRotateGizmoCommand : IIrreversibleCommand
|
||||
{
|
||||
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
|
||||
public string id { get => "Rotate Gizmo"; set => throw new System.NotImplementedException(); }
|
||||
|
||||
public bool CanExecute()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Studio.Command
|
||||
|
||||
}
|
||||
|
||||
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
|
||||
public string id { get => "Scale Gizmo"; set => throw new System.NotImplementedException(); }
|
||||
|
||||
public bool CanExecute()
|
||||
{
|
||||
|
||||
@@ -13,6 +13,20 @@ namespace Studio.Command
|
||||
|
||||
Stack<ICommand> commandStack = new();
|
||||
Stack<IReversibleCommand> undoableStack = new ();
|
||||
public void Invoke(ICommand command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case IReversibleCommand reversible:
|
||||
Invoke(reversible);
|
||||
break;
|
||||
case IIrreversibleCommand irreversible:
|
||||
Invoke(irreversible);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void Invoke(IReversibleCommand command)
|
||||
{
|
||||
Debug.Log($"Invoke Reversible Command={command}");
|
||||
|
||||
@@ -12,9 +12,13 @@ namespace Studio.Core
|
||||
private set;
|
||||
} = new CommandInvoker();
|
||||
|
||||
public CommandLocalizationHelper commandLocalizationHelper;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
commandLocalizationHelper = FindAnyObjectByType<CommandLocalizationHelper>();
|
||||
ManagerHub.instance.Init();
|
||||
CommandHub.instance.Init();
|
||||
CanvasManager.instance.Init();
|
||||
}
|
||||
}
|
||||
|
||||
57
Assets/Scripts/Studio/Managers/CommandHub.cs
Normal file
57
Assets/Scripts/Studio/Managers/CommandHub.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Studio.AssetTool;
|
||||
using Studio.Core;
|
||||
using Studio.Manage;
|
||||
using Studio.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using UnityEngine;
|
||||
using XRLib.Collections;
|
||||
|
||||
namespace Studio.Command
|
||||
{
|
||||
public class CommandHub : UnitySingleton<CommandHub>
|
||||
{
|
||||
public HashSet<ICommand> commands = new HashSet<ICommand>();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Join(new ActivateMoveGizmoCommand());
|
||||
Join(new ActivateRotateGizmoCommand());
|
||||
Join(new ActivateScaleGizmoCommand());
|
||||
Join(new ResetGizmoCommand());
|
||||
Join(new CopyObjectCommand());
|
||||
Join(new RemoveAllObjectCommand());
|
||||
Join(new RemoveSelectObjectCommand());
|
||||
Join(new NewProjectCommand());
|
||||
Join(new OpenProjectCommand());
|
||||
Join(new SaveAndNewProjectCommand());
|
||||
Join(new SaveAndOpenProjectCommand());
|
||||
Join(new SaveProjectCommand());
|
||||
Join(new TopMenuNewProjectCommand());
|
||||
Join(new TopMenuOpenProjectCommand());
|
||||
Join(new CreateConnectedAssetCommand());
|
||||
Join(new ExitProgramCommand());
|
||||
|
||||
}
|
||||
|
||||
void Join(ICommand newCommand)
|
||||
{
|
||||
if (!commands.Add(newCommand))
|
||||
{
|
||||
Debug.LogError($"Command {newCommand} already exists in the hub.");
|
||||
}
|
||||
}
|
||||
|
||||
public T Get<T>() where T : ICommand
|
||||
{
|
||||
foreach (var c in commands)
|
||||
{
|
||||
if (c is T command)
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Studio/Managers/CommandHub.cs.meta
Normal file
2
Assets/Scripts/Studio/Managers/CommandHub.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 625661f14d5328e438380b4797ae4955
|
||||
38
Assets/Scripts/Studio/Managers/LanguageManager.cs
Normal file
38
Assets/Scripts/Studio/Managers/LanguageManager.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Studio.Core;
|
||||
using Studio.Manage;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Settings;
|
||||
|
||||
namespace Studio.Manage
|
||||
{
|
||||
public class LanguageManager : Manager
|
||||
{
|
||||
public CommandLocalizationHelper commandHelper;
|
||||
|
||||
public enum ELanguage
|
||||
{
|
||||
English = 0,
|
||||
Korean = 1,
|
||||
}
|
||||
|
||||
private ELanguage curLanguage = ELanguage.English;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
commandHelper = SystemMain.instance.commandLocalizationHelper;
|
||||
SetLanguage();
|
||||
}
|
||||
|
||||
public void ChangeLanguage()
|
||||
{
|
||||
curLanguage = curLanguage == ELanguage.English ? ELanguage.Korean : ELanguage.English;
|
||||
SetLanguage();
|
||||
}
|
||||
|
||||
private void SetLanguage()
|
||||
{
|
||||
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[(int)curLanguage];
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Studio/Managers/LanguageManager.cs.meta
Normal file
2
Assets/Scripts/Studio/Managers/LanguageManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51494d306c55b9743b517cc8901f5642
|
||||
@@ -25,6 +25,8 @@ namespace Studio.Manage
|
||||
Join(new SceneStartSettingManager());
|
||||
Join(new RunManager());
|
||||
Join(new ProjectDataComparerManager());
|
||||
Join(new SearchManager());
|
||||
Join(new LanguageManager());
|
||||
foreach(var m in managers)
|
||||
{
|
||||
m.Init();
|
||||
|
||||
69
Assets/Scripts/Studio/Managers/SearchManager.cs
Normal file
69
Assets/Scripts/Studio/Managers/SearchManager.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Studio.Command;
|
||||
using Studio.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using XRLib.Collections;
|
||||
|
||||
namespace Studio.Manage
|
||||
{
|
||||
public class SearchManager : Manager
|
||||
{
|
||||
private Dictionary<string, Action> commands = new();
|
||||
private Dictionary<string, string> localizedTexts = new();
|
||||
|
||||
private Trie trie;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
trie = new Trie();
|
||||
|
||||
AddCommand(new ActivateMoveGizmoCommand());
|
||||
AddCommand(new ActivateRotateGizmoCommand());
|
||||
AddCommand(new ActivateScaleGizmoCommand());
|
||||
//AddCommand(new ResetGizmoCommand());
|
||||
//AddCommand(new CopyObjectCommand());
|
||||
//AddCommand(new RemoveAllObjectCommand());
|
||||
//AddCommand(new RemoveSelectObjectCommand());
|
||||
//AddCommand(new NewProjectCommand());
|
||||
//AddCommand(new OpenProjectCommand());
|
||||
//AddCommand(new SaveAndNewProjectCommand());
|
||||
//AddCommand(new SaveAndOpenProjectCommand());
|
||||
//AddCommand(new SaveProjectCommand());
|
||||
//AddCommand(new CreateConnectedAssetCommand());
|
||||
//AddCommand(new ExitProgramCommand());
|
||||
}
|
||||
|
||||
private async Task AddCommand(string id, Action action)
|
||||
{
|
||||
commands[id] = action;
|
||||
List<string> words = await ManagerHub.instance.Get<LanguageManager>().commandHelper.GetLocalizedAllLocales(id);
|
||||
foreach (string word in words)
|
||||
{
|
||||
trie.Insert(word);
|
||||
localizedTexts[word] = id;
|
||||
}
|
||||
}
|
||||
|
||||
private async void AddCommand(ICommand command)
|
||||
{
|
||||
await AddCommand(command.id, () => CommandInvoker.instance.Invoke(command));
|
||||
}
|
||||
|
||||
public List<string> GetTrieContainingWords(string text)
|
||||
{
|
||||
return trie.TryGetContainingWords(text, out var words) ? words : new List<string>();
|
||||
}
|
||||
|
||||
public string GetCommandId(string word)
|
||||
{
|
||||
return localizedTexts.TryGetValue(word, out var id) ? id : word;
|
||||
}
|
||||
|
||||
public Action GetCommandEvent(string id)
|
||||
{
|
||||
return commands.TryGetValue(id, out var action) ? action : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Studio/Managers/SearchManager.cs.meta
Normal file
2
Assets/Scripts/Studio/Managers/SearchManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8524d9420949394198db65718b76360
|
||||
@@ -32,8 +32,9 @@ namespace Studio.UI
|
||||
panel_studiotopbar.onClickExit += () => CommandInvoker.instance.Invoke(new ExitProgramCommand());
|
||||
panel_studiotopbar.onClickSaveProject += () => CommandInvoker.instance.Invoke(new SaveProjectCommand());
|
||||
|
||||
panel_studiotopbar.onClickClose += () => CommandInvoker.instance.Invoke(new ExitProgramCommand());
|
||||
panel_studiotopbar.onClickLanguageSetting += ManagerHub.instance.Get<LanguageManager>().ChangeLanguage; // TODO: open panel
|
||||
|
||||
panel_studiotopbar.onClickClose += () => CommandInvoker.instance.Invoke(new ExitProgramCommand());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
93
Assets/Scripts/Studio/UI/Elements/UI_SearchCommand.cs
Normal file
93
Assets/Scripts/Studio/UI/Elements/UI_SearchCommand.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using Studio.Command;
|
||||
using Studio.Core;
|
||||
using Studio.Manage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Settings;
|
||||
using UnityEngine.UI;
|
||||
using XRLib.Collections;
|
||||
using XRLib.UI;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Studio.UI
|
||||
{
|
||||
public class UI_SearchCommand : UIBase
|
||||
{
|
||||
private SearchManager searchManager;
|
||||
private CommandLocalizationHelper helper;
|
||||
|
||||
public TMP_InputField InputField_Search;
|
||||
public TextMeshProUGUI Text_SearchResult;
|
||||
public RectTransform ResultRoot;
|
||||
|
||||
private readonly List<Button> resultButtons = new();
|
||||
private readonly List<TextMeshProUGUI> resultTexts = new();
|
||||
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
searchManager = ManagerHub.instance.Get<SearchManager>();
|
||||
helper = FindAnyObjectByType<CommandLocalizationHelper>();
|
||||
|
||||
InputField_Search = GetComponent<TMP_InputField>();
|
||||
InputField_Search.onValueChanged.AddListener((s) => Search());
|
||||
|
||||
foreach (Transform child in ResultRoot)
|
||||
{
|
||||
resultButtons.Add(child.GetComponent<Button>());
|
||||
resultTexts.Add(child.GetComponentInChildren<TextMeshProUGUI>());
|
||||
}
|
||||
}
|
||||
|
||||
public void Search()
|
||||
{
|
||||
ClearResult();
|
||||
|
||||
string input = InputField_Search.text;
|
||||
if (input.Length == 0)
|
||||
{
|
||||
ResultRoot.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> words = searchManager.GetTrieContainingWords(input);
|
||||
int displayCount = Mathf.Clamp(words.Count, 0, resultButtons.Count);
|
||||
ResultRoot.gameObject.SetActive(displayCount > 0);
|
||||
|
||||
for (int i = 0; i < displayCount; i++)
|
||||
{
|
||||
string word = words[i];
|
||||
string commandId = searchManager.GetCommandId(word);
|
||||
int index = i;
|
||||
|
||||
var button = resultButtons[index];
|
||||
var label = resultTexts[index];
|
||||
|
||||
button.gameObject.SetActive(true);
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
searchManager.GetCommandEvent(commandId)?.Invoke();
|
||||
InputField_Search.text = string.Empty;
|
||||
});
|
||||
|
||||
helper.Localization(commandId, localized =>
|
||||
{
|
||||
label.text = $"{localized} ({commandId})";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearResult()
|
||||
{
|
||||
for (int i = 0; i < resultButtons.Count; i++)
|
||||
{
|
||||
resultButtons[i].gameObject.SetActive(false);
|
||||
resultTexts[i].text = string.Empty;
|
||||
resultButtons[i].onClick.RemoveAllListeners();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a03b6048948d34dba8479afd5aef42
|
||||
@@ -51,6 +51,11 @@ namespace Studio.UI
|
||||
|
||||
public event Action onClickClose;
|
||||
|
||||
/*ControlBox*/
|
||||
public Button Button_LanguageSetting;
|
||||
public event Action onClickLanguageSetting;
|
||||
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
Button_NewProject.onClick.AddListener(OnClickNewProject);
|
||||
@@ -69,6 +74,7 @@ namespace Studio.UI
|
||||
Button_APISetting.onClick.AddListener(OnClickAPISetting);
|
||||
Button_MQTTSetting.onClick.AddListener(OnClickMQTTSetting);
|
||||
Button_AssetSetting.onClick.AddListener(OnClickAssetSetting);
|
||||
Button_LanguageSetting.onClick.AddListener(OnClickLanguageSetting);
|
||||
|
||||
|
||||
Button_Build.onClick.AddListener(OnClickBuild);
|
||||
@@ -100,11 +106,16 @@ namespace Studio.UI
|
||||
Debug.Log("On TopMenu Click App Setting");
|
||||
CanvasManager.instance.GetCanvas<Canvas_Popup>().panel_appsetting.SetActive(true);
|
||||
}
|
||||
void OnClickAssetSetting()
|
||||
private void OnClickAssetSetting()
|
||||
{
|
||||
Debug.Log("On Click Asset Manager");
|
||||
CanvasManager.instance.GetCanvas<Canvas_Popup>().panel_assetsetting.SetActive(true);
|
||||
}
|
||||
private void OnClickLanguageSetting()
|
||||
{
|
||||
Debug.Log("On Click anguage Setting");
|
||||
onClickLanguageSetting?.Invoke();
|
||||
}
|
||||
|
||||
private void OnClickNewProject()
|
||||
{
|
||||
|
||||
66
Assets/Scripts/XRLib/UI/CommandLocalizationHelper.cs
Normal file
66
Assets/Scripts/XRLib/UI/CommandLocalizationHelper.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Studio.Command;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization;
|
||||
using UnityEngine.Localization.Components;
|
||||
using UnityEngine.Localization.Settings;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class CommandLocalizationHelper : LocalizeStringEvent
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
public void Localization(string id, Action<string> onCompleted)
|
||||
{
|
||||
var localizedString = new LocalizedString()
|
||||
{
|
||||
TableReference = "Command",
|
||||
TableEntryReference = id
|
||||
};
|
||||
|
||||
AsyncOperationHandle<string> stringOperation = localizedString.GetLocalizedStringAsync();
|
||||
stringOperation.Completed += (op) =>
|
||||
{
|
||||
if (op.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
onCompleted?.Invoke(op.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Not exist in table");
|
||||
onCompleted?.Invoke(id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetLocalizedAllLocales(string id)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var locales = LocalizationSettings.AvailableLocales.Locales;
|
||||
|
||||
foreach (var locale in locales)
|
||||
{
|
||||
var handle = LocalizationSettings.StringDatabase.GetTableEntryAsync("Command", id, locale);
|
||||
await handle.Task;
|
||||
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded && handle.Result.Entry != null)
|
||||
{
|
||||
result.Add(handle.Result.Entry.GetLocalizedString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bd9ae3f3097fe1469025dda7574bf9d
|
||||
21
ProjectSettings/LocalizationSettings.asset
Normal file
21
ProjectSettings/LocalizationSettings.asset
Normal file
@@ -0,0 +1,21 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &1
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aa32dd7bcb4d749abb23199c1f0f51af, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_StringTable:
|
||||
m_TableReference:
|
||||
m_TableCollectionName:
|
||||
m_AssetTable:
|
||||
m_TableReference:
|
||||
m_TableCollectionName:
|
||||
m_TrackingChanges: 0
|
||||
Reference in New Issue
Block a user