├── .gitignore ├── LICENSE ├── README.md └── UniFramework ├── UniAnimation.meta ├── UniAnimation ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── AnimClip.cs │ ├── AnimClip.cs.meta │ ├── AnimMixer.cs │ ├── AnimMixer.cs.meta │ ├── AnimNode.cs │ ├── AnimNode.cs.meta │ ├── AnimPlayable.cs │ ├── AnimPlayable.cs.meta │ ├── AnimState.cs │ ├── AnimState.cs.meta │ ├── UniAnimation.cs │ ├── UniAnimation.cs.meta │ ├── UniFramework.Animation.asmdef │ ├── UniFramework.Animation.asmdef.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniEvent.meta ├── UniEvent ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── EventGroup.cs │ ├── EventGroup.cs.meta │ ├── IEventMessage.cs │ ├── IEventMessage.cs.meta │ ├── UniEvent.cs │ ├── UniEvent.cs.meta │ ├── UniEventDriver.cs │ ├── UniEventDriver.cs.meta │ ├── UniFramework.Event.asmdef │ ├── UniFramework.Event.asmdef.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniLocalization.meta ├── UniLocalization ├── Editor.meta ├── Editor │ ├── Extension.meta │ ├── Extension │ │ ├── UnityEngine_Rect_Extension.cs │ │ └── UnityEngine_Rect_Extension.cs.meta │ ├── ILocalizeReader.cs │ ├── ILocalizeReader.cs.meta │ ├── LocalizationSetting.cs │ ├── LocalizationSetting.cs.meta │ ├── LocalizationSettingData.cs │ ├── LocalizationSettingData.cs.meta │ ├── PopupWindow.meta │ ├── PopupWindow │ │ ├── TreeView.cs │ │ ├── TreeView.cs.meta │ │ ├── TreeViewItem.cs │ │ ├── TreeViewItem.cs.meta │ │ ├── TreeViewPopupWindow.cs │ │ └── TreeViewPopupWindow.cs.meta │ ├── PropertyDrawer.meta │ ├── PropertyDrawer │ │ ├── ReadOnlyDrawer.cs │ │ ├── ReadOnlyDrawer.cs.meta │ │ ├── TableNameDrawer.cs │ │ ├── TableNameDrawer.cs.meta │ │ ├── TranslationKeyDrawer.cs │ │ └── TranslationKeyDrawer.cs.meta │ ├── UniFramework.Localization.Editor.asmdef │ └── UniFramework.Localization.Editor.asmdef.meta ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── Attribute.meta │ ├── Attribute │ ├── LocalizedBehaviourAttribute.cs │ ├── LocalizedBehaviourAttribute.cs.meta │ ├── ReadOnlyAttribute.cs │ ├── ReadOnlyAttribute.cs.meta │ ├── TableNameAttribute.cs │ ├── TableNameAttribute.cs.meta │ ├── TranslationKeyAttribute.cs │ └── TranslationKeyAttribute.cs.meta │ ├── Behaviour.meta │ ├── Behaviour │ ├── LocalizedAudio.cs │ ├── LocalizedAudio.cs.meta │ ├── LocalizedBehaviour.cs │ ├── LocalizedBehaviour.cs.meta │ ├── LocalizedDropdown.cs │ ├── LocalizedDropdown.cs.meta │ ├── LocalizedImage.cs │ ├── LocalizedImage.cs.meta │ ├── LocalizedText.cs │ └── LocalizedText.cs.meta │ ├── LocaleIdentifier.cs │ ├── LocaleIdentifier.cs.meta │ ├── Table.meta │ ├── Table │ ├── TableCollection.cs │ ├── TableCollection.cs.meta │ ├── TableData.cs │ └── TableData.cs.meta │ ├── Translation.meta │ ├── Translation │ ├── ITranslation.cs │ ├── ITranslation.cs.meta │ ├── StringFormatter.cs │ ├── StringFormatter.cs.meta │ ├── TranslationAudio.cs │ ├── TranslationAudio.cs.meta │ ├── TranslationSprite.cs │ ├── TranslationSprite.cs.meta │ ├── TranslationString.cs │ └── TranslationString.cs.meta │ ├── UniFramework.Localization.asmdef │ ├── UniFramework.Localization.asmdef.meta │ ├── UniLocalization.cs │ ├── UniLocalization.cs.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniLog.meta ├── UniLog ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── UniFramework.Log.asmdef │ ├── UniFramework.Log.asmdef.meta │ ├── UniLog.cs │ ├── UniLog.cs.meta │ ├── UniLogDriver.cs │ ├── UniLogDriver.cs.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniMachine.meta ├── UniMachine ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── IStateNode.cs │ ├── IStateNode.cs.meta │ ├── StateMachine.cs │ ├── StateMachine.cs.meta │ ├── UniFramework.Machine.asmdef │ ├── UniFramework.Machine.asmdef.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniNetwork.meta ├── UniNetwork ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── Package.meta │ ├── Package │ ├── DefaultNetPackage.cs │ ├── DefaultNetPackage.cs.meta │ ├── DefaultNetPackageDecoder.cs │ ├── DefaultNetPackageDecoder.cs.meta │ ├── DefaultNetPackageEncoder.cs │ ├── DefaultNetPackageEncoder.cs.meta │ ├── INetPackage.cs │ ├── INetPackage.cs.meta │ ├── INetPackageDecoder.cs │ ├── INetPackageDecoder.cs.meta │ ├── INetPackageEncoder.cs │ └── INetPackageEncoder.cs.meta │ ├── RingBuffer.cs │ ├── RingBuffer.cs.meta │ ├── TCP.meta │ ├── TCP │ ├── TcpChannel.cs │ ├── TcpChannel.cs.meta │ ├── TcpClient.cs │ └── TcpClient.cs.meta │ ├── ThreadSyncContext.cs │ ├── ThreadSyncContext.cs.meta │ ├── UniFramework.Network.asmdef │ ├── UniFramework.Network.asmdef.meta │ ├── UniLogger.cs │ ├── UniLogger.cs.meta │ ├── UniNetwork.cs │ ├── UniNetwork.cs.meta │ ├── UniNetworkDriver.cs │ └── UniNetworkDriver.cs.meta ├── UniPooling.meta ├── UniPooling ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── CreatePoolOperation.cs │ ├── CreatePoolOperation.cs.meta │ ├── GameObjectPool.cs │ ├── GameObjectPool.cs.meta │ ├── SpawnHandle.cs │ ├── SpawnHandle.cs.meta │ ├── Spawner.cs │ ├── Spawner.cs.meta │ ├── UniFramework.Pooling.asmdef │ ├── UniFramework.Pooling.asmdef.meta │ ├── UniLogger.cs │ ├── UniLogger.cs.meta │ ├── UniPooling.cs │ ├── UniPooling.cs.meta │ ├── UniPoolingDriver.cs │ └── UniPoolingDriver.cs.meta ├── UniReference.meta ├── UniReference ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── IReference.cs │ ├── IReference.cs.meta │ ├── ReferenceCollector.cs │ ├── ReferenceCollector.cs.meta │ ├── UniFramework.Reference.asmdef │ ├── UniFramework.Reference.asmdef.meta │ ├── UniReference.cs │ └── UniReference.cs.meta ├── UniSingleton.meta ├── UniSingleton ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── ISingleton.cs │ ├── ISingleton.cs.meta │ ├── SingletonInstance.cs │ ├── SingletonInstance.cs.meta │ ├── UniFramework.Singleton.asmdef │ ├── UniFramework.Singleton.asmdef.meta │ ├── UniLogger.cs │ ├── UniLogger.cs.meta │ ├── UniSingleton.cs │ ├── UniSingleton.cs.meta │ ├── UniSingletonDriver.cs │ └── UniSingletonDriver.cs.meta ├── UniTween.meta ├── UniTween ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── ETweenLoop.cs │ ├── ETweenLoop.cs.meta │ ├── ETweenStatus.cs │ ├── ETweenStatus.cs.meta │ ├── ITweenChain.cs │ ├── ITweenChain.cs.meta │ ├── ITweenNode.cs │ ├── ITweenNode.cs.meta │ ├── TweenChain.meta │ ├── TweenChain │ ├── TweenChainExtension.cs │ └── TweenChainExtension.cs.meta │ ├── TweenEase.cs │ ├── TweenEase.cs.meta │ ├── TweenExtension.meta │ ├── TweenExtension │ ├── UnityEngine_CanvasGroup_Tween_Extension.cs │ ├── UnityEngine_CanvasGroup_Tween_Extension.cs.meta │ ├── UnityEngine_GameObject_Tween_Extension.cs │ ├── UnityEngine_GameObject_Tween_Extension.cs.meta │ ├── UnityEngine_MaterialPropertyBlock_Tween_Extension.cs │ ├── UnityEngine_MaterialPropertyBlock_Tween_Extension.cs.meta │ ├── UnityEngine_RectTransform_Tween_Extension.cs │ ├── UnityEngine_RectTransform_Tween_Extension.cs.meta │ ├── UnityEngine_SpriteRenderer_Tween_Extension.cs │ ├── UnityEngine_SpriteRenderer_Tween_Extension.cs.meta │ ├── UnityEngine_Transform_Tween_Extension.cs │ ├── UnityEngine_Transform_Tween_Extension.cs.meta │ ├── UnityEngine_UI_Image_Tween_Extension.cs │ ├── UnityEngine_UI_Image_Tween_Extension.cs.meta │ ├── UnityEngine_UI_Text_Tween_Extension.cs │ └── UnityEngine_UI_Text_Tween_Extension.cs.meta │ ├── TweenHandle.cs │ ├── TweenHandle.cs.meta │ ├── TweenMath.cs │ ├── TweenMath.cs.meta │ ├── TweenNode.meta │ ├── TweenNode │ ├── ChainNode.cs │ ├── ChainNode.cs.meta │ ├── ExecuteNode.cs │ ├── ExecuteNode.cs.meta │ ├── ParallelNode.cs │ ├── ParallelNode.cs.meta │ ├── SelectorNode.cs │ ├── SelectorNode.cs.meta │ ├── SequenceNode.cs │ ├── SequenceNode.cs.meta │ ├── TimerNode.cs │ ├── TimerNode.cs.meta │ ├── UntilNode.cs │ ├── UntilNode.cs.meta │ ├── ValueNode.cs │ └── ValueNode.cs.meta │ ├── UniFramework.Tween.asmdef │ ├── UniFramework.Tween.asmdef.meta │ ├── UniLogger.cs │ ├── UniLogger.cs.meta │ ├── UniTimer.cs │ ├── UniTimer.cs.meta │ ├── UniTween.cs │ ├── UniTween.cs.meta │ ├── UniTweenDriver.cs │ ├── UniTweenDriver.cs.meta │ ├── UniTweenFactory.cs │ └── UniTweenFactory.cs.meta ├── UniUtility.meta ├── UniUtility ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime │ ├── BitMask32.cs │ ├── BitMask32.cs.meta │ ├── BitMask64.cs │ ├── BitMask64.cs.meta │ ├── CoroutineUtility.cs │ ├── CoroutineUtility.cs.meta │ ├── Gizmoss.cs │ ├── Gizmoss.cs.meta │ ├── StringConvert.cs │ ├── StringConvert.cs.meta │ ├── StringFormat.cs │ ├── StringFormat.cs.meta │ ├── StringPairs.cs │ ├── StringPairs.cs.meta │ ├── UniFramework.Utility.asmdef │ ├── UniFramework.Utility.asmdef.meta │ ├── UniTimer.cs │ ├── UniTimer.cs.meta │ ├── UniUtility.cs │ └── UniUtility.cs.meta ├── UniWebRequest.meta ├── UniWebRequest ├── Runtime.meta └── Runtime │ ├── EReqeustStatus.cs │ ├── EReqeustStatus.cs.meta │ ├── RequestAsset.cs │ ├── RequestAsset.cs.meta │ ├── Requester.meta │ ├── Requester │ ├── WebRequestAudio.cs │ ├── WebRequestAudio.cs.meta │ ├── WebRequestBase.cs │ ├── WebRequestBase.cs.meta │ ├── WebRequestFile.cs │ ├── WebRequestFile.cs.meta │ ├── WebRequestGet.cs │ ├── WebRequestGet.cs.meta │ ├── WebRequestHeader.cs │ ├── WebRequestHeader.cs.meta │ ├── WebRequestPost.cs │ ├── WebRequestPost.cs.meta │ ├── WebRequestTexture.cs │ └── WebRequestTexture.cs.meta │ ├── UniLogger.cs │ └── UniLogger.cs.meta ├── UniWindow.meta └── UniWindow ├── README.md ├── README.md.meta ├── Runtime.meta └── Runtime ├── OpenWindowOperation.cs ├── OpenWindowOperation.cs.meta ├── UIWindow.cs ├── UIWindow.cs.meta ├── UniFramework.Window.asmdef ├── UniFramework.Window.asmdef.meta ├── UniLogger.cs ├── UniLogger.cs.meta ├── UniWindow.cs ├── UniWindow.cs.meta ├── UniWindowDriver.cs ├── UniWindowDriver.cs.meta ├── WindowAttribute.cs └── WindowAttribute.cs.meta /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UniFramework 2 | Unity game development framework 3 | 4 | Simple Code, Happy life ~ ~ 5 | 6 | 该库仅供源码级学习,不做长期版本维护。 7 | 8 | [UniAnimation](./UniFramework/UniAnimation) 9 | 10 | [UniNetwork](./UniFramework/UniNetwork) 11 | 12 | [UniPooling](./UniFramework/UniPooling) 13 | 14 | [UniTween](./UniFramework/UniTween) 15 | 16 | [UniEvent](./UniFramework/UniEvent) 17 | 18 | [UniMachine](./UniFramework/UniMachine) 19 | 20 | [UniSingleton](./UniFramework/UniSingleton) 21 | 22 | [UniWindow](./UniFramework/UniWindow) 23 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22c4a6746deb208479f4b7a040eed7f3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/README.md: -------------------------------------------------------------------------------- 1 | # UniFramework.Animation 2 | 3 | 一个轻量级的高效率的动画系统。 4 | 5 | 支持新的动画文件格式,不再依赖Animator文件来驱动动画,使用方式非常类似于老的Animation系统。 6 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a7da62cb3785ef45b2dda8fa0b3c8e5 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8664294e17a47c14c8d12545da2349a1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/AnimClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 606e5729d04cc8742a38f58e595c02f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/AnimMixer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b33204afd07c00c4f8b425276778b8bf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/AnimNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6928afd60ab2ed489e492e00d9ddaba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/AnimPlayable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 772b8a9edd8466646bab12d6f5ba1084 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/AnimState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5660d9e37e5c2a44f818506c9fe76624 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/UniAnimation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef52174816df6104587b15c5b250201a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/UniFramework.Animation.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniFramework.Animation", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/UniFramework.Animation.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccbd3ee89c7c8614bb89388a769680c1 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/UniLogger.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace UniFramework.Animation 4 | { 5 | internal static class UniLogger 6 | { 7 | [Conditional("DEBUG")] 8 | public static void Log(string info) 9 | { 10 | UnityEngine.Debug.Log(info); 11 | } 12 | public static void Warning(string info) 13 | { 14 | UnityEngine.Debug.LogWarning(info); 15 | } 16 | public static void Error(string info) 17 | { 18 | UnityEngine.Debug.LogError(info); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /UniFramework/UniAnimation/Runtime/UniLogger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c11371eb114ef24daad9fc81ac6e0cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniEvent.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1cc49e5bd383f040b0f9d481de62f04 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/README.md: -------------------------------------------------------------------------------- 1 | # UniFramework.Event 2 | 3 | 一个轻量级的事件系统。 4 | 5 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dfad42c0d1a02f429a99108a35bbfce 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e86e06e6a95e6cc43940623bcc15721c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/EventGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniFramework.Event 5 | { 6 | public class EventGroup 7 | { 8 | private readonly Dictionary>> _cachedListener = new Dictionary>>(); 9 | private int? _groupId = null; 10 | 11 | public EventGroup() { } 12 | 13 | public EventGroup(int groupId) 14 | { 15 | _groupId = groupId; 16 | } 17 | 18 | /// 19 | /// 添加一个监听 20 | /// 21 | public void AddListener(System.Action listener) where TEvent : IEventMessage 22 | { 23 | System.Type eventType = typeof(TEvent); 24 | if (_cachedListener.ContainsKey(eventType) == false) 25 | _cachedListener.Add(eventType, new List>()); 26 | 27 | if (_cachedListener[eventType].Contains(listener) == false) 28 | { 29 | _cachedListener[eventType].Add(listener); 30 | if (_groupId != null) 31 | UniEvent.AddListener((int)_groupId, listener); 32 | else 33 | UniEvent.AddListener(eventType, listener); 34 | } 35 | else 36 | { 37 | UniLogger.Warning($"Event listener is exist : {eventType}"); 38 | } 39 | } 40 | 41 | /// 42 | /// 移除所有缓存的监听 43 | /// 44 | public void RemoveAllListener() 45 | { 46 | foreach (var pair in _cachedListener) 47 | { 48 | System.Type eventType = pair.Key; 49 | for (int i = 0; i < pair.Value.Count; i++) 50 | { 51 | if (_groupId != null) 52 | UniEvent.RemoveListener((int)_groupId, pair.Value[i]); 53 | else 54 | UniEvent.RemoveListener(eventType, pair.Value[i]); 55 | } 56 | pair.Value.Clear(); 57 | } 58 | _cachedListener.Clear(); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/EventGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc5e4008d087434eb5db1390d8e4e6a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/IEventMessage.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace UniFramework.Event 3 | { 4 | public interface IEventMessage 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/IEventMessage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7dcd12aabf986c6468f748911b1af65a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2a39e0393e22c44b8416d1445c9bb2c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniEventDriver.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniFramework.Event 4 | { 5 | internal class UniEventDriver : MonoBehaviour 6 | { 7 | void Update() 8 | { 9 | UniEvent.Update(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniEventDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91e57d06457f3ec40914e4d3ed58c070 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniFramework.Event.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniFramework.Event", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:e168ba7048aa3904897471c4265f0162" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": true, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniFramework.Event.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f22fac247a56d2d41b687bb0d900e54e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniLogger.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace UniFramework.Event 4 | { 5 | internal static class UniLogger 6 | { 7 | [Conditional("DEBUG")] 8 | public static void Log(string info) 9 | { 10 | UnityEngine.Debug.Log(info); 11 | } 12 | public static void Warning(string info) 13 | { 14 | UnityEngine.Debug.LogWarning(info); 15 | } 16 | public static void Error(string info) 17 | { 18 | UnityEngine.Debug.LogError(info); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /UniFramework/UniEvent/Runtime/UniLogger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bb2f71f321705a4286de583f1c930d7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7047c4daf6700d9408e6c85a2874121b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf9ab7f6b170fd74b9a73bb8affc7687 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/Extension.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09b5fbbfc99860349a281b92d230146b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/Extension/UnityEngine_Rect_Extension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | 5 | namespace UnityEngine 6 | { 7 | public static class UnityEngine_Rect_Extension 8 | { 9 | public static void MoveToNextLine(this ref Rect rect) 10 | { 11 | rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/Extension/UnityEngine_Rect_Extension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25dbbf6b10b13db4ba40d658c763f318 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/ILocalizeReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniFramework.Localization.Editor 5 | { 6 | public interface ILocalizeReader 7 | { 8 | /// 9 | /// 本地化KEY集合 10 | /// 11 | List Keys { get; } 12 | 13 | /// 14 | /// 读取数据 15 | /// 16 | void Read(string assetPath); 17 | } 18 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/ILocalizeReader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5404ca602b1ee6419eb7067ff3afa4b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/LocalizationSetting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniFramework.Localization.Editor 7 | { 8 | [CreateAssetMenu(fileName = "LocalizationSetting", menuName = "UniFramework/Create Localization Setting")] 9 | public class LocalizationSetting : ScriptableObject 10 | { 11 | [Serializable] 12 | public class TableSetting 13 | { 14 | public string TableName; 15 | public string LocalizeReaderClassName; 16 | public UnityEngine.Object FileObject; 17 | 18 | [NonSerialized] 19 | public ILocalizeReader ReaderInstance; 20 | 21 | public void LoadSetting() 22 | { 23 | if (string.IsNullOrEmpty(TableName)) 24 | return; 25 | if (string.IsNullOrEmpty(LocalizeReaderClassName)) 26 | return; 27 | if (FileObject == null) 28 | return; 29 | 30 | // 获取配置路径 31 | string assetPath = AssetDatabase.GetAssetPath(FileObject); 32 | if (string.IsNullOrEmpty(assetPath)) 33 | { 34 | Debug.LogWarning($"Not found localize table data file : {assetPath}"); 35 | return; 36 | } 37 | 38 | // 获取读取器类型 39 | TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom(); 40 | System.Type readerType = null; 41 | foreach (var type in collection) 42 | { 43 | if (type.Name == LocalizeReaderClassName) 44 | { 45 | readerType = type; 46 | break; 47 | } 48 | } 49 | if (readerType == null) 50 | { 51 | Debug.LogWarning($"Not found {nameof(ILocalizeReader)} type with name {LocalizeReaderClassName}"); 52 | return; 53 | } 54 | 55 | // 实例化读取器并解析数据 56 | ReaderInstance = (ILocalizeReader)Activator.CreateInstance(readerType); 57 | ReaderInstance.Read(assetPath); 58 | } 59 | } 60 | 61 | public List TableSettings = new List(); 62 | } 63 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/LocalizationSetting.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c91050b92ed1b64aa9b6d9af508ebc1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/LocalizationSettingData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniFramework.Localization.Editor 7 | { 8 | public class LocalizationSettingData 9 | { 10 | static LocalizationSettingData() 11 | { 12 | } 13 | 14 | private static LocalizationSetting _setting = null; 15 | public static LocalizationSetting Setting 16 | { 17 | get 18 | { 19 | if (_setting == null) 20 | { 21 | _setting = YooAsset.Editor.SettingLoader.LoadSettingData(); 22 | for(int i=0; i<_setting.TableSettings.Count; i++) 23 | { 24 | var tableSetting = _setting.TableSettings[i]; 25 | tableSetting.LoadSetting(); 26 | } 27 | } 28 | return _setting; 29 | } 30 | } 31 | 32 | public static ILocalizeReader GetLocalizeReader(string tableName) 33 | { 34 | foreach(var tableSetting in Setting.TableSettings) 35 | { 36 | if (tableSetting.TableName == tableName) 37 | { 38 | if (tableSetting.ReaderInstance == null) 39 | Debug.LogWarning($"The table reader instance is invalid : {tableName}"); 40 | return tableSetting.ReaderInstance; 41 | } 42 | } 43 | 44 | Debug.LogWarning($"Not found localize table setting: {tableName}"); 45 | return null; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/LocalizationSettingData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72db6b8a11d90db4c8a2cc3ce2f17fbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65f38428e7a3fcd4c8c34bb9231ed07a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEditor.IMGUI.Controls; 7 | using UnityEngine; 8 | 9 | namespace UniFramework.Localization.Editor 10 | { 11 | internal class TranslationKeyTreeView : TreeView 12 | { 13 | protected string _tableName; 14 | protected Action _selectionHandler; 15 | 16 | public TreeViewItem Root { get; private set; } 17 | 18 | public TranslationKeyTreeView() 19 | : base(new TreeViewState()) 20 | { 21 | this.showAlternatingRowBackgrounds = true; 22 | this.showBorder = true; 23 | } 24 | 25 | public TranslationKeyTreeView(string tableName, Action selectionHandler) 26 | : this() 27 | { 28 | _tableName = tableName; 29 | _selectionHandler = selectionHandler; 30 | this.showAlternatingRowBackgrounds = true; 31 | this.showBorder = true; 32 | Reload(); 33 | } 34 | 35 | protected override bool CanMultiSelect(TreeViewItem item) => false; 36 | 37 | protected override TreeViewItem BuildRoot() 38 | { 39 | Root = new TreeViewItem(-1, -1); 40 | 41 | var readerInstance = LocalizationSettingData.GetLocalizeReader(_tableName); 42 | if (readerInstance != null) 43 | { 44 | int itemID = 1; 45 | foreach (var key in readerInstance.Keys) 46 | { 47 | Root.AddChild(new TranslationKeyTreeViewItem(key, itemID++, 0) { displayName = key }); 48 | } 49 | } 50 | 51 | if (Root.hasChildren == false) 52 | { 53 | Root.AddChild(new TreeViewItem(1, 0, "No Tables Found.")); 54 | } 55 | 56 | SetupDepthsFromParentsAndChildren(Root); 57 | return Root; 58 | } 59 | 60 | protected override void SelectionChanged(IList selectedIds) 61 | { 62 | if (selectedIds.Count == 0) 63 | return; 64 | 65 | var selected = FindItem(selectedIds[0], rootItem); 66 | if (selected is TranslationKeyTreeViewItem keyNode) 67 | { 68 | _selectionHandler(keyNode.Key); 69 | return; 70 | } 71 | 72 | // Toggle the foldout 73 | if (selected.hasChildren) 74 | { 75 | SetExpanded(selected.id, !IsExpanded(selected.id)); 76 | } 77 | 78 | // Ignore Table selections. We just care about table entries. 79 | SetSelection(new int[] { }); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 088e7a830b93d2f4cacc99708004108c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeViewItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEditor.IMGUI.Controls; 5 | using UnityEngine; 6 | 7 | namespace UniFramework.Localization.Editor 8 | { 9 | internal class TranslationKeyTreeViewItem : TreeViewItem 10 | { 11 | public string Key { get; set; } 12 | 13 | public TranslationKeyTreeViewItem(string key, int id, int depth) : 14 | base(id, depth) 15 | { 16 | Key = key; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeViewItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b03d6e6ff1b1d3a4eb9d8be15cfebc63 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeViewPopupWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEditor.IMGUI.Controls; 5 | using UnityEngine; 6 | 7 | namespace UniFramework.Localization.Editor 8 | { 9 | class TreeViewPopupWindow : PopupWindowContent 10 | { 11 | readonly SearchField _searchField; 12 | readonly TreeView _treeView; 13 | private bool _shouldClose; 14 | 15 | public float Width { get; set; } 16 | 17 | public TreeViewPopupWindow(TreeView contents) 18 | { 19 | _searchField = new SearchField(); 20 | _treeView = contents; 21 | } 22 | 23 | public override void OnGUI(Rect rect) 24 | { 25 | // Escape closes the window 26 | if (_shouldClose || UnityEngine.Event.current.type == EventType.KeyDown && UnityEngine.Event.current.keyCode == KeyCode.Escape) 27 | { 28 | GUIUtility.hotControl = 0; 29 | this.editorWindow.Close(); 30 | GUIUtility.ExitGUI(); 31 | } 32 | 33 | const int border = 4; 34 | const int topPadding = 12; 35 | const int searchHeight = 20; 36 | const int remainTop = topPadding + searchHeight + border; 37 | var searchRect = new Rect(border, topPadding, rect.width - border * 2, searchHeight); 38 | var remainingRect = new Rect(border, topPadding + searchHeight + border, rect.width - border * 2, rect.height - remainTop - border); 39 | 40 | _treeView.searchString = _searchField.OnGUI(searchRect, _treeView.searchString); 41 | _treeView.OnGUI(remainingRect); 42 | 43 | if (_treeView.HasSelection()) 44 | ForceClose(); 45 | } 46 | 47 | public override Vector2 GetWindowSize() 48 | { 49 | var result = base.GetWindowSize(); 50 | result.x = Width; 51 | return result; 52 | } 53 | 54 | public override void OnOpen() 55 | { 56 | _searchField.SetFocus(); 57 | base.OnOpen(); 58 | } 59 | 60 | public void ForceClose() => _shouldClose = true; 61 | } 62 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PopupWindow/TreeViewPopupWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b1be94c8a2614b46a6a4f2d384e9682 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49199f0d3a845ee49a060464733b988c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/ReadOnlyDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniFramework.Localization.Editor 6 | { 7 | [CustomPropertyDrawer(typeof(ReadOnlyAttribute))] 8 | internal class ReadOnlyDrawer : PropertyDrawer 9 | { 10 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 11 | { 12 | EditorGUI.LabelField(position, label); 13 | EditorGUI.BeginDisabledGroup(true); 14 | EditorGUI.PropertyField(position, property); 15 | EditorGUI.EndDisabledGroup(); 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/ReadOnlyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 895cac07ac2265043b5283d3f8a6c5fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/TableNameDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UniFramework.Localization.Editor 5 | { 6 | [CustomPropertyDrawer(typeof(TableNameAttribute))] 7 | public class TableNameDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | Rect left = position; left.xMax -= 40; 12 | Rect right = position; right.xMin = left.xMax + 2; 13 | Color color = GUI.color; 14 | 15 | EditorGUI.BeginDisabledGroup(true); 16 | EditorGUI.PropertyField(left, property); 17 | EditorGUI.EndDisabledGroup(); 18 | 19 | GUI.color = color; 20 | if (GUI.Button(right, "List") == true) 21 | { 22 | ShowMenu(right, property); 23 | } 24 | } 25 | 26 | private void ShowMenu(Rect right, SerializedProperty property) 27 | { 28 | var menu = new GenericMenu(); 29 | foreach (var tableSetting in LocalizationSettingData.Setting.TableSettings) 30 | { 31 | menu.AddItem(new GUIContent(tableSetting.TableName), property.stringValue == tableSetting.TableName, () => 32 | { 33 | property.stringValue = tableSetting.TableName; 34 | property.serializedObject.ApplyModifiedProperties(); 35 | }); 36 | } 37 | 38 | if (menu.GetItemCount() > 0) 39 | { 40 | menu.DropDown(right); 41 | } 42 | else 43 | { 44 | Debug.LogWarning($"Not found any table names ! Please check {nameof(LocalizationSetting)}"); 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/TableNameDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 151f031adcec9c348b32732459559f50 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/TranslationKeyDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UniFramework.Localization.Editor 5 | { 6 | [CustomPropertyDrawer(typeof(TranslationKeyAttribute))] 7 | public class TranslationKeyDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | Rect left = position; left.xMax -= 40; 12 | Rect right = position; right.xMin = left.xMax + 2; 13 | Color color = GUI.color; 14 | 15 | Rect rowPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 16 | Rect foldoutRect = new Rect(rowPosition.x, rowPosition.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); 17 | Rect dropDownPosition = new Rect(foldoutRect.xMax, rowPosition.y, rowPosition.width - EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); 18 | rowPosition.MoveToNextLine(); 19 | 20 | EditorGUI.BeginDisabledGroup(true); 21 | EditorGUI.PropertyField(left, property); 22 | EditorGUI.EndDisabledGroup(); 23 | 24 | GUI.color = color; 25 | if (GUI.Button(right, "List") == true) 26 | { 27 | ShowPicker(dropDownPosition, property); 28 | } 29 | } 30 | 31 | private void ShowPicker(Rect dropDownPosition, SerializedProperty property) 32 | { 33 | var component = property.serializedObject.targetObject as Component; 34 | var bhv = component.GetComponent(); 35 | var treeView = new TranslationKeyTreeView(bhv.DataTableName, (key) => 36 | { 37 | if(string.IsNullOrEmpty(key) == false) 38 | { 39 | property.stringValue = key; 40 | property.serializedObject.ApplyModifiedProperties(); 41 | } 42 | }); 43 | 44 | PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeView) { Width = dropDownPosition.width }); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/PropertyDrawer/TranslationKeyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01c984d6ad833224fa50291f6d094f1e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/UniFramework.Localization.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniFramework.Localization.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:e168ba7048aa3904897471c4265f0162", 6 | "GUID:7815d60d16b60414f9d85833b64e743c", 7 | "GUID:4d1926c9df5b052469a1c63448b7609a" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": true, 14 | "overrideReferences": false, 15 | "precompiledReferences": [], 16 | "autoReferenced": true, 17 | "defineConstraints": [], 18 | "versionDefines": [], 19 | "noEngineReferences": false 20 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Editor/UniFramework.Localization.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e95d448bc563f9c4d961344cdcf965f7 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/README.md: -------------------------------------------------------------------------------- 1 | # UniFramework.Localization 2 | 3 | 一个轻量级的本地化系统。 4 | 5 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62b78c3b73549a7428030aa2ece40b6c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28eea255b2c4c0441b9ad219bdf8dd6c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba3ddfd554bf1f74a8d27865a8b221cf 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/LocalizedBehaviourAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniFramework 4 | { 5 | public class LocalizedBehaviourAttribute : Attribute 6 | { 7 | public Type TranslationType { private set; get; } 8 | 9 | public LocalizedBehaviourAttribute(Type translationType) 10 | { 11 | TranslationType = translationType; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/LocalizedBehaviourAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95f7713f32a99a24ea097f6e3c4602ab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/ReadOnlyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UniFramework 5 | { 6 | [AttributeUsage(AttributeTargets.Field)] 7 | public class ReadOnlyAttribute : PropertyAttribute 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/ReadOnlyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c59ccd4b33790044a613f560d78a2ca 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/TableNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniFramework 4 | { 5 | public class TableNameAttribute : PropertyAttribute 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/TableNameAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c95f54893150f7e4490c681aa2368a38 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/TranslationKeyAttribute.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniFramework 4 | { 5 | public class TranslationKeyAttribute : PropertyAttribute 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Attribute/TranslationKeyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edc38135327369a41af6cab93d228842 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0212bcd5ef95e2d4b8d2bcd551007e4f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour/LocalizedAudio.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniFramework.Localization 4 | { 5 | [ExecuteInEditMode] 6 | [DisallowMultipleComponent] 7 | [RequireComponent(typeof(AudioSource))] 8 | [LocalizedBehaviour(typeof(TranslationAudio))] 9 | public class LocalizedAudio : LocalizedBehaviour 10 | { 11 | private AudioSource _audioSource; 12 | 13 | protected override void OnTranslation(ITranslation translation) 14 | { 15 | if (_audioSource == null) 16 | _audioSource = GetComponent(); 17 | 18 | _audioSource.clip = translation.GetTranslationResult(this) as AudioClip; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour/LocalizedAudio.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a5a2c52eb6022c4090f76bb4e12f54d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour/LocalizedBehaviour.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Reflection; 5 | 6 | namespace UniFramework.Localization 7 | { 8 | public abstract class LocalizedBehaviour : MonoBehaviour 9 | { 10 | private Type _translationType; 11 | 12 | [SerializeField] 13 | [TableName] 14 | private string _dataTableName; 15 | 16 | [SerializeField] 17 | [TranslationKey] 18 | private string _translationKey; 19 | 20 | /// 21 | /// 数据表名称 22 | /// 23 | public string DataTableName 24 | { 25 | set 26 | { 27 | _dataTableName = value; 28 | } 29 | 30 | get 31 | { 32 | return _dataTableName; 33 | } 34 | } 35 | 36 | /// 37 | /// 翻译KEY 38 | /// 39 | public string TranslationKey 40 | { 41 | set 42 | { 43 | _translationKey = value; 44 | } 45 | 46 | get 47 | { 48 | return _translationKey; 49 | } 50 | } 51 | 52 | protected virtual void Awake() 53 | { 54 | var attribute = this.GetType().GetCustomAttribute(); 55 | if (attribute == null) 56 | throw new Exception($"Not found {nameof(LocalizedBehaviourAttribute)} in class : {this.GetType().FullName}"); 57 | _translationType = attribute.TranslationType; 58 | } 59 | protected virtual void OnEnable() 60 | { 61 | UniLocalization.OnLocalizationChanged += TranslationInternal; 62 | TranslationInternal(); 63 | } 64 | protected virtual void OnDisable() 65 | { 66 | UniLocalization.OnLocalizationChanged -= TranslationInternal; 67 | } 68 | private void TranslationInternal() 69 | { 70 | var translation = UniLocalization.GetOrCreateTranslation(_translationType); 71 | if (translation != null) 72 | { 73 | OnTranslation(translation); 74 | } 75 | } 76 | 77 | /// 78 | /// 刷新组件 79 | /// 80 | public void Refresh() 81 | { 82 | TranslationInternal(); 83 | } 84 | 85 | /// 86 | /// 执行翻译 87 | /// 88 | protected abstract void OnTranslation(ITranslation translation); 89 | 90 | /* 91 | #if UNITY_EDITOR 92 | protected virtual void OnValidate() 93 | { 94 | if (isActiveAndEnabled == true) 95 | { 96 | TranslationInternal(); 97 | } 98 | } 99 | #endif 100 | */ 101 | } 102 | } -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour/LocalizedBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81bc3c8fe278b364d8d182c18fe6735c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UniFramework/UniLocalization/Runtime/Behaviour/LocalizedDropdown.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace UniFramework.Localization 6 | { 7 | [ExecuteInEditMode] 8 | [DisallowMultipleComponent] 9 | [RequireComponent(typeof(Text))] 10 | [LocalizedBehaviour(typeof(TranslationString))] 11 | public class LocalizedDropdown : LocalizedBehaviour 12 | { 13 | [System.Serializable] 14 | public class Option 15 | { 16 | [TranslationKey] 17 | public string StringTranslationKey; 18 | } 19 | 20 | [SerializeField] 21 | private List