diff --git a/EintooAR/Assets/Animancer Settings.asset b/EintooAR/Assets/Animancer Settings.asset
new file mode 100644
index 00000000..5634d4ad
--- /dev/null
+++ b/EintooAR/Assets/Animancer Settings.asset
@@ -0,0 +1,61 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 16
+ 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: 18bd840b706853d4a934ec3199f63a41, type: 3}
+ m_Name: Animancer Settings
+ m_EditorClassIdentifier:
+ _Data:
+ - rid: 4686946972895019210
+ - rid: 4686946972895019211
+ - rid: 4686946972895019212
+ - rid: 4686946972895019213
+ - rid: 4686946972895019214
+ - rid: 4686946972895019215
+ references:
+ version: 2
+ RefIds:
+ - rid: 4686946972895019210
+ type: {class: AnimancerComponentPreviewSettings, ns: Animancer.Editor.Previews, asm: Kybernetik.Animancer.Editor}
+ data:
+ _RepaintRate: 30
+ - rid: 4686946972895019211
+ type: {class: AnimancerGraphControls, ns: Animancer.Editor, asm: Kybernetik.Animancer.Editor}
+ data:
+ _FrameStep: 0.02
+ - rid: 4686946972895019212
+ type: {class: TransitionPreviewSettings, ns: Animancer.Editor.Previews, asm: Kybernetik.Animancer.Editor}
+ data:
+ _AutoClose: 1
+ _SceneLighting: 0
+ _ShowSkybox: 0
+ _FrameStep: 0.02
+ _SceneEnvironment: {fileID: 0}
+ _Models: []
+ - rid: 4686946972895019213
+ type: {class: SerializableEventSequenceDrawerSettings, ns: Animancer.Editor, asm: Kybernetik.Animancer.Editor}
+ data:
+ _HideEventCallbacks: 0
+ - rid: 4686946972895019214
+ type: {class: AnimationTimeAttributeSettings, ns: Animancer.Units.Editor, asm: Kybernetik.Animancer.Editor}
+ data:
+ showApproximations: 1
+ showNormalized: 1
+ showSeconds: 1
+ showFrames: 1
+ - rid: 4686946972895019215
+ type: {class: GenerateSpriteAnimationsSettings, ns: Animancer.Editor.Tools, asm: Kybernetik.Animancer.Editor}
+ data:
+ _FrameRate: 12
+ _HierarchyPath:
+ _TargetType:
+ _QualifiedName: UnityEngine.SpriteRenderer, UnityEngine.CoreModule, Version=0.0.0.0,
+ Culture=neutral, PublicKeyToken=null
+ _PropertyName: m_Sprite
diff --git a/EintooAR/Assets/Animancer Settings.asset.meta b/EintooAR/Assets/Animancer Settings.asset.meta
new file mode 100644
index 00000000..4128e696
--- /dev/null
+++ b/EintooAR/Assets/Animancer Settings.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e5fe825ea12eca744ab2410e203856c2
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/AssetArt.meta b/EintooAR/Assets/AssetArt.meta
new file mode 100644
index 00000000..ecd49c60
--- /dev/null
+++ b/EintooAR/Assets/AssetArt.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3ab86ad0f95d7fd438621794de0e0f95
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/AssetRaw.meta b/EintooAR/Assets/AssetRaw.meta
new file mode 100644
index 00000000..bc0d5a69
--- /dev/null
+++ b/EintooAR/Assets/AssetRaw.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8de5bf9d0c58b9042907faa7cfe9a7de
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/DefaultVolumeProfile.asset b/EintooAR/Assets/DefaultVolumeProfile.asset
new file mode 100644
index 00000000..36c3781a
--- /dev/null
+++ b/EintooAR/Assets/DefaultVolumeProfile.asset
@@ -0,0 +1,15 @@
+%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: d7fd9488000d3734a9e00ee676215985, type: 3}
+ m_Name: DefaultVolumeProfile
+ m_EditorClassIdentifier:
+ components: []
diff --git a/EintooAR/Assets/DefaultVolumeProfile.asset.meta b/EintooAR/Assets/DefaultVolumeProfile.asset.meta
new file mode 100644
index 00000000..045ca8f3
--- /dev/null
+++ b/EintooAR/Assets/DefaultVolumeProfile.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 885a73187e1fd1746bed2b42b85ebfaa
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/Editor.meta b/EintooAR/Assets/Editor.meta
new file mode 100644
index 00000000..a218c824
--- /dev/null
+++ b/EintooAR/Assets/Editor.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3b549395c8849674b9cafbbf4c694e57
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/GameScripts.meta b/EintooAR/Assets/GameScripts.meta
new file mode 100644
index 00000000..cdeed4da
--- /dev/null
+++ b/EintooAR/Assets/GameScripts.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7c3a047ecd3df324f8173b18e341b00c
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/Plugins.meta b/EintooAR/Assets/Plugins.meta
new file mode 100644
index 00000000..31f5e631
--- /dev/null
+++ b/EintooAR/Assets/Plugins.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 96b331509cb4a2d4b8ee2e2231163061
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/Resources.meta b/EintooAR/Assets/Resources.meta
new file mode 100644
index 00000000..3bd71238
--- /dev/null
+++ b/EintooAR/Assets/Resources.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c9f44168256b58449b48c5beb13c07aa
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/Scenes.meta b/EintooAR/Assets/Scenes.meta
new file mode 100644
index 00000000..dac72239
--- /dev/null
+++ b/EintooAR/Assets/Scenes.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f46b2e8a7bdbd6e4cb5b2477d7bd38a4
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/StreamingAssets.meta b/EintooAR/Assets/StreamingAssets.meta
new file mode 100644
index 00000000..e8475155
--- /dev/null
+++ b/EintooAR/Assets/StreamingAssets.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d1707a36949a8cc4d8a16aae67a41802
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine.meta b/EintooAR/Assets/TEngine.meta
new file mode 100644
index 00000000..2e5c0ce3
--- /dev/null
+++ b/EintooAR/Assets/TEngine.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e25f00a32f8e7ca4eaa2c45d3c20530f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/AssetSetting.meta b/EintooAR/Assets/TEngine/AssetSetting.meta
new file mode 100644
index 00000000..8eddc302
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 99f69e470317dae4baa94d3f4d000253
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml
new file mode 100644
index 00000000..8a611403
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml.meta b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml.meta
new file mode 100644
index 00000000..3ae38d6b
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorConfig.xml.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 218816e46e4f6304eaecd6fdc3a99f4d
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset
new file mode 100644
index 00000000..32d26934
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset
@@ -0,0 +1,203 @@
+%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: 185f6993d5150494d98da50e26cb1c25, type: 3}
+ m_Name: AssetBundleCollectorSetting
+ m_EditorClassIdentifier:
+ ShowPackageView: 0
+ ShowEditorAlias: 0
+ UniqueBundleName: 0
+ Packages:
+ - PackageName: DefaultPackage
+ PackageDesc: "\u9ED8\u8BA4\u8D44\u6E90\u5305"
+ EnableAddressable: 1
+ LocationToLower: 0
+ IncludeAssetGUID: 0
+ AutoCollectShaders: 1
+ IgnoreRuleName: NormalIgnoreRule
+ Groups:
+ - GroupName: Actor
+ GroupDesc: "\u89D2\u8272"
+ AssetTags: Actor
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Actor
+ CollectorGUID: 9c67ce0c9edfd4e4aa1006ee39846d66
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: UIRaw
+ GroupDesc: "\u56FE\u7247\u8D44\u6E90"
+ AssetTags: UIRaw
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/UIRaw/Atlas
+ CollectorGUID: 6d11fa91acc253840a648b58f23db139
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - CollectPath: Assets/AssetRaw/UIRaw/Raw
+ CollectorGUID: 6bc134b912ac6bb4399ea1bec4c11636
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Audios
+ GroupDesc: "\u97F3\u9891"
+ AssetTags: Audios
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Audios
+ CollectorGUID: 8ef7a411b66e70f4cb65c2233c9a0868
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Configs
+ GroupDesc: "\u914D\u7F6E\u8868"
+ AssetTags: Configs
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Configs
+ CollectorGUID: dd2928019aef34248af368b99bc53bea
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags: WEBGL_PRELOAD
+ UserData:
+ - GroupName: DLL
+ GroupDesc: "\u4EE3\u7801"
+ AssetTags: DLL
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/DLL
+ CollectorGUID: 3aad79ec1ea08c24c891bd3c669d4125
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Effects
+ GroupDesc: "\u7279\u6548"
+ AssetTags: Effects
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Effects
+ CollectorGUID: 0fe175e1e1bd49a4ca71e66b6a9b7237
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Materials
+ GroupDesc: "\u6750\u8D28\u7403"
+ AssetTags: Materials
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Materials
+ CollectorGUID: 228b1547e7065d546ad0bf215fd6a276
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Scenes
+ GroupDesc: "\u573A\u666F"
+ AssetTags: Scenes
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Scenes
+ CollectorGUID: cace6ee6539f661419b5e5f8ae1c0146
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackSeparately
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Shaders
+ GroupDesc: "\u7740\u8272\u5668"
+ AssetTags: Shaders
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Shaders
+ CollectorGUID: 2a4bceb84ed685447ace957f497eb810
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackSeparately
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: UI
+ GroupDesc: "UI\u9762\u677F"
+ AssetTags: UI
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/UI
+ CollectorGUID: 27e87d83814156648b58f380b834e046
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackSeparately
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Fonts
+ GroupDesc: "\u5B57\u4F53"
+ AssetTags: Fonts
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Fonts
+ CollectorGUID: 2473375c9ee163a4b861278b38091455
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: ScriptableObject
+ GroupDesc: "\u5E8F\u5217\u5316\u8D44\u6E90"
+ AssetTags:
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/ScriptableObject
+ CollectorGUID: 1b58ac5eefb69124eb767cd325772350
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
+ - GroupName: Animation
+ GroupDesc: "\u52A8\u753B"
+ AssetTags:
+ ActiveRuleName: EnableGroup
+ Collectors:
+ - CollectPath: Assets/AssetRaw/Animation
+ CollectorGUID: acc72186faad1b74db841ed9f4de45a1
+ CollectorType: 0
+ AddressRuleName: AddressByFileName
+ PackRuleName: PackDirectory
+ FilterRuleName: CollectAll
+ AssetTags:
+ UserData:
diff --git a/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset.meta b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset.meta
new file mode 100644
index 00000000..b35e5acb
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/AssetBundleCollectorSetting.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 007a65bdc7416fd4a8823ff50f753d50
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/AssetSetting/Resources.meta b/EintooAR/Assets/TEngine/AssetSetting/Resources.meta
new file mode 100644
index 00000000..1c20db44
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/Resources.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 5bee0ab9d1e77fa409a7ddf10bf7fa7f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset b/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset
new file mode 100644
index 00000000..a307713e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset
@@ -0,0 +1,16 @@
+%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: 5bd1afdce9715f84eb4cbc901922afc2, type: 3}
+ m_Name: YooAssetSettings
+ m_EditorClassIdentifier:
+ ManifestFileName: PackageManifest
+ DefaultYooFolderName: package
diff --git a/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset.meta b/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset.meta
new file mode 100644
index 00000000..3fc35863
--- /dev/null
+++ b/EintooAR/Assets/TEngine/AssetSetting/Resources/YooAssetSettings.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7637ee5d97b976b4ca47bcf91324aca5
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor.meta b/EintooAR/Assets/TEngine/Editor.meta
new file mode 100644
index 00000000..c541d1eb
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 2125a57c5434d7842a5f97624829667e
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols.meta b/EintooAR/Assets/TEngine/Editor/DefineSymbols.meta
new file mode 100644
index 00000000..640b36a2
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 9d9e289b71d5448498e7ee52d1da52d8
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs b/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs
new file mode 100644
index 00000000..0b53399c
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs
@@ -0,0 +1,172 @@
+using UnityEditor;
+
+namespace TEngine.Editor
+{
+ ///
+ /// 日志脚本宏定义操作类。
+ ///
+ public static class LogScriptingDefineSymbols
+ {
+ private const string EnableLogScriptingDefineSymbol = "ENABLE_LOG";
+ private const string EnableDebugAndAboveLogScriptingDefineSymbol = "ENABLE_DEBUG_AND_ABOVE_LOG";
+ private const string EnableInfoAndAboveLogScriptingDefineSymbol = "ENABLE_INFO_AND_ABOVE_LOG";
+ private const string EnableWarningAndAboveLogScriptingDefineSymbol = "ENABLE_WARNING_AND_ABOVE_LOG";
+ private const string EnableErrorAndAboveLogScriptingDefineSymbol = "ENABLE_ERROR_AND_ABOVE_LOG";
+ private const string EnableFatalAndAboveLogScriptingDefineSymbol = "ENABLE_FATAL_AND_ABOVE_LOG";
+ private const string EnableDebugLogScriptingDefineSymbol = "ENABLE_DEBUG_LOG";
+ private const string EnableInfoLogScriptingDefineSymbol = "ENABLE_INFO_LOG";
+ private const string EnableWarningLogScriptingDefineSymbol = "ENABLE_WARNING_LOG";
+ private const string EnableErrorLogScriptingDefineSymbol = "ENABLE_ERROR_LOG";
+ private const string EnableFatalLogScriptingDefineSymbol = "ENABLE_FATAL_LOG";
+
+ private static readonly string[] AboveLogScriptingDefineSymbols = new string[]
+ {
+ EnableDebugAndAboveLogScriptingDefineSymbol,
+ EnableInfoAndAboveLogScriptingDefineSymbol,
+ EnableWarningAndAboveLogScriptingDefineSymbol,
+ EnableErrorAndAboveLogScriptingDefineSymbol,
+ EnableFatalAndAboveLogScriptingDefineSymbol
+ };
+
+ private static readonly string[] SpecifyLogScriptingDefineSymbols = new string[]
+ {
+ EnableDebugLogScriptingDefineSymbol,
+ EnableInfoLogScriptingDefineSymbol,
+ EnableWarningLogScriptingDefineSymbol,
+ EnableErrorLogScriptingDefineSymbol,
+ EnableFatalLogScriptingDefineSymbol
+ };
+
+ ///
+ /// 禁用所有日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Disable All Logs", false, 30)]
+ public static void DisableAllLogs()
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableLogScriptingDefineSymbol);
+
+ foreach (string specifyLogScriptingDefineSymbol in SpecifyLogScriptingDefineSymbols)
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(specifyLogScriptingDefineSymbol);
+ }
+
+ foreach (string aboveLogScriptingDefineSymbol in AboveLogScriptingDefineSymbols)
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
+ }
+ }
+
+ ///
+ /// 开启所有日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable All Logs", false, 31)]
+ public static void EnableAllLogs()
+ {
+ DisableAllLogs();
+ ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 开启调试及以上级别的日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable Debug And Above Logs", false, 32)]
+ public static void EnableDebugAndAboveLogs()
+ {
+ SetAboveLogScriptingDefineSymbol(EnableDebugAndAboveLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 开启信息及以上级别的日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable Info And Above Logs", false, 33)]
+ public static void EnableInfoAndAboveLogs()
+ {
+ SetAboveLogScriptingDefineSymbol(EnableInfoAndAboveLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 开启警告及以上级别的日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable Warning And Above Logs", false, 34)]
+ public static void EnableWarningAndAboveLogs()
+ {
+ SetAboveLogScriptingDefineSymbol(EnableWarningAndAboveLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 开启错误及以上级别的日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable Error And Above Logs", false, 35)]
+ public static void EnableErrorAndAboveLogs()
+ {
+ SetAboveLogScriptingDefineSymbol(EnableErrorAndAboveLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 开启严重错误及以上级别的日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Log Scripting Define Symbols/Enable Fatal And Above Logs", false, 36)]
+ public static void EnableFatalAndAboveLogs()
+ {
+ SetAboveLogScriptingDefineSymbol(EnableFatalAndAboveLogScriptingDefineSymbol);
+ }
+
+ ///
+ /// 设置日志脚本宏定义。
+ ///
+ /// 要设置的日志脚本宏定义。
+ public static void SetAboveLogScriptingDefineSymbol(string aboveLogScriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(aboveLogScriptingDefineSymbol))
+ {
+ return;
+ }
+
+ foreach (string i in AboveLogScriptingDefineSymbols)
+ {
+ if (i == aboveLogScriptingDefineSymbol)
+ {
+ DisableAllLogs();
+ ScriptingDefineSymbols.AddScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
+ return;
+ }
+ }
+ }
+
+ ///
+ /// 设置日志脚本宏定义。
+ ///
+ /// 要设置的日志脚本宏定义。
+ public static void SetSpecifyLogScriptingDefineSymbols(string[] specifyLogScriptingDefineSymbols)
+ {
+ if (specifyLogScriptingDefineSymbols == null || specifyLogScriptingDefineSymbols.Length <= 0)
+ {
+ return;
+ }
+
+ bool removed = false;
+ foreach (string specifyLogScriptingDefineSymbol in specifyLogScriptingDefineSymbols)
+ {
+ if (string.IsNullOrEmpty(specifyLogScriptingDefineSymbol))
+ {
+ continue;
+ }
+
+ foreach (string i in SpecifyLogScriptingDefineSymbols)
+ {
+ if (i == specifyLogScriptingDefineSymbol)
+ {
+ if (!removed)
+ {
+ removed = true;
+ DisableAllLogs();
+ }
+
+ ScriptingDefineSymbols.AddScriptingDefineSymbol(specifyLogScriptingDefineSymbol);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs.meta b/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs.meta
new file mode 100644
index 00000000..15449fa6
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/LogScriptingDefineSymbols.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a7f38582e7109d344bd714fb29e2cd97
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs
new file mode 100644
index 00000000..e416bb7a
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs
@@ -0,0 +1,44 @@
+using UnityEditor;
+
+namespace TEngine.Editor
+{
+ ///
+ /// Profiler分析器宏定义操作类。
+ ///
+ public class ProfilerDefineSymbols
+ {
+ private const string EnableFirstProfiler = "FIRST_PROFILER";
+ private const string EnableTProFiler = "T_PROFILER";
+
+ private static readonly string[] AllProfilerDefineSymbols = new string[]
+ {
+ EnableFirstProfiler,
+ EnableTProFiler,
+ };
+
+ ///
+ /// 禁用所有日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Profiler Define Symbols/Disable All Profiler", false, 30)]
+ public static void DisableAllProfiler()
+ {
+ foreach (string aboveLogScriptingDefineSymbol in AllProfilerDefineSymbols)
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
+ }
+ }
+
+ ///
+ /// 开启所有日志脚本宏定义。
+ ///
+ [MenuItem("TEngine/Profiler Define Symbols/Enable All Profiler", false, 31)]
+ public static void EnableAllProfiler()
+ {
+ DisableAllProfiler();
+ foreach (string aboveLogScriptingDefineSymbol in AllProfilerDefineSymbols)
+ {
+ ScriptingDefineSymbols.AddScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs.meta b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs.meta
new file mode 100644
index 00000000..025f04cf
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ProfilerDefineSymbols.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 1503a11737564a498b65d84dc90758c2
+timeCreated: 1694790771
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs
new file mode 100644
index 00000000..01010d88
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs
@@ -0,0 +1,151 @@
+using System.Collections.Generic;
+using UnityEditor;
+
+namespace TEngine.Editor
+{
+ ///
+ /// 脚本宏定义操作类。
+ ///
+ public static class ScriptingDefineSymbols
+ {
+ private static readonly BuildTargetGroup[] BuildTargetGroups = new BuildTargetGroup[]
+ {
+ BuildTargetGroup.Standalone,
+ BuildTargetGroup.iOS,
+ BuildTargetGroup.Android,
+ BuildTargetGroup.WSA,
+ BuildTargetGroup.WebGL,
+ BuildTargetGroup.PS5
+ };
+
+ ///
+ /// 检查指定平台是否存在指定的脚本宏定义。
+ ///
+ /// 要检查脚本宏定义的平台。
+ /// 要检查的脚本宏定义。
+ /// 指定平台是否存在指定的脚本宏定义。
+ public static bool HasScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(scriptingDefineSymbol))
+ {
+ return false;
+ }
+
+ string[] scriptingDefineSymbols = GetScriptingDefineSymbols(buildTargetGroup);
+ foreach (string i in scriptingDefineSymbols)
+ {
+ if (i == scriptingDefineSymbol)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ ///
+ /// 为指定平台增加指定的脚本宏定义。
+ ///
+ /// 要增加脚本宏定义的平台。
+ /// 要增加的脚本宏定义。
+ public static void AddScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ if (HasScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ List scriptingDefineSymbols = new List(GetScriptingDefineSymbols(buildTargetGroup))
+ {
+ scriptingDefineSymbol
+ };
+
+ SetScriptingDefineSymbols(buildTargetGroup, scriptingDefineSymbols.ToArray());
+ }
+
+ ///
+ /// 为指定平台移除指定的脚本宏定义。
+ ///
+ /// 要移除脚本宏定义的平台。
+ /// 要移除的脚本宏定义。
+ public static void RemoveScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ if (!HasScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ List scriptingDefineSymbols = new List(GetScriptingDefineSymbols(buildTargetGroup));
+ while (scriptingDefineSymbols.Contains(scriptingDefineSymbol))
+ {
+ scriptingDefineSymbols.Remove(scriptingDefineSymbol);
+ }
+
+ SetScriptingDefineSymbols(buildTargetGroup, scriptingDefineSymbols.ToArray());
+ }
+
+ ///
+ /// 为所有平台增加指定的脚本宏定义。
+ ///
+ /// 要增加的脚本宏定义。
+ public static void AddScriptingDefineSymbol(string scriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroups)
+ {
+ AddScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol);
+ }
+ }
+
+ ///
+ /// 为所有平台移除指定的脚本宏定义。
+ ///
+ /// 要移除的脚本宏定义。
+ public static void RemoveScriptingDefineSymbol(string scriptingDefineSymbol)
+ {
+ if (string.IsNullOrEmpty(scriptingDefineSymbol))
+ {
+ return;
+ }
+
+ foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroups)
+ {
+ RemoveScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol);
+ }
+ }
+
+ ///
+ /// 获取指定平台的脚本宏定义。
+ ///
+ /// 要获取脚本宏定义的平台。
+ /// 平台的脚本宏定义。
+ public static string[] GetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup)
+ {
+ return PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(';');
+ }
+
+ ///
+ /// 设置指定平台的脚本宏定义。
+ ///
+ /// 要设置脚本宏定义的平台。
+ /// 要设置的脚本宏定义。
+ public static void SetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup, string[] scriptingDefineSymbols)
+ {
+ PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", scriptingDefineSymbols));
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs.meta b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs.meta
new file mode 100644
index 00000000..5d7cb7c2
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/DefineSymbols/ScriptingDefineSymbols.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 654ee3e03c534f841bf22040608d720e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/EditorTools.meta b/EintooAR/Assets/TEngine/Editor/EditorTools.meta
new file mode 100644
index 00000000..65cf4b8d
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EditorTools.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 654d71b5910a48b686279708db8865e2
+timeCreated: 1710744353
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs b/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs
new file mode 100644
index 00000000..d90ffd00
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs
@@ -0,0 +1,20 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor
+{
+ public static class LubanTools
+ {
+ [MenuItem("TEngine/Tools/Luban 转表")]
+ public static void BuildLubanExcel()
+ {
+ Application.OpenURL(Application.dataPath + @"/../../Configs/GameConfig/gen_code_bin_to_project_lazyload.bat");
+ }
+
+ [MenuItem("TEngine/Tools/打开表格目录")]
+ public static void OpenConfigFolder()
+ {
+ OpenFolderHelper.Execute(Application.dataPath + @"/../../Configs/GameConfig");
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs.meta b/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs.meta
new file mode 100644
index 00000000..c06325dd
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EditorTools/LubanTools.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 0d51346d2ce24afaba0b8c9e8095fff4
+timeCreated: 1708583331
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/EventInterface.meta b/EintooAR/Assets/TEngine/Editor/EventInterface.meta
new file mode 100644
index 00000000..22841d96
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EventInterface.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 86094b7c7ca31ab4da174cc7eae14a3c
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs b/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs
new file mode 100644
index 00000000..fd398f35
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs
@@ -0,0 +1,307 @@
+/*#region Class Documentation
+/************************************************************************************************************
+Class Name: EventInterfaceGenerate.cs
+Type: Editor, Generator, Util, Static
+Definition:
+ 用法,在目录"Assets/GameScripts/HotFix/GameLogic/Event/Interface/"下分组照示例声明Interface 模块待抛出事件的接口。编译后自动生成接口实现抛出的脚本。
+Example:
+
+ 旧版抛出事件方式: GameEvent.Send(RuntimeId.ToRuntimeId("OnMainPlayerCurrencyChange"),CurrencyType.Gold,oldVal,newVal);
+
+ 新版抛出事件方式 : GameEvent.Get().OnMainPlayerCurrencyChange(CurrencyType.Gold,oldVal,newVal);
+
+***********************************************************************************************************#1#
+#endregion
+
+using HybridCLR.Editor.Settings;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using TEngine;
+using Unity.EditorCoroutines.Editor;
+using UnityEditor;
+using UnityEngine;
+
+[InitializeOnLoad]
+public static class EventInterfaceGenerate
+{
+ public static string NameSpace = @"GameLogic";
+
+
+ public const string EventInterfacePath = "Assets/GameScripts/HotFix/GameLogic/Event/Interface/";
+
+ public static bool BOpenAutoGenerate = false;
+
+ static EventInterfaceGenerate()
+ {
+ BOpenAutoGenerate = EditorPrefs.GetBool("EventInterfaceGenerate.BOpenAutoGenerate", true);
+ if (BOpenAutoGenerate)
+ {
+ Generate();
+ }
+ }
+
+ [MenuItem("TEngine/EventInterface/OpenAutoGenerate", false, 300)]
+ public static void OpenAutoGenerate()
+ {
+ EditorPrefs.SetBool("EventInterfaceGenerate.BOpenAutoGenerate", true);
+ Debug.Log("OpenAutoGenerate");
+ }
+
+ [MenuItem("TEngine/EventInterface/CloseAutoGenerate", false, 301)]
+ public static void CloseAutoGenerate()
+ {
+ EditorPrefs.SetBool("EventInterfaceGenerate.BOpenAutoGenerate", false);
+ Debug.Log("CloseAutoGenerate");
+ }
+
+ [MenuItem("TEngine/EventInterface/Generate EventInterface", false, 302)]
+ public static void Generate()
+ {
+ if (EventInterfaceGenerateTag.HadGenerate)
+ {
+ return;
+ }
+
+ EventInterfaceGenerateTag.HadGenerate = true;
+
+ // 加载程序集
+ Assembly assembly = null;
+ foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ foreach(var type in asm.GetTypes())
+ {
+ if (type.Name == "GameApp")
+ {
+ assembly = asm;
+ break;
+ }
+ }
+ }
+ if(assembly == null)
+ {
+ Debug.LogError("Game App Class Not Found");
+ return;
+ }
+
+ // 获取程序集中的所有类型
+ Type[] types = assembly.GetTypes();
+
+ // 遍历每个类型
+ foreach (Type type in types)
+ {
+ // 检查类型是否是接口
+ if (!type.IsInterface)
+ {
+ continue;
+ }
+
+ var attribute = type.GetCustomAttributes(typeof(EventInterfaceAttribute), false).FirstOrDefault();
+
+ if (attribute != null)
+ {
+ EventInterfaceAttribute eventInterfaceAttribute = attribute as EventInterfaceAttribute;
+
+ GenAutoBindCode(type, eventInterfaceAttribute);
+ }
+ }
+
+ AssetDatabase.Refresh();
+ Debug.Log("Generate EventInterface Complete");
+ // EditorUtility.DisplayDialog("提示", "代码生成完毕", "OK");
+
+ EditorCoroutineUtility.StartCoroutine(EventInterfaceGenerateTag.Reset(), null);
+ }
+
+ ///
+ /// 生成自动绑定代码
+ ///
+ private static void GenAutoBindCode(Type interfaceType, EventInterfaceAttribute eventInterfaceAttribute)
+ {
+ string interfaceName = interfaceType.Name;
+ string className = $"{interfaceName}_Gen";
+ string codePath = $"{Application.dataPath}/GameScripts/HotFix/GameLogic/Event/Gen/{eventInterfaceAttribute.EventGroup}";
+
+ if (!Directory.Exists(codePath))
+ {
+ Directory.CreateDirectory(codePath);
+ }
+
+ using (StreamWriter sw = new StreamWriter($"{codePath}/{className}.cs"))
+ {
+ sw.WriteLine(
+ $"//------------------------------------------------------------------------------\n//\t\n//\t\tThis code was generated by autoBindTool.\n//\t\tChanges to this file may cause incorrect behavior and will be lost if\n//\t\tthe code is regenerated.\n//\t\n//------------------------------------------------------------------------------");
+ sw.WriteLine("using UnityEngine;");
+ sw.WriteLine("using UnityEngine.UI;");
+ sw.WriteLine("using TEngine;");
+ sw.WriteLine("");
+
+ if (!string.IsNullOrEmpty(NameSpace))
+ {
+ //命名空间
+ sw.WriteLine("namespace " + NameSpace);
+ sw.WriteLine("{");
+ }
+
+ #region EventId生成
+
+ sw.WriteLine($"\tpublic partial class {interfaceName}_Event");
+ sw.WriteLine("\t{");
+
+ // 获取接口中的所有方法
+ MethodInfo[] methods = interfaceType.GetMethods();
+
+ HashSet hadGenerate = new HashSet();
+
+ //组件字段
+ foreach (MethodInfo method in methods)
+ {
+ if (hadGenerate.Contains(method.Name))
+ {
+ continue;
+ }
+ sw.WriteLine($"\t\tpublic static readonly int {method.Name} = RuntimeId.ToRuntimeId(\"{interfaceName}_Event.{method.Name}\");");
+ hadGenerate.Add(method.Name);
+ }
+
+ sw.WriteLine("\t}");
+ sw.WriteLine("");
+
+ #endregion
+
+
+ //类名
+ sw.WriteLine($"\t[EventInterfaceImp(EEventGroup.{eventInterfaceAttribute.EventGroup})]");
+ sw.WriteLine($"\tpublic partial class {className} : {interfaceName}");
+ sw.WriteLine("\t{");
+
+ sw.WriteLine("\t\tprivate EventDispatcher _dispatcher;");
+ sw.WriteLine($"\t\tpublic {className}(EventDispatcher dispatcher)");
+ sw.WriteLine("\t\t{");
+ sw.WriteLine($"\t\t\t_dispatcher = dispatcher;");
+ sw.WriteLine("\t\t}");
+ sw.WriteLine("");
+
+ //组件字段
+ foreach (MethodInfo methodInfo in methods)
+ {
+ ParameterInfo[] parameterInfos = methodInfo.GetParameters(); //得到指定方法的参数列表
+ if (parameterInfos.Length <= 0)
+ {
+ sw.WriteLine(
+ $" public void {methodInfo.Name}()\n {{\n _dispatcher.Send({interfaceName}_Event.{methodInfo.Name});\n }}");
+ }
+ else
+ {
+ string paramStr = "";
+ string paramStr2 = "";
+ for (int i = 0; i < parameterInfos.Length; i++)
+ {
+ var parameterInfo = parameterInfos[i];
+ Type type = parameterInfo.ParameterType;
+ string paramName = parameterInfo.Name;
+
+ if (type.FullName.StartsWith("System.Collections.Generic.List"))
+ {
+ Debug.Log("123");
+ }
+
+ if (i == parameterInfos.Length - 1)
+ {
+ paramStr += $"{GetTypeName(parameterInfo)} {paramName}";
+ paramStr2 += $"{paramName}";
+ }
+ else
+ {
+ paramStr += $"{GetTypeName(parameterInfo)} {paramName},";
+ paramStr2 += $"{paramName},";
+ }
+ }
+
+ sw.WriteLine(
+ $" public void {methodInfo.Name}({paramStr})\n {{\n _dispatcher.Send({interfaceName}_Event.{methodInfo.Name},{paramStr2});\n }}");
+ }
+
+ sw.WriteLine("");
+ }
+
+ sw.WriteLine("\t}");
+
+ if (!string.IsNullOrEmpty(NameSpace))
+ {
+ sw.WriteLine("}");
+ }
+ }
+ }
+
+ private static string GetTypeName(ParameterInfo parameterInfo)
+ {
+ if (parameterInfo.ParameterType.IsList() && parameterInfo.ParameterType.IsGenericType)
+ {
+ string typeName = parameterInfo.ParameterType.FullName.Split('`')[0];
+
+ return $"{typeName}<{parameterInfo.ParameterType.GenericTypeArguments[0].FullName}>";
+ }
+ else if (parameterInfo.ParameterType.IsDictionary() && parameterInfo.ParameterType.IsGenericType)
+ {
+ string typeName = parameterInfo.ParameterType.FullName.Split('`')[0];
+
+ return $"{typeName}<{parameterInfo.ParameterType.GenericTypeArguments[0].FullName},{parameterInfo.ParameterType.GenericTypeArguments[1].FullName}>";
+ }
+ else
+ {
+ return parameterInfo.ParameterType.FullName;
+ }
+ }
+
+ ///
+ /// 判断类型是否为可操作的列表类型
+ ///
+ ///
+ ///
+ public static bool IsList(this Type type)
+ {
+ if (typeof (System.Collections.IList).IsAssignableFrom(type))
+ {
+ return true;
+ }
+
+ foreach (var it in type.GetInterfaces())
+ {
+ if (it.IsGenericType && typeof (IList<>) == it.GetGenericTypeDefinition())
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool IsDictionary(this Type type)
+ {
+ if (typeof (System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return true;
+ }
+
+ foreach (var it in type.GetInterfaces())
+ {
+ if (it.IsGenericType && typeof (IDictionary) == it.GetGenericTypeDefinition())
+ return true;
+ }
+
+ return false;
+ }
+}
+
+public static class EventInterfaceGenerateTag
+{
+ public static bool HadGenerate = false;
+
+ public static IEnumerator Reset()
+ {
+ yield return new WaitForSeconds(10f);
+ HadGenerate = false;
+ }
+}*/
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta b/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta
new file mode 100644
index 00000000..2d2f0d43
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3e3af172e88343e4cb49c9e870518ede
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings.meta b/EintooAR/Assets/TEngine/Editor/GameSettings.meta
new file mode 100644
index 00000000..3b266102
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 8886f3797aa14b80ab35d4d5e20d32e6
+timeCreated: 1695127130
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs b/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs
new file mode 100644
index 00000000..b368883e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs
@@ -0,0 +1,7 @@
+using UnityEditor;
+
+public static class SettingsMenu
+{
+ [MenuItem("TEngine/Settings/TEngineSettings", priority = -1)]
+ public static void OpenSettings() => SettingsService.OpenProjectSettings("TEngine/TEngineSettings");
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs.meta b/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs.meta
new file mode 100644
index 00000000..39aa9c82
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/SettingsMenu.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1afcc6b01c286a54d84a1c6a27deceb8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs b/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs
new file mode 100644
index 00000000..784a5772
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs
@@ -0,0 +1,35 @@
+using UnityEditor;
+using UnityEngine;
+
+///
+/// 同步程序集上下文。
+///
+public static class SyncAssemblyContent
+{
+ public static void RefreshAssembly()
+ {
+ var hotUpdateAssemblyFiles = HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyFilesIncludePreserved;
+ var aotAssemblyNames = HybridCLR.Editor.SettingsUtil.AOTAssemblyNames;
+
+ // 检查两个列表是否都为空,如果是,记录日志并返回。
+ if (hotUpdateAssemblyFiles.Count == 0 && aotAssemblyNames.Count == 0)
+ {
+ Debug.Log("HybridCLR.Editor.SettingsUtil 程序集列表值为空");
+ return;
+ }
+
+ // 如果列表不为空,则更新相应的设置。
+ if (hotUpdateAssemblyFiles.Count > 0)
+ {
+ SettingsUtils.SetHybridCLRHotUpdateAssemblies(hotUpdateAssemblyFiles);
+ }
+
+ if (aotAssemblyNames.Count > 0)
+ {
+ SettingsUtils.SetHybridCLRAOTMetaAssemblies(aotAssemblyNames);
+ }
+
+ AssetDatabase.Refresh();
+ AssetDatabase.SaveAssets();
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs.meta b/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs.meta
new file mode 100644
index 00000000..fcdafeab
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 04407344026702f4ebd61f63c8a35c69
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs b/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs
new file mode 100644
index 00000000..0d16fc28
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs
@@ -0,0 +1,115 @@
+using System.IO;
+using UnityEditor;
+using UnityEngine.UIElements;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TEngineSettingsProvider : SettingsProvider
+{
+ const string k_SettingsPathHeader = "Assets/TEngine/ResRaw/Resources/";
+ const string k_SettingsPath = "Assets/TEngine/ResRaw/Resources/TEngineGlobalSettings.asset";
+ private const string headerName = "TEngine/TEngineSettings";
+ private SerializedObject m_CustomSettings;
+
+ private static string m_SettingsPath = k_SettingsPath;
+ internal static SerializedObject GetSerializedSettings()
+ {
+ return new SerializedObject(SettingsUtils.GlobalSettings);
+ }
+
+ public static bool IsSettingsAvailable()
+ {
+ var pathes = AssetDatabase.FindAssets("TEngineGlobalSettings", new string[2] { k_SettingsPathHeader,"Packages/com.tengine/" });
+ if (pathes.Length > 0)
+ {
+ m_SettingsPath = AssetDatabase.GUIDToAssetPath(pathes[0]);
+ }
+ return pathes.Length > 0;
+ }
+
+ public override void OnActivate(string searchContext, VisualElement rootElement)
+ {
+ base.OnActivate(searchContext, rootElement);
+ m_CustomSettings = GetSerializedSettings();
+ }
+
+ public override void OnDeactivate()
+ {
+ base.OnDeactivate();
+
+ // 确保只有在有修改时才保存
+ if (m_CustomSettings != null && m_CustomSettings.hasModifiedProperties)
+ {
+ EditorApplication.delayCall += () => SaveAssetData(k_SettingsPath);
+ }
+ }
+
+ void SaveAssetData(string path)
+ {
+ TEngineSettings old = AssetDatabase.LoadAssetAtPath(k_SettingsPath);
+ if (old == null)
+ {
+ Debug.LogError($"Failed to load TEngineSettings from path: {k_SettingsPath}");
+ return;
+ }
+
+ TEngineSettings data = ScriptableObject.CreateInstance();
+ data.Set(old.FrameworkGlobalSettings, old.BybridCLRCustomGlobalSettings);
+
+ if (AssetDatabase.DeleteAsset(path))
+ {
+ AssetDatabase.CreateAsset(data, path);
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ }
+ else
+ {
+ Debug.LogError($"Failed to delete existing asset at path: {path}");
+ }
+ }
+
+
+ public override void OnGUI(string searchContext)
+ {
+ base.OnGUI(searchContext);
+ using var changeCheckScope = new EditorGUI.ChangeCheckScope();
+ EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_FrameworkGlobalSettings"));
+
+ if (GUILayout.Button("Refresh HotUpdateAssemblies"))
+ {
+ SyncAssemblyContent.RefreshAssembly();
+ m_CustomSettings.ApplyModifiedPropertiesWithoutUndo();
+ m_CustomSettings = null;
+ m_CustomSettings = GetSerializedSettings();
+ }
+
+ EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_HybridCLRCustomGlobalSettings"));
+ EditorGUILayout.Space(20);
+ if (!changeCheckScope.changed)
+ {
+ return;
+ }
+ m_CustomSettings.ApplyModifiedPropertiesWithoutUndo();
+ }
+
+ public TEngineSettingsProvider(string path, SettingsScope scopes, IEnumerable keywords = null) : base(path, scopes, keywords)
+ {
+ }
+
+ [SettingsProvider]
+ private static SettingsProvider CreateSettingProvider()
+ {
+ if (IsSettingsAvailable())
+ {
+ var provider = new TEngineSettingsProvider(headerName, SettingsScope.Project);
+ provider.keywords = GetSearchKeywordsFromGUIContentProperties();
+ return provider;
+ }
+ else
+ {
+ Debug.LogError($"Open TEngine Settings error,Please Create TEngine TEngineGlobalSettings.assets File in Path TEngine/ResRaw/Resources/");
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs.meta b/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs.meta
new file mode 100644
index 00000000..f88cb196
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/GameSettings/TEngineSettingsProvider.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 09fb422339ad47ec86205963c369718b
+timeCreated: 1678946531
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/HybridCLR.meta b/EintooAR/Assets/TEngine/Editor/HybridCLR.meta
new file mode 100644
index 00000000..714d76dc
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/HybridCLR.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 71b72a5760a04a4c8a3d8197729c3d10
+timeCreated: 1695127841
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs b/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs
new file mode 100644
index 00000000..6ad5d3e6
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs
@@ -0,0 +1,99 @@
+#if ENABLE_HYBRIDCLR
+using HybridCLR.Editor;
+using HybridCLR.Editor.Commands;
+#endif
+using TEngine.Editor;
+using UnityEditor;
+using UnityEngine;
+
+public static class BuildDLLCommand
+{
+ private const string EnableHybridClrScriptingDefineSymbol = "ENABLE_HYBRIDCLR";
+
+ ///
+ /// 禁用HybridCLR宏定义。
+ ///
+ [MenuItem("HybridCLR/Define Symbols/Disable HybridCLR", false, 30)]
+ public static void Disable()
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
+ HybridCLR.Editor.SettingsUtil.Enable = false;
+ SyncAssemblyContent.RefreshAssembly();
+ }
+
+ ///
+ /// 开启HybridCLR宏定义。
+ ///
+ [MenuItem("HybridCLR/Define Symbols/Enable HybridCLR", false, 31)]
+ public static void Enable()
+ {
+ ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
+ ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
+ HybridCLR.Editor.SettingsUtil.Enable = true;
+ SyncAssemblyContent.RefreshAssembly();
+ }
+
+ [MenuItem("HybridCLR/Build/BuildAssets And CopyTo AssemblyTextAssetPath")]
+ public static void BuildAndCopyDlls()
+ {
+#if ENABLE_HYBRIDCLR
+ BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
+ CompileDllCommand.CompileDll(target);
+ CopyAOTHotUpdateDlls(target);
+#endif
+ }
+
+ public static void BuildAndCopyDlls(BuildTarget target)
+ {
+#if ENABLE_HYBRIDCLR
+ CompileDllCommand.CompileDll(target);
+ CopyAOTHotUpdateDlls(target);
+#endif
+ }
+
+ public static void CopyAOTHotUpdateDlls(BuildTarget target)
+ {
+ CopyAOTAssembliesToAssetPath();
+ CopyHotUpdateAssembliesToAssetPath();
+ AssetDatabase.Refresh();
+ }
+
+ public static void CopyAOTAssembliesToAssetPath()
+ {
+#if ENABLE_HYBRIDCLR
+ var target = EditorUserBuildSettings.activeBuildTarget;
+ string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
+ string aotAssembliesDstDir = Application.dataPath +"/"+ SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath;
+
+ foreach (var dll in SettingsUtils.HybridCLRCustomGlobalSettings.AOTMetaAssemblies)
+ {
+ string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
+ if (!System.IO.File.Exists(srcDllPath))
+ {
+ Debug.LogError($"ab中添加AOT补充元数据dll:{srcDllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。");
+ continue;
+ }
+ string dllBytesPath = $"{aotAssembliesDstDir}/{dll}.bytes";
+ System.IO.File.Copy(srcDllPath, dllBytesPath, true);
+ Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {srcDllPath} -> {dllBytesPath}");
+ }
+#endif
+ }
+
+ public static void CopyHotUpdateAssembliesToAssetPath()
+ {
+#if ENABLE_HYBRIDCLR
+ var target = EditorUserBuildSettings.activeBuildTarget;
+
+ string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
+ string hotfixAssembliesDstDir = Application.dataPath +"/"+ SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath;
+ foreach (var dll in SettingsUtil.HotUpdateAssemblyFilesExcludePreserved)
+ {
+ string dllPath = $"{hotfixDllSrcDir}/{dll}";
+ string dllBytesPath = $"{hotfixAssembliesDstDir}/{dll}.bytes";
+ System.IO.File.Copy(dllPath, dllBytesPath, true);
+ Debug.Log($"[CopyHotUpdateAssembliesToStreamingAssets] copy hotfix dll {dllPath} -> {dllBytesPath}");
+ }
+#endif
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs.meta b/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs.meta
new file mode 100644
index 00000000..0d759b52
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/HybridCLR/BuildDLLCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b43c8d69a58c066469f4f28e310d8181
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector.meta b/EintooAR/Assets/TEngine/Editor/Inspector.meta
new file mode 100644
index 00000000..cf5ab3b2
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d070fe16674cbe240be91ed06370b6be
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Asset.meta b/EintooAR/Assets/TEngine/Editor/Inspector/Asset.meta
new file mode 100644
index 00000000..ad882a4e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1d6f43591dfb9c54fbbebda60c1210fa
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs
new file mode 100644
index 00000000..58d309e0
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs
@@ -0,0 +1,52 @@
+using UnityEngine;
+using UnityEditor;
+using System.IO;
+
+[CanEditMultipleObjects, CustomEditor(typeof(DefaultAsset), false)]
+public class DefaultAssetInspector : Editor
+{
+ private const int MaxColum = 10240;
+
+ private GUIStyle _textStyle;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+ if (_textStyle == null)
+ {
+ _textStyle = "ScriptText";
+ }
+
+ bool enabled = GUI.enabled;
+ GUI.enabled = true;
+ string assetPath = AssetDatabase.GetAssetPath(target);
+ if (assetPath.EndsWith(".lua") ||
+ assetPath.EndsWith(".properties") ||
+ assetPath.EndsWith(".gradle")
+ )
+ {
+ string luaFile = File.ReadAllText(assetPath);
+ string text;
+ if (targets.Length > 1)
+ {
+ text = Path.GetFileName(assetPath);
+ }
+ else
+ {
+ text = luaFile;
+ if (text.Length > MaxColum)
+ {
+ text = text.Substring(0, MaxColum) + "...\n\n<...etc...>";
+ }
+ }
+
+ Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle);
+ rect.x = 0f;
+ rect.y -= 3f;
+ rect.width = EditorGUIUtility.currentViewWidth + 1f;
+ GUI.Box(rect, text, _textStyle);
+ }
+
+ GUI.enabled = enabled;
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta
new file mode 100644
index 00000000..3fe57bdc
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 83f53d2e775d0ff449616ff946f1be55
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs
new file mode 100644
index 00000000..b2e7ea4f
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs
@@ -0,0 +1,53 @@
+using UnityEngine;
+using UnityEditor;
+using System.IO;
+
+[CanEditMultipleObjects, CustomEditor(typeof(TextAsset))]
+public class TextAssetInspector : Editor
+{
+ private const int MaxColum = 10240;
+
+ private GUIStyle _textStyle;
+
+ public override void OnInspectorGUI()
+ {
+ if (_textStyle == null)
+ {
+ _textStyle = "ScriptText";
+ }
+
+ bool enabled = GUI.enabled;
+ GUI.enabled = true;
+ string assetPath = AssetDatabase.GetAssetPath(target);
+ if (assetPath.EndsWith(".md")
+ || assetPath.EndsWith(".xml")
+ || assetPath.EndsWith(".txt")
+ || assetPath.EndsWith(".html")
+ || assetPath.EndsWith(".csv")
+ )
+ {
+ string luaFile = File.ReadAllText(assetPath);
+ string text;
+ if (base.targets.Length > 1)
+ {
+ text = Path.GetFileName(assetPath);
+ }
+ else
+ {
+ text = luaFile;
+ if (text.Length > MaxColum)
+ {
+ text = text.Substring(0, MaxColum) + "...\n\n<...etc...>";
+ }
+ }
+
+ Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle);
+ rect.x = 0f;
+ rect.y -= 3f;
+ rect.width = EditorGUIUtility.currentViewWidth + 1f;
+ GUI.Box(rect, text, _textStyle);
+ }
+
+ GUI.enabled = enabled;
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta
new file mode 100644
index 00000000..7d2cb6fc
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ad0327765273616459117746a53a35e6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs
new file mode 100644
index 00000000..4dbc50f5
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs
@@ -0,0 +1,54 @@
+using UnityEditor;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(AudioModule))]
+ internal sealed class AudioModuleInspector : GameFrameworkInspector
+ {
+ private SerializedProperty m_InstanceRoot = null;
+ private SerializedProperty m_AudioMixer = null;
+ private SerializedProperty m_AudioGroupConfigs = null;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ AudioModule t = (AudioModule)target;
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ EditorGUILayout.PropertyField(m_InstanceRoot);
+ EditorGUILayout.PropertyField(m_AudioMixer);
+
+ EditorGUILayout.PropertyField(m_AudioGroupConfigs, true);
+ }
+ EditorGUI.EndDisabledGroup();
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_InstanceRoot = serializedObject.FindProperty("m_InstanceRoot");
+ m_AudioMixer = serializedObject.FindProperty("m_AudioMixer");
+ m_AudioGroupConfigs = serializedObject.FindProperty("m_AudioGroupConfigs");
+ RefreshTypeNames();
+ }
+
+ private void RefreshTypeNames()
+ {
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs.meta
new file mode 100644
index 00000000..9d6ae3f5
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/AudioModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3ab21fc9c6dd70744a63b928446497bd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Core.meta b/EintooAR/Assets/TEngine/Editor/Inspector/Core.meta
new file mode 100644
index 00000000..39b3a8ad
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Core.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b430ccb333d3963468369c50283c6174
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs
new file mode 100644
index 00000000..078713d8
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs
@@ -0,0 +1,57 @@
+using UnityEditor;
+
+namespace TEngine.Editor.Inspector
+{
+ ///
+ /// 游戏框架 Inspector 抽象类。
+ ///
+ public abstract class GameFrameworkInspector : UnityEditor.Editor
+ {
+ private bool m_IsCompiling = false;
+
+ ///
+ /// 绘制事件。
+ ///
+ public override void OnInspectorGUI()
+ {
+ if (m_IsCompiling && !EditorApplication.isCompiling)
+ {
+ m_IsCompiling = false;
+ OnCompileComplete();
+ }
+ else if (!m_IsCompiling && EditorApplication.isCompiling)
+ {
+ m_IsCompiling = true;
+ OnCompileStart();
+ }
+ }
+
+ ///
+ /// 编译开始事件。
+ ///
+ protected virtual void OnCompileStart()
+ {
+ }
+
+ ///
+ /// 编译完成事件。
+ ///
+ protected virtual void OnCompileComplete()
+ {
+ }
+
+ protected bool IsPrefabInHierarchy(UnityEngine.Object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+
+#if UNITY_2018_3_OR_NEWER
+ return PrefabUtility.GetPrefabAssetType(obj) != PrefabAssetType.Regular;
+#else
+ return PrefabUtility.GetPrefabType(obj) != PrefabType.Prefab;
+#endif
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs.meta
new file mode 100644
index 00000000..ae6810e8
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/Core/GameFrameworkInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9d91af5de1cd262429b9414da4df0a4d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs
new file mode 100644
index 00000000..b0978fdc
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs
@@ -0,0 +1,40 @@
+using UnityEditor;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(FsmModule))]
+ internal sealed class FsmComponentInspector : GameFrameworkInspector
+ {
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ if (!EditorApplication.isPlaying)
+ {
+ EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info);
+ return;
+ }
+
+ FsmModule t = (FsmModule)target;
+
+ if (IsPrefabInHierarchy(t.gameObject))
+ {
+ EditorGUILayout.LabelField("FSM Count", t.Count.ToString());
+
+ FsmBase[] fsms = t.GetAllFsms();
+ foreach (FsmBase fsm in fsms)
+ {
+ DrawFsm(fsm);
+ }
+ }
+
+ Repaint();
+ }
+
+ private void DrawFsm(FsmBase fsm)
+ {
+ EditorGUILayout.LabelField(fsm.FullName,
+ fsm.IsRunning ? Utility.Text.Format("{0}, {1:F1} s", fsm.CurrentStateName, fsm.CurrentStateTime) : (fsm.IsDestroyed ? "Destroyed" : "Not Running"));
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs.meta
new file mode 100644
index 00000000..7f6da490
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/FsmComponentInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 70767d883b439f84d8daaed6ca3f6d35
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs
new file mode 100644
index 00000000..012209b3
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs
@@ -0,0 +1,143 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(MemoryPoolModule))]
+ internal sealed class MemoryPoolModuleInspector : GameFrameworkInspector
+ {
+ private readonly Dictionary> m_MemoryPoolInfos = new Dictionary>(StringComparer.Ordinal);
+ private readonly HashSet m_OpenedItems = new HashSet();
+
+ private SerializedProperty m_EnableStrictCheck = null;
+
+ private bool m_ShowFullClassName = false;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ MemoryPoolModule t = (MemoryPoolModule)target;
+
+ if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
+ {
+ bool enableStrictCheck = EditorGUILayout.Toggle("Enable Strict Check", t.EnableStrictCheck);
+ if (enableStrictCheck != t.EnableStrictCheck)
+ {
+ t.EnableStrictCheck = enableStrictCheck;
+ }
+
+ EditorGUILayout.LabelField("Memory Pool Count", MemoryPool.Count.ToString());
+ m_ShowFullClassName = EditorGUILayout.Toggle("Show Full Class Name", m_ShowFullClassName);
+ m_MemoryPoolInfos.Clear();
+ MemoryPoolInfo[] memoryPoolInfos = MemoryPool.GetAllMemoryPoolInfos();
+ foreach (MemoryPoolInfo memoryPoolInfo in memoryPoolInfos)
+ {
+ string assemblyName = memoryPoolInfo.Type.Assembly.GetName().Name;
+ List results = null;
+ if (!m_MemoryPoolInfos.TryGetValue(assemblyName, out results))
+ {
+ results = new List();
+ m_MemoryPoolInfos.Add(assemblyName, results);
+ }
+
+ results.Add(memoryPoolInfo);
+ }
+
+ foreach (KeyValuePair> assemblyMemoryPoolInfo in m_MemoryPoolInfos)
+ {
+ bool lastState = m_OpenedItems.Contains(assemblyMemoryPoolInfo.Key);
+ bool currentState = EditorGUILayout.Foldout(lastState, assemblyMemoryPoolInfo.Key);
+ if (currentState != lastState)
+ {
+ if (currentState)
+ {
+ m_OpenedItems.Add(assemblyMemoryPoolInfo.Key);
+ }
+ else
+ {
+ m_OpenedItems.Remove(assemblyMemoryPoolInfo.Key);
+ }
+ }
+
+ if (currentState)
+ {
+ EditorGUILayout.BeginVertical("box");
+ {
+ EditorGUILayout.LabelField(m_ShowFullClassName ? "Full Class Name" : "Class Name", "Unused\tUsing\tAcquire\tRelease\tAdd\tRemove");
+ assemblyMemoryPoolInfo.Value.Sort(Comparison);
+ foreach (MemoryPoolInfo memoryPoolInfo in assemblyMemoryPoolInfo.Value)
+ {
+ DrawMemoryPoolInfo(memoryPoolInfo);
+ }
+
+ if (GUILayout.Button("Export CSV Data"))
+ {
+ string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, Utility.Text.Format("Memory Pool Data - {0}.csv", assemblyMemoryPoolInfo.Key), string.Empty);
+ if (!string.IsNullOrEmpty(exportFileName))
+ {
+ try
+ {
+ int index = 0;
+ string[] data = new string[assemblyMemoryPoolInfo.Value.Count + 1];
+ data[index++] = "Class Name,Full Class Name,Unused,Using,Acquire,Release,Add,Remove";
+ foreach (MemoryPoolInfo memoryPoolInfo in assemblyMemoryPoolInfo.Value)
+ {
+ data[index++] = Utility.Text.Format("{0},{1},{2},{3},{4},{5},{6},{7}", memoryPoolInfo.Type.Name, memoryPoolInfo.Type.FullName, memoryPoolInfo.UnusedMemoryCount.ToString(), memoryPoolInfo.UsingMemoryCount.ToString(), memoryPoolInfo.AcquireMemoryCount.ToString(), memoryPoolInfo.ReleaseMemoryCount.ToString(), memoryPoolInfo.AddMemoryCount.ToString(), memoryPoolInfo.RemoveMemoryCount.ToString());
+ }
+
+ File.WriteAllLines(exportFileName, data, Encoding.UTF8);
+ Debug.Log(Utility.Text.Format("Export memory pool CSV data to '{0}' success.", exportFileName));
+ }
+ catch (Exception exception)
+ {
+ Debug.LogError(Utility.Text.Format("Export memory pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString()));
+ }
+ }
+ }
+ }
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.Separator();
+ }
+ }
+ }
+ else
+ {
+ EditorGUILayout.PropertyField(m_EnableStrictCheck);
+ }
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ private void OnEnable()
+ {
+ m_EnableStrictCheck = serializedObject.FindProperty("m_EnableStrictCheck");
+ }
+
+ private void DrawMemoryPoolInfo(MemoryPoolInfo memoryPoolInfo)
+ {
+ EditorGUILayout.LabelField(m_ShowFullClassName ? memoryPoolInfo.Type.FullName : memoryPoolInfo.Type.Name, Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", memoryPoolInfo.UnusedMemoryCount.ToString(), memoryPoolInfo.UsingMemoryCount.ToString(), memoryPoolInfo.AcquireMemoryCount.ToString(), memoryPoolInfo.ReleaseMemoryCount.ToString(), memoryPoolInfo.AddMemoryCount.ToString(), memoryPoolInfo.RemoveMemoryCount.ToString()));
+ }
+
+ private int Comparison(MemoryPoolInfo a, MemoryPoolInfo b)
+ {
+ if (m_ShowFullClassName)
+ {
+ return a.Type.FullName.CompareTo(b.Type.FullName);
+ }
+ else
+ {
+ return a.Type.Name.CompareTo(b.Type.Name);
+ }
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs.meta
new file mode 100644
index 00000000..c3cd948b
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/MemoryPoolModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 17406c25c88f31948b13eed588b32244
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs
new file mode 100644
index 00000000..de504bd5
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(ObjectPoolModule))]
+ internal sealed class ObjectPoolModuleInspector : GameFrameworkInspector
+ {
+ private readonly HashSet m_OpenedItems = new HashSet();
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ if (!EditorApplication.isPlaying)
+ {
+ EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info);
+ return;
+ }
+
+ ObjectPoolModule t = (ObjectPoolModule)target;
+
+ if (IsPrefabInHierarchy(t.gameObject))
+ {
+ EditorGUILayout.LabelField("Object Pool Count", t.Count.ToString());
+
+ ObjectPoolBase[] objectPools = t.GetAllObjectPools(true);
+ foreach (ObjectPoolBase objectPool in objectPools)
+ {
+ DrawObjectPool(objectPool);
+ }
+ }
+
+ Repaint();
+ }
+
+ private void OnEnable()
+ {
+ }
+
+ private void DrawObjectPool(ObjectPoolBase objectPool)
+ {
+ bool lastState = m_OpenedItems.Contains(objectPool.FullName);
+ bool currentState = EditorGUILayout.Foldout(lastState, objectPool.FullName);
+ if (currentState != lastState)
+ {
+ if (currentState)
+ {
+ m_OpenedItems.Add(objectPool.FullName);
+ }
+ else
+ {
+ m_OpenedItems.Remove(objectPool.FullName);
+ }
+ }
+
+ if (currentState)
+ {
+ EditorGUILayout.BeginVertical("box");
+ {
+ EditorGUILayout.LabelField("Name", objectPool.Name);
+ EditorGUILayout.LabelField("Type", objectPool.ObjectType.FullName);
+ EditorGUILayout.LabelField("Auto Release Interval", objectPool.AutoReleaseInterval.ToString());
+ EditorGUILayout.LabelField("Capacity", objectPool.Capacity.ToString());
+ EditorGUILayout.LabelField("Used Count", objectPool.Count.ToString());
+ EditorGUILayout.LabelField("Can Release Count", objectPool.CanReleaseCount.ToString());
+ EditorGUILayout.LabelField("Expire Time", objectPool.ExpireTime.ToString());
+ EditorGUILayout.LabelField("Priority", objectPool.Priority.ToString());
+ ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos();
+ if (objectInfos.Length > 0)
+ {
+ EditorGUILayout.LabelField("Name",
+ objectPool.AllowMultiSpawn ? "Locked\tCount\tFlag\tPriority\tLast Use Time" : "Locked\tIn Use\tFlag\tPriority\tLast Use Time");
+ foreach (ObjectInfo objectInfo in objectInfos)
+ {
+ EditorGUILayout.LabelField(string.IsNullOrEmpty(objectInfo.Name) ? "" : objectInfo.Name,
+ objectPool.AllowMultiSpawn
+ ? Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.SpawnCount,
+ objectInfo.CustomCanReleaseFlag,
+ objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
+ : Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.IsInUse,
+ objectInfo.CustomCanReleaseFlag,
+ objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime()));
+ }
+
+ if (GUILayout.Button("Release"))
+ {
+ objectPool.Release();
+ }
+
+ if (GUILayout.Button("Release All Unused"))
+ {
+ objectPool.ReleaseAllUnused();
+ }
+
+ if (GUILayout.Button("Export CSV Data"))
+ {
+ string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty,
+ Utility.Text.Format("Object Pool Data - {0}.csv", objectPool.Name),
+ string.Empty);
+ if (!string.IsNullOrEmpty(exportFileName))
+ {
+ try
+ {
+ int index = 0;
+ string[] data = new string[objectInfos.Length + 1];
+ data[index++] = Utility.Text.Format("Name,Locked,{0},Custom Can Release Flag,Priority,Last Use Time",
+ objectPool.AllowMultiSpawn ? "Count" : "In Use");
+ foreach (ObjectInfo objectInfo in objectInfos)
+ {
+ data[index++] = objectPool.AllowMultiSpawn
+ ? Utility.Text.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked,
+ objectInfo.SpawnCount,
+ objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
+ : Utility.Text.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked,
+ objectInfo.IsInUse,
+ objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime());
+ }
+
+ File.WriteAllLines(exportFileName, data, Encoding.UTF8);
+ Debug.Log(Utility.Text.Format("Export object pool CSV data to '{0}' success.", exportFileName));
+ }
+ catch (Exception exception)
+ {
+ Debug.LogError(Utility.Text.Format("Export object pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName,
+ exception));
+ }
+ }
+ }
+ }
+ else
+ {
+ GUILayout.Label("Object Pool is Empty ...");
+ }
+ }
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.Separator();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs.meta
new file mode 100644
index 00000000..9c73a738
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ObjectPoolModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 581eaf027c4a96d4d8227e2e16a6645b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs
new file mode 100644
index 00000000..0eedc1cb
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs
@@ -0,0 +1,163 @@
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(ProcedureModule))]
+ internal sealed class ProcedureModuleInspector : GameFrameworkInspector
+ {
+ private SerializedProperty m_AvailableProcedureTypeNames = null;
+ private SerializedProperty m_EntranceProcedureTypeName = null;
+
+ private string[] m_ProcedureTypeNames = null;
+ private List m_CurrentAvailableProcedureTypeNames = null;
+ private int m_EntranceProcedureIndex = -1;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ ProcedureModule t = (ProcedureModule)target;
+
+ if (string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
+ {
+ EditorGUILayout.HelpBox("Entrance procedure is invalid.", MessageType.Error);
+ }
+ else if (EditorApplication.isPlaying)
+ {
+ EditorGUILayout.LabelField("Current Procedure", t.CurrentProcedure == null ? "None" : t.CurrentProcedure.GetType().ToString());
+ }
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ GUILayout.Label("Available Procedures", EditorStyles.boldLabel);
+ if (m_ProcedureTypeNames.Length > 0)
+ {
+ EditorGUILayout.BeginVertical("box");
+ {
+ foreach (string procedureTypeName in m_ProcedureTypeNames)
+ {
+ bool selected = m_CurrentAvailableProcedureTypeNames.Contains(procedureTypeName);
+ if (selected != EditorGUILayout.ToggleLeft(procedureTypeName, selected))
+ {
+ if (!selected)
+ {
+ m_CurrentAvailableProcedureTypeNames.Add(procedureTypeName);
+ WriteAvailableProcedureTypeNames();
+ }
+ else if (procedureTypeName != m_EntranceProcedureTypeName.stringValue)
+ {
+ m_CurrentAvailableProcedureTypeNames.Remove(procedureTypeName);
+ WriteAvailableProcedureTypeNames();
+ }
+ }
+ }
+ }
+ EditorGUILayout.EndVertical();
+ }
+ else
+ {
+ EditorGUILayout.HelpBox("There is no available procedure.", MessageType.Warning);
+ }
+
+ if (m_CurrentAvailableProcedureTypeNames.Count > 0)
+ {
+ EditorGUILayout.Separator();
+
+ int selectedIndex = EditorGUILayout.Popup("Entrance Procedure", m_EntranceProcedureIndex, m_CurrentAvailableProcedureTypeNames.ToArray());
+ if (selectedIndex != m_EntranceProcedureIndex)
+ {
+ m_EntranceProcedureIndex = selectedIndex;
+ m_EntranceProcedureTypeName.stringValue = m_CurrentAvailableProcedureTypeNames[selectedIndex];
+ }
+ }
+ else
+ {
+ EditorGUILayout.HelpBox("Select available procedures first.", MessageType.Info);
+ }
+ }
+ EditorGUI.EndDisabledGroup();
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_AvailableProcedureTypeNames = serializedObject.FindProperty("availableProcedureTypeNames");
+ m_EntranceProcedureTypeName = serializedObject.FindProperty("entranceProcedureTypeName");
+
+ RefreshTypeNames();
+ }
+
+ private void RefreshTypeNames()
+ {
+ m_ProcedureTypeNames = Type.GetRuntimeTypeNames(typeof(ProcedureBase));
+ ReadAvailableProcedureTypeNames();
+ int oldCount = m_CurrentAvailableProcedureTypeNames.Count;
+ m_CurrentAvailableProcedureTypeNames = m_CurrentAvailableProcedureTypeNames.Where(x => m_ProcedureTypeNames.Contains(x)).ToList();
+ if (m_CurrentAvailableProcedureTypeNames.Count != oldCount)
+ {
+ WriteAvailableProcedureTypeNames();
+ }
+ else if (!string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
+ {
+ m_EntranceProcedureIndex = m_CurrentAvailableProcedureTypeNames.IndexOf(m_EntranceProcedureTypeName.stringValue);
+ if (m_EntranceProcedureIndex < 0)
+ {
+ m_EntranceProcedureTypeName.stringValue = null;
+ }
+ }
+
+ serializedObject.ApplyModifiedProperties();
+ }
+
+ private void ReadAvailableProcedureTypeNames()
+ {
+ m_CurrentAvailableProcedureTypeNames = new List();
+ int count = m_AvailableProcedureTypeNames.arraySize;
+ for (int i = 0; i < count; i++)
+ {
+ m_CurrentAvailableProcedureTypeNames.Add(m_AvailableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue);
+ }
+ }
+
+ private void WriteAvailableProcedureTypeNames()
+ {
+ m_AvailableProcedureTypeNames.ClearArray();
+ if (m_CurrentAvailableProcedureTypeNames == null)
+ {
+ return;
+ }
+
+ m_CurrentAvailableProcedureTypeNames.Sort();
+ int count = m_CurrentAvailableProcedureTypeNames.Count;
+ for (int i = 0; i < count; i++)
+ {
+ m_AvailableProcedureTypeNames.InsertArrayElementAtIndex(i);
+ m_AvailableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue = m_CurrentAvailableProcedureTypeNames[i];
+ }
+
+ if (!string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
+ {
+ m_EntranceProcedureIndex = m_CurrentAvailableProcedureTypeNames.IndexOf(m_EntranceProcedureTypeName.stringValue);
+ if (m_EntranceProcedureIndex < 0)
+ {
+ m_EntranceProcedureTypeName.stringValue = null;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs.meta
new file mode 100644
index 00000000..affc01b3
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ProcedureModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6f8673b671dafe048a9fcd213c958166
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs
new file mode 100644
index 00000000..abe51a2a
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs
@@ -0,0 +1,290 @@
+using System;
+using System.Collections.Generic;
+using UnityEditor;
+using YooAsset.Editor;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(ResourceModule))]
+ internal sealed class ResourceModuleInspector : GameFrameworkInspector
+ {
+ private static readonly string[] _resourceModeNames = new string[]
+ {
+ "EditorSimulateMode (编辑器下的模拟模式)",
+ "OfflinePlayMode (单机模式)",
+ "HostPlayMode (联机运行模式)",
+ "WebPlayMode (WebGL运行模式)"
+ };
+
+ private static readonly string[] _verifyLevelNames = new string[]
+ {
+ "Low (验证文件存在)",
+ "Middle (验证文件大小)",
+ "High (验证文件大小和CRC)"
+ };
+
+ private SerializedProperty m_PlayMode = null;
+ private SerializedProperty m_UpdatableWhilePlaying = null;
+ private SerializedProperty m_VerifyLevel = null;
+ private SerializedProperty m_Milliseconds = null;
+ private SerializedProperty m_ReadWritePathType = null;
+ private SerializedProperty m_MinUnloadUnusedAssetsInterval = null;
+ private SerializedProperty m_MaxUnloadUnusedAssetsInterval = null;
+ private SerializedProperty m_UseSystemUnloadUnusedAssets = null;
+ private SerializedProperty m_AssetAutoReleaseInterval = null;
+ private SerializedProperty m_AssetCapacity = null;
+ private SerializedProperty m_AssetExpireTime = null;
+ private SerializedProperty m_AssetPriority = null;
+ private SerializedProperty m_DownloadingMaxNum = null;
+ private SerializedProperty m_FailedTryAgain = null;
+ private SerializedProperty m_PackageName = null;
+ private int m_ResourceModeIndex = 0;
+ private int m_VerifyIndex = 0;
+
+ private int m_PackageNameIndex = 0;
+ private string[] m_PackageNames;
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ ResourceModule t = (ResourceModule)target;
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
+ {
+ EditorGUILayout.EnumPopup("Resource Mode", t.PlayMode);
+
+ EditorGUILayout.EnumPopup("VerifyLevel", t.VerifyLevel);
+ }
+ else
+ {
+ int selectedIndex = EditorGUILayout.Popup("Resource Mode", m_ResourceModeIndex, _resourceModeNames);
+ if (selectedIndex != m_ResourceModeIndex)
+ {
+ m_ResourceModeIndex = selectedIndex;
+ m_PlayMode.enumValueIndex = selectedIndex;
+ }
+
+ int selectedVerifyIndex = EditorGUILayout.Popup("VerifyLevel", m_VerifyIndex, _verifyLevelNames);
+ if (selectedVerifyIndex != m_VerifyIndex)
+ {
+ m_VerifyIndex = selectedVerifyIndex;
+ m_VerifyLevel.enumValueIndex = selectedVerifyIndex;
+ }
+ }
+
+ m_ReadWritePathType.enumValueIndex = (int)(ReadWritePathType)EditorGUILayout.EnumPopup("Read-Write Path Type", t.ReadWritePathType);
+ }
+ EditorGUILayout.PropertyField(m_UpdatableWhilePlaying);
+
+ EditorGUI.EndDisabledGroup();
+
+ m_PackageNames = GetBuildPackageNames().ToArray();
+ m_PackageNameIndex = Array.IndexOf(m_PackageNames, m_PackageName.stringValue);
+ if (m_PackageNameIndex < 0)
+ {
+ m_PackageNameIndex = 0;
+ }
+ m_PackageNameIndex = EditorGUILayout.Popup("Package Name", m_PackageNameIndex, m_PackageNames);
+ if (m_PackageName.stringValue != m_PackageNames[m_PackageNameIndex])
+ {
+ m_PackageName.stringValue = m_PackageNames[m_PackageNameIndex];
+ }
+
+ int milliseconds = EditorGUILayout.DelayedIntField("Milliseconds", m_Milliseconds.intValue);
+ if (milliseconds != m_Milliseconds.intValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.Milliseconds = milliseconds;
+ }
+ else
+ {
+ m_Milliseconds.longValue = milliseconds;
+ }
+ }
+
+ EditorGUILayout.PropertyField(m_UseSystemUnloadUnusedAssets);
+
+ float minUnloadUnusedAssetsInterval =
+ EditorGUILayout.Slider("Min Unload Unused Assets Interval", m_MinUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
+ if (Math.Abs(minUnloadUnusedAssetsInterval - m_MinUnloadUnusedAssetsInterval.floatValue) > 0.01f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.MinUnloadUnusedAssetsInterval = minUnloadUnusedAssetsInterval;
+ }
+ else
+ {
+ m_MinUnloadUnusedAssetsInterval.floatValue = minUnloadUnusedAssetsInterval;
+ }
+ }
+
+ float maxUnloadUnusedAssetsInterval =
+ EditorGUILayout.Slider("Max Unload Unused Assets Interval", m_MaxUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
+ if (Math.Abs(maxUnloadUnusedAssetsInterval - m_MaxUnloadUnusedAssetsInterval.floatValue) > 0.01f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.MaxUnloadUnusedAssetsInterval = maxUnloadUnusedAssetsInterval;
+ }
+ else
+ {
+ m_MaxUnloadUnusedAssetsInterval.floatValue = maxUnloadUnusedAssetsInterval;
+ }
+ }
+
+ float downloadingMaxNum = EditorGUILayout.Slider("Max Downloading Num", m_DownloadingMaxNum.intValue, 1f, 48f);
+ if (Math.Abs(downloadingMaxNum - m_DownloadingMaxNum.intValue) > 0.001f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.DownloadingMaxNum = (int)downloadingMaxNum;
+ }
+ else
+ {
+ m_DownloadingMaxNum.intValue = (int)downloadingMaxNum;
+ }
+ }
+
+ float failedTryAgain = EditorGUILayout.Slider("Max FailedTryAgain Count", m_FailedTryAgain.intValue, 1f, 48f);
+ if (Math.Abs(failedTryAgain - m_FailedTryAgain.intValue) > 0.001f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.FailedTryAgain = (int)failedTryAgain;
+ }
+ else
+ {
+ m_FailedTryAgain.intValue = (int)failedTryAgain;
+ }
+ }
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);
+ {
+ float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", m_AssetAutoReleaseInterval.floatValue);
+ if (Math.Abs(assetAutoReleaseInterval - m_AssetAutoReleaseInterval.floatValue) > 0.01f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.AssetAutoReleaseInterval = assetAutoReleaseInterval;
+ }
+ else
+ {
+ m_AssetAutoReleaseInterval.floatValue = assetAutoReleaseInterval;
+ }
+ }
+
+ int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", m_AssetCapacity.intValue);
+ if (assetCapacity != m_AssetCapacity.intValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.AssetCapacity = assetCapacity;
+ }
+ else
+ {
+ m_AssetCapacity.intValue = assetCapacity;
+ }
+ }
+
+ float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", m_AssetExpireTime.floatValue);
+ if (Math.Abs(assetExpireTime - m_AssetExpireTime.floatValue) > 0.01f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.AssetExpireTime = assetExpireTime;
+ }
+ else
+ {
+ m_AssetExpireTime.floatValue = assetExpireTime;
+ }
+ }
+
+ int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", m_AssetPriority.intValue);
+ if (assetPriority != m_AssetPriority.intValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.AssetPriority = assetPriority;
+ }
+ else
+ {
+ m_AssetPriority.intValue = assetPriority;
+ }
+ }
+ }
+ EditorGUI.EndDisabledGroup();
+
+ if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
+ {
+ EditorGUILayout.LabelField("Unload Unused Assets",
+ Utility.Text.Format("{0:F2} / {1:F2}", t.LastUnloadUnusedAssetsOperationElapseSeconds, t.MaxUnloadUnusedAssetsInterval));
+ EditorGUILayout.LabelField("Read-Only Path", t?.ReadOnlyPath?.ToString());
+ EditorGUILayout.LabelField("Read-Write Path", t?.ReadWritePath?.ToString());
+ EditorGUILayout.LabelField("Applicable Game Version", t.ApplicableGameVersion ?? "");
+ }
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_PlayMode = serializedObject.FindProperty("playMode");
+ m_UpdatableWhilePlaying = serializedObject.FindProperty("m_UpdatableWhilePlaying");
+ m_VerifyLevel = serializedObject.FindProperty("VerifyLevel");
+ m_Milliseconds = serializedObject.FindProperty("Milliseconds");
+ m_ReadWritePathType = serializedObject.FindProperty("m_ReadWritePathType");
+ m_MinUnloadUnusedAssetsInterval = serializedObject.FindProperty("m_MinUnloadUnusedAssetsInterval");
+ m_MaxUnloadUnusedAssetsInterval = serializedObject.FindProperty("m_MaxUnloadUnusedAssetsInterval");
+ m_UseSystemUnloadUnusedAssets = serializedObject.FindProperty("m_UseSystemUnloadUnusedAssets");
+ m_AssetAutoReleaseInterval = serializedObject.FindProperty("m_AssetAutoReleaseInterval");
+ m_AssetCapacity = serializedObject.FindProperty("m_AssetCapacity");
+ m_AssetExpireTime = serializedObject.FindProperty("m_AssetExpireTime");
+ m_AssetPriority = serializedObject.FindProperty("m_AssetPriority");
+ m_DownloadingMaxNum = serializedObject.FindProperty("m_DownloadingMaxNum");
+ m_FailedTryAgain = serializedObject.FindProperty("m_FailedTryAgain");
+ m_PackageName = serializedObject.FindProperty("packageName");
+
+ RefreshModes();
+ RefreshTypeNames();
+ }
+
+ private void RefreshModes()
+ {
+ m_ResourceModeIndex = m_PlayMode.enumValueIndex > 0 ? m_PlayMode.enumValueIndex : 0;
+ m_VerifyIndex = m_VerifyLevel.enumValueIndex > 0 ? m_VerifyLevel.enumValueIndex : 0;
+ }
+
+ private void RefreshTypeNames()
+ {
+ serializedObject.ApplyModifiedProperties();
+ }
+
+ ///
+ /// 获取构建包名称列表,用于下拉可选择
+ ///
+ ///
+ private List GetBuildPackageNames()
+ {
+ List result = new List();
+ foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
+ {
+ result.Add(package.PackageName);
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs.meta
new file mode 100644
index 00000000..2744c7d3
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/ResourceModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e3331df47456eb44388680ac13979201
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs
new file mode 100644
index 00000000..c9d70136
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs
@@ -0,0 +1,278 @@
+using System;
+using TEngine;
+using System.Collections.Generic;
+using TEngine.Editor.Inspector;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor
+{
+ [CustomEditor(typeof(RootModule))]
+ internal sealed class RootModuleInspector : GameFrameworkInspector
+ {
+ private const string NoneOptionName = "";
+ private static readonly float[] GameSpeed = new float[] { 0f, 0.01f, 0.1f, 0.25f, 0.5f, 1f, 1.5f, 2f, 4f, 8f };
+ private static readonly string[] GameSpeedForDisplay = new string[] { "0x", "0.01x", "0.1x", "0.25x", "0.5x", "1x", "1.5x", "2x", "4x", "8x" };
+
+ private SerializedProperty m_EditorLanguage = null;
+ private SerializedProperty m_TextHelperTypeName = null;
+ private SerializedProperty m_VersionHelperTypeName = null;
+ private SerializedProperty m_LogHelperTypeName = null;
+ private SerializedProperty m_CompressionHelperTypeName = null;
+ private SerializedProperty m_JsonHelperTypeName = null;
+ private SerializedProperty m_FrameRate = null;
+ private SerializedProperty m_GameSpeed = null;
+ private SerializedProperty m_RunInBackground = null;
+ private SerializedProperty m_NeverSleep = null;
+
+ private string[] m_TextHelperTypeNames = null;
+ private int m_TextHelperTypeNameIndex = 0;
+ private string[] m_VersionHelperTypeNames = null;
+ private int m_VersionHelperTypeNameIndex = 0;
+ private string[] m_LogHelperTypeNames = null;
+ private int m_LogHelperTypeNameIndex = 0;
+ private string[] m_JsonHelperTypeNames = null;
+ private int m_JsonHelperTypeNameIndex = 0;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ RootModule t = (RootModule)target;
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ EditorGUILayout.PropertyField(m_EditorLanguage);
+
+ EditorGUILayout.BeginVertical("box");
+ {
+ EditorGUILayout.LabelField("Global Helpers", EditorStyles.boldLabel);
+
+ int textHelperSelectedIndex = EditorGUILayout.Popup("Text Helper", m_TextHelperTypeNameIndex, m_TextHelperTypeNames);
+ if (textHelperSelectedIndex != m_TextHelperTypeNameIndex)
+ {
+ m_TextHelperTypeNameIndex = textHelperSelectedIndex;
+ m_TextHelperTypeName.stringValue = textHelperSelectedIndex <= 0 ? null : m_TextHelperTypeNames[textHelperSelectedIndex];
+ }
+
+ int versionHelperSelectedIndex = EditorGUILayout.Popup("Version Helper", m_VersionHelperTypeNameIndex, m_VersionHelperTypeNames);
+ if (versionHelperSelectedIndex != m_VersionHelperTypeNameIndex)
+ {
+ m_VersionHelperTypeNameIndex = versionHelperSelectedIndex;
+ m_VersionHelperTypeName.stringValue = versionHelperSelectedIndex <= 0 ? null : m_VersionHelperTypeNames[versionHelperSelectedIndex];
+ }
+
+ int logHelperSelectedIndex = EditorGUILayout.Popup("Log Helper", m_LogHelperTypeNameIndex, m_LogHelperTypeNames);
+ if (logHelperSelectedIndex != m_LogHelperTypeNameIndex)
+ {
+ m_LogHelperTypeNameIndex = logHelperSelectedIndex;
+ m_LogHelperTypeName.stringValue = logHelperSelectedIndex <= 0 ? null : m_LogHelperTypeNames[logHelperSelectedIndex];
+ }
+
+ int jsonHelperSelectedIndex = EditorGUILayout.Popup("JSON Helper", m_JsonHelperTypeNameIndex, m_JsonHelperTypeNames);
+ if (jsonHelperSelectedIndex != m_JsonHelperTypeNameIndex)
+ {
+ m_JsonHelperTypeNameIndex = jsonHelperSelectedIndex;
+ m_JsonHelperTypeName.stringValue = jsonHelperSelectedIndex <= 0 ? null : m_JsonHelperTypeNames[jsonHelperSelectedIndex];
+ }
+ }
+ EditorGUILayout.EndVertical();
+ }
+ EditorGUI.EndDisabledGroup();
+
+ int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 120);
+ if (frameRate != m_FrameRate.intValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.FrameRate = frameRate;
+ }
+ else
+ {
+ m_FrameRate.intValue = frameRate;
+ }
+ }
+
+ EditorGUILayout.BeginVertical("box");
+ {
+ float gameSpeed = EditorGUILayout.Slider("Game Speed", m_GameSpeed.floatValue, 0f, 8f);
+ int selectedGameSpeed = GUILayout.SelectionGrid(GetSelectedGameSpeed(gameSpeed), GameSpeedForDisplay, 5);
+ if (selectedGameSpeed >= 0)
+ {
+ gameSpeed = GetGameSpeed(selectedGameSpeed);
+ }
+
+ if (Math.Abs(gameSpeed - m_GameSpeed.floatValue) > 0.01f)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.GameSpeed = gameSpeed;
+ }
+ else
+ {
+ m_GameSpeed.floatValue = gameSpeed;
+ }
+ }
+ }
+ EditorGUILayout.EndVertical();
+
+ bool runInBackground = EditorGUILayout.Toggle("Run in Background", m_RunInBackground.boolValue);
+ if (runInBackground != m_RunInBackground.boolValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.RunInBackground = runInBackground;
+ }
+ else
+ {
+ m_RunInBackground.boolValue = runInBackground;
+ }
+ }
+
+ bool neverSleep = EditorGUILayout.Toggle("Never Sleep", m_NeverSleep.boolValue);
+ if (neverSleep != m_NeverSleep.boolValue)
+ {
+ if (EditorApplication.isPlaying)
+ {
+ t.NeverSleep = neverSleep;
+ }
+ else
+ {
+ m_NeverSleep.boolValue = neverSleep;
+ }
+ }
+
+ serializedObject.ApplyModifiedProperties();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_EditorLanguage = serializedObject.FindProperty("m_EditorLanguage");
+ m_TextHelperTypeName = serializedObject.FindProperty("m_TextHelperTypeName");
+ m_VersionHelperTypeName = serializedObject.FindProperty("m_VersionHelperTypeName");
+ m_LogHelperTypeName = serializedObject.FindProperty("m_LogHelperTypeName");
+ m_CompressionHelperTypeName = serializedObject.FindProperty("m_CompressionHelperTypeName");
+ m_JsonHelperTypeName = serializedObject.FindProperty("m_JsonHelperTypeName");
+ m_FrameRate = serializedObject.FindProperty("m_FrameRate");
+ m_GameSpeed = serializedObject.FindProperty("m_GameSpeed");
+ m_RunInBackground = serializedObject.FindProperty("m_RunInBackground");
+ m_NeverSleep = serializedObject.FindProperty("m_NeverSleep");
+
+ RefreshTypeNames();
+ }
+
+ private void RefreshTypeNames()
+ {
+ List textHelperTypeNames = new List
+ {
+ NoneOptionName
+ };
+
+ textHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(Utility.Text.ITextHelper)));
+ m_TextHelperTypeNames = textHelperTypeNames.ToArray();
+ m_TextHelperTypeNameIndex = 0;
+ if (!string.IsNullOrEmpty(m_TextHelperTypeName.stringValue))
+ {
+ m_TextHelperTypeNameIndex = textHelperTypeNames.IndexOf(m_TextHelperTypeName.stringValue);
+ if (m_TextHelperTypeNameIndex <= 0)
+ {
+ m_TextHelperTypeNameIndex = 0;
+ m_TextHelperTypeName.stringValue = null;
+ }
+ }
+
+ List versionHelperTypeNames = new List
+ {
+ NoneOptionName
+ };
+
+ versionHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(Version.IVersionHelper)));
+ m_VersionHelperTypeNames = versionHelperTypeNames.ToArray();
+ m_VersionHelperTypeNameIndex = 0;
+ if (!string.IsNullOrEmpty(m_VersionHelperTypeName.stringValue))
+ {
+ m_VersionHelperTypeNameIndex = versionHelperTypeNames.IndexOf(m_VersionHelperTypeName.stringValue);
+ if (m_VersionHelperTypeNameIndex <= 0)
+ {
+ m_VersionHelperTypeNameIndex = 0;
+ m_VersionHelperTypeName.stringValue = null;
+ }
+ }
+
+ List logHelperTypeNames = new List
+ {
+ NoneOptionName
+ };
+
+ logHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(GameFrameworkLog.ILogHelper)));
+ m_LogHelperTypeNames = logHelperTypeNames.ToArray();
+ m_LogHelperTypeNameIndex = 0;
+ if (!string.IsNullOrEmpty(m_LogHelperTypeName.stringValue))
+ {
+ m_LogHelperTypeNameIndex = logHelperTypeNames.IndexOf(m_LogHelperTypeName.stringValue);
+ if (m_LogHelperTypeNameIndex <= 0)
+ {
+ m_LogHelperTypeNameIndex = 0;
+ m_LogHelperTypeName.stringValue = null;
+ }
+ }
+
+ List jsonHelperTypeNames = new List
+ {
+ NoneOptionName
+ };
+
+ jsonHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(Utility.Json.IJsonHelper)));
+ m_JsonHelperTypeNames = jsonHelperTypeNames.ToArray();
+ m_JsonHelperTypeNameIndex = 0;
+ if (!string.IsNullOrEmpty(m_JsonHelperTypeName.stringValue))
+ {
+ m_JsonHelperTypeNameIndex = jsonHelperTypeNames.IndexOf(m_JsonHelperTypeName.stringValue);
+ if (m_JsonHelperTypeNameIndex <= 0)
+ {
+ m_JsonHelperTypeNameIndex = 0;
+ m_JsonHelperTypeName.stringValue = null;
+ }
+ }
+
+ serializedObject.ApplyModifiedProperties();
+ }
+
+ private float GetGameSpeed(int selectedGameSpeed)
+ {
+ if (selectedGameSpeed < 0)
+ {
+ return GameSpeed[0];
+ }
+
+ if (selectedGameSpeed >= GameSpeed.Length)
+ {
+ return GameSpeed[GameSpeed.Length - 1];
+ }
+
+ return GameSpeed[selectedGameSpeed];
+ }
+
+ private int GetSelectedGameSpeed(float gameSpeed)
+ {
+ for (int i = 0; i < GameSpeed.Length; i++)
+ {
+ if (gameSpeed == GameSpeed[i])
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs.meta
new file mode 100644
index 00000000..5c178008
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/RootModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 250c436df9563f04881e590c3fc80e81
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs
new file mode 100644
index 00000000..5e215bc1
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs
@@ -0,0 +1,73 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(SettingModule))]
+ internal sealed class SettingModuleInspector : GameFrameworkInspector
+ {
+ private HelperInfo m_SettingHelperInfo = new HelperInfo("Setting");
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ SettingModule t = (SettingModule)target;
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ m_SettingHelperInfo.Draw();
+ }
+ EditorGUI.EndDisabledGroup();
+
+ if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
+ {
+ EditorGUILayout.LabelField("Setting Count", t.Count >= 0 ? t.Count.ToString() : "");
+ if (t.Count > 0)
+ {
+ string[] settingNames = t.GetAllSettingNames();
+ foreach (string settingName in settingNames)
+ {
+ EditorGUILayout.LabelField(settingName, t.GetString(settingName));
+ }
+ }
+ }
+
+ if (EditorApplication.isPlaying)
+ {
+ if (GUILayout.Button("Save Settings"))
+ {
+ t.Save();
+ }
+ if (GUILayout.Button("Remove All Settings"))
+ {
+ t.RemoveAllSettings();
+ }
+ }
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_SettingHelperInfo.Init(serializedObject);
+
+ RefreshTypeNames();
+ }
+
+ private void RefreshTypeNames()
+ {
+ m_SettingHelperInfo.Refresh();
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs.meta
new file mode 100644
index 00000000..74fa2ef8
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/SettingModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5ef9a06ba6ea31f47bf3f0ef922cf41b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs b/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs
new file mode 100644
index 00000000..4a65ab7e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs
@@ -0,0 +1,57 @@
+using UnityEditor;
+
+namespace TEngine.Editor.Inspector
+{
+ [CustomEditor(typeof(UIModule))]
+ internal sealed class UIModuleInspector : GameFrameworkInspector
+ {
+ private SerializedProperty m_InstanceRoot = null;
+ private SerializedProperty m_enableErrorLog = null;
+ private SerializedProperty m_dontDestroyUIRoot = null;
+ private SerializedProperty m_UICamera = null;
+
+ public override void OnInspectorGUI()
+ {
+ base.OnInspectorGUI();
+
+ serializedObject.Update();
+
+ UIModule t = (UIModule)target;
+
+ EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
+ {
+ EditorGUILayout.PropertyField(m_InstanceRoot);
+ EditorGUILayout.PropertyField(m_enableErrorLog);
+ EditorGUILayout.PropertyField(m_dontDestroyUIRoot);
+ EditorGUILayout.PropertyField(m_UICamera);
+ }
+ EditorGUI.EndDisabledGroup();
+
+ serializedObject.ApplyModifiedProperties();
+
+ Repaint();
+ }
+
+ protected override void OnCompileComplete()
+ {
+ base.OnCompileComplete();
+
+ RefreshTypeNames();
+ }
+
+ private void OnEnable()
+ {
+ m_InstanceRoot = serializedObject.FindProperty("m_InstanceRoot");
+ m_enableErrorLog = serializedObject.FindProperty("m_enableErrorLog");
+ m_dontDestroyUIRoot = serializedObject.FindProperty("m_dontDestroyUIRoot");
+ m_UICamera = serializedObject.FindProperty("m_UICamera");
+
+ RefreshTypeNames();
+ }
+
+ private void RefreshTypeNames()
+ {
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs.meta
new file mode 100644
index 00000000..d3afc96f
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Inspector/UIModuleInspector.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f3d5af6a82ddad247810928f33f2c609
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization.meta b/EintooAR/Assets/TEngine/Editor/Localization.meta
new file mode 100644
index 00000000..b95318b5
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: eee776b99f3e76a4c968d6943979829b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs b/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs
new file mode 100644
index 00000000..0ecd5f0d
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs
@@ -0,0 +1,764 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+using Object = UnityEngine.Object;
+
+namespace TEngine.Localization
+{
+ public class GUITools
+ {
+ static public Color White = Color.white;
+ static public Color LightGray = Color.Lerp(Color.gray, Color.white, 0.5f);
+ static public Color DarkGray = Color.Lerp(Color.gray, Color.white, 0.2f);
+ static public Color LightYellow = Color.Lerp(Color.yellow, Color.white, 0.5f);
+
+ static public GUILayoutOption DontExpandWidth = GUILayout.ExpandWidth(false);
+ static public GUIContent EmptyContent = new GUIContent ();
+
+ static List mDelayedEditorCallbacks = new List();
+
+ #region Delayed Editor Callback
+
+ public static void DelayedCall( System.Action action )
+ {
+ if (mDelayedEditorCallbacks.Count == 0)
+ EditorApplication.update += OnDelayedCall;
+
+ mDelayedEditorCallbacks.Add(action);
+ }
+
+ static void OnDelayedCall()
+ {
+ EditorApplication.update -= OnDelayedCall;
+ var calls = mDelayedEditorCallbacks.ToArray();
+ mDelayedEditorCallbacks.Clear();
+
+ foreach (var call in calls)
+ call();
+ }
+
+
+ #endregion
+
+ #region Header
+ public delegate void fnOnToggled(bool enabled);
+ static public bool DrawHeader (string text, string key, bool ShowToggle=false, bool ToggleState=false, fnOnToggled OnToggle = null, string HelpURL=default(string), Color disabledColor = default(Color))
+ {
+ bool state = EditorPrefs.GetBool(key, false);
+
+ bool newState = DrawHeader (text, state, ShowToggle, ToggleState, OnToggle, HelpURL, disabledColor);
+
+ if (state!=newState) EditorPrefs.SetBool(key, newState);
+ return newState;
+ }
+
+ static public bool DrawHeader (string text, bool state, bool ShowToggle=false, bool ToggleState=false, fnOnToggled OnToggle = null, string HelpURL=default(string), Color disabledColor = default(Color), bool allowCollapsing = true)
+ {
+ GUIStyle Style = new GUIStyle(EditorStyles.foldout);
+ Style.richText = true;
+ EditorStyles.foldout.richText = true;
+ if (state)
+ {
+ //GUI.backgroundColor=DarkGray;
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea/*, GUILayout.Height(1)*/);
+ GUILayout.BeginHorizontal();
+ if (!string.IsNullOrEmpty(text))
+ {
+ if (allowCollapsing)
+ state = GUILayout.Toggle(state, text, Style, GUILayout.ExpandWidth(true));
+ else
+ GUILayout.Label(text, GUILayout.ExpandWidth(true));
+ }
+
+ if (!string.IsNullOrEmpty(HelpURL))
+ {
+ if (GUILayout.Button (Icon_Help, EditorStyles.label, GUILayout.ExpandWidth(false)))
+ Application.OpenURL(HelpURL);
+ }
+ if (ShowToggle)
+ {
+ GUI.changed = false;
+ bool newBool = GUILayout.Toggle(ToggleState, "", "OL Toggle", GUILayout.ExpandWidth(false));
+ if (GUI.changed && OnToggle!=null)
+ OnToggle(newBool);
+ }
+ GUILayout.EndHorizontal();
+ GUILayout.Space(2);
+
+ //GUI.backgroundColor = Color.white;
+ }
+ else
+ {
+ if (ShowToggle && !ToggleState)
+ GUI.color = disabledColor;
+
+ GUILayout.BeginHorizontal("Box");
+ //GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ state = GUILayout.Toggle(state, text, Style, GUILayout.ExpandWidth(true));
+ if (ShowToggle)
+ {
+ GUI.changed = false;
+ bool newBool = GUILayout.Toggle(ToggleState, "", "OL Toggle", GUILayout.ExpandWidth(false));
+ if (GUI.changed && OnToggle!=null)
+ OnToggle(newBool);
+ }
+ GUILayout.EndHorizontal();
+ GUI.color = White;
+ }
+ return state;
+ }
+
+ static public void CloseHeader()
+ {
+ GUILayout.EndHorizontal();
+ }
+
+ public static void OnGUI_Footer(string pluginName, string pluginVersion, string helpURL, string documentationURL, string assetStoreURL)
+ {
+ GUILayout.BeginHorizontal();
+ string versionTip = "";
+ /*if (I2Analytics.HasNewVersion(pluginName))
+ {
+ versionTip = "There is a new version of " + pluginName + ".\nClick here for more details";
+ if (GUILayout.Button(new GUIContent("", versionTip), EditorStyles.label, GUILayout.Width(25)))
+ I2AboutWindow.DoShowScreen();
+
+ var rect = GUILayoutUtility.GetLastRect();
+ rect.yMin = rect.yMax - 25;
+ rect.xMax = rect.xMin + 25;
+ rect.y += 3;
+ GUITools.DrawSkinIcon(rect, "CN EntryWarnIcon", "CN EntryWarn");
+ }*/
+
+ if (GUILayout.Button(new GUIContent("v" + pluginVersion, versionTip), EditorStyles.miniLabel))
+ {
+ Application.OpenURL(assetStoreURL);
+ //I2AboutWindow.DoShowScreen();
+ }
+
+ GUILayout.FlexibleSpace();
+
+ if (GUILayout.Button("Ask a Question", EditorStyles.miniLabel))
+ Application.OpenURL(helpURL);
+
+ GUILayout.Space(10);
+
+ if (GUILayout.Button("Documentation", EditorStyles.miniLabel))
+ Application.OpenURL(documentationURL);
+ GUILayout.EndHorizontal();
+ }
+
+
+ #endregion
+
+ #region Content
+
+ static public void BeginContents ()
+ {
+ EditorGUILayout.BeginHorizontal(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.MinHeight(10f));
+ GUILayout.Space(2f);
+ EditorGUILayout.BeginVertical();
+ GUILayout.Space(2f);
+ }
+
+ static public void EndContents () { EndContents(true); }
+ static public void EndContents ( bool closeHeader )
+ {
+ GUILayout.Space(2f);
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(3f);
+ GUILayout.EndHorizontal();
+
+ if (closeHeader) CloseHeader();
+ }
+
+ #endregion
+
+ #region Tabs
+
+ static public void DrawTabs( SerializedProperty mProperty, GUIStyle Style=null, int height=25 )
+ {
+ int curIndex = mProperty.enumValueIndex;
+ int newIndex = DrawTabs( curIndex, mProperty.enumNames, Style, height);
+
+ if (curIndex!=newIndex)
+ mProperty.enumValueIndex = newIndex;
+ }
+
+ static public int DrawTabs( int Index, string[] Tabs, GUIStyle Style=null, int height=25, bool expand = true)
+ {
+ GUIStyle MyStyle = new GUIStyle(Style!=null?Style:GUI.skin.FindStyle("dragtab"));
+ MyStyle.fixedHeight=0;
+
+ GUILayout.BeginHorizontal();
+ for (int i=0; i0)
+ {
+ string text = Tabs[i].Substring(0, idx);
+ string tooltip = Tabs[i].Substring(idx+1);
+ if ( GUILayout.Toggle(Index==i, new GUIContent(text, tooltip), MyStyle, GUILayout.Height(height), GUILayout.ExpandWidth(expand)) && Index!=i)
+ {
+ Index=i;
+ GUI.FocusControl(string.Empty);
+ }
+ }
+ else
+ {
+ if ( GUILayout.Toggle(Index==i, Tabs[i], MyStyle, GUILayout.Height(height), GUILayout.ExpandWidth(expand)) && Index!=i)
+ {
+ Index=i;
+ GUI.FocusControl(string.Empty);
+ }
+ }
+ }
+ GUILayout.EndHorizontal();
+ return Index;
+ }
+
+ static public void DrawShadowedTabs( SerializedProperty mProperty, GUIStyle Style=null, int height=25, bool expand=true )
+ {
+ int curIndex = mProperty.enumValueIndex;
+ int newIndex = DrawShadowedTabs( curIndex, mProperty.enumNames, height, expand);
+
+ if (curIndex!=newIndex)
+ mProperty.enumValueIndex = newIndex;
+ }
+
+ static public int DrawShadowedTabs( int Index, string[] Tabs, int height = 25, bool expand=true )
+ {
+ GUI.backgroundColor=Color.Lerp (Color.gray, Color.white, 0.2f);
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(1));
+ GUI.backgroundColor=Color.white;
+ GUILayout.Space(2);
+ Index = DrawTabs( Index, Tabs, height: height, expand:expand );
+ GUILayout.EndVertical();
+ return Index;
+ }
+
+ static public int DrawTabs( int Index, Texture2D[] Tabs, GUIStyle Style, int height )
+ {
+ GUIStyle MyStyle = new GUIStyle(Style!=null?Style:GUI.skin.FindStyle("dragtab"));
+ MyStyle.fixedHeight=0;
+
+ //width = Mathf.Max (width, height * Tabs[0].width/(float)Tabs[0].height);
+
+ GUILayout.BeginHorizontal();
+ float width = (EditorGUIUtility.currentViewWidth-(MyStyle.border.left+MyStyle.border.right)*(Tabs.Length-1)) / Tabs.Length;
+ for (int i=0; i1)
+ GUILayout.Space (18);
+ }
+ else
+ {
+ if (GUILayout.Button( "\u25B2", EditorStyles.toolbarButton, GUILayout.Width(18)))
+ MoveUpElement = i;
+ }
+
+ GUILayout.EndHorizontal();
+ }
+
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ Object NewObj = EditorGUILayout.ObjectField( null, typeof(Object), allowSceneObj, GUILayout.ExpandWidth(true));
+ if (testAdd != null)
+ {
+ NewObj = testAdd;
+ }
+
+ if (!allowResources && NewObj != null)
+ {
+ var path = AssetDatabase.GetAssetPath(NewObj);
+ if (path != null && path.Contains("/Resources/"))
+ NewObj = null;
+ }
+ if (NewObj && (allowDuplicates || !ObjectsArrayHasReference(PropArray, NewObj)))
+ {
+ int Index = PropArray.arraySize;
+ PropArray.InsertArrayElementAtIndex( Index );
+ PropArray.GetArrayElementAtIndex(Index).objectReferenceValue = NewObj;
+ hasChanged = true;
+ }
+ GUILayout.EndHorizontal();
+
+ if (DeleteElement>=0)
+ {
+ PropArray.DeleteArrayElementAtIndex( DeleteElement );
+ //PropArray.DeleteArrayElementAtIndex( DeleteElement );
+ hasChanged = true;
+ }
+
+ if (MoveUpElement>=0)
+ {
+ PropArray.MoveArrayElement(MoveUpElement, MoveUpElement-1);
+ hasChanged = true;
+ }
+
+ GUILayout.EndVertical();
+ return hasChanged;
+ }
+
+ static public bool ObjectsArrayHasReference(SerializedProperty PropArray, Object obj)
+ {
+ for (int i = 0, imax = PropArray.arraySize; i < imax; ++i)
+ {
+ SerializedProperty Prop = PropArray.GetArrayElementAtIndex(i);
+ if (Prop.objectReferenceValue == obj)
+ return true;
+ }
+ return false;
+ }
+
+
+ #endregion
+
+ #region Toggle
+
+ static public int ToggleToolbar( int Index, string[] Options )
+ {
+ GUILayout.BeginHorizontal();
+ for (int i=0; i 0)
+ return false;
+
+ // We are not interested in Prefab, unless they are Prefab Instances
+ PrefabType pfType = PrefabUtility.GetPrefabType(Obj);
+ if(pfType == PrefabType.Prefab || pfType == PrefabType.ModelPrefab)
+ return false;
+
+ // If the database contains the object then its not an scene object,
+ // but the previous test should get rid of them, so I will just comment this
+ // unless an false positive object is found in the future
+ //if (AssetDatabase.Contains(Obj))
+ // return false;
+
+ return true;*/
+ }
+
+ public static IEnumerable SceneRoots()
+ {
+ var prop = new HierarchyProperty(HierarchyType.GameObjects);
+ var expanded = new int[0];
+ while (prop.Next(expanded)) {
+ yield return prop.pptrValue as GameObject;
+ }
+ }
+
+ public static List SceneRootsList()
+ {
+ return new List(SceneRoots());
+ }
+
+ public static IEnumerable AllSceneObjects()
+ {
+ var queue = new Queue();
+
+ foreach (var root in SceneRoots()) {
+ var tf = root.transform;
+ yield return tf;
+ queue.Enqueue(tf);
+ }
+
+ while (queue.Count > 0) {
+ foreach (Transform child in queue.Dequeue()) {
+ yield return child;
+ queue.Enqueue(child);
+ }
+ }
+ }
+
+ public static string GetScenePath(Transform tr)
+ {
+ if (tr==null)
+ return string.Empty;
+
+ string path = tr.name;
+ while (tr.parent != null)
+ {
+ tr = tr.parent;
+ path = tr.name + "/" + path;
+ }
+ return path;
+ }
+
+ public static Transform FindObjectInEditor( string scenePath )
+ {
+ if (string.IsNullOrEmpty(scenePath))
+ return null;
+
+ int index = scenePath.IndexOfAny("/\\".ToCharArray());
+ string first = index<0 ? scenePath : scenePath.Substring(0, index);
+
+ foreach (var root in AllSceneObjects())
+ if (root.name==first)
+ {
+ if (index<0)
+ return root;
+
+ return root.Find(scenePath.Substring(index+1));
+ }
+ return null;
+ }
+
+
+ public static GUIContent Icon_Help {
+ get{
+ if (mIconHelp == null)
+ mIconHelp = EditorGUIUtility.IconContent("_Help");
+ return mIconHelp;
+ }
+ }
+ static GUIContent mIconHelp;
+
+ public static GUIStyle FindSkinStyle(string name)
+ {
+ var allStyles = GUI.skin.customStyles;
+ for (int i = 0, imax = allStyles.Length; i < imax; ++i)
+ {
+ if (allStyles[i].name == name)
+ return allStyles[i];
+ }
+ return null;
+ }
+ public static void DrawSkinIcon(Rect rect, params string[] iconNames)
+ {
+ foreach (var icon in iconNames)
+ {
+ var style = FindSkinStyle(icon);
+ if (style == null || style.normal == null || style.normal.background == null)
+ continue;
+
+ GUI.DrawTexture(rect, style.normal.background);
+ return;
+ }
+ //Debug.Log("unable to find icon");
+ }
+
+ #endregion
+
+ #region Angle Drawer
+ private static Vector2 mAngle_lastMousePosition;
+ static Texture mAngle_TextureCircle;
+ static Texture pAngle_TextureCircle {
+ get{
+ if (mAngle_TextureCircle) return mAngle_TextureCircle;
+ mAngle_TextureCircle = GUI.skin.GetStyle("CN CountBadge").normal.background;
+ return mAngle_TextureCircle;
+ }
+ }
+
+ public static float FloatAngle(Rect rect, float value)
+ {
+ return FloatAngle(rect, value, -1, -1, -1);
+ }
+
+ public static float FloatAngle(Rect rect, float value, float snap)
+ {
+ return FloatAngle(rect, value, snap, -1, -1);
+ }
+
+ public static float FloatAngle(Rect rect, float value, float snap, float min, float max)
+ {
+ int id = GUIUtility.GetControlID(FocusType.Passive, rect);
+
+ Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height);
+
+ float delta;
+ if (min != max)
+ delta = (max - min) / 360;
+ else
+ delta = 1;
+
+ if (UnityEngine.Event.current != null)
+ {
+ if (UnityEngine.Event.current.type == EventType.MouseDown && knobRect.Contains(UnityEngine.Event.current.mousePosition))
+ {
+ GUIUtility.hotControl = id;
+ mAngle_lastMousePosition = UnityEngine.Event.current.mousePosition;
+ }
+ else if (UnityEngine.Event.current.type == EventType.MouseUp && GUIUtility.hotControl == id)
+ GUIUtility.hotControl = -1;
+ else if (UnityEngine.Event.current.type == EventType.MouseDrag && GUIUtility.hotControl == id)
+ {
+ Vector2 move = mAngle_lastMousePosition - UnityEngine.Event.current.mousePosition;
+ value += delta * (-move.x - move.y);
+
+ if (snap > 0)
+ {
+ float mod = value % snap;
+
+ if (mod < delta * 3 || Mathf.Abs(mod - snap) < delta * 3)
+ value = Mathf.Round(value / snap) * snap;
+ }
+
+ mAngle_lastMousePosition = UnityEngine.Event.current.mousePosition;
+ GUI.changed = true;
+ }
+ }
+
+ if (pAngle_TextureCircle) GUI.DrawTexture(knobRect, pAngle_TextureCircle);
+ Matrix4x4 matrix = GUI.matrix;
+
+ if (min != max)
+ GUIUtility.RotateAroundPivot(value * (360 / (max - min)), knobRect.center);
+ else
+ GUIUtility.RotateAroundPivot(value, knobRect.center);
+
+ knobRect.height = 5;
+ knobRect.width = 5;
+ if (pAngle_TextureCircle) GUI.DrawTexture(knobRect, pAngle_TextureCircle);
+ GUI.matrix = matrix;
+
+ Rect label = new Rect(rect.x + rect.height, rect.y + rect.height / 2 - 9, rect.height, 18);
+ value = EditorGUI.FloatField(label, value);
+
+ if (min != max)
+ value = Mathf.Clamp(value, min, max);
+
+ return value;
+ }
+
+ public static float AngleCircle(Rect rect, float angle, float snap, float min, float max, Texture background=null, Texture knobLine=null)
+ {
+ Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height);
+
+ float delta;
+ if (min != max)
+ delta = (max - min) / 360;
+ else
+ delta = 1;
+
+ if (UnityEngine.Event.current != null && GUIUtility.hotControl<=0 && (UnityEngine.Event.current.type==EventType.MouseDown || UnityEngine.Event.current.type==EventType.MouseDrag) && knobRect.Contains(UnityEngine.Event.current.mousePosition))
+ {
+ angle = Vector2.Angle( Vector2.right, UnityEngine.Event.current.mousePosition-knobRect.center);
+ if (UnityEngine.Event.current.mousePosition.y 0)
+ {
+ float mod = Mathf.Repeat(angle, snap);
+
+ if (mod < delta * 3 || Mathf.Abs(mod - snap) < delta * 3)
+ angle = Mathf.Round(angle / snap) * snap;
+ }
+
+ GUI.changed = true;
+ }
+
+ if (background==null) background = pAngle_TextureCircle;
+ if (background) GUI.DrawTexture (knobRect, background);
+
+ Matrix4x4 matrix = GUI.matrix;
+
+ if (min != max)
+ GUIUtility.RotateAroundPivot(angle * (360 / (max - min))+90, knobRect.center);
+ else
+ GUIUtility.RotateAroundPivot(angle+90, knobRect.center);
+
+ float Radius = Mathf.Min (knobRect.width, knobRect.height) * 0.5f;
+ knobRect.x = knobRect.x + 0.5f * knobRect.width - 4;
+ knobRect.y += 2;
+ knobRect.width = 8;
+ knobRect.height = Radius+2;
+ if (knobLine == null)
+ knobLine = GUI.skin.FindStyle ("MeBlendPosition").normal.background;
+ if (knobLine) GUI.DrawTexture(knobRect, knobLine);
+ GUI.matrix = matrix;
+
+ return Mathf.Repeat(angle, 360);
+ }
+ #endregion
+
+ #region Unity Version branching
+
+ public static string Editor_GetCurrentScene()
+ {
+ #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ return EditorApplication.currentScene;
+ #else
+ return SceneManager.GetActiveScene().path;
+ #endif
+ }
+
+ public static void Editor_MarkSceneDirty()
+ {
+ #if UNITY_5_3 || UNITY_5_3_OR_NEWER
+ EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
+ #else
+ EditorApplication.MarkSceneDirty();
+ #endif
+ }
+
+ public static void Editor_SaveScene()
+ {
+ #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ EditorApplication.SaveScene ();
+ #else
+ EditorSceneManager.SaveOpenScenes();
+ #endif
+ }
+
+ public static void Editor_OpenScene( string sceneName )
+ {
+ #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ EditorApplication.OpenScene( sceneName );
+ #else
+ EditorSceneManager.OpenScene(sceneName);
+ #endif
+ }
+
+ #endregion
+
+ #region Reflection
+ static public object Reflection_InvokeMethod ( object instanceObject, string methodName, params object[] p_args )
+ {
+ BindingFlags _flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
+ MethodInfo mi = instanceObject.GetType().GetMethods( _flags ).Where( x => x.Name==methodName ).FirstOrDefault();
+ if (mi == null) return null;
+ return mi.Invoke( instanceObject, p_args );
+ }
+ static public object Reflection_InvokeMethod ( Type targetType, string methodName, params object[] p_args )
+ {
+ BindingFlags _flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
+ MethodInfo mi = targetType.GetMethods( _flags ).Where( x => x.Name==methodName ).FirstOrDefault();
+ if (mi == null) return null;
+ return mi.Invoke( null, p_args );
+ }
+
+
+ public static object s_RecycledEditor;
+ public static string TextField ( Rect position, string text, int maxLength, GUIStyle style, int controlID )
+ {
+ if (s_RecycledEditor==null)
+ {
+ FieldInfo info = typeof(EditorGUI).GetField("s_RecycledEditor", BindingFlags.NonPublic | BindingFlags.Static);
+ s_RecycledEditor = info?.GetValue(null);
+ }
+
+ if (s_RecycledEditor == null)
+ return "";
+
+ return Reflection_InvokeMethod( typeof( EditorGUI ), "DoTextField", s_RecycledEditor, controlID, position, text, style, null, false, false, false, false ) as string;
+
+ }
+
+ static public void RepaintInspectors()
+ {
+ EditorApplication.update -= RepaintInspectors;
+ var assemblyEditor = Assembly.GetAssembly(typeof(UnityEditor.Editor));
+ var typeInspectorWindow = assemblyEditor.GetType("UnityEditor.InspectorWindow");
+ typeInspectorWindow.GetMethod("RepaintAllInspectors", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
+ }
+
+ public static void ScheduleRepaintInspectors()
+ {
+ EditorApplication.update += RepaintInspectors;
+ }
+
+
+ #endregion
+
+ #if UNITY_2022_3_OR_NEWER
+ public const string Style_ToolbarSearchTextField = "ToolbarSearchTextField";
+ public const string Style_ToolbarSearchCancelButtonEmpty = "ToolbarSearchCancelButtonEmpty";
+ public const string Style_ToolbarSearchCancelButton = "ToolbarSearchCancelButton";
+ #else
+ public const string Style_ToolbarSearchTextField = "ToolbarSeachTextField";
+ public const string Style_ToolbarSearchCancelButtonEmpty = "ToolbarSeachCancelButtonEmpty";
+ public const string Style_ToolbarSearchCancelButton = "ToolbarSeachCancelButton";
+ #endif
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs.meta
new file mode 100644
index 00000000..de59c6b6
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/EditorTools.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: df33c1000ac895241a433812e40a2096
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors.meta
new file mode 100644
index 00000000..8a09e58e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: a500716e59f61824ba1fa6b418ce31a7
+folderAsset: yes
+timeCreated: 1461137613
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs
new file mode 100644
index 00000000..f6187b4c
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs
@@ -0,0 +1,20 @@
+using UnityEditor;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(LanguageSourceAsset))]
+ public class LanguageSourceAssetInspector : LocalizationEditor
+ {
+ void OnEnable()
+ {
+ var newSource = target as LanguageSourceAsset;
+ SerializedProperty propSource = serializedObject.FindProperty("mSource");
+
+ Custom_OnEnable(newSource.mSource, propSource);
+ }
+ public override LanguageSourceData GetSourceData()
+ {
+ return (target as LanguageSourceAsset).mSource;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs.meta
new file mode 100644
index 00000000..ef8182c4
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceAssetInspector.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: f03a75bf70a306a4fb36646f24c1c1f1
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs
new file mode 100644
index 00000000..b11b01ae
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs
@@ -0,0 +1,22 @@
+using UnityEditor;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(LanguageSource))]
+ public class LanguageSourceInspector : LocalizationEditor
+ {
+ void OnEnable()
+ {
+ var newSource = target as LanguageSource;
+ SerializedProperty propSource = serializedObject.FindProperty("mSource");
+
+ Custom_OnEnable(newSource.mSource, propSource);
+ }
+
+ public override LanguageSourceData GetSourceData()
+ {
+ return (target as LanguageSource).mSource;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs.meta
new file mode 100644
index 00000000..ce993bdf
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LanguageSourceInspector.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: a441ed994a43a0a4a9d33be67a8d3f15
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs
new file mode 100644
index 00000000..a9c4cfcc
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs
@@ -0,0 +1,200 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ public abstract partial class LocalizationEditor : UnityEditor.Editor
+ {
+ #region Variables
+
+ SerializedProperty mProp_Assets, mProp_Languages,
+ mProp_Google_WebServiceURL, mProp_GoogleUpdateFrequency, mProp_GoogleUpdateDelay, mProp_Google_SpreadsheetKey, mProp_Google_SpreadsheetName, mProp_Google_Password,
+ mProp_Spreadsheet_LocalFileName, mProp_Spreadsheet_LocalCSVSeparator, mProp_CaseInsensitiveTerms, mProp_Spreadsheet_LocalCSVEncoding,
+ mProp_OnMissingTranslation, mProp_AppNameTerm, mProp_IgnoreDeviceLanguage, mProp_Spreadsheet_SpecializationAsRows, mProp_Spreadsheet_SortRows, mProp_GoogleInEditorCheckFrequency,
+ mProp_HighlightLocalizedTargets, mProp_GoogleLiveSyncIsUptoDate, mProp_AllowUnloadingLanguages, mProp_GoogleUpdateSynchronization;
+
+ public static LanguageSourceData mLanguageSource;
+ public static Object mLanguageSourceObject;
+ public static LocalizationEditor mLanguageSourceEditor;
+ public static UnityEditor.Editor mCurrentInspector;
+
+ static bool mIsParsing; // This is true when the editor is opening several scenes to avoid reparsing objects
+
+ #endregion
+
+ #region Variables GUI
+
+ GUIStyle Style_ToolBar_Big, Style_ToolBarButton_Big;
+
+
+ public GUISkin CustomSkin;
+
+ static Vector3 mScrollPos_Languages;
+ public static string mLanguages_NewLanguage = "";
+
+ #endregion
+
+ #region Styles
+
+ public static GUIStyle Style_WrapTextField {
+ get{
+ if (mStyle_WrapTextField==null)
+ {
+ mStyle_WrapTextField = new GUIStyle(EditorStyles.textArea);
+ mStyle_WrapTextField.wordWrap = true;
+ mStyle_WrapTextField.fixedHeight = 0;
+ }
+ return mStyle_WrapTextField;
+ }
+ }
+ static GUIStyle mStyle_WrapTextField;
+
+ #endregion
+
+ #region Inspector
+
+ public void Custom_OnEnable( LanguageSourceData sourceData, SerializedProperty propSource)
+ {
+ bool ForceParse = mLanguageSource != sourceData;
+
+ mLanguageSource = sourceData;
+ mLanguageSourceEditor = this;
+ mCurrentInspector = this;
+
+ if (!LocalizationManager.Sources.Contains(mLanguageSource))
+ LocalizationManager.UpdateSources();
+
+ mProp_Assets = propSource.FindPropertyRelative("Assets");
+ mProp_Languages = propSource.FindPropertyRelative("mLanguages");
+ mProp_Google_WebServiceURL = propSource.FindPropertyRelative("Google_WebServiceURL");
+ mProp_GoogleUpdateFrequency = propSource.FindPropertyRelative("GoogleUpdateFrequency");
+ mProp_GoogleUpdateSynchronization = propSource.FindPropertyRelative("GoogleUpdateSynchronization");
+ mProp_GoogleInEditorCheckFrequency = propSource.FindPropertyRelative("GoogleInEditorCheckFrequency");
+ mProp_GoogleUpdateDelay = propSource.FindPropertyRelative("GoogleUpdateDelay");
+ mProp_Google_SpreadsheetKey = propSource.FindPropertyRelative("Google_SpreadsheetKey");
+ mProp_Google_SpreadsheetName = propSource.FindPropertyRelative("Google_SpreadsheetName");
+ mProp_Google_Password = propSource.FindPropertyRelative("Google_Password");
+ mProp_CaseInsensitiveTerms = propSource.FindPropertyRelative("CaseInsensitiveTerms");
+ mProp_Spreadsheet_LocalFileName = propSource.FindPropertyRelative("Spreadsheet_LocalFileName");
+ mProp_Spreadsheet_LocalCSVSeparator = propSource.FindPropertyRelative("Spreadsheet_LocalCSVSeparator");
+ mProp_Spreadsheet_LocalCSVEncoding = propSource.FindPropertyRelative("Spreadsheet_LocalCSVEncoding");
+ mProp_Spreadsheet_SpecializationAsRows = propSource.FindPropertyRelative("Spreadsheet_SpecializationAsRows");
+ mProp_Spreadsheet_SortRows = propSource.FindPropertyRelative("Spreadsheet_SortRows");
+ mProp_OnMissingTranslation = propSource.FindPropertyRelative("OnMissingTranslation");
+ mProp_AppNameTerm = propSource.FindPropertyRelative("mTerm_AppName");
+ mProp_IgnoreDeviceLanguage = propSource.FindPropertyRelative("IgnoreDeviceLanguage");
+ mProp_GoogleLiveSyncIsUptoDate = propSource.FindPropertyRelative("GoogleLiveSyncIsUptoDate");
+ mProp_AllowUnloadingLanguages = propSource.FindPropertyRelative("_AllowUnloadingLanguages");
+
+ if (!mIsParsing)
+ {
+ if (string.IsNullOrEmpty(mLanguageSource.Google_SpreadsheetKey))
+ mSpreadsheetMode = eSpreadsheetMode.Local;
+ else
+ mSpreadsheetMode = eSpreadsheetMode.Google;
+
+ mCurrentViewMode = mLanguageSource.mLanguages.Count>0 ? eViewMode.Keys : eViewMode.Languages;
+
+ UpdateSelectedKeys();
+
+ if (ForceParse || mParsedTerms.Count < mLanguageSource.mTerms.Count)
+ {
+ mSelectedCategories.Clear();
+ ParseTerms(true, false, true);
+ }
+ }
+ ScheduleUpdateTermsToShowInList();
+ LoadSelectedCategories();
+ //UpgradeManager.EnablePlugins();
+ }
+
+ void OnDisable()
+ {
+ //LocalizationManager.LocalizeAll();
+ SaveSelectedCategories();
+ mLanguageSourceEditor = null;
+ if (mCurrentInspector==this) mCurrentInspector = null;
+ }
+
+
+ void UpdateSelectedKeys()
+ {
+ // Remove all keys that are not in this source
+ string trans;
+ for (int i=mSelectedKeys.Count-1; i>=0; --i)
+ if (!mLanguageSource.TryGetTranslation(mSelectedKeys[i], out trans))
+ mSelectedKeys.RemoveAt(i);
+
+ // Remove all Categories that are not in this source
+ /*var mCateg = mLanguageSource.GetCategories();
+ for (int i=mSelectedCategories.Count-1; i>=0; --i)
+ if (!mCateg.Contains(mSelectedCategories[i]))
+ mSelectedCategories.RemoveAt(i);
+ if (mSelectedCategories.Count==0)
+ mSelectedCategories = mCateg;*/
+
+ if (mSelectedScenes.Count==0)
+ mSelectedScenes.Add (Editor_GetCurrentScene());
+ }
+
+ public override void OnInspectorGUI()
+ {
+ // Load Test:
+ /*if (mLanguageSource.mTerms.Count<40000)
+ {
+ mLanguageSource.mTerms.Clear();
+ for (int i=0; i<40020; ++i)
+ mLanguageSource.AddTerm("ahh"+i.ToString("00000"), eTermType.Text, false);
+ mLanguageSource.UpdateDictionary();
+ }*/
+ //Profiler.maxNumberOfSamplesPerFrame = -1; // REMOVE ---------------------------------------------------
+
+ mIsParsing = false;
+
+ //#if UNITY_5_6_OR_NEWER
+ // serializedObject.UpdateIfRequiredOrScript();
+ //#else
+ // serializedObject.UpdateIfDirtyOrScript();
+ //#endif
+
+ if (mLanguageSource.mTerms.Count<1000)
+ Undo.RecordObject(target, "LanguageSource");
+
+ //GUI.backgroundColor = Color.Lerp (Color.black, Color.gray, 1);
+ //GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background);
+ //GUI.backgroundColor = Color.white;
+
+ if (GUILayout.Button("Language Source", LocalizeInspector.GUIStyle_Header))
+ {
+ Application.OpenURL(LocalizeInspector.HelpURL_Documentation);
+ }
+
+ InitializeStyles();
+
+ GUILayout.Space(10);
+
+ //GUI.backgroundColor = Color.Lerp(GUITools.LightGray, Color.white, 0.5f);
+ //GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background);
+ //GUI.backgroundColor = Color.white;
+ OnGUI_Main();
+ //GUILayout.EndVertical();
+
+ GUILayout.Space (10);
+ GUILayout.FlexibleSpace();
+
+ GUITools.OnGUI_Footer("I2 Localization", LocalizationManager.GetVersion(), LocalizeInspector.HelpURL_forum, LocalizeInspector.HelpURL_Documentation, LocalizeInspector.HelpURL_AssetStore);
+
+ //GUILayout.EndVertical();
+
+ serializedObject.ApplyModifiedProperties();
+ if (UnityEngine.Event.current.type == EventType.Repaint)
+ {
+ mTestAction = eTest_ActionType.None;
+ mTestActionArg = null;
+ mTestActionArg2 = null;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs.meta
new file mode 100644
index 00000000..34e4a0e9
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationEditor.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 90c932abd0dc445448366dfe101408ba
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs
new file mode 100644
index 00000000..b8603c12
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs
@@ -0,0 +1,107 @@
+using UnityEditor;
+using UnityEditorInternal;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(LocalizationParamsManager))]
+ public class LocalizationParamsManagerInspector : UnityEditor.Editor
+ {
+ private ReorderableList mList;
+ private SerializedProperty mProp_IsGlobalManager;
+
+
+ private ReorderableList getList(SerializedObject serObject)
+ {
+ if (mList == null) {
+ mList = new ReorderableList (serObject, serObject.FindProperty ("_Params"), true, true, true, true);
+ mList.drawElementCallback = drawElementCallback;
+ mList.drawHeaderCallback = drawHeaderCallback;
+ mList.onAddCallback = addElementCallback;
+ mList.onRemoveCallback = removeElementCallback;
+ }
+ else
+ {
+ mList.serializedProperty = serObject.FindProperty ("_Params");
+ }
+ return mList;
+ }
+
+ private void addElementCallback( ReorderableList list )
+ {
+ serializedObject.ApplyModifiedProperties();
+ var objParams = target as LocalizationParamsManager;
+ objParams._Params.Add(new LocalizationParamsManager.ParamValue());
+ list.index = objParams._Params.Count - 1;
+ serializedObject.Update();
+ }
+
+ private void removeElementCallback( ReorderableList list )
+ {
+ if (list.index < 0)
+ return;
+ serializedObject.ApplyModifiedProperties();
+ var objParams = target as LocalizationParamsManager;
+ objParams._Params.RemoveAt(list.index);
+ serializedObject.Update();
+ }
+
+ private void drawHeaderCallback(Rect rect)
+ {
+ GUI.Label(rect, "Parameters:");
+ }
+
+ private void drawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
+ {
+ var serializedElement = mList.serializedProperty.GetArrayElementAtIndex (index);
+ var content = new GUIContent ();
+
+ Rect r = rect; r.xMax = r.xMin+40;
+ GUI.Label(r, "Name");
+
+ r = rect; r.xMax = (r.xMax + r.xMin)/2 - 2; r.xMin = r.xMin+40;
+ EditorGUI.PropertyField (r, serializedElement.FindPropertyRelative ("Name"),content);
+
+ r = rect; r.xMin = (r.xMax + r.xMin) / 2 + 2; r.xMax = r.xMin+40;
+ GUI.Label(r, "Value");
+
+ r = rect; r.xMin = (r.xMax + r.xMin)/2 + 2 + 40;
+ EditorGUI.PropertyField (r, serializedElement.FindPropertyRelative ("Value"), content);
+ }
+
+ void OnEnable()
+ {
+ mList = getList(serializedObject);
+ mProp_IsGlobalManager = serializedObject.FindProperty("_IsGlobalManager");
+ }
+ public override void OnInspectorGUI()
+ {
+ #if UNITY_5_6_OR_NEWER
+ serializedObject.UpdateIfRequiredOrScript();
+ #else
+ serializedObject.UpdateIfDirtyOrScript();
+ #endif
+
+ GUI.backgroundColor = Color.Lerp (Color.black, Color.gray, 1);
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background);
+ GUI.backgroundColor = Color.white;
+
+ if (GUILayout.Button("Dynamic Parameters", LocalizeInspector.GUIStyle_Header))
+ {
+ Application.OpenURL(LocalizeInspector.HelpURL_Documentation);
+ }
+
+ GUILayout.Space(5);
+ mProp_IsGlobalManager.boolValue = EditorGUILayout.Popup(new GUIContent("Manager Type", "Local Manager only apply parameters to the Localize component in the same GameObject\n\nGlobal Manager apply parameters to all Localize components"), mProp_IsGlobalManager.boolValue ? 1 : 0, new[] { new GUIContent("Local"), new GUIContent("Global") }) == 1;
+
+
+ GUILayout.Space(5);
+ mList.DoLayoutList();
+
+ //EditorGUILayout.PropertyField(serializedObject.FindProperty("_AutoRegister"), new GUIContent("Auto Register"));
+
+ GUILayout.EndVertical();
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs.meta
new file mode 100644
index 00000000..8c96c158
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizationParamsManagerInspector.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 93f1f9aecf6f7ed40ad1a082c22c47e5
+timeCreated: 1468111539
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs
new file mode 100644
index 00000000..0244d51a
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEditorInternal;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ #if !UNITY_5_0 && !UNITY_5_1
+
+ [CustomEditor(typeof(LocalizeDropdown))]
+ public class LocalizeDropdownInspector : UnityEditor.Editor
+ {
+ private ReorderableList mList;
+
+ private List terms;
+
+ private ReorderableList getList(SerializedObject serObject)
+ {
+ if (mList == null) {
+ mList = new ReorderableList (serObject, serObject.FindProperty ("_Terms"), true, true, true, true);
+ mList.drawElementCallback = drawElementCallback;
+ mList.drawHeaderCallback = drawHeaderCallback;
+ mList.onAddCallback = addElementCallback;
+ mList.onRemoveCallback = removeElementCallback;
+ }
+ else
+ {
+ mList.serializedProperty = serObject.FindProperty ("_Terms");
+ }
+ return mList;
+ }
+
+ private void addElementCallback( ReorderableList list )
+ {
+ serializedObject.ApplyModifiedProperties();
+
+ var objParams = target as LocalizeDropdown;
+ objParams._Terms.Add(string.Empty);
+
+ list.index = objParams._Terms.Count - 1;
+
+ serializedObject.Update();
+ }
+
+ private void removeElementCallback( ReorderableList list )
+ {
+ if (list.index < 0)
+ return;
+ serializedObject.ApplyModifiedProperties();
+
+ var objParams = target as LocalizeDropdown;
+ objParams._Terms.RemoveAt(list.index);
+
+ serializedObject.Update();
+ }
+
+ private void drawHeaderCallback(Rect rect)
+ {
+ GUI.Label(rect, "Terms:");
+ }
+
+ private void drawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
+ {
+ var serializedElement = mList.serializedProperty.GetArrayElementAtIndex (index);
+
+ EditorGUI.BeginChangeCheck ();
+
+ var prvIndex = serializedElement.stringValue == "-" || serializedElement.stringValue == "" ? terms.Count - 1 :
+ serializedElement.stringValue == " " ? terms.Count - 2 :
+ terms.IndexOf(serializedElement.stringValue);
+
+ var newIndex = EditorGUI.Popup(rect, prvIndex, terms.ToArray());
+
+ if (EditorGUI.EndChangeCheck ())
+ {
+ if (newIndex == terms.Count - 1)
+ serializedElement.stringValue = "-";
+ else
+ if (newIndex < 0 || newIndex == terms.Count - 2)
+ serializedElement.stringValue = string.Empty;
+ else
+ serializedElement.stringValue = terms[newIndex];
+ }
+ }
+
+ void OnEnable()
+ {
+ mList = getList(serializedObject);
+ }
+
+ public override void OnInspectorGUI()
+ {
+ #if UNITY_5_6_OR_NEWER
+ serializedObject.UpdateIfRequiredOrScript();
+ #else
+ serializedObject.UpdateIfDirtyOrScript();
+ #endif
+ terms = LocalizationManager.GetTermsList ();
+ terms.Sort(StringComparer.OrdinalIgnoreCase);
+ terms.Add("");
+ terms.Add("");
+ terms.Add("");
+
+ GUI.backgroundColor = Color.Lerp (Color.black, Color.gray, 1);
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background);
+ GUI.backgroundColor = Color.white;
+
+ if (GUILayout.Button("Localize DropDown", LocalizeInspector.GUIStyle_Header))
+ {
+ Application.OpenURL(LocalizeInspector.HelpURL_Documentation);
+ }
+
+
+ GUILayout.Space(5);
+ mList.DoLayoutList();
+
+ GUILayout.Space (10);
+
+ GUITools.OnGUI_Footer("I2 Localization", LocalizationManager.GetVersion(), LocalizeInspector.HelpURL_forum, LocalizeInspector.HelpURL_Documentation, LocalizeInspector.HelpURL_AssetStore);
+
+ EditorGUIUtility.labelWidth = 0;
+
+
+ GUILayout.EndVertical();
+ serializedObject.ApplyModifiedProperties();
+ terms = null;
+ }
+ }
+ #endif
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs.meta
new file mode 100644
index 00000000..fb4a5ed1
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeDropdownInspector.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 65bbef08e6e42d24d9834945c3769202
+timeCreated: 1468111539
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs
new file mode 100644
index 00000000..c80e822b
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs
@@ -0,0 +1,896 @@
+//#define UGUI
+//#define NGUI
+//#define DFGUI
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using UnityEditor;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(Localize))]
+ [CanEditMultipleObjects]
+ public class LocalizeInspector : UnityEditor.Editor
+ {
+ #region Variables
+
+ Localize mLocalize;
+ SerializedProperty mProp_mTerm, mProp_mTermSecondary,
+ mProp_TranslatedObjects, mProp_LocalizeOnAwake, mProp_AlwaysForceLocalize, mProp_AllowLocalizedParameters, mProp_AllowParameters,
+ mProp_IgnoreRTL, mProp_MaxCharactersInRTL, mProp_CorrectAlignmentForRTL, mProp_IgnoreNumbersInRTL, mProp_TermSuffix, mProp_TermPrefix, mProp_SeparateWords,
+ mProp_CallbackEvent;
+
+
+ bool mAllowEditKeyName;
+ string mNewKeyName = "";
+
+ string[] mTermsArray;
+
+
+ public static string HelpURL_forum = "http://goo.gl/Uiyu8C";//http://www.inter-illusion.com/forum/i2-localization";
+ public static string HelpURL_Documentation = "http://www.inter-illusion.com/assets/I2LocalizationManual/I2LocalizationManual.html";
+ public static string HelpURL_Tutorials = "http://inter-illusion.com/tools/i2-localization";
+ public static string HelpURL_ReleaseNotes = "http://inter-illusion.com/forum/i2-localization/26-release-notes";
+ public static string HelpURL_AssetStore = "https://www.assetstore.unity3d.com/#!/content/14884";
+
+ public static LocalizeInspector mLocalizeInspector;
+ #endregion
+
+ #region Inspector
+
+ void OnEnable()
+ {
+ mLocalize = (Localize)target;
+ mLocalizeInspector = this;
+ LocalizationEditor.mCurrentInspector = this;
+ mProp_mTerm = serializedObject.FindProperty("mTerm");
+ mProp_mTermSecondary = serializedObject.FindProperty("mTermSecondary");
+ mProp_TranslatedObjects = serializedObject.FindProperty("TranslatedObjects");
+ mProp_IgnoreRTL = serializedObject.FindProperty("IgnoreRTL");
+ mProp_SeparateWords = serializedObject.FindProperty("AddSpacesToJoinedLanguages");
+ mProp_MaxCharactersInRTL = serializedObject.FindProperty ("MaxCharactersInRTL");
+ mProp_IgnoreNumbersInRTL = serializedObject.FindProperty("IgnoreNumbersInRTL");
+ mProp_CorrectAlignmentForRTL = serializedObject.FindProperty ("CorrectAlignmentForRTL");
+ mProp_LocalizeOnAwake = serializedObject.FindProperty("LocalizeOnAwake");
+ mProp_AlwaysForceLocalize = serializedObject.FindProperty("AlwaysForceLocalize");
+ mProp_TermSuffix = serializedObject.FindProperty("TermSuffix");
+ mProp_TermPrefix = serializedObject.FindProperty("TermPrefix");
+ mProp_CallbackEvent = serializedObject.FindProperty("LocalizeEvent");
+ mProp_AllowLocalizedParameters = serializedObject.FindProperty("AllowLocalizedParameters");
+ mProp_AllowParameters = serializedObject.FindProperty("AllowParameters");
+
+
+ if (LocalizationManager.Sources.Count==0)
+ LocalizationManager.UpdateSources();
+ //LocalizationEditor.ParseTerms (true);
+
+ //mGUI_ShowReferences = (mLocalize.TranslatedObjects!=null && mLocalize.TranslatedObjects.Length>0);
+ //mGUI_ShowCallback = (mLocalize.LocalizeCallBack.Target!=null);
+ //mGUI_ShowTems = true;
+ LocalizationEditor.mKeysDesc_AllowEdit = false;
+ GUI_SelectedTerm = 0;
+ mNewKeyName = mLocalize.Term;
+
+ if (mLocalize.Source != null)
+ LocalizationEditor.mLanguageSource = mLocalize.Source.SourceData;
+ else
+ {
+ if (LocalizationManager.Sources.Count==0)
+ LocalizationManager.UpdateSources();
+ LocalizationEditor.mLanguageSource = LocalizationManager.GetSourceContaining( mLocalize.Term );
+ }
+
+ //UpgradeManager.EnablePlugins();
+ LocalizationEditor.ApplyInferredTerm (mLocalize);
+ RemoveUnusedReferences(mLocalize);
+ }
+
+ void OnDisable()
+ {
+ mLocalizeInspector = null;
+ if (LocalizationEditor.mCurrentInspector == this) LocalizationEditor.mCurrentInspector = null;
+
+
+ if (mLocalize == null)
+ return;
+
+ //#if TextMeshPro
+ //string previous = null;
+
+ //if (!Application.isPlaying && !string.IsNullOrEmpty(mLocalize.TMP_previewLanguage))
+ //{
+ // previous = LocalizationManager.CurrentLanguage;
+ // LocalizationManager.PreviewLanguage( mLocalize.TMP_previewLanguage );
+ //}
+ //#endif
+
+ //mLocalize.OnLocalize();
+
+ // Revert the preview language
+ // except when in TMPro and not changing to another GameObject (TMPro has a bug where any change causes the inspector to Disable and Enable)
+ if (!mLocalize.mLocalizeTargetName.Contains("LocalizeTarget_TextMeshPro") || Selection.activeGameObject==null || !Selection.gameObjects.Contains(mLocalize.gameObject))
+ {
+ LocalizationManager.LocalizeAll();
+ }
+
+ //#if TextMeshPro
+ //if (!string.IsNullOrEmpty(previous))
+ //{
+ // LocalizationManager.PreviewLanguage(previous);
+ // mLocalize.TMP_previewLanguage = null;
+ //}
+ //#endif
+
+ RemoveUnusedReferences(mLocalize);
+ }
+
+ #endregion
+
+ #region GUI
+
+ public override void OnInspectorGUI()
+ {
+ Undo.RecordObject(target, "Localize");
+
+ //GUI.backgroundColor = Color.Lerp (Color.black, Color.gray, 1);
+ //GUILayout.BeginVertical(GUIStyle_Background, GUILayout.Height(1));
+ //GUI.backgroundColor = Color.white;
+
+ if (GUILayout.Button("Localize", GUIStyle_Header))
+ {
+ //Application.OpenURL(HelpURL_Documentation);
+ }
+ GUILayout.Space(-10);
+
+ LocalizationManager.UpdateSources();
+
+ if (LocalizationManager.Sources.Count==0)
+ {
+ EditorGUILayout.HelpBox("Unable to find a Language Source.", MessageType.Warning);
+ }
+ else
+ {
+ GUILayout.Space(10);
+ OnGUI_Target ();
+ GUILayout.Space(10);
+ OnGUI_Terms();
+
+ //if (mGUI_ShowTems || mGUI_ShowReferences) GUILayout.Space(5);
+
+ OnGUI_References();
+
+ if (mLocalize.mGUI_ShowReferences || mLocalize.mGUI_ShowCallback) GUILayout.Space(10);
+
+ //Localize loc = target as Localize;
+
+ //--[ Localize Callback ]----------------------
+ EditorGUILayout.PropertyField(mProp_CallbackEvent, new GUIContent("On Localize Callback"));
+
+ //string HeaderTitle = "On Localize Call:";
+ //if (!mLocalize.mGUI_ShowCallback && loc.LocalizeCallBack.Target!=null && !string.IsNullOrEmpty(loc.LocalizeCallBack.MethodName))
+ // HeaderTitle = string.Concat(HeaderTitle, " ",loc.LocalizeCallBack.Target.name, ".", loc.LocalizeCallBack.MethodName, "");
+ //mLocalize.mGUI_ShowCallback = GUITools.DrawHeader(HeaderTitle, mLocalize.mGUI_ShowCallback);
+ //if (mLocalize.mGUI_ShowCallback)
+ //{
+ // GUITools.BeginContents();
+ // DrawEventCallBack( loc.LocalizeCallBack, loc );
+ // GUITools.EndContents();
+ //}
+ }
+ OnGUI_Source ();
+
+ GUILayout.Space (10);
+
+ GUITools.OnGUI_Footer("I2 Localization", LocalizationManager.GetVersion(), HelpURL_forum, HelpURL_Documentation, HelpURL_AssetStore);
+
+ //GUILayout.EndVertical();
+
+ serializedObject.ApplyModifiedProperties();
+ if (UnityEngine.Event.current.type == EventType.Repaint)
+ {
+ LocalizationEditor.mTestAction = LocalizationEditor.eTest_ActionType.None;
+ LocalizationEditor.mTestActionArg = null;
+ LocalizationEditor.mTestActionArg2 = null;
+ }
+ }
+
+ #endregion
+
+ #region References
+
+ void OnGUI_References()
+ {
+ if (mLocalize.mGUI_ShowReferences = GUITools.DrawHeader ("References", mLocalize.mGUI_ShowReferences))
+ {
+ GUITools.BeginContents();
+
+ bool canTest = UnityEngine.Event.current.type == EventType.Repaint;
+
+ var testAddObj = canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Add ? (Object)LocalizationEditor.mTestActionArg : null;
+ var testReplaceIndx = canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Replace ? (int)LocalizationEditor.mTestActionArg : -1;
+ var testReplaceObj = canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Replace ? (Object)LocalizationEditor.mTestActionArg2 : null;
+ var testDeleteIndx = canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Delete ? (int)LocalizationEditor.mTestActionArg : -1;
+
+ bool changed = GUITools.DrawObjectsArray( mProp_TranslatedObjects, false, false, true, testAddObj, testReplaceObj, testReplaceIndx, testDeleteIndx);
+ if (changed)
+ {
+ serializedObject.ApplyModifiedProperties();
+ foreach (var obj in serializedObject.targetObjects)
+ (obj as Localize).UpdateAssetDictionary();
+ }
+
+ GUITools.EndContents();
+ }
+ }
+
+ void RemoveUnusedReferences(Localize cmp)
+ {
+ cmp.TranslatedObjects.RemoveAll(x => !IsUsingReference(LocalizationManager.GetTermData(cmp.Term), x) && !IsUsingReference(LocalizationManager.GetTermData(cmp.SecondaryTerm), x));
+ if (cmp.TranslatedObjects.Count != cmp.mAssetDictionary.Count)
+ cmp.UpdateAssetDictionary();
+ }
+
+ bool IsUsingReference(TermData termData, Object obj )
+ {
+ if (obj == null || termData==null) return false;
+
+ string objName = obj.name;
+ foreach (string translation in termData.Languages)
+ {
+ if (translation != null && translation.Contains(objName))
+ return true;
+ }
+ return false;
+ }
+
+
+ #endregion
+
+
+ #region Terms
+
+ int GUI_SelectedTerm;
+ void OnGUI_Terms()
+ {
+ if ((mLocalize.mGUI_ShowTems=GUITools.DrawHeader ("Terms", mLocalize.mGUI_ShowTems)))
+ {
+ //--[ tabs: Main and Secondary Terms ]----------------
+ int oldTab = GUI_SelectedTerm;
+ if (mLocalize.mLocalizeTarget!=null && mLocalize.mLocalizeTarget.CanUseSecondaryTerm())
+ {
+ GUI_SelectedTerm = GUITools.DrawTabs (GUI_SelectedTerm, new[]{"Main", "Secondary"});
+ }
+ else
+ {
+ GUI_SelectedTerm = 0;
+ GUITools.DrawTabs (GUI_SelectedTerm, new[]{"Main", ""});
+ }
+
+ GUITools.BeginContents();
+
+ TermData termData = null;
+
+ if (GUI_SelectedTerm==0) termData = OnGUI_PrimaryTerm( oldTab!=GUI_SelectedTerm );
+ else termData = OnGUI_SecondaryTerm(oldTab!=GUI_SelectedTerm);
+
+ GUITools.EndContents();
+
+ //--[ Modifier ]-------------
+ if (mLocalize.Term != "-" && termData!=null && termData.TermType==eTermType.Text)
+ {
+ EditorGUI.BeginChangeCheck();
+ GUILayout.BeginHorizontal();
+ GUILayout.Label("Prefix:");
+ EditorGUILayout.PropertyField(mProp_TermPrefix, GUITools.EmptyContent);
+ GUILayout.Label("Suffix:");
+ EditorGUILayout.PropertyField(mProp_TermSuffix, GUITools.EmptyContent);
+ GUILayout.EndHorizontal();
+ if (EditorGUI.EndChangeCheck())
+ {
+ EditorApplication.delayCall += () =>
+ {
+ if (targets != null)
+ {
+ foreach (var t in targets)
+ if (t as Localize != null)
+ (t as Localize).OnLocalize(true);
+ }
+ };
+ }
+ EditorGUI.BeginChangeCheck();
+ int val = EditorGUILayout.Popup("Modifier", GUI_SelectedTerm == 0 ? (int)mLocalize.PrimaryTermModifier : (int)mLocalize.SecondaryTermModifier, Enum.GetNames(typeof(Localize.TermModification)));
+ if (EditorGUI.EndChangeCheck())
+ {
+ serializedObject.FindProperty(GUI_SelectedTerm == 0 ? "PrimaryTermModifier" : "SecondaryTermModifier").enumValueIndex = val;
+ GUI.changed = false;
+ }
+ }
+
+ OnGUI_Options();
+ //--[ OnAwake vs OnEnable ]-------------
+ //GUILayout.BeginHorizontal();
+ //mProp_LocalizeOnAwake.boolValue = GUILayout.Toggle(mProp_LocalizeOnAwake.boolValue, new GUIContent(" Pre-Localize on Awake", "Localizing on Awake could result in a lag when the level is loaded but faster later when objects are enabled. If false, it will Localize OnEnable, so will yield faster level load but could have a lag when screens are enabled"));
+ //GUILayout.FlexibleSpace();
+ //if (mLocalize.HasCallback())
+ //{
+ // GUI.enabled = false;
+ // GUILayout.Toggle(true, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
+ // GUI.enabled = true;
+ //}
+ //else
+ //{
+ // mProp_AlwaysForceLocalize.boolValue = GUILayout.Toggle(mProp_AlwaysForceLocalize.boolValue, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
+ //}
+ //GUILayout.EndHorizontal();
+
+ //--[ Right To Left ]-------------
+ if (!mLocalize.IgnoreRTL && mLocalize.Term!="-" && termData != null && termData.TermType == eTermType.Text)
+ {
+ GUILayout.BeginVertical("Box");
+ //GUILayout.BeginHorizontal();
+ // mProp_IgnoreRTL.boolValue = GUILayout.Toggle(mProp_IgnoreRTL.boolValue, new GUIContent(" Ignore Right To Left", "Arabic and other RTL languages require processing them so they render correctly, this toogle allows ignoring that processing (in case you are doing it manually during a callback)"));
+ // GUILayout.FlexibleSpace();
+ // mProp_SeparateWords.boolValue = GUILayout.Toggle(mProp_SeparateWords.boolValue, new GUIContent(" Separate Words", " Some languages (e.g. Chinese, Japanese and Thai) don't add spaces to their words (all characters are placed toguether), enabling this checkbox, will add spaces to all characters to allow wrapping long texts into multiple lines."));
+ //GUILayout.EndHorizontal();
+ {
+ mProp_MaxCharactersInRTL.intValue = EditorGUILayout.IntField( new GUIContent("Max line length", "If the language is Right To Left, long lines will be split at this length and the RTL fix will be applied to each line, this should be set to the maximum number of characters that fit in this text width. 0 disables the per line fix"), mProp_MaxCharactersInRTL.intValue );
+ GUILayout.BeginHorizontal();
+ mProp_CorrectAlignmentForRTL.boolValue = GUILayout.Toggle(mProp_CorrectAlignmentForRTL.boolValue, new GUIContent(" Adjust Alignment", "Right-align when Right-To-Left Language, and Left-Align otherwise") );
+ GUILayout.FlexibleSpace();
+ mProp_IgnoreNumbersInRTL.boolValue = GUILayout.Toggle(mProp_IgnoreNumbersInRTL.boolValue, new GUIContent(" Ignore Numbers", "Preserve numbers as latin characters instead of converting them"));
+ GUILayout.EndHorizontal();
+ }
+
+ GUILayout.EndVertical();
+ }
+
+
+ ////GUILayout.EndHorizontal();
+ }
+ }
+
+ void OnGUI_Options()
+ {
+ int mask = 0;
+ if (mProp_LocalizeOnAwake.boolValue) mask |= 1 << 0;
+ if (mProp_AlwaysForceLocalize.boolValue) mask |= 1 << 1;
+ if (mProp_AllowParameters.boolValue) mask |= 1 << 2;
+ if (mProp_AllowLocalizedParameters.boolValue) mask |= 1 << 3;
+ if (mProp_SeparateWords.boolValue) mask |= 1 << 4;
+ if (mProp_IgnoreRTL.boolValue) mask |= 1 << 5;
+
+ EditorGUI.BeginChangeCheck();
+ mask = EditorGUILayout.MaskField(new GUIContent("Options"), mask, new []{
+ "Localize On Awake",
+ "Force Localize",
+ "Allow Parameters",
+ "Allow Localized Parameters",
+ "Separate Words",
+ "Ignore RTL"
+ });
+ if (EditorGUI.EndChangeCheck())
+ {
+ mProp_LocalizeOnAwake.boolValue = (mask & (1 << 0))> 0;
+ mProp_AlwaysForceLocalize.boolValue = (mask & (1 << 1))> 0;
+ mProp_AllowParameters.boolValue = (mask & (1 << 2))> 0;
+ mProp_AllowLocalizedParameters.boolValue = (mask & (1 << 3))> 0;
+ mProp_SeparateWords.boolValue = (mask & (1 << 4))> 0;
+ mProp_IgnoreRTL.boolValue = (mask & (1 << 5))> 0;
+ }
+ }
+
+ TermData OnGUI_PrimaryTerm( bool OnOpen )
+ {
+ string Key = mLocalize.mTerm;
+ if (string.IsNullOrEmpty(Key))
+ {
+ string SecondaryTerm;
+ mLocalize.GetFinalTerms( out Key, out SecondaryTerm );
+ }
+
+ if (OnOpen) mNewKeyName = Key;
+ if ( OnGUI_SelectKey( ref Key, string.IsNullOrEmpty(mLocalize.mTerm)))
+ mProp_mTerm.stringValue = Key;
+ return LocalizationEditor.OnGUI_Keys_Languages( Key, mLocalize );
+ }
+
+ TermData OnGUI_SecondaryTerm( bool OnOpen )
+ {
+ string Key = mLocalize.mTermSecondary;
+
+ if (string.IsNullOrEmpty(Key))
+ {
+ string ss;
+ mLocalize.GetFinalTerms( out ss, out Key );
+ }
+
+ if (OnOpen) mNewKeyName = Key;
+ if ( OnGUI_SelectKey( ref Key, string.IsNullOrEmpty(mLocalize.mTermSecondary)))
+ mProp_mTermSecondary.stringValue = Key;
+ return LocalizationEditor.OnGUI_Keys_Languages( Key, mLocalize, false );
+ }
+
+ bool OnGUI_SelectKey( ref string Term, bool Inherited ) // Inherited==true means that the mTerm is empty and we are using the Label.text instead
+ {
+ GUILayout.Space (5);
+ GUILayout.BeginHorizontal();
+
+ GUI.changed = false;
+ mAllowEditKeyName = GUILayout.Toggle(mAllowEditKeyName, "Term:", EditorStyles.foldout, GUILayout.ExpandWidth(false));
+ if (GUI.changed && mAllowEditKeyName) {
+ mNewKeyName = Term;
+ mTermsArray = null;
+ }
+
+ bool bChanged = false;
+
+ if (mTermsArray==null || Term!="-" && Array.IndexOf(mTermsArray, Term)<0)
+ UpdateTermsList(Term);
+
+ if (Inherited)
+ GUI.contentColor = Color.Lerp (Color.gray, Color.yellow, 0.1f);
+
+ int Index = Term=="-" || Term=="" ? mTermsArray.Length-1 : Array.IndexOf( mTermsArray, Term );
+
+ GUI.changed = false;
+
+ int newIndex = EditorGUILayout.Popup( Index, mTermsArray);
+
+ GUI.contentColor = Color.white;
+ if (/*newIndex != Index && newIndex>=0*/GUI.changed)
+ {
+ GUI.changed = false;
+ if (mLocalize.Source != null && newIndex == mTermsArray.Length - 4) //< show terms from all sources >
+ {
+ mLocalize.Source = null;
+ mTermsArray = null;
+ }
+ else
+ if (newIndex == mTermsArray.Length - 2) //
+ mNewKeyName = Term = string.Empty;
+ else
+ if (newIndex == mTermsArray.Length - 1) //
+ mNewKeyName = Term = "-";
+ else
+ mNewKeyName = Term = mTermsArray[newIndex];
+
+
+ if (GUI_SelectedTerm==0)
+ mLocalize.SetTerm (mNewKeyName);
+ else
+ mLocalize.SetTerm (null, mNewKeyName);
+ mAllowEditKeyName = false;
+ bChanged = true;
+ }
+
+ LanguageSourceData source = LocalizationManager.GetSourceContaining(Term);
+ TermData termData = source.GetTermData(Term);
+ if (termData!=null)
+ {
+ if (Inherited)
+ bChanged = true; // if the term its inferred and a matching term its found, then use that
+ eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termData.TermType, GUILayout.Width(90));
+ if (termData.TermType != NewType)
+ termData.TermType = NewType;
+ }
+
+ GUILayout.EndHorizontal();
+
+ if (mAllowEditKeyName)
+ {
+ GUILayout.BeginHorizontal(GUILayout.Height (1));
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ if(mNewKeyName==null) mNewKeyName = string.Empty;
+
+ GUI.changed = false;
+ mNewKeyName = EditorGUILayout.TextField(mNewKeyName, new GUIStyle(GUITools.Style_ToolbarSearchTextField), GUILayout.ExpandWidth(true));
+ if (GUI.changed)
+ {
+ mTermsArray = null; // regenerate this array to apply filtering
+ GUI.changed = false;
+ }
+
+ if (GUILayout.Button (string.Empty, string.IsNullOrEmpty(mNewKeyName) ? GUITools.Style_ToolbarSearchCancelButtonEmpty : GUITools.Style_ToolbarSearchCancelButton, GUILayout.ExpandWidth(false)))
+ {
+ mTermsArray = null; // regenerate this array to apply filtering
+ mNewKeyName = string.Empty;
+ }
+
+ GUILayout.EndHorizontal();
+
+ string ValidatedName = mNewKeyName;
+ LanguageSourceData.ValidateFullTerm( ref ValidatedName );
+
+ bool CanUseNewName = source.GetTermData(ValidatedName)==null;
+ GUI.enabled = !string.IsNullOrEmpty(mNewKeyName) && CanUseNewName;
+ if (GUILayout.Button ("Create", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ mNewKeyName = ValidatedName;
+ mTermsArray=null; // this recreates that terms array
+
+ LanguageSourceData Source = null;
+ #if UNITY_EDITOR
+ if (mLocalize.Source!=null)
+ Source = mLocalize.Source.SourceData;
+ #endif
+
+ if (Source==null)
+ Source = LocalizationManager.Sources[0];
+ Term = mNewKeyName;
+ var data = Source.AddTerm( mNewKeyName, eTermType.Text, false );
+ if (data.Languages.Length > 0)
+ data.Languages[0] = mLocalize.GetMainTargetsText();
+ Source.Editor_SetDirty();
+ AssetDatabase.SaveAssets();
+ mAllowEditKeyName = false;
+ bChanged = true;
+ GUIUtility.keyboardControl = 0;
+ }
+ GUI.enabled = termData!=null && !string.IsNullOrEmpty(mNewKeyName) && CanUseNewName;
+ if (GUILayout.Button (new GUIContent("Rename","Renames the term in the source and updates every object using it in the current scene"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ mNewKeyName = ValidatedName;
+ Term = mNewKeyName;
+ mTermsArray=null; // this recreates that terms array
+ mAllowEditKeyName = false;
+ bChanged = true;
+ LocalizationEditor.TermReplacements = new Dictionary(StringComparer.Ordinal);
+ LocalizationEditor.TermReplacements[ termData.Term ] = mNewKeyName;
+ termData.Term = mNewKeyName;
+ source.UpdateDictionary(true);
+ LocalizationEditor.ReplaceTermsInCurrentScene();
+ GUIUtility.keyboardControl = 0;
+ EditorApplication.update += LocalizationEditor.DoParseTermsInCurrentScene;
+ }
+ GUI.enabled = true;
+ GUILayout.EndHorizontal();
+
+ bChanged |= OnGUI_SelectKey_PreviewTerms ( ref Term);
+ }
+
+ GUILayout.Space (5);
+ return bChanged;
+ }
+
+ void UpdateTermsList( string currentTerm )
+ {
+ List Terms = mLocalize.Source==null ? LocalizationManager.GetTermsList() : mLocalize.Source.SourceData.GetTermsList();
+
+ // If there is a filter, remove all terms not matching that filter
+ if (mAllowEditKeyName && !string.IsNullOrEmpty(mNewKeyName))
+ {
+ string Filter = mNewKeyName.ToUpper();
+ for (int i=Terms.Count-1; i>=0; --i)
+ if (!Terms[i].ToUpper().Contains(Filter) && Terms[i]!=currentTerm)
+ Terms.RemoveAt(i);
+
+ }
+
+ if (!string.IsNullOrEmpty(currentTerm) && currentTerm!="-" && !Terms.Contains(currentTerm))
+ Terms.Add (currentTerm);
+
+ Terms.Sort(StringComparer.OrdinalIgnoreCase);
+ Terms.Add("");
+ if (mLocalize.Source != null)
+ {
+ Terms.Add("< Show Terms from all sources >");
+ Terms.Add("");
+ }
+ Terms.Add("");
+ Terms.Add("");
+
+ mTermsArray = Terms.ToArray();
+ }
+
+ bool OnGUI_SelectKey_PreviewTerms ( ref string Term)
+ {
+ if (mTermsArray==null)
+ UpdateTermsList(Term);
+
+ int nTerms = mTermsArray.Length;
+ if (nTerms<=0)
+ return false;
+
+ if (nTerms==1 && mTermsArray[0]==Term)
+ return false;
+
+ bool bChanged = false;
+ GUI.backgroundColor = Color.gray;
+ GUILayout.BeginVertical (GUIStyle_OldTextArea);
+ for (int i = 0, imax = Mathf.Min (nTerms, 3); i < imax; ++i)
+ {
+ ParsedTerm parsedTerm;
+ int nUses = -1;
+ if (LocalizationEditor.mParsedTerms.TryGetValue (mTermsArray [i], out parsedTerm))
+ nUses = parsedTerm.Usage;
+
+ string FoundText = mTermsArray [i];
+ if (nUses > 0)
+ FoundText = string.Concat ("(", nUses, ") ", FoundText);
+
+ if (GUILayout.Button (FoundText, EditorStyles.miniLabel, GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - 70)))
+ {
+ if (mTermsArray[i] == "")
+ mNewKeyName = Term = string.Empty;
+ else
+ if (mTermsArray[i] == "")
+ mNewKeyName = Term = "-";
+ else
+ if (mTermsArray[i] != "< Show Terms from all sources >")
+ mNewKeyName = Term = mTermsArray[i];
+
+ //mNewKeyName = Term = (mTermsArray [i]=="" ? string.Empty : mTermsArray [i]);
+ GUIUtility.keyboardControl = 0;
+ mAllowEditKeyName = false;
+ bChanged = true;
+ }
+ }
+ if (nTerms > 3)
+ GUILayout.Label ("...");
+ GUILayout.EndVertical ();
+ GUI.backgroundColor = Color.white;
+
+ return bChanged;
+ }
+
+ #endregion
+
+ #region Target
+
+ void OnGUI_Target()
+ {
+ List TargetTypes = new List();
+ int CurrentTarget = -1;
+
+ mLocalize.FindTarget();
+
+ foreach (var desc in LocalizationManager.mLocalizeTargets)
+ {
+ if (desc.CanLocalize(mLocalize))
+ {
+ TargetTypes.Add(desc.Name);
+
+ if (mLocalize.mLocalizeTarget!=null && desc.GetTargetType() == mLocalize.mLocalizeTarget.GetType())
+ CurrentTarget = TargetTypes.Count - 1;
+ }
+ }
+
+ if (CurrentTarget==-1)
+ {
+ CurrentTarget = TargetTypes.Count;
+ TargetTypes.Add("None");
+ }
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label ("Target:", GUILayout.Width (60));
+ EditorGUI.BeginChangeCheck();
+ int index = EditorGUILayout.Popup(CurrentTarget, TargetTypes.ToArray());
+ if (EditorGUI.EndChangeCheck())
+ {
+ serializedObject.ApplyModifiedProperties();
+ foreach (var obj in serializedObject.targetObjects)
+ {
+ var cmp = obj as Localize;
+ if (cmp == null)
+ continue;
+
+ if (cmp.mLocalizeTarget != null)
+ DestroyImmediate(cmp.mLocalizeTarget);
+ cmp.mLocalizeTarget = null;
+
+ foreach (var desc in LocalizationManager.mLocalizeTargets)
+ {
+ if (desc.Name == TargetTypes[index])
+ {
+ cmp.mLocalizeTarget = desc.CreateTarget(cmp);
+ cmp.mLocalizeTargetName = desc.GetTargetType().ToString();
+ break;
+ }
+ }
+ }
+ serializedObject.Update();
+ }
+ GUILayout.EndHorizontal();
+ }
+
+ #endregion
+
+ #region Source
+
+ void OnGUI_Source()
+ {
+ GUILayout.BeginHorizontal();
+
+ ILanguageSource currentSource = mLocalize.Source;
+ if (currentSource==null)
+ {
+ LanguageSourceData source = LocalizationManager.GetSourceContaining(mLocalize.Term);
+ currentSource = source==null ? null : source.owner;
+ }
+
+ if (GUILayout.Button("Open Source", EditorStyles.toolbarButton, GUILayout.Width (100)))
+ {
+ Selection.activeObject = currentSource as Object;
+
+ string sTerm, sSecondary;
+ mLocalize.GetFinalTerms( out sTerm, out sSecondary );
+ if (GUI_SelectedTerm==1) sTerm = sSecondary;
+ LocalizationEditor.mKeyToExplore = sTerm;
+ }
+
+ GUILayout.Space (2);
+
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ EditorGUI.BeginChangeCheck ();
+ if (mLocalize.Source == null)
+ {
+ GUI.contentColor = Color.Lerp (Color.gray, Color.yellow, 0.1f);
+ }
+ Object obj = EditorGUILayout.ObjectField(currentSource as Object, typeof(Object), true);
+ GUI.contentColor = Color.white;
+ if (EditorGUI.EndChangeCheck())
+ {
+ ILanguageSource NewSource = obj as ILanguageSource;
+ if (NewSource == null && obj as GameObject != null)
+ {
+ NewSource = (obj as GameObject).GetComponent();
+ }
+
+ mLocalize.Source = NewSource;
+ string sTerm, sSecondary;
+ mLocalize.GetFinalTerms(out sTerm, out sSecondary);
+ if (GUI_SelectedTerm == 1) sTerm = sSecondary;
+ UpdateTermsList(sTerm);
+ }
+
+ if (GUILayout.Button(new GUIContent("Detect", "Finds the LanguageSource containing the selected term, the term list will now only show terms inside that source."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ string sTerm, sSecondary;
+ mLocalize.GetFinalTerms(out sTerm, out sSecondary);
+ if (GUI_SelectedTerm == 1) sTerm = sSecondary;
+
+ var data = LocalizationManager.GetSourceContaining(sTerm, false);
+ mLocalize.Source = data==null ? null : data.owner;
+ mTermsArray = null;
+ }
+ GUILayout.EndHorizontal();
+
+ GUILayout.EndHorizontal();
+ }
+
+ #endregion
+
+
+ #region Event CallBack
+
+ //public void DrawEventCallBack( EventCallback CallBack, Localize loc )
+ //{
+ //if (CallBack==null)
+ // return;
+
+ //GUI.changed = false;
+
+ //GUILayout.BeginHorizontal();
+ //GUILayout.Label("Target:", GUILayout.ExpandWidth(false));
+ //CallBack.Target = EditorGUILayout.ObjectField( CallBack.Target, typeof(MonoBehaviour), true) as MonoBehaviour;
+ //GUILayout.EndHorizontal();
+
+ //if (CallBack.Target!=null)
+ //{
+ // GameObject GO = CallBack.Target.gameObject;
+ // List Infos = new List();
+
+ // var targets = GO.GetComponents(typeof(MonoBehaviour));
+ // foreach (var behavior in targets)
+ // Infos.AddRange( behavior.GetType().GetMethods() );
+
+ // List Methods = new List();
+
+ // for (int i = 0, imax=Infos.Count; i 1) return false;
+
+ if (Params [0].ParameterType.IsSubclassOf (typeof(Object))) return true;
+ if (Params [0].ParameterType == typeof(Object)) return true;
+ return false;
+ }
+
+
+ #endregion
+
+ #region Styles
+
+ public static GUIStyle GUIStyle_Header {
+ get{
+ if (mGUIStyle_Header==null)
+ {
+ mGUIStyle_Header = new GUIStyle("HeaderLabel");
+ mGUIStyle_Header.fontSize = 25;
+ mGUIStyle_Header.normal.textColor = Color.Lerp(Color.white, Color.gray, 0.5f);
+ mGUIStyle_Header.fontStyle = FontStyle.BoldAndItalic;
+ mGUIStyle_Header.alignment = TextAnchor.UpperCenter;
+ }
+ return mGUIStyle_Header;
+ }
+ }
+ static GUIStyle mGUIStyle_Header;
+
+ public static GUIStyle GUIStyle_SubHeader {
+ get{
+ if (mGUIStyle_SubHeader==null)
+ {
+ mGUIStyle_SubHeader = new GUIStyle("HeaderLabel");
+ mGUIStyle_SubHeader.fontSize = 13;
+ mGUIStyle_SubHeader.fontStyle = FontStyle.Normal;
+ mGUIStyle_SubHeader.margin.top = -50;
+ mGUIStyle_SubHeader.alignment = TextAnchor.UpperCenter;
+ }
+ return mGUIStyle_SubHeader;
+ }
+ }
+ static GUIStyle mGUIStyle_SubHeader;
+
+ public static GUIStyle GUIStyle_Background {
+ get{
+ if (mGUIStyle_Background==null)
+ {
+ mGUIStyle_Background = new GUIStyle(EditorStyles.textArea);
+ mGUIStyle_Background.fixedHeight = 0;
+ mGUIStyle_Background.overflow.left = 50;
+ mGUIStyle_Background.overflow.right = 50;
+ mGUIStyle_Background.overflow.top = -5;
+ mGUIStyle_Background.overflow.bottom = 0;
+ }
+ return mGUIStyle_Background;
+ }
+ }
+ static GUIStyle mGUIStyle_Background;
+
+ public static GUIStyle GUIStyle_OldTextArea
+ {
+ get
+ {
+ if (mGUIStyle_OldTextArea == null)
+ {
+ mGUIStyle_OldTextArea = new GUIStyle(EditorStyles.textArea);
+ mGUIStyle_OldTextArea.fixedHeight = 0;
+ }
+ return mGUIStyle_OldTextArea;
+ }
+ }
+ static GUIStyle mGUIStyle_OldTextArea;
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs.meta
new file mode 100644
index 00000000..6d7f3aad
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/LocalizeInspector.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 675119279b2a30245801272112cfbe38
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs
new file mode 100644
index 00000000..692c70bd
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs
@@ -0,0 +1,29 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(ResourceManager))]
+ public class ResourceManagerInspector : UnityEditor.Editor
+ {
+ SerializedProperty mAssets;
+
+ void OnEnable()
+ {
+ UpgradeManager.EnablePlugins();
+ mAssets = serializedObject.FindProperty("Assets");
+ }
+
+ public override void OnInspectorGUI()
+ {
+ GUILayout.Space(5);
+ GUITools.DrawHeader("Assets:", true);
+ GUITools.BeginContents();
+ ///GUILayout.Label ("Assets:");
+ GUITools.DrawObjectsArray( mAssets );
+ GUITools.EndContents();
+
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs.meta
new file mode 100644
index 00000000..96076a94
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/ResourceManagerInspector.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: ba2fdf8face79dd4f9e1ed80448db843
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs
new file mode 100644
index 00000000..17a5e4e9
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs
@@ -0,0 +1,60 @@
+using System;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ [CustomEditor(typeof(SetLanguage))]
+ public class SetLanguageInspector : UnityEditor.Editor
+ {
+ public SetLanguage setLan;
+ public SerializedProperty mProp_Language;
+
+ public void OnEnable()
+ {
+ setLan = (SetLanguage)target;
+ mProp_Language = serializedObject.FindProperty("_Language");
+ }
+
+ public override void OnInspectorGUI()
+ {
+ string[] Languages;
+ LanguageSource sourceObj = setLan.mSource;
+ if (sourceObj == null)
+ {
+ LocalizationManager.UpdateSources();
+ Languages = LocalizationManager.GetAllLanguages().ToArray();
+ Array.Sort(Languages);
+ }
+ else
+ {
+ Languages = sourceObj.mSource.GetLanguages().ToArray();
+ Array.Sort(Languages);
+ }
+
+ int index = Array.IndexOf(Languages, mProp_Language.stringValue);
+
+ GUI.changed = false;
+ index = EditorGUILayout.Popup("Language", index, Languages);
+ if (GUI.changed)
+ {
+ if (index<0 || index>=Languages.Length)
+ mProp_Language.stringValue = string.Empty;
+ else
+ mProp_Language.stringValue = Languages[index];
+ GUI.changed = false;
+ serializedObject.ApplyModifiedProperties();
+ }
+
+ GUILayout.Space(5);
+ if (setLan.mSource==null) GUI.contentColor = Color.Lerp (Color.gray, Color.yellow, 0.1f);
+ sourceObj = EditorGUILayout.ObjectField("Language Source:", sourceObj, typeof(LanguageSource), true) as LanguageSource;
+ GUI.contentColor = Color.white;
+
+ if (GUI.changed)
+ setLan.mSource = sourceObj;
+
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs.meta
new file mode 100644
index 00000000..8fb138e1
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/SetLanguageInspector.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 7af58b4da44670e47a509c59754e8c2b
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs
new file mode 100644
index 00000000..05e17645
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ [CustomPropertyDrawer (typeof (TermsPopup))]
+ public class TermsPopup_Drawer : PropertyDrawer
+ {
+ GUIContent[] mTerms_Context;
+ int nFramesLeftBeforeUpdate;
+ string mPrevFilter;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ var filter = ((TermsPopup)attribute).Filter;
+ ShowGUICached(position, property, label, null, filter, ref mTerms_Context, ref nFramesLeftBeforeUpdate, ref mPrevFilter);
+ }
+
+ public static bool ShowGUI(Rect position, SerializedProperty property, GUIContent label, LanguageSourceData source, string filter = "")
+ {
+ GUIContent[] terms=null;
+ int framesLeftBeforeUpdate=0;
+ string prevFilter = null;
+
+ return ShowGUICached(position, property, label, source, filter, ref terms, ref framesLeftBeforeUpdate, ref prevFilter);
+ }
+
+ public static bool ShowGUICached(Rect position, SerializedProperty property, GUIContent label, LanguageSourceData source, string filter, ref GUIContent[] terms_Contexts, ref int framesBeforeUpdating, ref string prevFilter)
+ {
+ UpdateTermsCache(source, filter, ref terms_Contexts, ref framesBeforeUpdating, ref prevFilter);
+
+ label = EditorGUI.BeginProperty(position, label, property);
+
+ EditorGUI.BeginChangeCheck ();
+
+ var index = property.stringValue == "-" || property.stringValue == "" ? terms_Contexts.Length - 1 :
+ property.stringValue == " " ? terms_Contexts.Length - 2 :
+ GetTermIndex(terms_Contexts, property.stringValue);
+ var newIndex = EditorGUI.Popup(position, label, index, terms_Contexts);
+
+ if (EditorGUI.EndChangeCheck())
+ {
+ property.stringValue = newIndex < 0 || newIndex == terms_Contexts.Length - 1 ? string.Empty : terms_Contexts[newIndex].text;
+ if (newIndex == terms_Contexts.Length - 1)
+ property.stringValue = "-";
+ else
+ if (newIndex < 0 || newIndex == terms_Contexts.Length - 2)
+ property.stringValue = string.Empty;
+ else
+ property.stringValue = terms_Contexts[newIndex].text;
+
+ EditorGUI.EndProperty();
+ return true;
+ }
+
+ EditorGUI.EndProperty();
+ return false;
+ }
+
+ static int GetTermIndex(GUIContent[] terms_Contexts, string term )
+ {
+ for (int i = 0; i < terms_Contexts.Length; ++i)
+ if (terms_Contexts[i].text == term)
+ return i;
+ return -1;
+ }
+
+
+ static void UpdateTermsCache(LanguageSourceData source, string filter, ref GUIContent[] terms_Contexts, ref int framesBeforeUpdating, ref string prevFilter)
+ {
+ framesBeforeUpdating--;
+ if (terms_Contexts!=null && framesBeforeUpdating>0 && filter==prevFilter)
+ {
+ return;
+ }
+ framesBeforeUpdating = 60;
+ prevFilter = filter;
+
+ var Terms = source == null ? LocalizationManager.GetTermsList() : source.GetTermsList();
+
+ if (string.IsNullOrEmpty(filter) == false)
+ {
+ Terms = Filter(Terms, filter);
+ }
+
+ Terms.Sort(StringComparer.OrdinalIgnoreCase);
+ Terms.Add("");
+ Terms.Add("");
+ Terms.Add("");
+
+ terms_Contexts = DisplayOptions(Terms);
+ }
+
+ private static List Filter(List terms, string filter)
+ {
+ var filtered = new List();
+ for (var i = 0; i < terms.Count; i++)
+ {
+ var term = terms[i];
+ if (term.Contains(filter))
+ {
+ filtered.Add(term);
+ }
+ }
+
+ return filtered;
+ }
+
+ private static GUIContent[] DisplayOptions(IList terms)
+ {
+ var options = new GUIContent[terms.Count];
+ for (var i = 0; i < terms.Count; i++)
+ {
+ options[i] = new GUIContent(terms[i]);
+ }
+
+ return options;
+ }
+ }
+
+ [CustomPropertyDrawer(typeof(LocalizedString))]
+ public class LocalizedStringDrawer : PropertyDrawer
+ {
+ GUIContent[] mTerms_Context;
+ int nFramesLeftBeforeUpdate;
+ string mPrevFilter;
+
+ public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
+ {
+ var termRect = rect; termRect.xMax -= 50;
+ var termProp = property.FindPropertyRelative("mTerm");
+ TermsPopup_Drawer.ShowGUICached(termRect, termProp, label, null, "", ref mTerms_Context, ref nFramesLeftBeforeUpdate, ref mPrevFilter);
+
+ var maskRect = rect; maskRect.xMin = maskRect.xMax - 30;
+ var termIgnoreRTL = property.FindPropertyRelative("mRTL_IgnoreArabicFix");
+ var termConvertNumbers = property.FindPropertyRelative("mRTL_ConvertNumbers");
+ var termDontLocalizeParams = property.FindPropertyRelative("m_DontLocalizeParameters");
+ int mask = (termIgnoreRTL.boolValue ? 0 : 1) +
+ (termConvertNumbers.boolValue ? 0 : 2) +
+ (termDontLocalizeParams.boolValue ? 0 : 4);
+
+ int newMask = EditorGUI.MaskField(maskRect, mask, new[] { "Arabic Fix", "Ignore Numbers in RTL", "Localize Parameters" });
+ if (newMask != mask)
+ {
+ termIgnoreRTL.boolValue = (newMask & 1) == 0;
+ termConvertNumbers.boolValue = (newMask & 2) == 0;
+ termDontLocalizeParams.boolValue = (newMask & 4) == 0;
+ }
+
+ var showRect = rect; showRect.xMin = termRect.xMax; showRect.xMax=maskRect.xMin;
+ bool enabled = GUI.enabled;
+ GUI.enabled = enabled & (!string.IsNullOrEmpty (termProp.stringValue) && termProp.stringValue!="-");
+ if (GUI.Button (showRect, "?"))
+ {
+ var source = LocalizationManager.GetSourceContaining(termProp.stringValue);
+ LocalizationEditor.mKeyToExplore = termProp.stringValue;
+ Selection.activeObject = source.ownerObject;
+ }
+ GUI.enabled = enabled;
+ }
+ }
+}
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs.meta
new file mode 100644
index 00000000..0290190a
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Inspectors/TermsPopup_Drawer.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 51c22a426b92fa84cb6ca7b75176da8a
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization.meta
new file mode 100644
index 00000000..f169efc7
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 8ad136296e8e6e14eaa2726ac1992b6c
+folderAsset: yes
+timeCreated: 1461137613
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs
new file mode 100644
index 00000000..1fecf387
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs
@@ -0,0 +1,308 @@
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+
+ #region Variables
+
+ public enum eViewMode { ImportExport, Keys, Languages, Tools, References }
+ public static eViewMode mCurrentViewMode = eViewMode.Keys;
+
+ public enum eSpreadsheetMode { Local, Google }
+ public eSpreadsheetMode mSpreadsheetMode = eSpreadsheetMode.Google;
+
+
+ public static string mLocalizationMsg = "";
+ public static MessageType mLocalizationMessageType = MessageType.None;
+
+ // These variables are for executing action from Unity Tests
+ public enum eTest_ActionType { None, Button_AddLanguageFromPopup, Button_AddLanguageManual,
+ Button_AddTerm_InTermsList, Button_AddSelectedTerms,
+ Button_RemoveSelectedTerms, Button_DeleteTerm,
+ Button_SelectTerms_All, Button_SelectTerms_None, Button_SelectTerms_Used, Button_SelectTerms_Missing,
+ Button_Term_Translate, Button_Term_TranslateAll, Button_Languages_TranslateAll,
+ Button_Assets_Add, Button_Assets_Replace, Button_Assets_Delete,
+ Button_GoogleSpreadsheet_RefreshList, Button_GoogleSpreadsheet_Export, Button_GoogleSpreadsheet_Import
+ }
+ public static eTest_ActionType mTestAction = eTest_ActionType.None;
+ public static object mTestActionArg, mTestActionArg2;
+
+ #endregion
+
+ #region Editor
+
+ /*[MenuItem("Window/Localization", false)]
+ public static void OpenLocalizationEditor()
+ {
+ EditorWindow.GetWindow(false, "Localization", true);
+ }*/
+
+ #endregion
+
+ #region GUI
+
+ void InitializeStyles()
+ {
+ Style_ToolBar_Big = new GUIStyle(EditorStyles.toolbar);
+ Style_ToolBar_Big.fixedHeight = Style_ToolBar_Big.fixedHeight*1.5f;
+
+ Style_ToolBarButton_Big = new GUIStyle(EditorStyles.toolbarButton);
+ Style_ToolBarButton_Big.fixedHeight = Style_ToolBarButton_Big.fixedHeight*1.5f;
+ }
+
+
+ void OnGUI_Main()
+ {
+ OnGUI_Warning_SourceInScene();
+ OnGUI_Warning_SourceInsidePluginsFolder();
+ OnGUI_Warning_SourceNotUpToDate();
+
+ var prevViewMode = mCurrentViewMode;
+
+ GUILayout.BeginHorizontal();
+ //OnGUI_ToggleEnumBig( "Spreadsheets", ref mCurrentViewMode, eViewMode.ImportExport, GUI.skin.GetStyle("CN EntryWarn").normal.background, "External Spreadsheet File or Service" );
+ OnGUI_ToggleEnumBig( "Spreadsheets", ref mCurrentViewMode, eViewMode.ImportExport, null, "External Spreadsheet File or Service" );
+ OnGUI_ToggleEnumBig( "Terms", ref mCurrentViewMode, eViewMode.Keys, null, null );
+ OnGUI_ToggleEnumBig( "Languages", ref mCurrentViewMode, eViewMode.Languages, null, null );
+ OnGUI_ToggleEnumBig( "Tools", ref mCurrentViewMode, eViewMode.Tools, null, null );
+ OnGUI_ToggleEnumBig( "Assets", ref mCurrentViewMode, eViewMode.References, null, null );
+ GUILayout.EndHorizontal();
+ //GUILayout.Space(10);
+
+ switch (mCurrentViewMode)
+ {
+ case eViewMode.ImportExport : OnGUI_ImportExport(); break;
+ case eViewMode.Keys : OnGUI_KeysList(); break;
+ case eViewMode.Languages : OnGUI_Languages(); break;
+ case eViewMode.Tools : OnGUI_Tools(prevViewMode != mCurrentViewMode); break;
+ case eViewMode.References : OnGUI_References(); break;
+ }
+ }
+
+ void OnGUI_ImportExport()
+ {
+ eSpreadsheetMode OldMode = mSpreadsheetMode;
+ mSpreadsheetMode = (eSpreadsheetMode)GUITools.DrawShadowedTabs ((int)mSpreadsheetMode, new[]{"Local", "Google"});
+ if (mSpreadsheetMode != OldMode)
+ ClearErrors();
+
+ GUITools.BeginContents();
+ switch (mSpreadsheetMode)
+ {
+ case eSpreadsheetMode.Local : OnGUI_Spreadsheet_Local(); break;
+ case eSpreadsheetMode.Google : OnGUI_Spreadsheet_Google(); break;
+ }
+ GUITools.EndContents(false);
+ }
+
+ void OnGUI_References()
+ {
+ EditorGUILayout.HelpBox("These are the assets that are referenced by the Terms and not in the Resources folder", MessageType.Info);
+
+ bool canTest = UnityEngine.Event.current.type == EventType.Repaint;
+
+ var testAddObj = canTest && mTestAction == eTest_ActionType.Button_Assets_Add ? (Object)mTestActionArg : null;
+ var testReplaceIndx = canTest && mTestAction == eTest_ActionType.Button_Assets_Replace ? (int)mTestActionArg : -1;
+ var testReplaceObj = canTest && mTestAction == eTest_ActionType.Button_Assets_Replace ? (Object)mTestActionArg2 : null;
+ var testDeleteIndx = canTest && mTestAction == eTest_ActionType.Button_Assets_Delete ? (int)mTestActionArg : -1;
+
+ bool changed = GUITools.DrawObjectsArray( mProp_Assets, false, false, false, testAddObj, testReplaceObj, testReplaceIndx, testDeleteIndx);
+ if (changed)
+ {
+ serializedObject.ApplyModifiedProperties();
+ foreach (var obj in serializedObject.targetObjects)
+ (obj as LanguageSource).mSource.UpdateAssetDictionary();
+ }
+ }
+
+ #endregion
+
+ #region Misc
+
+ void OnGUI_ToggleEnumBig( string text, ref Enum currentMode, Enum newMode, Texture texture, string tooltip) { OnGUI_ToggleEnum( text, ref currentMode, newMode, texture, tooltip, Style_ToolBarButton_Big); }
+ void OnGUI_ToggleEnumSmall( string text, ref Enum currentMode, Enum newMode, Texture texture, string tooltip) { OnGUI_ToggleEnum( text, ref currentMode, newMode, texture, tooltip, EditorStyles.toolbarButton); }
+ void OnGUI_ToggleEnum( string text, ref Enum currentMode, Enum newMode, Texture texture, string tooltip, GUIStyle style)
+ {
+ GUI.changed = false;
+ if (GUILayout.Toggle( currentMode.Equals(newMode), new GUIContent(text, texture, tooltip), style, GUILayout.ExpandWidth(true)))
+ {
+ currentMode = newMode;
+ if (GUI.changed)
+ ClearErrors();
+ }
+ }
+
+ int OnGUI_FlagToogle( string Text, string tooltip, int flags, int bit )
+ {
+ bool State = (flags & bit)>0;
+ bool NewState = GUILayout.Toggle(State, new GUIContent(Text, tooltip), "toolbarbutton");
+ if (State!=NewState)
+ {
+ if (!NewState && flags==bit)
+ return flags;
+
+ flags = NewState ? flags | bit : flags & ~bit;
+ }
+
+ return flags;
+ }
+
+ void OnGUI_SelectableToogleListItem( string Element, ref List Selections, string Style )
+ {
+ bool WasEnabled = Selections.Contains(Element);
+ bool IsEnabled = GUILayout.Toggle( WasEnabled, "", Style, GUILayout.ExpandWidth(false) );
+
+ if (IsEnabled && !WasEnabled)
+ Selections.Add(Element);
+ else
+ if (!IsEnabled && WasEnabled)
+ Selections.Remove(Element);
+ }
+
+ void OnGUI_SelectableToogleListItem( Rect rect, string Element, ref List Selections, string Style )
+ {
+ bool WasEnabled = Selections.Contains(Element);
+ bool IsEnabled = GUI.Toggle( rect, WasEnabled, "", Style );
+
+ if (IsEnabled && !WasEnabled)
+ Selections.Add(Element);
+ else
+ if (!IsEnabled && WasEnabled)
+ Selections.Remove(Element);
+ }
+
+ static bool InTestAction( eTest_ActionType testType )
+ {
+ return mTestAction == testType && UnityEngine.Event.current.type == EventType.Repaint;
+ }
+ static bool TestButton(eTest_ActionType action, string text, GUIStyle style, params GUILayoutOption[] options)
+ {
+ return GUILayout.Button(text, style, options) || mTestAction == action && UnityEngine.Event.current.type == EventType.Repaint;
+ }
+
+ static bool TestButtonArg(eTest_ActionType action, object arg, string text, GUIStyle style, params GUILayoutOption[] options)
+ {
+ return GUILayout.Button(text, style, options) || mTestAction == action && (mTestActionArg==null || mTestActionArg.Equals(arg)) && UnityEngine.Event.current.type == EventType.Repaint;
+ }
+
+
+ static bool TestButton(eTest_ActionType action, GUIContent text, GUIStyle style, params GUILayoutOption[] options)
+ {
+ return GUILayout.Button(text, style, options) || mTestAction == action && UnityEngine.Event.current.type == EventType.Repaint;
+ }
+
+ static bool TestButtonArg(eTest_ActionType action, object arg, GUIContent text, GUIStyle style, params GUILayoutOption[] options)
+ {
+ return GUILayout.Button(text, style, options) || mTestAction == action && (mTestActionArg == null || mTestActionArg.Equals(arg)) && UnityEngine.Event.current.type == EventType.Repaint;
+ }
+
+ #endregion
+
+ #region Error Management
+
+ static void OnGUI_ShowMsg()
+ {
+ if (!string.IsNullOrEmpty(mLocalizationMsg))
+ {
+ GUILayout.BeginHorizontal();
+ EditorGUILayout.HelpBox(mLocalizationMsg, mLocalizationMessageType);
+
+ GUILayout.Space(-5);
+ GUILayout.BeginVertical(GUILayout.Width(15), GUILayout.ExpandHeight(false));
+ GUILayout.Space(15);
+ if (GUILayout.Button("X", GUITools.Style_ToolbarSearchCancelButton, GUILayout.ExpandWidth(false)))
+ ClearErrors();
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+ GUILayout.Space(8);
+ }
+ }
+
+ static void ShowError ( string Error, bool ShowInConsole = true ) { ShowMessage ( Error, MessageType.Error, ShowInConsole ); }
+ static void ShowInfo ( string Msg, bool ShowInConsole = false ) { ShowMessage ( Msg, MessageType.Info, ShowInConsole ); }
+ static void ShowWarning( string Msg, bool ShowInConsole = true) { ShowMessage ( Msg, MessageType.Warning, ShowInConsole ); }
+
+ static void ShowMessage( string Msg, MessageType msgType, bool ShowInConsole )
+ {
+ if (string.IsNullOrEmpty(Msg))
+ Msg = string.Empty;
+
+ mLocalizationMsg = Msg;
+ mLocalizationMessageType = msgType;
+ if (ShowInConsole)
+ {
+ switch (msgType)
+ {
+ case MessageType.Error : Debug.LogError(Msg); break;
+ case MessageType.Warning : Debug.LogWarning(Msg); break;
+ default : Debug.Log(Msg); break;
+ }
+ }
+ }
+
+
+ public static void ClearErrors()
+ {
+ GUI.FocusControl(null);
+
+ mLocalizationMsg = string.Empty;
+ }
+
+ #endregion
+
+ #region Unity Version branching
+
+ public static string Editor_GetCurrentScene()
+ {
+ #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ return EditorApplication.currentScene;
+ #else
+ return SceneManager.GetActiveScene().path;
+ #endif
+ }
+
+ public static void Editor_MarkSceneDirty()
+ {
+ #if UNITY_5_3 || UNITY_5_3_OR_NEWER
+ EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
+ #else
+ EditorApplication.MarkSceneDirty();
+ #endif
+ }
+
+ public static void Editor_SaveScene(bool force=false)
+ {
+ if (force)
+ Editor_MarkSceneDirty();
+
+ #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ EditorApplication.SaveScene ();
+ #else
+ EditorSceneManager.SaveOpenScenes();
+ #endif
+ }
+
+ public static void Editor_OpenScene( string sceneName )
+ {
+#if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
+ if (string.IsNullOrEmpty(sceneName))
+ EditorApplication.NewEmptyScene();
+ else
+ EditorApplication.OpenScene(sceneName);
+#else
+ if (string.IsNullOrEmpty(sceneName))
+ EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+ else
+ EditorSceneManager.OpenScene(sceneName);
+ #endif
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs.meta
new file mode 100644
index 00000000..71ed09b3
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: ffd53aaaf6936407d8b087583b0626e9
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs
new file mode 100644
index 00000000..d43cdd78
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs
@@ -0,0 +1,477 @@
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+ #region Variables
+ private List mTranslationTerms = new List();
+ private Dictionary mTranslationRequests = new Dictionary ();
+ private bool mAppNameTerm_Expanded;
+
+ private List mLanguageCodePopupList;
+
+ #endregion
+
+ void OnGUI_Languages()
+ {
+ //GUILayout.Space(5);
+
+ OnGUI_ShowMsg();
+
+ OnGUI_LanguageList();
+
+ OnGUI_StoreIntegration();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label(new GUIContent("On Missing Translation:", "What should happen IN-GAME when a term is not yet translated to the current language?"), EditorStyles.boldLabel, GUILayout.Width(200));
+ GUILayout.BeginVertical();
+ GUILayout.Space(7);
+ EditorGUILayout.PropertyField(mProp_OnMissingTranslation, GUITools.EmptyContent, GUILayout.Width(165));
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label(new GUIContent("Unload Languages At Runtime:", "When playing the game, the plugin will unload all unused languages and only load them when needed"), EditorStyles.boldLabel, GUILayout.Width(200));
+ GUILayout.BeginVertical();
+ GUILayout.Space(7);
+ EditorGUILayout.PropertyField(mProp_AllowUnloadingLanguages, GUITools.EmptyContent, GUILayout.Width(165));
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+
+
+
+
+ string firstLanguage = "";
+ if (mLanguageSource.mLanguages.Count > 0)
+ firstLanguage = " (" + mLanguageSource.mLanguages [0].Name + ")";
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label(new GUIContent("Default Language:", "When the game starts this is the language that will be used until the player manually selects a language"), EditorStyles.boldLabel, GUILayout.Width(160));
+ GUILayout.BeginVertical();
+ GUILayout.Space(7);
+
+ mProp_IgnoreDeviceLanguage.boolValue = EditorGUILayout.Popup(mProp_IgnoreDeviceLanguage.boolValue?1:0, new[]{"Device Language", "First in List"+firstLanguage}, GUILayout.ExpandWidth(true))==1;
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+ }
+
+ #region GUI Languages
+
+ void OnGUI_LanguageList()
+ {
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ GUILayout.FlexibleSpace();
+ GUILayout.Label ("Languages:", EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
+ GUILayout.FlexibleSpace();
+ GUILayout.Label ("Code:", EditorStyles.miniLabel);
+ GUILayout.Space(170);
+ GUILayout.EndHorizontal();
+
+ //--[ Language List ]--------------------------
+
+ int IndexLanguageToDelete = -1;
+ int LanguageToMoveUp = -1;
+ int LanguageToMoveDown = -1;
+ GUI.backgroundColor = Color.Lerp(GUITools.LightGray, Color.white, 0.5f);
+ mScrollPos_Languages = GUILayout.BeginScrollView( mScrollPos_Languages, LocalizeInspector.GUIStyle_OldTextArea, GUILayout.MinHeight (200), /*GUILayout.MaxHeight(Screen.height),*/ GUILayout.ExpandHeight(false));
+ GUI.backgroundColor = Color.white;
+
+ if (mLanguageCodePopupList == null || mLanguageCodePopupList.Count==0)
+ {
+ mLanguageCodePopupList = GoogleLanguages.GetLanguagesForDropdown("", "");
+ mLanguageCodePopupList.Sort();
+ mLanguageCodePopupList.Insert(0, string.Empty);
+ }
+
+ for (int i=0, imax=mProp_Languages.arraySize; i c.Contains(currentCode)));
+ EditorGUI.BeginChangeCheck();
+ Index = EditorGUILayout.Popup(Index, mLanguageCodePopupList.ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(60));
+ if (EditorGUI.EndChangeCheck() && Index >= 0)
+ {
+ currentCode = mLanguageCodePopupList[Index];
+ int i0 = currentCode.IndexOf("[");
+ int i1 = currentCode.IndexOf("]");
+ if (i0 >= 0 && i1 > i0)
+ Prop_LangCode.stringValue = currentCode.Substring(i0 + 1, i1 - i0 - 1);
+ else
+ Prop_LangCode.stringValue = string.Empty;
+ }
+ var rect = GUILayoutUtility.GetLastRect();
+ GUI.Label(rect, Prop_LangCode.stringValue, EditorStyles.toolbarPopup);
+ }
+ else
+ {
+ GUILayout.Label(Prop_LangCode.stringValue, EditorStyles.toolbarPopup, GUILayout.Width(60));
+ }
+
+ GUILayout.EndHorizontal();
+
+ GUI.enabled = i0;
+ if (GUILayout.Button( "\u25B2", EditorStyles.toolbarButton, GUILayout.Width(18))) LanguageToMoveUp = i;
+
+ GUI.enabled = true;
+ if (GUILayout.Button( new GUIContent("Show", "Preview all localizations into this language"), EditorStyles.toolbarButton, GUILayout.Width(35)))
+ {
+ LocalizationManager.SetLanguageAndCode( LanName, Prop_LangCode.stringValue, false, true);
+ }
+
+ if (TestButtonArg( eTest_ActionType.Button_Languages_TranslateAll, i, new GUIContent("Translate", "Translate all empty terms"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ GUITools.DelayedCall( () => TranslateAllToLanguage(LanName));
+ }
+ GUI.enabled = true;
+ GUI.color = Color.white;
+
+ EditorGUI.BeginChangeCheck();
+ isLanguageEnabled = EditorGUILayout.Toggle(isLanguageEnabled, GUILayout.Width(15));
+
+ var r = GUILayoutUtility.GetLastRect();
+ GUI.Label(r, new GUIContent("", "Enable/Disable the language.\nDisabled languages can be used to store data values or to avoid showing Languages that are stil under development"));
+
+ if (EditorGUI.EndChangeCheck())
+ {
+ Prop_Flags.intValue = (Prop_Flags.intValue & ~(int)eLanguageDataFlags.DISABLED) | (isLanguageEnabled ? 0 : (int)eLanguageDataFlags.DISABLED);
+ }
+
+ GUILayout.EndHorizontal();
+ }
+
+ GUILayout.EndScrollView();
+
+ OnGUI_AddLanguage( mProp_Languages );
+
+ if (mConnection_WWW!=null || mConnection_Text.Contains("Translating"))
+ {
+ // Connection Status Bar
+ int time = (int)(Time.realtimeSinceStartup % 2 * 2.5);
+ string Loading = mConnection_Text + ".....".Substring(0, time);
+ GUI.color = Color.gray;
+ GUILayout.BeginHorizontal(LocalizeInspector.GUIStyle_OldTextArea);
+ GUILayout.Label (Loading, EditorStyles.miniLabel);
+ GUI.color = Color.white;
+ if (GUILayout.Button("Cancel", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ GoogleTranslation.CancelCurrentGoogleTranslations ();
+ StopConnectionWWW();
+ }
+ GUILayout.EndHorizontal();
+ Repaint();
+ }
+
+ if (IndexLanguageToDelete>=0)
+ {
+ if (EditorUtility.DisplayDialog ("Confirm delete", "Are you sure you want to delete the selected language", "Yes", "Cancel"))
+ {
+ mLanguageSource.RemoveLanguage (mLanguageSource.mLanguages [IndexLanguageToDelete].Name);
+ serializedObject.Update ();
+ ParseTerms (true, false, false);
+ }
+ }
+
+ if (LanguageToMoveUp>=0) SwapLanguages( LanguageToMoveUp, LanguageToMoveUp-1 );
+ if (LanguageToMoveDown>=0) SwapLanguages( LanguageToMoveDown, LanguageToMoveDown+1 );
+ }
+
+ void SwapLanguages( int iFirst, int iSecond )
+ {
+ serializedObject.ApplyModifiedProperties();
+ LanguageSourceData Source = mLanguageSource;
+
+ SwapValues( Source.mLanguages, iFirst, iSecond );
+ foreach (TermData termData in Source.mTerms)
+ {
+ SwapValues ( termData.Languages, iFirst, iSecond );
+ SwapValues ( termData.Flags, iFirst, iSecond );
+ }
+ serializedObject.Update();
+ }
+
+ void SwapValues( List mList, int Index1, int Index2 )
+ {
+ LanguageData temp = mList[Index1];
+ mList[Index1] = mList[Index2];
+ mList[Index2] = temp;
+ }
+ void SwapValues( string[] mList, int Index1, int Index2 )
+ {
+ string temp = mList[Index1];
+ mList[Index1] = mList[Index2];
+ mList[Index2] = temp;
+ }
+ void SwapValues( byte[] mList, int Index1, int Index2 )
+ {
+ byte temp = mList[Index1];
+ mList[Index1] = mList[Index2];
+ mList[Index2] = temp;
+ }
+
+
+ void OnGUI_AddLanguage( SerializedProperty Prop_Languages)
+ {
+ //--[ Add Language Upper Toolbar ]-----------------
+
+ GUILayout.BeginVertical();
+ GUILayout.BeginHorizontal();
+
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ mLanguages_NewLanguage = EditorGUILayout.TextField("", mLanguages_NewLanguage, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true));
+ GUILayout.EndHorizontal();
+
+ GUI.enabled = !string.IsNullOrEmpty (mLanguages_NewLanguage);
+ if (TestButton(eTest_ActionType.Button_AddLanguageManual,"Add", EditorStyles.toolbarButton, GUILayout.Width(50)))
+ {
+ Prop_Languages.serializedObject.ApplyModifiedProperties();
+ mLanguageSource.AddLanguage( mLanguages_NewLanguage, GoogleLanguages.GetLanguageCode(mLanguages_NewLanguage) );
+ Prop_Languages.serializedObject.Update();
+ mLanguages_NewLanguage = "";
+ GUI.FocusControl(string.Empty);
+ }
+ GUI.enabled = true;
+
+ GUILayout.EndHorizontal();
+
+
+ //--[ Add Language Bottom Toolbar ]-----------------
+
+ GUILayout.BeginHorizontal();
+
+ //-- Language Dropdown -----------------
+ string CodesToExclude = string.Empty;
+ foreach (var LanData in mLanguageSource.mLanguages)
+ CodesToExclude = string.Concat(CodesToExclude, "[", LanData.Code, "]");
+
+ List Languages = GoogleLanguages.GetLanguagesForDropdown(mLanguages_NewLanguage, CodesToExclude);
+
+ GUI.changed = false;
+ int index = EditorGUILayout.Popup(0, Languages.ToArray(), EditorStyles.toolbarDropDown);
+
+ if (GUI.changed && index>=0)
+ {
+ mLanguages_NewLanguage = GoogleLanguages.GetFormatedLanguageName( Languages[index] );
+ }
+
+
+ if (TestButton(eTest_ActionType.Button_AddLanguageFromPopup, "Add", EditorStyles.toolbarButton, GUILayout.Width(50)) && index>=0)
+ {
+ Prop_Languages.serializedObject.ApplyModifiedProperties();
+ mLanguages_NewLanguage = GoogleLanguages.GetFormatedLanguageName(Languages[index]);
+
+ if (!string.IsNullOrEmpty(mLanguages_NewLanguage))
+ mLanguageSource.AddLanguage(mLanguages_NewLanguage, GoogleLanguages.GetLanguageCode(mLanguages_NewLanguage));
+ Prop_Languages.serializedObject.Update();
+
+ mLanguages_NewLanguage = "";
+ GUI.FocusControl(string.Empty);
+ }
+
+ GUILayout.EndHorizontal();
+ GUILayout.EndVertical();
+ GUI.color = Color.white;
+ }
+
+
+ void TranslateAllToLanguage (string lanName)
+ {
+ if (!GoogleTranslation.CanTranslate ())
+ {
+ ShowError ("WebService is not set correctly or needs to be reinstalled");
+ return;
+ }
+ ClearErrors();
+ int LanIndex = mLanguageSource.GetLanguageIndex (lanName);
+ string code = mLanguageSource.mLanguages [LanIndex].Code;
+ string googleCode = GoogleLanguages.GetGoogleLanguageCode(code);
+ if (string.IsNullOrEmpty(googleCode))
+ {
+ ShowError("Language '" + code + "' is not supported by google translate");
+ return;
+ }
+ googleCode = code;
+
+ mTranslationTerms.Clear ();
+ mTranslationRequests.Clear ();
+ foreach (var termData in mLanguageSource.mTerms)
+ {
+ if (termData.TermType != eTermType.Text)
+ continue;
+
+ if (!string.IsNullOrEmpty(termData.Languages[LanIndex]))
+ continue;
+
+ string sourceCode, sourceText;
+ FindTranslationSource( LanguageSourceData.GetKeyFromFullTerm(termData.Term), termData, code, null, out sourceText, out sourceCode );
+
+ mTranslationTerms.Add (termData.Term);
+
+ GoogleTranslation.CreateQueries(sourceText, sourceCode, googleCode, mTranslationRequests); // can split plurals into several queries
+ }
+
+ if (mTranslationRequests.Count == 0)
+ {
+ StopConnectionWWW ();
+ return;
+ }
+
+ mConnection_WWW = null;
+ mConnection_Text = "Translating"; if (mTranslationRequests.Count > 1) mConnection_Text += " (" + mTranslationRequests.Count + ")";
+ mConnection_Callback = null;
+ //EditorApplication.update += CheckForConnection;
+
+ GoogleTranslation.Translate (mTranslationRequests, OnLanguageTranslated);
+ }
+
+ void OnLanguageTranslated( Dictionary requests, string Error )
+ {
+ //Debug.Log (Result);
+
+ //if (Result.Contains("Service invoked too many times"))
+ //{
+ // TimeStartTranslation = EditorApplication.timeSinceStartup + 1;
+ // EditorApplication.update += DelayedStartTranslation;
+ // mConnection_Text = "Translating (" + mTranslationRequests.Count + ")";
+ // return;
+ //}
+
+ //if (!string.IsNullOrEmpty(Error))/* || !Result.Contains("")*/
+ //{
+ // Debug.LogError("WEB ERROR: " + Error);
+ // ShowError ("Unable to access Google or not valid request");
+ // return;
+ //}
+
+ ClearErrors();
+ StopConnectionWWW();
+
+ if (!string.IsNullOrEmpty(Error))
+ {
+ ShowError (Error);
+ return;
+ }
+
+ if (requests.Values.Count == 0)
+ return;
+
+ var langCode = requests.Values.First().TargetLanguagesCode [0];
+ //langCode = GoogleLanguages.GetGoogleLanguageCode(langCode);
+ int langIndex = mLanguageSource.GetLanguageIndexFromCode (langCode, false);
+ //if (langIndex >= 0)
+ {
+ foreach (var term in mTranslationTerms)
+ {
+ var termData = mLanguageSource.GetTermData(term);
+ if (termData == null)
+ continue;
+ if (termData.TermType != eTermType.Text)
+ continue;
+ //if (termData.Languages.Length <= langIndex)
+ // continue;
+
+ string sourceCode, sourceText;
+ FindTranslationSource(LanguageSourceData.GetKeyFromFullTerm(termData.Term), termData, langCode, null, out sourceText, out sourceCode);
+
+ string result = GoogleTranslation.RebuildTranslation(sourceText, mTranslationRequests, langCode); // gets the result from google and rebuilds the text from multiple queries if its is plurals
+
+ termData.Languages[langIndex] = result;
+ }
+ }
+
+ mTranslationTerms.Clear ();
+ mTranslationRequests.Clear ();
+ StopConnectionWWW ();
+ }
+
+ #endregion
+
+ #region Store Integration
+
+ void OnGUI_StoreIntegration()
+ {
+ GUIStyle lstyle = new GUIStyle (EditorStyles.label);
+ lstyle.richText = true;
+
+ GUILayout.BeginHorizontal ();
+ GUILayout.Label (new GUIContent("Store Integration:", "Setups the stores to detect that the game has localization, Android adds strings.xml for each language. IOS modifies the Info.plist"), EditorStyles.boldLabel, GUILayout.Width(160));
+ GUILayout.FlexibleSpace();
+
+ GUILayout.Label( new GUIContent( "\u2713 IOS", "Setups the stores to show in iTunes and the Appstore all the languages that this app supports, also localizes the app name if available" ), lstyle, GUILayout.Width( 90 ) );
+ GUILayout.Label( new GUIContent( "\u2713 Android", "Setups the stores to show in GooglePlay all the languages this app supports, also localizes the app name if available" ), lstyle, GUILayout.Width( 90 ) );
+ GUILayout.EndHorizontal ();
+
+ GUILayout.BeginHorizontal();
+ mAppNameTerm_Expanded = GUILayout.Toggle(mAppNameTerm_Expanded, new GUIContent( "App Name translations:", "How should the game be named in the devices based on their language" ), EditorStyles.foldout, GUILayout.Width( 160 ) );
+
+ GUILayout.Label("", GUILayout.ExpandWidth(true));
+ var rect = GUILayoutUtility.GetLastRect();
+ TermsPopup_Drawer.ShowGUI( rect, mProp_AppNameTerm, GUITools.EmptyContent, mLanguageSource);
+
+ if (GUILayout.Button("New Term", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
+ {
+ AddLocalTerm("App_Name");
+ mProp_AppNameTerm.stringValue = "App_Name";
+ mAppNameTerm_Expanded = true;
+ }
+ GUILayout.EndHorizontal();
+
+ if (mAppNameTerm_Expanded)
+ {
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(10);
+
+ GUILayout.BeginVertical("Box");
+ var termName = mProp_AppNameTerm.stringValue;
+ if (!string.IsNullOrEmpty(termName))
+ {
+ var termData = LocalizationManager.GetTermData(termName);
+ if (termData != null)
+ OnGUI_Keys_Languages(mProp_AppNameTerm.stringValue, ref termData, null, true, mLanguageSource);
+ }
+ GUILayout.Space(10);
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label("Default App Name:", lstyle, GUITools.DontExpandWidth);
+ GUILayout.Label(Application.productName);
+ GUILayout.EndHorizontal();
+ GUILayout.EndVertical();
+
+ GUILayout.EndHorizontal();
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs.meta
new file mode 100644
index 00000000..375ebe73
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Languages.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 304783c1e95d94a598aecd17728c8556
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs
new file mode 100644
index 00000000..221d3b42
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs
@@ -0,0 +1,727 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Networking;
+using TEngine.Localization.SimpleJSON;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+ #region Variables
+
+ public static Dictionary mGoogleSpreadsheets = new Dictionary(StringComparer.Ordinal);
+
+ public UnityWebRequest mConnection_WWW;
+
+ delegate void fnConnectionCallback(string Result, string Error);
+ event fnConnectionCallback mConnection_Callback;
+ //float mConnection_TimeOut;
+
+ string mConnection_Text = string.Empty;
+
+ string mWebService_Status;
+
+ #endregion
+
+ #region GUI
+
+ void OnGUI_Spreadsheet_Google()
+ {
+ GUILayout.Space(20);
+
+#if UNITY_WEBPLAYER
+ mConnection_Text = string.Empty;
+ EditorGUILayout.HelpBox("Google Synchronization is not supported when in WebPlayer mode." + mConnection_Text, MessageType.Info);
+
+ mProp_GoogleUpdateFrequency.enumValueIndex = mProp_GoogleUpdateFrequency.enumValueIndex; // to avoid the warning "unused"
+ mProp_GoogleUpdateSynchronization.enumValueIndex = mProp_GoogleUpdateSynchronization.enumValueIndex;
+#else
+
+ OnGUI_GoogleCredentials();
+
+ OnGUI_ShowMsg();
+
+ if (string.IsNullOrEmpty(mProp_Google_WebServiceURL.stringValue))
+ return;
+
+ if (mWebService_Status == "Offline")
+ return;
+
+ GUILayout.Space(20);
+
+ GUI.backgroundColor = Color.Lerp(Color.gray, Color.white, 0.5f);
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height (1));
+ GUI.backgroundColor = Color.white;
+ GUILayout.Space(10);
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label(new GUIContent(" Password", "This should match the value of the LocalizationPassword variable in the WebService Script in your Google Drive"), GUILayout.Width(108));
+ mProp_Google_Password.stringValue = EditorGUILayout.TextField(mProp_Google_Password.stringValue, GUILayout.ExpandWidth(true));
+ GUILayout.EndHorizontal();
+
+ OnGUI_GoogleSpreadsheetsInGDrive();
+ GUILayout.EndVertical();
+
+ if (mConnection_WWW!=null)
+ {
+ // Connection Status Bar
+ int time = (int)(Time.realtimeSinceStartup % 2 * 2.5);
+ string Loading = mConnection_Text + ".....".Substring(0, time);
+ GUI.color = Color.gray;
+ GUILayout.BeginHorizontal(LocalizeInspector.GUIStyle_OldTextArea);
+ GUILayout.Label (Loading, EditorStyles.miniLabel);
+ GUI.color = Color.white;
+ if (GUILayout.Button("Cancel", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ StopConnectionWWW();
+ GUILayout.EndHorizontal();
+ Repaint();
+ }
+ //else
+ // GUILayout.Space(10);
+
+
+ EditorGUI.BeginChangeCheck();
+ GUILayout.Space(5);
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ LanguageSourceData.eGoogleUpdateFrequency GoogleUpdateFrequency = (LanguageSourceData.eGoogleUpdateFrequency)mProp_GoogleUpdateFrequency.enumValueIndex;
+ GoogleUpdateFrequency = (LanguageSourceData.eGoogleUpdateFrequency)EditorGUILayout.EnumPopup("Auto Update Frequency", GoogleUpdateFrequency, GUILayout.ExpandWidth(true));
+ if (EditorGUI.EndChangeCheck())
+ {
+ mProp_GoogleUpdateFrequency.enumValueIndex = (int)GoogleUpdateFrequency;
+ }
+
+ GUILayout.Space(10);
+ GUILayout.Label("Delay:");
+ mProp_GoogleUpdateDelay.floatValue = EditorGUILayout.FloatField(mProp_GoogleUpdateDelay.floatValue, GUILayout.Width(30));
+ GUILayout.Label("secs");
+
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ var GoogleInEditorCheckFrequency = (LanguageSourceData.eGoogleUpdateFrequency)mProp_GoogleInEditorCheckFrequency.enumValueIndex;
+ EditorGUI.BeginChangeCheck();
+ GoogleInEditorCheckFrequency = (LanguageSourceData.eGoogleUpdateFrequency)EditorGUILayout.EnumPopup(new GUIContent("In-Editor Check Frequency", "How often the editor will verify that the Spreadsheet is up-to-date with the LanguageSource. Having un-synchronized Spreadsheets can lead to issues when playing in the device as the download data will override the one in the build"), GoogleInEditorCheckFrequency, GUILayout.ExpandWidth(false));
+ if (EditorGUI.EndChangeCheck())
+ {
+ mProp_GoogleInEditorCheckFrequency.enumValueIndex = (int)GoogleInEditorCheckFrequency;
+ }
+ GUILayout.Space(122);
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ GUILayout.Label("Update Synchronization", GUILayout.Width(180));
+ EditorGUI.BeginChangeCheck();
+ LanguageSourceData.eGoogleUpdateSynchronization GoogleUpdateSynchronization = (LanguageSourceData.eGoogleUpdateSynchronization)mProp_GoogleUpdateSynchronization.enumValueIndex;
+ GoogleUpdateSynchronization = (LanguageSourceData.eGoogleUpdateSynchronization)EditorGUILayout.EnumPopup(GoogleUpdateSynchronization, GUILayout.Width(178));
+ if (EditorGUI.EndChangeCheck())
+ {
+ mProp_GoogleUpdateSynchronization.enumValueIndex = (int)GoogleUpdateSynchronization;
+ }
+ GUILayout.EndHorizontal();
+
+ GUILayout.Space(5);
+
+ GUI.changed = false;
+ bool OpenDataSourceAfterExport = EditorPrefs.GetBool("I2Loc OpenDataSourceAfterExport", true);
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ OpenDataSourceAfterExport = GUILayout.Toggle(OpenDataSourceAfterExport, "Open Spreadsheet after Export");
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+
+ if (GUI.changed)
+ {
+ GUI.changed = false;
+ EditorPrefs.SetBool("I2Loc OpenDataSourceAfterExport", OpenDataSourceAfterExport);
+ }
+
+#endif
+
+ GUILayout.Space(5);
+ }
+
+ void OnGUI_GoogleCredentials()
+ {
+ GUI.enabled = mConnection_WWW==null;
+
+ GUI.changed = false;
+
+ string WebServiceHelp = "The web service is a script running on the google drive where the spreadsheet you want to use is located.\nThat script allows the game to synchronize the localization even after the game is published.";
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label (new GUIContent("Web Service URL:", WebServiceHelp), GUILayout.Width(110));
+
+ GUI.SetNextControlName ("WebServiceURL");
+ mProp_Google_WebServiceURL.stringValue = EditorGUILayout.TextField(mProp_Google_WebServiceURL.stringValue);
+
+ if (!string.IsNullOrEmpty(mWebService_Status))
+ {
+ if (mWebService_Status=="Online")
+ {
+ GUI.color = Color.green;
+ GUILayout.Label( "", GUILayout.Width(17));
+ Rect r = GUILayoutUtility.GetLastRect(); r.xMin += 3; r.yMin-= 3; r.xMax+= 2; r.yMax+=2;
+ GUI.Label( r, new GUIContent("\u2713", "Online"), EditorStyles.whiteLargeLabel);
+ GUI.color = Color.white;
+ }
+ else
+ if (mWebService_Status=="Offline")
+ {
+ GUI.color = Color.red;
+ GUILayout.Label( "", GUILayout.Width(17));
+ Rect r = GUILayoutUtility.GetLastRect(); r.xMin += 3; r.yMin-= 3; r.xMax+= 2; r.yMax+=2;
+ GUI.Label( r, new GUIContent("\u2717", mWebService_Status), EditorStyles.whiteLargeLabel);
+ GUI.color = Color.white;
+ }
+ else
+ if (mWebService_Status=="UnsupportedVersion")
+ {
+ Rect rect = GUILayoutUtility.GetLastRect();
+ float Width = 15;
+ rect.xMin = rect.xMax+1;
+ rect.xMax = rect.xMin + rect.height;
+ GUITools.DrawSkinIcon(rect, "CN EntryWarnIcon", "CN EntryWarn");
+ GUI.Label(rect, new GUIContent("\u2717", "The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."));
+ GUILayout.Space (Width);
+ }
+ }
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Space (118);
+ if (GUILayout.Button(new GUIContent("Install", "This opens the Web Service Script and shows you steps to install and authorize it on your Google Drive"), EditorStyles.toolbarButton))
+ {
+ ClearErrors();
+ Application.OpenURL("https://script.google.com/d/1zcsLSmq3Oddd8AsLuoKNDG1Y0eYBOHzyvGT7v94u1oN6igmsZb_PJzEm/newcopy"); // V5
+ //Application.OpenURL("https://goo.gl/RBCO0o"); // V4:https://script.google.com/d/1T7e5_40NcgRyind-yeg4PAkHz9TNZJ22F4RcbOvCpAs03JNf1vKNNTZB/newcopy
+ //Application.OpenURL("https://goo.gl/wFSbv2");// V3:https://script.google.com/d/1CxQDSXflsXRaH3M7xGfrIDrFwOIHWPsYTWi4mRZ_k77nyIInTgIk63Kd/newcopy");
+ }
+ if (GUILayout.Button("Verify", EditorStyles.toolbarButton))
+ {
+ ClearErrors();
+ VerifyGoogleService(mProp_Google_WebServiceURL.stringValue);
+ GUI.changed = false;
+ }
+ GUILayout.EndHorizontal();
+
+
+ if (string.IsNullOrEmpty(mProp_Google_WebServiceURL.stringValue))
+ {
+ EditorGUILayout.HelpBox(WebServiceHelp, MessageType.Info);
+ }
+
+ if (GUI.changed)
+ {
+ if (string.IsNullOrEmpty(mProp_Google_WebServiceURL.stringValue))
+ {
+ mProp_Google_SpreadsheetKey.stringValue = string.Empty;
+ mProp_Google_SpreadsheetName.stringValue = string.Empty;
+ }
+
+
+ // If the web service changed then clear the cached spreadsheet keys
+ mGoogleSpreadsheets.Clear();
+
+ GUI.changed = false;
+ ClearErrors();
+ }
+ GUI.enabled = true;
+ }
+
+ void OnGUI_GoogleSpreadsheetsInGDrive()
+ {
+ GUI.enabled = mConnection_WWW==null;
+
+ string[] Spreadsheets;
+ string[] SpreadsheetsKey;
+ if (mGoogleSpreadsheets.Count>0 || string.IsNullOrEmpty(mProp_Google_SpreadsheetKey.stringValue))
+ {
+ Spreadsheets = new List(mGoogleSpreadsheets.Keys).ToArray();
+ SpreadsheetsKey = new List(mGoogleSpreadsheets.Values).ToArray();
+ }
+ else
+ {
+ Spreadsheets = new[]{mProp_Google_SpreadsheetName.stringValue ?? string.Empty};
+ SpreadsheetsKey = new[]{mProp_Google_SpreadsheetKey.stringValue ?? string.Empty};
+ }
+ int mSpreadsheetIndex = Array.IndexOf(SpreadsheetsKey, mProp_Google_SpreadsheetKey.stringValue);
+
+ //--[ Spreadsheets ]------------------
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(10);
+ GUILayout.Label ("In Google Drive:", GUILayout.Width(100));
+
+ GUI.changed = false;
+ GUI.enabled = Spreadsheets != null && Spreadsheets.Length>0;
+ mSpreadsheetIndex = EditorGUILayout.Popup(mSpreadsheetIndex, Spreadsheets, EditorStyles.toolbarPopup);
+ if (GUI.changed && mSpreadsheetIndex >= 0)
+ {
+ mProp_Google_SpreadsheetKey.stringValue = SpreadsheetsKey[mSpreadsheetIndex];
+ mProp_Google_SpreadsheetName.stringValue = Spreadsheets[mSpreadsheetIndex];
+ GUI.changed = false;
+ }
+ GUI.enabled = true;
+
+ GUI.enabled = !string.IsNullOrEmpty(mProp_Google_SpreadsheetKey.stringValue) && mConnection_WWW==null;
+ if (GUILayout.Button("X", EditorStyles.toolbarButton,GUILayout.ExpandWidth(false)))
+ mProp_Google_SpreadsheetKey.stringValue = string.Empty;
+ GUI.enabled = true;
+ GUILayout.Space(10);
+ GUILayout.EndHorizontal();
+
+ GUILayout.Space(2);
+
+ //--[ Spreadsheets Operations ]------------------
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(114);
+ if (GUILayout.Button("New", EditorStyles.toolbarButton,GUILayout.ExpandWidth(true)))
+ Google_NewSpreadsheet();
+
+ GUI.enabled = !string.IsNullOrEmpty(mProp_Google_SpreadsheetKey.stringValue) && mConnection_WWW==null;
+ if (GUILayout.Button("Open", EditorStyles.toolbarButton,GUILayout.ExpandWidth(true)))
+ OpenGoogleSpreadsheet(mProp_Google_SpreadsheetKey.stringValue);
+ GUI.enabled = mConnection_WWW==null;
+
+ GUILayout.Space(5);
+
+ if (TestButton(eTest_ActionType.Button_GoogleSpreadsheet_RefreshList, "Refresh", EditorStyles.toolbarButton,GUILayout.ExpandWidth(true)))
+ EditorApplication.update+=Google_FindSpreadsheets;
+
+ GUILayout.Space(10);
+ GUILayout.EndHorizontal();
+
+ GUILayout.Space(15);
+
+ if (!string.IsNullOrEmpty(mProp_Google_SpreadsheetKey.stringValue))
+ OnGUI_GoogleButtons_ImportExport( mProp_Google_SpreadsheetKey.stringValue );
+
+ GUI.enabled = true;
+ }
+
+
+ private void OnGUI_ImportButtons()
+ {
+ eSpreadsheetUpdateMode Mode = SynchronizationButtons("Import");
+ if (Mode != eSpreadsheetUpdateMode.None || InTestAction(eTest_ActionType.Button_GoogleSpreadsheet_Import))
+ {
+ if (mTestAction == eTest_ActionType.Button_GoogleSpreadsheet_Import)
+ Mode = (eSpreadsheetUpdateMode)mTestActionArg;
+
+ serializedObject.ApplyModifiedProperties();
+
+ var modeCopy = Mode;
+ GUITools.DelayedCall(() => Import_Google(modeCopy));
+ }
+ }
+
+ private void OnGUI_ExportButtons()
+ {
+ eSpreadsheetUpdateMode Mode = SynchronizationButtons("Export");
+ if (Mode != eSpreadsheetUpdateMode.None || InTestAction(eTest_ActionType.Button_GoogleSpreadsheet_Export))
+ {
+ if (mTestAction == eTest_ActionType.Button_GoogleSpreadsheet_Export)
+ Mode = (eSpreadsheetUpdateMode)mTestActionArg;
+
+ serializedObject.ApplyModifiedProperties();
+
+ var modeCopy = Mode;
+ GUITools.DelayedCall(() => Export_Google(modeCopy));
+ }
+ }
+
+ void OnGUI_GoogleButtons_ImportExport( string SpreadsheetKey )
+ {
+ GUI.enabled = !string.IsNullOrEmpty(SpreadsheetKey) && mConnection_WWW==null;
+
+ bool vertical = EditorGUIUtility.currentViewWidth < 450;
+
+ if (vertical)
+ {
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ OnGUI_ImportButtons();
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ OnGUI_ExportButtons();
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+ }
+ else
+ {
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ OnGUI_ImportButtons();
+ GUILayout.FlexibleSpace();
+ OnGUI_ExportButtons();
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+ }
+
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ GUILayout.BeginVertical();
+ EditorGUIUtility.labelWidth += 10;
+ EditorGUILayout.PropertyField(mProp_Spreadsheet_SpecializationAsRows, new GUIContent("Show Specializations as Rows", "true: Make each specialization a separate row (e.g. Term[VR]..., Term[Touch]....\nfalse: Merge specializations into same cell separated by [i2s_XXX]"));
+ EditorGUILayout.PropertyField(mProp_Spreadsheet_SortRows, new GUIContent("Sort Rows", "true: Sort each term by its name....\nfalse: Keep the terms order"));
+ EditorGUIUtility.labelWidth -= 10;
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+ GUILayout.Space(10);
+
+
+ GUI.enabled = true;
+ }
+
+ eSpreadsheetUpdateMode SynchronizationButtons( string Operation, bool ForceReplace = false )
+ {
+ eSpreadsheetUpdateMode Result = eSpreadsheetUpdateMode.None;
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Width (1));
+ GUI.backgroundColor = Color.white;
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ GUILayout.Label(Operation, EditorStyles.miniLabel);
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ if (GUILayout.Button( "Replace", EditorStyles.toolbarButton, GUILayout.Width(60)))
+ Result = eSpreadsheetUpdateMode.Replace;
+
+ if (ForceReplace) GUI.enabled = false;
+ if (GUILayout.Button( "Merge", EditorStyles.toolbarButton, GUILayout.Width(60)))
+ Result = eSpreadsheetUpdateMode.Merge;
+
+ if (GUILayout.Button( "Add New", EditorStyles.toolbarButton, GUILayout.Width(60)))
+ Result = eSpreadsheetUpdateMode.AddNewTerms;
+ GUI.enabled = mConnection_WWW==null;
+ GUILayout.Space(1);
+ GUILayout.EndHorizontal();
+
+ GUILayout.Space(2);
+ GUILayout.EndVertical();
+
+ if (Result != eSpreadsheetUpdateMode.None)
+ ClearErrors();
+
+ return Result;
+ }
+ #endregion
+
+ void VerifyGoogleService( string WebServiceURL )
+ {
+ #if UNITY_WEBPLAYER
+ ShowError ("Contacting google translation is not yet supported on WebPlayer" );
+ #else
+ StopConnectionWWW();
+ mWebService_Status = null;
+ mConnection_WWW = UnityWebRequest.Get(WebServiceURL + "?action=Ping");
+ I2Utils.SendWebRequest(mConnection_WWW);
+ mConnection_Callback = OnVerifyGoogleService;
+ EditorApplication.update += CheckForConnection;
+ mConnection_Text = "Verifying Web Service";
+ //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
+ #endif
+ }
+
+ void OnVerifyGoogleService( string Result, string Error )
+ {
+ if (Result.Contains("Authorization is required to perform that action"))
+ {
+ ShowWarning("You need to authorize the webservice before using it. Check the steps 4 and 5 in the WebService Script");
+ mWebService_Status = "Offline";
+ return;
+ }
+
+ try
+ {
+ var data = JSON.Parse(Result).AsObject;
+ int version = 0;
+ if (!int.TryParse(data["script_version"], out version))
+ version = 0;
+ int requiredVersion = LocalizationManager.GetRequiredWebServiceVersion();
+
+ if (requiredVersion == version)
+ {
+ mWebService_Status = "Online";
+ ClearErrors();
+ }
+ else
+ {
+ mWebService_Status = "UnsupportedVersion";
+ ShowError("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version.");
+ }
+ }
+ catch (Exception)
+ {
+ ShowError("Unable to access the WebService");
+ mWebService_Status = "Offline";
+ }
+ }
+
+
+ void Export_Google( eSpreadsheetUpdateMode UpdateMode )
+ {
+ StopConnectionWWW();
+ LanguageSourceData source = GetSourceData();
+ mConnection_WWW = source.Export_Google_CreateWWWcall( UpdateMode );
+ if (mConnection_WWW==null)
+ {
+ OnExported_Google(string.Empty, "WebPlayer can't contact Google");
+ }
+ else
+ {
+ mConnection_Callback = OnExported_Google;
+ EditorApplication.update += CheckForConnection;
+ mConnection_Text = "Uploading spreadsheet";
+ //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
+ }
+ }
+
+ void OnExported_Google( string Result, string Error )
+ {
+ // Checkf or error, but discard the "necessary data rewind wasn't possible" as thats not a real error, just a bug in Unity with POST redirects
+ if (!string.IsNullOrEmpty(Error) && !Error.Contains("rewind"))
+ {
+ Debug.Log (Error);
+ ShowError("Unable to access google");
+ return;
+ }
+
+ if (EditorPrefs.GetBool("I2Loc OpenDataSourceAfterExport", true) && !string.IsNullOrEmpty(GetSourceData().Google_SpreadsheetName))
+ OpenGoogleSpreadsheet(GetSourceData().Google_SpreadsheetKey );
+ mProp_GoogleLiveSyncIsUptoDate.boolValue = true;
+ }
+
+ static void OpenGoogleSpreadsheet( string SpreadsheetKey )
+ {
+ ClearErrors();
+ string SpreadsheetUrl = "https://docs.google.com/spreadsheet/ccc?key=" + SpreadsheetKey;
+ Application.OpenURL(SpreadsheetUrl);
+ }
+
+ public abstract LanguageSourceData GetSourceData();
+
+
+ void Import_Google( eSpreadsheetUpdateMode UpdateMode )
+ {
+ StopConnectionWWW();
+ LanguageSourceData source = GetSourceData();
+ mConnection_WWW = source.Import_Google_CreateWWWcall(true, false);
+ if (mConnection_WWW==null)
+ {
+ OnImported_Google(string.Empty, "Unable to import from google", eSpreadsheetUpdateMode.Replace);
+ }
+ else
+ {
+ mConnection_Callback=null;
+ switch (UpdateMode)
+ {
+ case eSpreadsheetUpdateMode.Replace : mConnection_Callback += OnImported_Google_Replace; break;
+ case eSpreadsheetUpdateMode.Merge : mConnection_Callback += OnImported_Google_Merge; break;
+ case eSpreadsheetUpdateMode.AddNewTerms : mConnection_Callback += OnImported_Google_AddNewTerms; break;
+ }
+ EditorApplication.update += CheckForConnection;
+ mConnection_Text = "Downloading spreadsheet";
+ //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
+ }
+ }
+
+ void OnImported_Google_Replace( string Result, string Error ) { OnImported_Google(Result, Error, eSpreadsheetUpdateMode.Replace); }
+ void OnImported_Google_Merge( string Result, string Error ) { OnImported_Google(Result, Error, eSpreadsheetUpdateMode.Merge); }
+ void OnImported_Google_AddNewTerms( string Result, string Error ) { OnImported_Google(Result, Error, eSpreadsheetUpdateMode.AddNewTerms); }
+
+ void OnImported_Google( string Result, string Error, eSpreadsheetUpdateMode UpdateMode )
+ {
+ if (!string.IsNullOrEmpty(Error))
+ {
+ Debug.Log(Error);
+ ShowError("Unable to access google");
+ return;
+ }
+ LanguageSourceData source = GetSourceData();
+ string ErrorMsg = source.Import_Google_Result(Result, UpdateMode);
+ bool HasErrors = !string.IsNullOrEmpty(ErrorMsg);
+ if (HasErrors)
+ ShowError(ErrorMsg);
+
+ serializedObject.Update();
+ ParseTerms(true, false, !HasErrors);
+ mSelectedKeys.Clear ();
+ mSelectedCategories.Clear();
+ ScheduleUpdateTermsToShowInList();
+ mLanguageSource.GetCategories(false, mSelectedCategories);
+
+ EditorUtility.SetDirty (target);
+ AssetDatabase.SaveAssets();
+ }
+
+ void CheckForConnection()
+ {
+ if (mConnection_WWW!=null && mConnection_WWW.isDone)
+ {
+ fnConnectionCallback callback = mConnection_Callback;
+ string Result = string.Empty;
+ string Error = mConnection_WWW.error;
+
+ if (string.IsNullOrEmpty(Error))
+ {
+ // Try first converting with the right encoding
+ var bytes = mConnection_WWW.downloadHandler.data;
+ if (bytes!=null)
+ Result = Encoding.UTF8.GetString(bytes); //mConnection_WWW.text;
+
+ // Fallback to use the default encoding
+ else
+ Result = mConnection_WWW.downloadHandler.text;
+ }
+
+ StopConnectionWWW();
+ if (callback!=null)
+ callback(Result, Error);
+ }
+ /*else
+ if (Time.realtimeSinceStartup > mConnection_TimeOut+30)
+ {
+ fnConnectionCallback callback = mConnection_Callback;
+ StopConnectionWWW();
+ if (callback!=null)
+ callback(string.Empty, "Time Out");
+ }*/
+ }
+
+ void StopConnectionWWW()
+ {
+ EditorApplication.update -= CheckForConnection;
+ mConnection_WWW = null;
+ mConnection_Callback = null;
+ mConnection_Text = string.Empty;
+ }
+
+ #region New Spreadsheet
+
+ void Google_NewSpreadsheet()
+ {
+ #if UNITY_WEBPLAYER
+ ShowError ("Contacting google translation is not yet supported on WebPlayer" );
+ #else
+
+ ClearErrors();
+ string SpreadsheetName;
+
+ LanguageSourceData source = GetSourceData();
+ if (source.IsGlobalSource())
+ SpreadsheetName = string.Format("{0} Localization", PlayerSettings.productName);
+ else
+ SpreadsheetName = string.Format("{0} {1} {2}", PlayerSettings.productName, Editor_GetCurrentScene(), source.ownerObject.name);
+
+ string query = mProp_Google_WebServiceURL.stringValue + "?action=NewSpreadsheet&name=" + Uri.EscapeDataString(SpreadsheetName) + "&password="+ Uri.EscapeDataString(mProp_Google_Password.stringValue);
+
+ mConnection_WWW = UnityWebRequest.Get(query);
+ I2Utils.SendWebRequest(mConnection_WWW);
+ mConnection_Callback = Google_OnNewSpreadsheet;
+ EditorApplication.update += CheckForConnection;
+ mConnection_Text = "Creating Spreadsheet";
+ //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
+ #endif
+ }
+
+ void Google_OnNewSpreadsheet( string Result, string Error )
+ {
+ if (!string.IsNullOrEmpty(Error))
+ {
+ ShowError("Unable to access google");
+ return;
+ }
+ if (Result=="Wrong Password")
+ {
+ ShowError(Result);
+ return;
+ }
+
+ try
+ {
+ var data = JSON.Parse(Result).AsObject;
+
+ string name = data["name"];
+ string key = data["id"];
+
+ serializedObject.Update();
+ mProp_Google_SpreadsheetKey.stringValue = key;
+ mProp_Google_SpreadsheetName.stringValue = name;
+ serializedObject.ApplyModifiedProperties();
+ mGoogleSpreadsheets[name] = key;
+
+ LanguageSourceData source = GetSourceData();
+ if (source.mTerms.Count>0 || source.mLanguages.Count>0)
+ Export_Google( eSpreadsheetUpdateMode.Replace );
+ else
+ if (EditorPrefs.GetBool("I2Loc OpenDataSourceAfterExport", true))
+ OpenGoogleSpreadsheet( key );
+
+ }
+ catch(Exception e)
+ {
+ ShowError (e.Message);
+ }
+ }
+
+ #endregion
+
+ #region FindSpreadsheets
+
+ void Google_FindSpreadsheets()
+ {
+ ClearErrors();
+ EditorApplication.update -= Google_FindSpreadsheets;
+ string query = mProp_Google_WebServiceURL.stringValue + "?action=GetSpreadsheetList&password="+ Uri.EscapeDataString(mProp_Google_Password.stringValue);
+ mConnection_WWW = UnityWebRequest.Get(query);
+ I2Utils.SendWebRequest(mConnection_WWW);
+ mConnection_Callback = Google_OnFindSpreadsheets;
+ EditorApplication.update += CheckForConnection;
+ mConnection_Text = "Accessing google";
+ //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
+ }
+
+ void Google_OnFindSpreadsheets( string Result, string Error)
+ {
+ if (!string.IsNullOrEmpty(Error))
+ {
+ ShowError("Unable to access google");
+ return;
+ }
+
+ if (Result=="Wrong Password")
+ {
+ ShowError(Result);
+ return;
+ }
+
+ try
+ {
+ mGoogleSpreadsheets.Clear();
+ var data = JSON.Parse(Result).AsObject;
+ foreach (KeyValuePair element in data)
+ mGoogleSpreadsheets[element.Key] = element.Value;
+ }
+ catch(Exception e)
+ {
+ ShowError (e.Message);
+ }
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs.meta
new file mode 100644
index 00000000..77261f67
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Google.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 800caf7e364ec2947be099b4f9ed976d
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs
new file mode 100644
index 00000000..ade61d17
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs
@@ -0,0 +1,339 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+ enum eLocalSpreadsheeet { CSV, XLS, XLSX, NONE }
+
+ void OnGUI_Spreadsheet_Local()
+ {
+ GUILayout.Space(10);
+ GUILayout.BeginVertical();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Label ("File:", GUILayout.ExpandWidth(false));
+
+ mProp_Spreadsheet_LocalFileName.stringValue = EditorGUILayout.TextField(mProp_Spreadsheet_LocalFileName.stringValue);
+ /*if (GUILayout.Button("...", "toolbarbutton", GUILayout.ExpandWidth(false)))
+ {
+ string sFileName = mProp_Spreadsheet_LocalFileName.stringValue;
+
+ string sPath = string.Empty;
+ try {
+ sPath = System.IO.Path.GetDirectoryName(sFileName);
+ }
+ catch( System.Exception e){}
+
+ if (string.IsNullOrEmpty(sPath))
+ sPath = Application.dataPath + "/";
+
+ sFileName = System.IO.Path.GetFileName(sFileName);
+ if (string.IsNullOrEmpty(sFileName))
+ sFileName = "Localization.csv";
+
+ string FullFileName = EditorUtility.SaveFilePanel("Select CSV File", sPath, sFileName, "csv");
+ //string FullFileName = EditorUtility.OpenFilePanel("Select CSV, XLS or XLSX File", sFileName, "csv;*.xls;*.xlsx");
+
+ if (!string.IsNullOrEmpty(FullFileName))
+ {
+ Prop_LocalFileName.stringValue = TryMakingPathRelativeToProject(FullFileName);
+ }
+ }*/
+ GUILayout.EndHorizontal();
+
+ //--[ Find current extension ]---------------
+ eLocalSpreadsheeet CurrentExtension = eLocalSpreadsheeet.NONE;
+ //string FileNameLower = Prop_LocalFileName.stringValue.ToLower();
+ /*if (FileNameLower.EndsWith(".csv")) */CurrentExtension = eLocalSpreadsheeet.CSV;
+ /*if (FileNameLower.EndsWith(".xls")) CurrentExtension = eLocalSpreadsheeet.XLS;
+ if (FileNameLower.EndsWith(".xlsx")) CurrentExtension = eLocalSpreadsheeet.XLSX;*/
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ switch (CurrentExtension)
+ {
+ case eLocalSpreadsheeet.NONE :
+ case eLocalSpreadsheeet.CSV :
+ {
+ string FileTypesDesc = "Select or Drag any file of the following types:\n\n";
+ FileTypesDesc+= "*.csv (Comma Separated Values)\n";
+ FileTypesDesc+= "*.txt (CSV file renamed as txt)\n";
+ //FileTypesDesc+= "\n*.xls (Excel 97-2003)";
+ //FileTypesDesc+= "\n*.xlsx (Excel Open XML format)";
+ EditorGUILayout.HelpBox(FileTypesDesc, MessageType.None);
+ }
+ break;
+ case eLocalSpreadsheeet.XLS : EditorGUILayout.HelpBox("Excel 97-2003", MessageType.None); break;
+ case eLocalSpreadsheeet.XLSX : EditorGUILayout.HelpBox("Excel Open XML format", MessageType.None); break;
+ }
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+
+ GUILayout.EndVertical();
+
+ //--[ Allow Dragging files ]-----------------
+ if (GUILayoutUtility.GetLastRect().Contains (UnityEngine.Event.current.mousePosition) && IsValidDraggedLoadSpreadsheet())
+ {
+ if (UnityEngine.Event.current.type == EventType.DragUpdated)
+ DragAndDrop.visualMode = DragAndDropVisualMode.Link;
+
+ if (UnityEngine.Event.current.type == EventType.DragPerform)
+ {
+ mProp_Spreadsheet_LocalFileName.stringValue = TryMakingPathRelativeToProject( DragAndDrop.paths[0] );
+ DragAndDrop.AcceptDrag();
+ UnityEngine.Event.current.Use();
+ }
+ }
+
+ GUILayout.Space(10);
+
+ OnGUI_Spreadsheet_Local_ImportExport( CurrentExtension, mProp_Spreadsheet_LocalFileName.stringValue );
+
+ //if (Application.platform == RuntimePlatform.OSXEditor)
+
+ //-- CSV Separator ----------------
+ GUI.changed = false;
+ var CSV_Separator = mProp_Spreadsheet_LocalCSVSeparator.stringValue;
+ if (string.IsNullOrEmpty (CSV_Separator))
+ CSV_Separator = ",";
+
+ GUILayout.Space(10);
+ GUILayout.BeginVertical("Box");
+ GUILayout.BeginHorizontal();
+ GUILayout.Label("Separator:");
+ GUILayout.FlexibleSpace();
+
+ if (GUILayout.Toggle(CSV_Separator==",", "Comma(,)") && CSV_Separator!=",")
+ CSV_Separator = ",";
+
+ GUILayout.FlexibleSpace();
+
+ if (GUILayout.Toggle(CSV_Separator==";", "Semicolon(;)") && CSV_Separator!=";")
+ CSV_Separator = ";";
+
+ GUILayout.FlexibleSpace();
+
+ if (GUILayout.Toggle(CSV_Separator=="\t", "TAB(\\t)") && CSV_Separator!="\t")
+ CSV_Separator = "\t";
+
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ //--[ Encoding ]---------------
+ var encodings = Encoding.GetEncodings ().OrderBy(e=>e.Name).ToArray();
+ var encodingNames = encodings.Select(e=>e.Name).ToArray();
+
+ int idx = Array.IndexOf (encodingNames, mProp_Spreadsheet_LocalCSVEncoding.stringValue);
+ if (idx == -1)
+ idx = Array.IndexOf (encodingNames, "utf-8");
+ EditorGUIUtility.labelWidth = 80;
+
+ idx = EditorGUILayout.Popup ("Encoding:", idx, encodingNames);
+ if (GUILayout.Button("Default", GUILayout.ExpandWidth(false)))
+ idx = Array.IndexOf (encodingNames, "utf-8");
+
+ if (idx>=0 && mProp_Spreadsheet_LocalCSVEncoding.stringValue != encodings [idx].Name)
+ mProp_Spreadsheet_LocalCSVEncoding.stringValue = encodings [idx].Name;
+ GUILayout.EndHorizontal();
+
+ GUILayout.EndVertical();
+
+ if (GUI.changed)
+ {
+ mProp_Spreadsheet_LocalCSVSeparator.stringValue = CSV_Separator;
+ }
+
+ GUILayout.Space(10);
+ EditorGUILayout.HelpBox("On some Mac OS, there is a Unity Bug that makes the IDE crash when selecting a CSV file in the Open/Save File Dialog.\nJust by clicking the file, unity tries to preview the content and crashes.\n\nIf any of your the team members use Mac, its adviced to import/export the CSV Files with TXT extension.", MessageType.Warning);
+ GUILayout.Space(10);
+
+ OnGUI_ShowMsg();
+ }
+
+ bool IsValidDraggedLoadSpreadsheet()
+ {
+ if (DragAndDrop.paths==null || DragAndDrop.paths.Length!=1)
+ return false;
+
+ string sPath = DragAndDrop.paths[0].ToLower();
+ if (sPath.EndsWith(".csv")) return true;
+ if (sPath.EndsWith(".txt")) return true;
+ //if (sPath.EndsWith(".xls")) return true;
+ //if (sPath.EndsWith(".xlsx")) return true;
+
+ /*int iChar = sPath.LastIndexOfAny( "/\\.".ToCharArray() );
+ if (iChar<0 || sPath[iChar]!='.')
+ return true;
+ return false;*/
+ return false;
+ }
+
+ string TryMakingPathRelativeToProject( string FileName )
+ {
+ string ProjectPath = Application.dataPath.ToLower();
+ string FileNameLower = FileName.ToLower();
+
+ if (FileNameLower.StartsWith(ProjectPath))
+ FileName = FileName.Substring(ProjectPath.Length+1);
+ else
+ if (FileNameLower.StartsWith("assets/"))
+ FileName = FileName.Substring("assets/".Length);
+ return FileName;
+ }
+
+ void OnGUI_Spreadsheet_Local_ImportExport( eLocalSpreadsheeet CurrentExtension, string File )
+ {
+ GUI.enabled = CurrentExtension!=eLocalSpreadsheeet.NONE;
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(10);
+
+ GUI.backgroundColor = Color.Lerp(Color.gray, Color.white, 0.5f);
+ eSpreadsheetUpdateMode Mode = SynchronizationButtons("Import");
+ if ( Mode!= eSpreadsheetUpdateMode.None)
+ Import_Local(File, CurrentExtension, Mode);
+
+ GUILayout.FlexibleSpace();
+
+ GUI.backgroundColor = Color.Lerp(Color.gray, Color.white, 0.5f);
+ Mode = SynchronizationButtons("Export", true);
+ if ( Mode != eSpreadsheetUpdateMode.None)
+ Export_Local(File, CurrentExtension, Mode);
+
+ GUILayout.Space(10);
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+
+ GUILayout.BeginVertical();
+ EditorGUIUtility.labelWidth += 10;
+ EditorGUILayout.PropertyField(mProp_Spreadsheet_SpecializationAsRows, new GUIContent("Show Specializations as Rows", "true: Make each specialization a separate row (e.g. Term[VR]..., Term[Touch]....\nfalse: Merge specializations into same cell separated by [i2s_XXX]"));
+ EditorGUILayout.PropertyField(mProp_Spreadsheet_SortRows, new GUIContent("Sort Rows", "true: Sort each term by its name....\nfalse: Keep the terms order"));
+ EditorGUIUtility.labelWidth -= 10;
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+
+
+ GUI.enabled = true;
+ }
+
+ void Import_Local( string File, eLocalSpreadsheeet CurrentExtension, eSpreadsheetUpdateMode UpdateMode )
+ {
+ try
+ {
+ serializedObject.ApplyModifiedProperties();
+ serializedObject.Update();
+ ClearErrors();
+
+ if (string.IsNullOrEmpty(File))
+ File = Application.dataPath + "/Localization.csv";
+ else
+ if (!Path.IsPathRooted(File))
+ File = string.Concat(Application.dataPath, "/", File);
+
+ // On Mac there is an issue with previewing CSV files, so its forced to only TXT
+ if (Application.platform == RuntimePlatform.OSXEditor)
+ File = EditorUtility.OpenFilePanel("Select a CSV file renamed as TXT", File, "txt");
+ else
+ File = EditorUtility.OpenFilePanel("Select a CSV file or a CSV file renamed as TXT", File, "csv;*.txt");
+ //File = EditorUtility.OpenFilePanel("Select CSV, XLS or XLSX File", File, "csv;*.xls;*.xlsx");
+ if (!string.IsNullOrEmpty(File))
+ {
+ mLanguageSource.Spreadsheet_LocalFileName = TryMakingPathRelativeToProject(File);
+ switch (CurrentExtension)
+ {
+ case eLocalSpreadsheeet.CSV : Import_CSV(File, UpdateMode); break;
+ }
+ ParseTerms(true, false, true);
+ EditorUtility.SetDirty (target);
+ AssetDatabase.SaveAssets();
+ }
+ }
+ catch (Exception ex)
+ {
+ ShowError("Unable to import file");
+ Debug.LogError(ex.Message);
+ }
+ }
+
+ void Import_CSV( string FileName, eSpreadsheetUpdateMode UpdateMode )
+ {
+ LanguageSourceData source = GetSourceData();
+ var encoding = Encoding.GetEncoding (mProp_Spreadsheet_LocalCSVEncoding.stringValue);
+ if (encoding == null)
+ encoding = Encoding.UTF8;
+ string CSVstring = LocalizationReader.ReadCSVfile (FileName, encoding);
+
+ char Separator = mProp_Spreadsheet_LocalCSVSeparator.stringValue.Length>0 ? mProp_Spreadsheet_LocalCSVSeparator.stringValue[0] : ',';
+ string sError = source.Import_CSV( string.Empty, CSVstring, UpdateMode, Separator);
+ if (!string.IsNullOrEmpty(sError))
+ ShowError(sError);
+
+ mSelectedCategories = source.GetCategories();
+ }
+
+ void Export_Local( string File, eLocalSpreadsheeet CurrentExtension, eSpreadsheetUpdateMode UpdateMode )
+ {
+ try
+ {
+ serializedObject.ApplyModifiedProperties();
+ serializedObject.Update();
+ ClearErrors();
+
+ string sPath = string.Empty;
+ if (!Path.IsPathRooted(File))
+ File = string.Concat(Application.dataPath, "/", File);
+
+ try {
+ sPath = Path.GetDirectoryName(File);
+ }
+ catch( Exception){}
+
+ if (string.IsNullOrEmpty(sPath))
+ sPath = Application.dataPath + "/";
+
+ File = Path.GetFileName(File);
+ if (string.IsNullOrEmpty(File))
+ File = "Localization.csv";
+
+ if (Application.platform == RuntimePlatform.OSXEditor)
+ File = EditorUtility.SaveFilePanel("Select a CSV file renamed as TXT", sPath, File, "txt");
+ else
+ File = EditorUtility.SaveFilePanel("Select a CSV or TXT file", sPath, File, "csv;*.txt");
+ if (!string.IsNullOrEmpty(File))
+ {
+ mLanguageSource.Spreadsheet_LocalFileName = TryMakingPathRelativeToProject(File);
+
+ char Separator = mProp_Spreadsheet_LocalCSVSeparator.stringValue.Length>0 ? mProp_Spreadsheet_LocalCSVSeparator.stringValue[0] : ',';
+ var encoding = Encoding.GetEncoding (mProp_Spreadsheet_LocalCSVEncoding.stringValue);
+ if (encoding == null)
+ encoding = Encoding.UTF8;
+
+ switch (CurrentExtension)
+ {
+ case eLocalSpreadsheeet.CSV : Export_CSV(File, UpdateMode, Separator, encoding); break;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ShowError("Unable to export file\nCheck it is not READ-ONLY and that\nits not opened in an external viewer");
+ }
+ }
+
+ public void Export_CSV( string FileName, eSpreadsheetUpdateMode UpdateMode, char Separator, Encoding encoding )
+ {
+ LanguageSourceData source = GetSourceData();
+
+ string CSVstring = source.Export_CSV(null, Separator, mProp_Spreadsheet_SpecializationAsRows.boolValue, mProp_Spreadsheet_SortRows.boolValue);
+ File.WriteAllText (FileName, CSVstring, encoding);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs.meta
new file mode 100644
index 00000000..dd66d4c6
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Spreadsheet_Local.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: fdca66efafe784661b464934cacff065
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs
new file mode 100644
index 00000000..8063255e
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs
@@ -0,0 +1,840 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+ #region Variables
+
+ Vector2 mScrollPos_Keys = Vector2.zero;
+
+ public static string mKeyToExplore; // Key that should show all the language details
+ static string KeyList_Filter = "";
+ float mRowSize=-1;
+ float ScrollHeight;
+ float mTermList_MaxWidth = -1;
+
+ public static List mSelectedKeys = new List(); // Selected Keys in the list of mParsedKeys
+ public static List mSelectedCategories = new List();
+
+
+ public enum eFlagsViewKeys
+ {
+ Used = 1<<1,
+ Missing = 1<<2,
+ NotUsed = 1<<3,
+ Untranslated = 1<<4,
+ }
+ public static int mFlagsViewKeys = (int)eFlagsViewKeys.Used | (int)eFlagsViewKeys.NotUsed;
+
+ public static string mTermsList_NewTerm;
+ Rect mKeyListFilterRect;
+
+ #endregion
+
+ #region GUI Key List
+
+ float ExpandedViewHeight;
+ float TermsListHeight;
+
+ void OnGUI_KeysList(bool AllowExpandKey = true, float Height = 300.0f, bool ShowTools=true)
+ {
+ ///if (mTermList_MaxWidth<=0)
+ CalculateTermsListMaxWidth();
+
+ //--[ List Filters ]--------------------------------------
+
+ // The ID of this control is registered here to avoid losing focus when the terms list grows in the scrollbox
+ // This control is drawn later on
+ int KeyListFilterID = GUIUtility.GetControlID( FocusType.Keyboard );
+
+ OnGUI_ShowMsg();
+
+ GUILayout.BeginHorizontal();
+ GUIStyle bstyle = new GUIStyle ("toolbarbutton");
+ bstyle.fontSize = 15;
+ if (GUILayout.Button (new GUIContent("\u21bb", "Parse Scene and update terms list with missing and unused terms"), bstyle, GUILayout.Width(25)))
+ EditorApplication.update += DoParseTermsInCurrentSceneAndScripts;
+ if (GUILayout.Button(new GUIContent("\u21ea", "Refresh the translation of all Localize objects"), bstyle, GUILayout.Width(25)))
+ CallLocalizeAll();
+
+ GUILayout.Space (1);
+
+ var oldFlags = mFlagsViewKeys;
+ mFlagsViewKeys = OnGUI_FlagToogle("Used","Shows All Terms referenced in the parsed scenes", mFlagsViewKeys, (int)eFlagsViewKeys.Used);
+ mFlagsViewKeys = OnGUI_FlagToogle("Not Used", "Shows all Terms from the Source that are not been used", mFlagsViewKeys, (int)eFlagsViewKeys.NotUsed);
+ mFlagsViewKeys = OnGUI_FlagToogle("Missing","Shows all Terms Used but not defined in the Source", mFlagsViewKeys, (int)eFlagsViewKeys.Missing);
+
+ mFlagsViewKeys = OnGUI_FlagToogle("Untranslated", "Shows all Terms that were not translated to any language", mFlagsViewKeys, (int)eFlagsViewKeys.Untranslated);
+
+ if (oldFlags!=mFlagsViewKeys)
+ ScheduleUpdateTermsToShowInList();
+
+ OnGUI_SelectedCategories();
+
+ GUILayout.EndHorizontal();
+
+ /*//if (UnityEngine.Event.current.type == EventType.Repaint)
+ TermsListHeight = Screen.height - 400;
+ Debug.Log(UnityEngine.Event.current.type + " " + TermsListHeight + " " + Screen.height + " " + GUILayoutUtility.GetLastRect().yMax);
+
+ //TermsListHeight = Mathf.Min(Screen.height*0.5f, TermsListHeight);
+ mScrollPos_Keys = GUILayout.BeginScrollView(mScrollPos_Keys, false, false, "horizontalScrollbar", "verticalScrollbar", LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(TermsListHeight));
+ for (int i = 0; i < 1000; ++i)
+ GUILayout.Label("ahhh" + i);
+ GUILayout.EndScrollView();
+
+ return;*/
+ TermsListHeight = Mathf.Min(Screen.height*0.5f, TermsListHeight);
+
+ //--[ Keys List ]-----------------------------------------
+ GUI.backgroundColor = Color.Lerp(GUITools.LightGray, Color.white, 0.5f);
+ mScrollPos_Keys = GUILayout.BeginScrollView( mScrollPos_Keys, false, false, "horizontalScrollbar", "verticalScrollbar", LocalizeInspector.GUIStyle_OldTextArea ,GUILayout.Height(TermsListHeight)/*GUILayout.MinHeight(Height), GUILayout.MaxHeight(Screen.height), GUILayout.ExpandHeight(true)*/);
+ GUI.backgroundColor = Color.white;
+
+ bool bAnyValidUsage = false;
+
+ mRowSize = EditorStyles.toolbar.fixedHeight;
+ if (UnityEngine.Event.current!=null && UnityEngine.Event.current.type == EventType.Layout)
+ ScrollHeight = mScrollPos_Keys.y;
+
+ float YPosMin = -ScrollHeight;
+ int nSkip = 0;
+ int nDraw = 0;
+
+ if (mShowableTerms.Count == 0 && UnityEngine.Event.current.type == EventType.Layout)
+ UpdateTermsToShownInList ();
+
+ float SkipSize = 0;
+ foreach (var parsedTerm in mShowableTerms)
+ {
+ string sKey = parsedTerm.Term;
+ string sCategory = parsedTerm.Category;
+ string FullKey = parsedTerm.FullTerm;
+
+ int nUses = parsedTerm.Usage;
+ bAnyValidUsage = bAnyValidUsage | (nUses>=0);
+
+ ShowTerm_termData = parsedTerm.termData;
+
+ // Skip lines outside the view -----------------------
+ YPosMin += mRowSize;
+ SkipSize += mRowSize;
+ float YPosMax = YPosMin + mRowSize;
+ bool isExpanded = AllowExpandKey && mKeyToExplore==FullKey;
+ if (!isExpanded && (YPosMax<-2*mRowSize || YPosMin>/*Screen.height*/TermsListHeight+mRowSize))
+ {
+ if (YPosMin>TermsListHeight+mRowSize)
+ break;
+
+ nSkip++;
+ continue;
+ }
+ nDraw++;
+
+ //------------------------------------------------------
+
+ OnGUI_KeyHeader (sKey, sCategory, FullKey, nUses, YPosMin-mRowSize+mScrollPos_Keys.y);
+
+ //--[ Key Details ]-------------------------------
+
+ if (isExpanded)
+ {
+ GUILayout.Space(SkipSize);
+ SkipSize = 0;
+ OnGUI_KeyList_ShowKeyDetails();
+ Rect rect = GUILayoutUtility.GetLastRect();
+ if (rect.height>5)
+ ExpandedViewHeight = rect.height;
+ YPosMin += ExpandedViewHeight;
+ }
+ }
+ SkipSize += (mShowableTerms.Count - nDraw-nSkip) * mRowSize;
+ GUILayout.Space(SkipSize+2);
+ if (mSelectedCategories.Count < mParsedCategories.Count)
+ {
+ SkipSize += 25;
+ if (GUILayout.Button ("...", EditorStyles.label))
+ {
+ mSelectedCategories.Clear ();
+ mSelectedCategories.AddRange (mParsedCategories);
+ }
+ }
+ OnGUI_KeysList_AddKey();
+
+ GUILayout.Label("", GUILayout.Width(mTermList_MaxWidth+10+30), GUILayout.Height(1));
+
+ GUILayout.EndScrollView();
+
+ TermsListHeight = YPosMin + mRowSize + 25;//SkipSize+25;
+
+ //Rect ListRect = GUILayoutUtility.GetLastRect();
+ //if (ListRect.height>5)
+ // TermsListHeight = ListRect.height;
+ //Debug.Log(nDraw + " " + nSkip + " " + Screen.height + " " + TermsListHeight);
+
+ OnGUI_Keys_ListSelection( KeyListFilterID ); // Selection Buttons
+
+// if (!bAnyValidUsage)
+// EditorGUILayout.HelpBox("Use (Tools\\Parse Terms) to find how many times each of the Terms are used", UnityEditor.MessageType.Info);
+
+ if (ShowTools)
+ {
+ GUILayout.BeginHorizontal();
+ GUI.enabled = mSelectedKeys.Count>0 || !string.IsNullOrEmpty(mKeyToExplore);
+ if (TestButton (eTest_ActionType.Button_AddSelectedTerms, new GUIContent("Add Terms", "Add terms to Source"), "Button", GUITools.DontExpandWidth)) AddTermsToSource();
+ if (TestButton (eTest_ActionType.Button_RemoveSelectedTerms, new GUIContent("Remove Terms", "Remove Terms from Source"), "Button", GUITools.DontExpandWidth)) RemoveTermsFromSource();
+
+ GUILayout.FlexibleSpace ();
+
+ if (GUILayout.Button ("Change Category")) OpenTool_ChangeCategoryOfSelectedTerms();
+ GUI.enabled = true;
+ GUILayout.EndHorizontal();
+
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace ();
+ bool newBool = GUILayout.Toggle(mLanguageSource.CaseInsensitiveTerms, "Case Insensitive Terms");
+ if (newBool != mLanguageSource.CaseInsensitiveTerms)
+ {
+ mProp_CaseInsensitiveTerms.boolValue = newBool;
+ }
+ GUILayout.FlexibleSpace ();
+ GUILayout.EndHorizontal();
+ }
+ //Debug.Log ("Draw: " + nDraw + " Skip: " + nSkip);
+ }
+
+ static void ScheduleUpdateTermsToShowInList()
+ {
+ if (!mUpdateShowTermIsScheduled)
+ {
+ EditorApplication.update += UpdateTermsToShownInList;
+ mUpdateShowTermIsScheduled = true;
+ }
+ }
+ static bool mUpdateShowTermIsScheduled;
+ static void UpdateTermsToShownInList()
+ {
+ EditorApplication.update -= UpdateTermsToShownInList;
+ mUpdateShowTermIsScheduled = false;
+
+ mShowableTerms.Clear ();
+ mSelectedCategories.Sort();
+ foreach (KeyValuePair kvp in mParsedTerms)
+ {
+ ParsedTerm parsedTerm = kvp.Value;
+ if (ShouldShowTerm (parsedTerm.Term, parsedTerm.Category, parsedTerm.Usage, parsedTerm))
+ mShowableTerms.Add(parsedTerm);
+ }
+ GUITools.RepaintInspectors();
+ GUITools.ScheduleRepaintInspectors();
+ }
+
+ void OnGUI_KeyHeader (string sKey, string sCategory, string FullKey, int nUses, float YPosMin)
+ {
+ //--[ Toggle ]---------------------
+ GUI.Box(new Rect(2, YPosMin+2, 18, mRowSize), "", "Toolbar");
+ OnGUI_SelectableToogleListItem (new Rect(2, YPosMin+3, 15, mRowSize), FullKey, ref mSelectedKeys, "OL Toggle");
+
+ bool bEnabled = mSelectedKeys.Contains (FullKey);
+ //--[ Number of Objects using this key ]---------------------
+ if (nUses >= 0)
+ {
+ if (nUses == 0)
+ {
+ GUI.color = Color.Lerp (Color.gray, Color.white, 0.5f);
+ GUI.Label (new Rect(20, YPosMin+2, 30, mRowSize), nUses.ToString (), "toolbarbutton");
+ }
+ else
+ {
+ if (GUI.Button(new Rect(20, YPosMin + 2, 30, mRowSize), nUses.ToString(), "toolbarbutton"))
+ {
+ List selection = new List(mSelectedKeys);
+ if (!selection.Contains(FullKey))
+ selection.Add(FullKey);
+
+ List selGOs = new List();
+ for (int i=0; i 0)
+ Selection.objects = selGOs.ToArray();
+ else
+ ShowWarning("The selected Terms are not used in this Scene. Try opening other scenes");
+ }
+ }
+ }
+ else
+ {
+ GUI.color = Color.Lerp (Color.red, Color.white, 0.6f);
+ if (GUI.Button (new Rect(20, YPosMin+2, 30, mRowSize), "", "toolbarbutton"))
+ {
+ mCurrentToolsMode = eToolsMode.Parse;
+ mCurrentViewMode = eViewMode.Tools;
+ }
+ }
+ GUI.color = Color.white;
+
+ TermData termData = ShowTerm_termData!=null ? ShowTerm_termData : mLanguageSource.GetTermData (FullKey);
+ bool bKeyIsMissing = termData == null;
+ float MinX = 50;
+ if (bKeyIsMissing)
+ {
+ Rect rect = new Rect(50, YPosMin+2, mRowSize, mRowSize+2);
+ GUITools.DrawSkinIcon(rect, "CN EntryWarnIcon", "CN EntryWarn");
+ GUI.Label (rect, new GUIContent ("", "This term is used in the scene, but its not localized in the Language Source"));
+ MinX += rect.width;
+ }
+ else MinX += 3;
+
+ float listWidth = Mathf.Max(EditorGUIUtility.currentViewWidth / EditorGUIUtility.pixelsPerPoint, mTermList_MaxWidth);
+ Rect rectKey = new Rect(MinX, YPosMin+2, listWidth-MinX, mRowSize);
+ if (sCategory != LanguageSourceData.EmptyCategory)
+ rectKey.width -= 130;
+ if (mKeyToExplore == FullKey)
+ {
+ GUI.backgroundColor = Color.Lerp (Color.blue, Color.white, 0.8f);
+ if (GUI.Button (rectKey, new GUIContent (sKey, EditorStyles.foldout.onNormal.background), LocalizeInspector.GUIStyle_OldTextArea))
+ {
+ mKeyToExplore = string.Empty;
+ ScheduleUpdateTermsToShowInList();
+ ClearErrors ();
+ }
+ GUI.backgroundColor = Color.white;
+ }
+ else
+ {
+ GUIStyle LabelStyle = EditorStyles.label;
+ if (!bKeyIsMissing && !TermHasAllTranslations (mLanguageSource, termData))
+ {
+ LabelStyle = new GUIStyle (EditorStyles.label);
+ LabelStyle.fontStyle = FontStyle.Italic;
+ GUI.color = Color.Lerp (Color.white, Color.yellow, 0.5f);
+ }
+ if (!bEnabled)
+ GUI.contentColor = Color.Lerp (Color.gray, Color.white, 0.3f);
+ if (GUI.Button (rectKey, sKey, LabelStyle))
+ {
+ SelectTerm (FullKey);
+ ClearErrors ();
+ }
+ if (!bEnabled)
+ GUI.contentColor = Color.white;
+ GUI.color = Color.white;
+ }
+ //--[ Category ]--------------------------
+ if (sCategory != LanguageSourceData.EmptyCategory)
+ {
+ if (mKeyToExplore == FullKey)
+ {
+ rectKey.x = listWidth - 100-38-20;
+ rectKey.width = 130;
+ if (GUI.Button (rectKey, sCategory, EditorStyles.toolbarButton))
+ OpenTool_ChangeCategoryOfSelectedTerms ();
+ }
+ else
+ {
+ GUIStyle stl = new GUIStyle(EditorStyles.miniLabel);
+ stl.alignment = TextAnchor.MiddleRight;
+ rectKey.width = 130;//EditorStyles.miniLabel.CalcSize(new GUIContent(sCategory)).x;
+ rectKey.x = listWidth - rectKey.width - 38-20;
+
+ if (GUI.Button (rectKey, sCategory, stl))
+ {
+ SelectTerm (FullKey);
+ ClearErrors ();
+ }
+ }
+ }
+ }
+
+
+ void CalculateTermsListMaxWidth()
+ {
+ mTermList_MaxWidth = EditorGUIUtility.currentViewWidth / EditorGUIUtility.pixelsPerPoint - 120;
+ /*float maxWidth = Screen.width / 18;
+ foreach (KeyValuePair kvp in mParsedTerms)
+ {
+ var txt = kvp.Key;
+ if (txt.Length > 100)
+ txt = txt.Substring(0, 100);
+ var size = EditorStyles.label.CalcSize(new GUIContent(txt));
+ mTermList_MaxWidth = Mathf.Max (mTermList_MaxWidth, size.x);
+ }*/
+ }
+
+ bool TermHasAllTranslations( LanguageSourceData source, TermData data )
+ {
+ if (source==null) source = LocalizationManager.Sources[0];
+ for (int i=0, imax=data.Languages.Length; ii ? source.mLanguages[i].IsEnabled() : true;
+ if (string.IsNullOrEmpty(data.Languages[i]) && isLangEnabled)
+ return false;
+ }
+ return true;
+ }
+
+ void OnGUI_KeysList_AddKey()
+ {
+ GUILayout.BeginHorizontal();
+ GUI.color = Color.Lerp(Color.gray, Color.white, 0.5f);
+ bool bWasEnabled = mTermsList_NewTerm!=null;
+ bool bEnabled = !GUILayout.Toggle (!bWasEnabled, "+", EditorStyles.toolbarButton, GUILayout.Width(30));
+ GUI.color = Color.white;
+
+ if (bWasEnabled && !bEnabled) mTermsList_NewTerm = null;
+ if (!bWasEnabled && bEnabled) mTermsList_NewTerm = string.Empty;
+
+ if (bEnabled)
+ {
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+ mTermsList_NewTerm = EditorGUILayout.TextField(mTermsList_NewTerm, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true));
+ GUILayout.EndHorizontal();
+
+ LanguageSourceData.ValidateFullTerm( ref mTermsList_NewTerm );
+ if (string.IsNullOrEmpty(mTermsList_NewTerm) || mLanguageSource.ContainsTerm(mTermsList_NewTerm) || mTermsList_NewTerm=="-")
+ GUI.enabled = false;
+
+ if (TestButton (eTest_ActionType.Button_AddTerm_InTermsList, "Create Key", "toolbarbutton", GUILayout.ExpandWidth(false)))
+ {
+ AddLocalTerm(mTermsList_NewTerm);
+ SelectTerm( mTermsList_NewTerm );
+ ClearErrors();
+ mTermsList_NewTerm = null;
+ SetAllTerms_When_InferredTerms_IsInSource ();
+ }
+ GUI.enabled = true;
+ }
+ GUILayout.EndHorizontal();
+ }
+
+ void OpenTool_ChangeCategoryOfSelectedTerms()
+ {
+ mCurrentViewMode = eViewMode.Tools;
+ mCurrentToolsMode = eToolsMode.Categorize;
+ if (!string.IsNullOrEmpty(mKeyToExplore) && !mSelectedKeys.Contains(mKeyToExplore))
+ mSelectedKeys.Add(mKeyToExplore);
+ mSelectedKeys.Sort();
+ }
+
+ void OnGUI_SelectedCategories()
+ {
+ if (mParsedCategories.Count == 0)
+ return;
+
+ string text = "Categories";
+ if (mSelectedCategories.Count() == 0)
+ text = "Nothing";
+ else
+ if (mSelectedCategories.Count() == mParsedCategories.Count)
+ text = "Everything";
+ else
+ text = mSelectedCategories.Count + " categories";
+
+ if (GUILayout.Button(new GUIContent(text), "toolbarbutton", GUILayout.Width(100)))
+ {
+ var menu = new GenericMenu();
+
+ menu.AddItem(new GUIContent("Everything"), false, () =>
+ {
+ mSelectedCategories.Clear();
+ mSelectedCategories.AddRange(mParsedCategories);
+ ScheduleUpdateTermsToShowInList();
+ });
+ menu.AddItem(new GUIContent("Nothing"), false, () =>
+ {
+ mSelectedCategories.Clear();
+ ScheduleUpdateTermsToShowInList();
+ });
+ menu.AddSeparator("");
+
+ var parsedList = mParsedCategories.OrderBy(x=>x).ToList();
+ for (int i=0, imax=parsedList.Count; ix.StartsWith(categoryRoot))), () =>
+ {
+ var CatHeader = category + "/";
+ if (mSelectedCategories.Contains(category))
+ {
+ mSelectedCategories.Remove(category);
+
+ if (isHeader)
+ {
+ mSelectedCategories.RemoveAll(x => x.StartsWith(CatHeader));
+ }
+ }
+ else
+ {
+ mSelectedCategories.Add(category);
+ if (isHeader)
+ {
+ mSelectedCategories.AddRange( parsedList.Where(x=>x.StartsWith(CatHeader)));
+ }
+ }
+ ScheduleUpdateTermsToShowInList();
+ });
+ if (isHeader)
+ {
+ menu.AddSeparator(category+"/");
+ }
+ }
+
+ menu.ShowAsContext();
+ }
+ }
+
+ void SaveSelectedCategories()
+ {
+ if (mSelectedCategories.Count == 0) {
+ EditorPrefs.DeleteKey ("I2 CategoryFilter");
+ } else {
+ var data = string.Join(",", mSelectedCategories.ToArray());
+ EditorPrefs.SetString ("I2 CategoryFilter", data);
+ }
+ }
+
+ void LoadSelectedCategories()
+ {
+ var data = EditorPrefs.GetString ("I2 CategoryFilter", null);
+ if (!string.IsNullOrEmpty(data))
+ {
+ mSelectedCategories.Clear ();
+ mSelectedCategories.AddRange( data.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
+ }
+ }
+
+
+ // Bottom part of the Key list (buttons: All, None, Used,... to select the keys)
+ void OnGUI_Keys_ListSelection ( int KeyListFilterID )
+ {
+ GUILayout.BeginHorizontal( "toolbarbutton" );
+
+ if (TestButton( eTest_ActionType.Button_SelectTerms_All, new GUIContent( "All", "Selects All Terms in the list" ), "toolbarbutton", GUILayout.ExpandWidth( false ) ))
+ {
+ mSelectedKeys.Clear();
+ foreach (var kvp in mParsedTerms)
+ if (ShouldShowTerm( kvp.Value.Term, kvp.Value.Category, kvp.Value.Usage ))
+ mSelectedKeys.Add( kvp.Key );
+ }
+ if (GUILayout.Button( new GUIContent( "None", "Clears the selection" ), "toolbarbutton", GUILayout.ExpandWidth( false ) )) { mSelectedKeys.Clear(); }
+ GUILayout.Space( 5 );
+
+ GUI.enabled = (mFlagsViewKeys & (int)eFlagsViewKeys.Used)>1;
+ if (TestButton(eTest_ActionType.Button_SelectTerms_Used, new GUIContent( "Used", "Selects All Terms referenced in the parsed scenes" ), "toolbarbutton", GUILayout.ExpandWidth( false ) ))
+ {
+ mSelectedKeys.Clear();
+ foreach (var kvp in mParsedTerms)
+ if (kvp.Value.Usage > 0 && ShouldShowTerm( kvp.Value.Term, kvp.Value.Category, kvp.Value.Usage ))
+ mSelectedKeys.Add( kvp.Key );
+ }
+ GUI.enabled = (mFlagsViewKeys & (int)eFlagsViewKeys.NotUsed)>1;
+ if (GUILayout.Button( new GUIContent( "Not Used", "Selects all Terms from the Source that are not been used" ), "toolbarbutton", GUILayout.ExpandWidth( false ) ))
+ {
+ mSelectedKeys.Clear();
+ foreach (var kvp in mParsedTerms)
+ if (kvp.Value.Usage == 0 && ShouldShowTerm( kvp.Value.Term, kvp.Value.Category, kvp.Value.Usage ))
+ mSelectedKeys.Add( kvp.Key );
+ }
+
+ GUI.enabled = (mFlagsViewKeys & (int)eFlagsViewKeys.Missing)>1;
+ if (TestButton(eTest_ActionType.Button_SelectTerms_Missing, new GUIContent( "Missing", "Selects all Terms Used but not defined in the Source" ), "toolbarbutton", GUILayout.ExpandWidth( false ) ))
+ {
+ mSelectedKeys.Clear();
+ foreach (var kvp in mParsedTerms)
+ if (!mLanguageSource.ContainsTerm( kvp.Key ) && ShouldShowTerm( kvp.Value.Term, kvp.Value.Category, kvp.Value.Usage ))
+ mSelectedKeys.Add( kvp.Key );
+ }
+
+ GUI.enabled = ((mFlagsViewKeys & (int)eFlagsViewKeys.Untranslated) > 1);
+ if (GUILayout.Button(new GUIContent("Untranslated", "Selects all Terms from the Source that are not translated to any language"), "toolbarbutton", GUILayout.ExpandWidth(false)))
+ {
+ mSelectedKeys.Clear();
+ foreach (var kvp in mParsedTerms)
+ if (kvp.Value.termData.Languages.All(o => string.IsNullOrEmpty(o)) && ShouldShowTerm(kvp.Value.Term, kvp.Value.Category, kvp.Value.Usage))
+ mSelectedKeys.Add(kvp.Key);
+ }
+
+ GUI.enabled = true;
+ EditorGUI.BeginChangeCheck();
+
+ // Terms Filter
+ {
+ //KeyList_Filter = EditorGUILayout.TextField(KeyList_Filter, GUI.skin.GetStyle(GUITools.Style_ToolbarSearchTextField), GUILayout.ExpandWidth(true));
+ GUILayout.Label( "", GUILayout.ExpandWidth( true ) );
+ mKeyListFilterRect = GUILayoutUtility.GetLastRect();
+ mKeyListFilterRect.xMax += 4;
+
+ KeyList_Filter = GUITools.TextField( mKeyListFilterRect, KeyList_Filter, 255, GUI.skin.GetStyle( GUITools.Style_ToolbarSearchTextField ), KeyListFilterID );
+ }
+
+
+
+ if (GUILayout.Button( string.Empty, string.IsNullOrEmpty( KeyList_Filter ) ? GUITools.Style_ToolbarSearchCancelButtonEmpty : GUITools.Style_ToolbarSearchCancelButton, GUILayout.ExpandWidth( false ) ))
+ {
+ KeyList_Filter = string.Empty;
+ EditorApplication.update += RepaintScene;
+ GUI.FocusControl( "" );
+ }
+
+ string filterHelp = "Fiter Options:\ntext - shows all key/categories matching text\nc text - shows all terms of the text category\nf text - show terms having 'text' in their translations";
+ GUILayout.Space(-5);
+ GUI.contentColor = new Color(1, 1, 1, 0.5f);
+ GUILayout.Label(new GUIContent(GUITools.Icon_Help.image, filterHelp), GUITools.DontExpandWidth);
+ GUI.contentColor = GUITools.White;
+ GUILayout.Space(-5);
+
+
+
+
+ if (EditorGUI.EndChangeCheck())
+ {
+ mShowableTerms.Clear();
+ GUI.changed = false;
+ }
+
+ GUILayout.EndHorizontal();
+ }
+
+
+ #endregion
+
+ #region Filtering
+
+ public bool ShouldShowTerm (string FullTerm)
+ {
+ ParsedTerm termData;
+ if (!mParsedTerms.TryGetValue(FullTerm, out termData))
+ return false;
+
+ return ShouldShowTerm (termData.Term, termData.Category, termData.Usage, termData);
+ }
+
+ private static TermData ShowTerm_termData;
+ public static bool ShouldShowTerm (string Term, string Category, int nUses, ParsedTerm parsedTerm=null )
+ {
+ if (!string.IsNullOrEmpty(Category) && !mSelectedCategories.Contains(Category))
+ return false;
+ if (Term == "-")
+ return false;
+
+
+ var fullTerm = Term;
+ if (!string.IsNullOrEmpty(Category) && Category != LanguageSourceData.EmptyCategory)
+ fullTerm = Category + "/" + Term;
+
+ if (parsedTerm != null && parsedTerm.termData != null)
+ ShowTerm_termData = parsedTerm.termData;
+ else
+ {
+ ShowTerm_termData = mLanguageSource.GetTermData (fullTerm);
+ if (parsedTerm!=null)
+ parsedTerm.termData = ShowTerm_termData;
+ }
+
+ var filter = KeyList_Filter.Trim();
+ bool useTranslation = filter.StartsWith("f ", StringComparison.OrdinalIgnoreCase);
+ if (useTranslation)
+ {
+ if (ShowTerm_termData == null)
+ return false;
+
+ filter = filter.Substring(2).Trim();
+ if (!string.IsNullOrEmpty(filter))
+ {
+ bool hasFilter = false;
+ for (int i = 0; i < ShowTerm_termData.Languages.Length; ++i)
+ {
+ if (!string.IsNullOrEmpty(ShowTerm_termData.Languages[i])
+ && StringContainsFilter(ShowTerm_termData.Languages[i], filter))
+ {
+ hasFilter = true;
+ break;
+ }
+
+ }
+ if (!hasFilter)
+ return false;
+ }
+ }
+ else
+ {
+ bool onlyCategory = filter.StartsWith("c ", StringComparison.OrdinalIgnoreCase);
+ if (onlyCategory)
+ filter = filter.Substring(2).Trim();
+
+ if (!string.IsNullOrEmpty(filter))
+ {
+ bool matchesCategory = StringContainsFilter(Category, filter);
+ bool matchesName = !onlyCategory && StringContainsFilter(Term, filter);
+
+ if (!matchesCategory && !matchesName)
+ return false;
+ }
+ }
+
+
+ bool bIsMissing = ShowTerm_termData == null;
+ bool hasTranslation = !bIsMissing && ShowTerm_termData.Languages.Any(o => !string.IsNullOrEmpty(o));
+
+ if ((mFlagsViewKeys & (int)eFlagsViewKeys.Untranslated) > 0) return !hasTranslation;
+
+ if (nUses<0) return true;
+
+
+ if ((mFlagsViewKeys & (int)eFlagsViewKeys.Missing)>0 && bIsMissing) return true;
+ if ((mFlagsViewKeys & (int)eFlagsViewKeys.Missing)==0 && bIsMissing) return false;
+
+ if ((mFlagsViewKeys & (int)eFlagsViewKeys.Used)>0 && nUses>0) return true;
+ if ((mFlagsViewKeys & (int)eFlagsViewKeys.NotUsed)>0 && nUses==0) return true;
+
+ return false;
+ }
+
+ static bool StringContainsFilter( string Term, string Filter )
+ {
+ if (string.IsNullOrEmpty(Filter) || string.IsNullOrEmpty(Term))
+ return true;
+ if (Term == "-")
+ return false;
+ Term = Term.ToLower();
+ string[] Filters = Filter.ToLower().Split(";, ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0, imax = Filters.Length; i < imax; ++i)
+ if (Term.Contains(Filters[i]))
+ return true;
+
+ return false;
+ }
+
+ #endregion
+
+ #region Add/Remove Keys to DB
+
+ void AddTermsToSource()
+ {
+ if (!string.IsNullOrEmpty (mKeyToExplore) && !mSelectedKeys.Contains(mKeyToExplore))
+ mSelectedKeys.Add (mKeyToExplore);
+
+ for (int i=mSelectedKeys.Count-1; i>=0; --i)
+ {
+ string key = mSelectedKeys[i];
+
+ if (!ShouldShowTerm(key))
+ continue;
+
+ AddLocalTerm(key);
+ mSelectedKeys.RemoveAt(i);
+ }
+ SetAllTerms_When_InferredTerms_IsInSource ();
+ }
+
+ void RemoveTermsFromSource()
+ {
+ if (mTestAction==eTest_ActionType.None && !EditorUtility.DisplayDialog("Confirm delete", "Are you sure you want to delete the selected terms", "Yes", "Cancel"))
+ return;
+
+ if (!string.IsNullOrEmpty (mKeyToExplore) && !mSelectedKeys.Contains(mKeyToExplore))
+ mSelectedKeys.Add (mKeyToExplore);
+
+ for (int i=mSelectedKeys.Count-1; i>=0; --i)
+ {
+ string key = mSelectedKeys[i];
+
+ if (!ShouldShowTerm(key))
+ continue;
+
+ mLanguageSource.RemoveTerm(key);
+ RemoveParsedTerm(key);
+ mSelectedKeys.Remove(key);
+ }
+
+ mKeyToExplore = string.Empty;
+ mTermList_MaxWidth = -1;
+ serializedObject.ApplyModifiedProperties();
+ mLanguageSource.Editor_SetDirty();
+
+ EditorApplication.update += DoParseTermsInCurrentScene;
+ EditorApplication.update += RepaintScene;
+ }
+
+ #endregion
+
+ #region Select Objects in Current Scene
+
+
+ public static void SelectTerm( string Key, bool SwitchToKeysTab=false )
+ {
+ GUI.FocusControl(null);
+ mKeyToExplore = Key;
+ mKeysDesc_AllowEdit = false;
+ if (SwitchToKeysTab)
+ mCurrentViewMode = eViewMode.Keys;
+ }
+
+
+ void SelectObjectsUsingKey( string Key )
+ {
+ List SelectedObjs = FindObjectsUsingKey(Key);
+
+ if (SelectedObjs.Count>0)
+ Selection.objects = SelectedObjs.ToArray();
+ else
+ ShowWarning("The selected Terms are not used in this Scene. Try opening other scenes");
+ }
+
+ List FindObjectsUsingKey(string Key)
+ {
+ List SelectedObjs = new List();
+
+ Localize[] Locals = (Localize[])Resources.FindObjectsOfTypeAll(typeof(Localize));
+
+ if (Locals == null)
+ return SelectedObjs;
+
+ for (int i = 0, imax = Locals.Length; i < imax; ++i)
+ {
+ Localize localize = Locals[i];
+ if (localize == null || localize.gameObject == null || !GUITools.ObjectExistInScene(localize.gameObject))
+ continue;
+
+ string Term, SecondaryTerm;
+ localize.GetFinalTerms(out Term, out SecondaryTerm);
+
+ if (Key == Term || Key == SecondaryTerm)
+ SelectedObjs.Add(localize.gameObject);
+ }
+
+ return SelectedObjs;
+ }
+
+
+ #endregion
+
+
+ [MenuItem("Tools/I2 Localization/Refresh Localizations", false, 16)]
+ public static void CallLocalizeAll()
+ {
+ LocalizationManager.LocalizeAll(true);
+ HandleUtility.Repaint();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs.meta b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs.meta
new file mode 100644
index 00000000..9384003c
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 9f0230a94fc864d5bb1f2261de16edce
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms_Description.cs b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms_Description.cs
new file mode 100644
index 00000000..a9f8f2ac
--- /dev/null
+++ b/EintooAR/Assets/TEngine/Editor/Localization/Localization/LocalizationEditor_Terms_Description.cs
@@ -0,0 +1,785 @@
+//#define UGUI
+//#define NGUI
+
+using System;
+using TMPro;
+using UnityEditor;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+namespace TEngine.Localization
+{
+ public partial class LocalizationEditor
+ {
+ #region Variables
+ internal static bool mKeysDesc_AllowEdit;
+ internal static string GUI_SelectedSpecialization
+ {
+ get{
+ if (string.IsNullOrEmpty(mGUI_SelectedSpecialization))
+ mGUI_SelectedSpecialization = EditorPrefs.GetString ("I2Loc Specialization", "Any");
+ return mGUI_SelectedSpecialization;
+ }
+ set{
+ if (value!=mGUI_SelectedSpecialization)
+ EditorPrefs.SetString ("I2Loc Specialization", value);
+ mGUI_SelectedSpecialization = value;
+ }
+ }
+ internal static string mGUI_SelectedSpecialization;
+
+ internal static bool GUI_ShowDisabledLanguagesTranslation = true;
+
+ internal static int mShowPlural = -1;
+ #endregion
+
+ #region Key Description
+
+ void OnGUI_KeyList_ShowKeyDetails()
+ {
+ GUI.backgroundColor = Color.Lerp(Color.blue, Color.white, 0.9f);
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(1));
+ OnGUI_Keys_Languages(mKeyToExplore, null);
+
+ GUILayout.BeginHorizontal();
+ if (TestButton(eTest_ActionType.Button_DeleteTerm, "Delete", "Button", GUILayout.ExpandWidth(true)))
+ {
+ if (mTestAction != eTest_ActionType.None || EditorUtility.DisplayDialog("Confirm delete", "Are you sure you want to delete term '" + mKeyToExplore + "'", "Yes", "Cancel"))
+ EditorApplication.update += DeleteCurrentKey;
+ }
+
+ if (GUILayout.Button("Rename"))
+ {
+ mCurrentViewMode = eViewMode.Tools;
+ mCurrentToolsMode = eToolsMode.Merge;
+ if (!mSelectedKeys.Contains(mKeyToExplore))
+ mSelectedKeys.Add(mKeyToExplore);
+ }
+ GUILayout.EndHorizontal();
+ GUILayout.EndVertical();
+ GUI.backgroundColor = Color.white;
+ }
+
+ void DeleteTerm( string Term, bool updateStructures = true )
+ {
+ mLanguageSource.RemoveTerm (Term);
+ RemoveParsedTerm(Term);
+ mSelectedKeys.Remove(Term);
+
+ if (Term==mKeyToExplore)
+ mKeyToExplore = string.Empty;
+
+ if (updateStructures)
+ {
+ UpdateParsedCategories();
+ mTermList_MaxWidth = -1;
+ serializedObject.ApplyModifiedProperties();
+ mLanguageSource.Editor_SetDirty();
+ ScheduleUpdateTermsToShowInList();
+ }
+ EditorApplication.update += RepaintScene;
+ }
+
+ void RepaintScene()
+ {
+ EditorApplication.update -= RepaintScene;
+ Repaint();
+ }
+
+ void DeleteCurrentKey()
+ {
+ EditorApplication.update -= DeleteCurrentKey;
+ DeleteTerm (mKeyToExplore);
+
+ mKeyToExplore = "";
+ EditorApplication.update += DoParseTermsInCurrentScene;
+ }
+
+ TermData AddLocalTerm( string Term, bool AutoSelect = true )
+ {
+ var data = AddTerm(Term, AutoSelect);
+ if (data==null)
+ return null;
+
+ mTermList_MaxWidth = -1;
+ serializedObject.ApplyModifiedProperties();
+ mLanguageSource.Editor_SetDirty();
+ return data;
+ }
+
+ static TermData AddTerm(string Term, bool AutoSelect = true, eTermType termType = eTermType.Text)
+ {
+ if (Term == "-" || string.IsNullOrEmpty(Term))
+ return null;
+
+ Term = I2Utils.GetValidTermName(Term, true);
+
+ TermData data = mLanguageSource.AddTerm(Term, termType);
+ GetParsedTerm(Term);
+ string sCategory = LanguageSourceData.GetCategoryFromFullTerm(Term);
+ mParsedCategories.Add(sCategory);
+
+ if (AutoSelect)
+ {
+ if (!mSelectedKeys.Contains(Term))
+ mSelectedKeys.Add(Term);
+
+ if (!mSelectedCategories.Contains(sCategory))
+ mSelectedCategories.Add(sCategory);
+ }
+ ScheduleUpdateTermsToShowInList();
+ mLanguageSource.Editor_SetDirty();
+ return data;
+ }
+
+ // this method shows the key description and the localization to each language
+ public static TermData OnGUI_Keys_Languages( string Key, Localize localizeCmp, bool IsPrimaryKey=true )
+ {
+ if (Key==null)
+ Key = string.Empty;
+
+ TermData termdata = null;
+
+ LanguageSourceData source = mLanguageSource;
+ if (localizeCmp != null && localizeCmp.Source != null)
+ source = localizeCmp.Source.SourceData;
+
+ if (source==null)
+ source = LocalizationManager.GetSourceContaining(Key, false);
+
+ if (source==null)
+ {
+ if (localizeCmp == null)
+ source = LocalizationManager.Sources[0];
+ else
+ source = LocalizationManager.GetSourceContaining(IsPrimaryKey ? localizeCmp.SecondaryTerm : localizeCmp.Term);
+ }
+
+
+ if (string.IsNullOrEmpty(Key))
+ {
+ EditorGUILayout.HelpBox( "Select a Term to Localize", MessageType.Info );
+ return null;
+ }
+
+ termdata = source.GetTermData(Key);
+ if (termdata==null && localizeCmp!=null)
+ {
+ var realSource = LocalizationManager.GetSourceContaining(Key, false);
+ if (realSource != null)
+ {
+ termdata = realSource.GetTermData(Key);
+ source = realSource;
+ }
+ }
+ if (termdata==null)
+ {
+ if (Key == "-")
+ return null;
+ EditorGUILayout.HelpBox( string.Format("Key '{0}' is not Localized or it is in a different Language Source", Key), MessageType.Error );
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ if (GUILayout.Button("Add Term to Source"))
+ {
+ var termType = eTermType.Text;
+ if (localizeCmp!=null && localizeCmp.mLocalizeTarget != null)
+ {
+ termType = IsPrimaryKey ? localizeCmp.mLocalizeTarget.GetPrimaryTermType(localizeCmp)
+ : localizeCmp.mLocalizeTarget.GetSecondaryTermType(localizeCmp);
+ }
+
+ AddTerm(Key, true, termType);
+ }
+ GUILayout.FlexibleSpace();
+ GUILayout.EndHorizontal();
+
+ return null;
+ }
+
+ //--[ Type ]----------------------------------
+ if (localizeCmp==null)
+ {
+ GUILayout.BeginHorizontal();
+ GUILayout.Label ("Type:", GUILayout.ExpandWidth(false));
+ eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termdata.TermType, GUILayout.ExpandWidth(true));
+ if (termdata.TermType != NewType)
+ termdata.TermType = NewType;
+ GUILayout.EndHorizontal();
+ }
+
+
+ //--[ Description ]---------------------------
+
+ mKeysDesc_AllowEdit = GUILayout.Toggle(mKeysDesc_AllowEdit, "Description", EditorStyles.foldout, GUILayout.ExpandWidth(true));
+
+ if (mKeysDesc_AllowEdit)
+ {
+ string NewDesc = EditorGUILayout.TextArea( termdata.Description, Style_WrapTextField );
+ if (NewDesc != termdata.Description)
+ {
+ termdata.Description = NewDesc;
+ source.Editor_SetDirty();
+ }
+ }
+ else
+ EditorGUILayout.HelpBox( string.IsNullOrEmpty(termdata.Description) ? "No description" : termdata.Description, MessageType.Info );
+
+ OnGUI_Keys_Language_SpecializationsBar (termdata, source);
+
+ OnGUI_Keys_Languages(Key, ref termdata, localizeCmp, IsPrimaryKey, source);
+ return termdata;
+ }
+
+ static void OnGUI_Keys_Languages( string Key, ref TermData termdata, Localize localizeCmp, bool IsPrimaryKey, LanguageSourceData source )
+ {
+ //--[ Languages ]---------------------------
+ GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(1));
+
+ OnGUI_Keys_LanguageTranslations(Key, localizeCmp, IsPrimaryKey, ref termdata, source);
+
+ if (termdata.TermType == eTermType.Text)
+ {
+ GUILayout.BeginHorizontal();
+ GUILayout.FlexibleSpace();
+ if (TestButton(eTest_ActionType.Button_Term_TranslateAll, "Translate All", "Button", GUILayout.Width(85)))
+ {
+ var termData = termdata;
+ GUITools.DelayedCall(() => TranslateLanguage( Key, termData, localizeCmp, source));
+ GUI.FocusControl(string.Empty);
+ }
+ GUILayout.EndHorizontal();
+ OnGUI_TranslatingMessage();
+ }
+ GUILayout.EndVertical();
+ }
+
+ static void TranslateLanguage( string Key, TermData termdata, Localize localizeCmp, LanguageSourceData source)
+ {
+ ClearErrors();
+ string mainText = localizeCmp == null ? LanguageSourceData.GetKeyFromFullTerm(Key) : localizeCmp.GetMainTargetsText();
+
+ for (int i = 0; i < source.mLanguages.Count; ++i)
+ if (source.mLanguages[i].IsEnabled() && string.IsNullOrEmpty(termdata.Languages[i]))
+ {
+ var langIdx = i;
+ var term = termdata;
+ var i2source = source;
+ Translate(mainText, ref termdata, source.mLanguages[i].Code,
+ (translation, error) =>
+ {
+ if (error != null)
+ ShowError(error);
+ else
+ if (translation != null)
+ {
+ term.Languages[langIdx] = translation; //SetTranslation(langIdx, translation);
+ i2source.Editor_SetDirty();
+ }
+ }, null);
+ }
+ }
+
+ static void OnGUI_TranslatingMessage()
+ {
+ if (GoogleTranslation.IsTranslating())
+ {
+ // Connection Status Bar
+ int time = (int)(Time.realtimeSinceStartup % 2 * 2.5);
+ string Loading = "Translating" + ".....".Substring(0, time);
+ GUI.color = Color.gray;
+ GUILayout.BeginHorizontal(LocalizeInspector.GUIStyle_OldTextArea);
+ GUILayout.Label(Loading, EditorStyles.miniLabel);
+ GUI.color = Color.white;
+ if (GUILayout.Button("Cancel", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
+ {
+ GoogleTranslation.CancelCurrentGoogleTranslations();
+ }
+ GUILayout.EndHorizontal();
+ HandleUtility.Repaint ();
+ }
+ }
+
+ static void OnGUI_Keys_Language_SpecializationsBar(TermData termData, LanguageSourceData source)
+ {
+ var activeSpecializations = termData.GetAllSpecializations();
+
+ GUILayout.BeginHorizontal();
+
+ var TabStyle = new GUIStyle(GUI.skin.FindStyle("dragtab"));
+ TabStyle.fixedHeight = 0;
+
+ //var ss = GUI.skin.FindStyle("TL tab left");
+ var TabOpenStyle = new GUIStyle(GUI.skin.FindStyle("minibuttonmid"));
+ TabOpenStyle.margin.right = -1;
+ var TabCloseStyle = new GUIStyle(EditorStyles.label);
+ //var TabCloseStyle = new GUIStyle(GUI.skin.FindStyle("TL tab right"));
+ TabCloseStyle.margin.left = -1;
+ TabCloseStyle.padding.left=4;
+
+ //-- Specialization Tabs -----
+
+ var prevSpecialization = "Any";
+ foreach (var specialization in SpecializationManager.Singleton.mSpecializations)
+ {
+ if (!activeSpecializations.Contains(specialization) && specialization != GUI_SelectedSpecialization)
+ continue;
+
+ bool isActive = specialization == GUI_SelectedSpecialization;
+ var labelContent = new GUIContent(specialization, "Specialization of the main translation (i.e. variants that show only on specific platforms or devices)\nThis allows using 'tap' instead of 'click' for touch devices.");
+
+ if (isActive && activeSpecializations.Count>1)
+ {
+ GUILayout.BeginHorizontal(TabOpenStyle);
+ GUILayout.Toggle(isActive, labelContent, TabStyle, GUILayout.Height(20), GUILayout.ExpandWidth(false));
+ //GUILayout.Label(labelContent, TabOpenStyle);
+ if (specialization != "Any" && GUILayout.Button("x", TabCloseStyle, GUILayout.Width(15)))
+ {
+ termData.RemoveSpecialization(specialization);
+ GUI_SelectedSpecialization = prevSpecialization;
+ GUI.FocusControl(null);
+ }
+ GUILayout.EndHorizontal();
+ }
+ else
+ if (GUILayout.Toggle(isActive, labelContent, TabStyle, GUILayout.Height(25), GUILayout.ExpandWidth(false)) && !isActive)
+ {
+ GUI_SelectedSpecialization = specialization;
+ GUI.FocusControl(null);
+ }
+ }
+
+
+ //-- Add new Specialization -----
+ int newIndex = EditorGUILayout.Popup(-1, SpecializationManager.Singleton.mSpecializations, "DropDown", GUILayout.Width(20));
+ if (newIndex>=0)
+ {
+ string newSpecialization = SpecializationManager.Singleton.mSpecializations[newIndex];
+ if (!activeSpecializations.Contains(newSpecialization))
+ {
+ for (int iLang = 0; iLang < source.mLanguages.Count; ++iLang)
+ {
+ string Translation = termData.GetTranslation(iLang, GUI_SelectedSpecialization, editMode: true);
+ termData.SetTranslation(iLang, Translation, GUI_SelectedSpecialization);
+ }
+ GUI_SelectedSpecialization = newSpecialization;
+ }
+ }
+
+ GUILayout.FlexibleSpace();
+
+
+ GUI_ShowDisabledLanguagesTranslation = GUILayout.Toggle(GUI_ShowDisabledLanguagesTranslation, new GUIContent("L", "Show Disabled Languages"), "Button", GUILayout.ExpandWidth(false));
+ GUILayout.EndHorizontal();
+ GUILayout.Space(-3);
+ }
+
+ static void OnGUI_Keys_LanguageTranslations (string Key, Localize localizeCmp, bool IsPrimaryKey, ref TermData termdata, LanguageSourceData source)
+ {
+ bool IsSelect = UnityEngine.Event.current.type==EventType.MouseUp;
+ for (int i=0; i< source.mLanguages.Count; ++ i)
+ {
+ bool forcePreview = false;
+ bool isEnabledLanguage = source.mLanguages[i].IsEnabled();
+
+ if (!isEnabledLanguage)
+ {
+ if (!GUI_ShowDisabledLanguagesTranslation)
+ continue;
+ GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.35f);
+ }
+ GUILayout.BeginHorizontal();
+
+ if (GUILayout.Button(source.mLanguages[i].Name, EditorStyles.label, GUILayout.Width(100)))
+ forcePreview = true;
+
+
+ string Translation = termdata.GetTranslation(i, GUI_SelectedSpecialization, editMode:true);
+ if (Translation == null) Translation = string.Empty;
+
+// if (termdata.Languages[i] != termdata.Languages_Touch[i] && !string.IsNullOrEmpty(termdata.Languages[i]) && !string.IsNullOrEmpty(termdata.Languages_Touch[i]))
+// GUI.contentColor = GUITools.LightYellow;
+
+ if (termdata.TermType == eTermType.Text || termdata.TermType==eTermType.Child)
+ {
+ EditorGUI.BeginChangeCheck ();
+ string CtrName = "TranslatedText"+i;
+ GUI.SetNextControlName(CtrName);
+
+ EditPluralTranslations (ref Translation, i, source.mLanguages[i].Code);
+ //Translation = EditorGUILayout.TextArea(Translation, Style_WrapTextField, GUILayout.Width(Screen.width - 260 - (autoTranslated ? 20 : 0)));
+ if (EditorGUI.EndChangeCheck ())
+ {
+ termdata.SetTranslation(i, Translation, GUI_SelectedSpecialization);
+ source.Editor_SetDirty();
+ forcePreview = true;
+ }
+
+ if (localizeCmp!=null &&
+ (forcePreview || /*GUI.changed || */GUI.GetNameOfFocusedControl()==CtrName && IsSelect))
+ {
+ if (IsPrimaryKey && string.IsNullOrEmpty(localizeCmp.Term))
+ {
+ localizeCmp.mTerm = Key;
+ }
+
+ if (!IsPrimaryKey && string.IsNullOrEmpty(localizeCmp.SecondaryTerm))
+ {
+ localizeCmp.mTermSecondary = Key;
+ }
+
+ string PreviousLanguage = LocalizationManager.CurrentLanguage;
+ LocalizationManager.PreviewLanguage(source.mLanguages[i].Name);
+ if (forcePreview || IsSelect)
+ LocalizationManager.LocalizeAll();
+ else
+ localizeCmp.OnLocalize(true);
+ LocalizationManager.PreviewLanguage(PreviousLanguage);
+ EditorUtility.SetDirty(localizeCmp);
+ }
+ GUI.contentColor = Color.white;
+
+ //if (autoTranslated)
+ //{
+ // if (GUILayout.Button(new GUIContent("\u2713"/*"A"*/,"Translated by Google Translator\nClick the button to approve the translation"), EditorStyles.toolbarButton, GUILayout.Width(autoTranslated ? 20 : 0)))
+ // {
+ // termdata.Flags[i] &= (byte)(byte.MaxValue ^ (byte)(GUI_SelectedSpecialization==0 ? TranslationFlag.AutoTranslated_Normal : TranslationFlag.AutoTranslated_Touch));
+ // }
+ //}
+
+ if (termdata.TermType == eTermType.Text)
+ {
+ if (TestButtonArg(eTest_ActionType.Button_Term_Translate, i, new GUIContent("T", "Translate"), EditorStyles.toolbarButton, GUILayout.Width(20)))
+ {
+ var termData = termdata;
+ var indx = i;
+ var key = Key;
+ GUITools.DelayedCall(()=>TranslateTerm(key, termData, source, indx));
+ GUI.FocusControl(string.Empty);
+ }
+ }
+ }
+ else
+ {
+ string MultiSpriteName = string.Empty;
+
+ if (termdata.TermType==eTermType.Sprite && Translation.EndsWith("]", StringComparison.Ordinal)) // Handle sprites of type (Multiple): "SpritePath[SpriteName]"
+ {
+ int idx = Translation.LastIndexOf("[", StringComparison.Ordinal);
+ int len = Translation.Length-idx-2;
+ MultiSpriteName = Translation.Substring(idx+1, len);
+ Translation = Translation.Substring(0, idx);
+ }
+
+ Object Obj = null;
+
+ // Try getting the asset from the References section
+ if (localizeCmp!=null)
+ Obj = localizeCmp.FindTranslatedObject