├── Assets ├── ClientDataBase │ ├── GameTable │ │ └── .gitkeep │ ├── Templates │ │ ├── TableClassProperty.txt │ │ ├── Scriptable.txt.meta │ │ ├── TableClass.txt.meta │ │ ├── ScriptableEditor.txt.meta │ │ ├── TableClassProperty.txt.meta │ │ ├── TableClass.txt │ │ ├── ScriptableEditor.txt │ │ └── Scriptable.txt │ ├── Scripts.meta │ ├── GameTable.meta │ ├── Resources.meta │ ├── Resources │ │ ├── Client DataBase Config.asset.meta │ │ └── Client DataBase Config.asset │ ├── Scripts │ │ ├── Base.meta │ │ ├── Config.meta │ │ ├── Editor.meta │ │ ├── Utility.meta │ │ ├── Base │ │ │ ├── TableClassBase.cs │ │ │ ├── TableClassBase.cs.meta │ │ │ ├── ScriptableObjectBase.cs.meta │ │ │ └── ScriptableObjectBase.cs │ │ ├── Utility │ │ │ ├── Utility.cs.meta │ │ │ ├── Singleton.cs.meta │ │ │ ├── SerializableDictionary.cs.meta │ │ │ ├── Singleton.cs │ │ │ ├── Utility.cs │ │ │ └── SerializableDictionary.cs │ │ ├── ClientDataBaseManager.cs.meta │ │ ├── Editor │ │ │ ├── UtilityEditor.cs.meta │ │ │ ├── ClientDataBaseParse.cs.meta │ │ │ ├── ClientDataBaseConfigEditor.cs.meta │ │ │ ├── ClientDataBaseEditorWindow.cs.meta │ │ │ ├── ClientDataBaseConfigEditor.cs │ │ │ ├── UtilityEditor.cs │ │ │ ├── ClientDataBaseEditorWindow.cs │ │ │ └── ClientDataBaseParse.cs │ │ ├── Config │ │ │ ├── ClientDataBaseConfig.cs.meta │ │ │ └── ClientDataBaseConfig.cs │ │ └── ClientDataBaseManager.cs │ └── Templates.meta └── ClientDataBase.meta ├── Documentation ├── en │ └── en.md ├── 04_Sample_1.png ├── 05_Sample_2.png ├── 02_Client DataBase Config.PNG ├── 03_Client DataBase Window.PNG ├── 01_Excel to ScriptableObject Asset.png └── zh-tw │ └── zh-tw.md ├── ProjectSettings ├── ProjectVersion.txt ├── ClusterInputManager.asset ├── EditorBuildSettings.asset ├── NetworkManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset ├── UnityConnectSettings.asset ├── AudioManager.asset ├── EditorSettings.asset ├── TagManager.asset ├── DynamicsManager.asset ├── Physics2DSettings.asset ├── NavMeshAreas.asset ├── GraphicsSettings.asset ├── QualitySettings.asset ├── InputManager.asset └── ProjectSettings.asset ├── README.md ├── .gitignore └── LICENCE /Assets/ClientDataBase/GameTable/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Documentation/en/en.md: -------------------------------------------------------------------------------- 1 | #:warning: Building... 2 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.6f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /Documentation/04_Sample_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k79k06k02k/ClientDataBase/HEAD/Documentation/04_Sample_1.png -------------------------------------------------------------------------------- /Documentation/05_Sample_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k79k06k02k/ClientDataBase/HEAD/Documentation/05_Sample_2.png -------------------------------------------------------------------------------- /Documentation/02_Client DataBase Config.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k79k06k02k/ClientDataBase/HEAD/Documentation/02_Client DataBase Config.PNG -------------------------------------------------------------------------------- /Documentation/03_Client DataBase Window.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k79k06k02k/ClientDataBase/HEAD/Documentation/03_Client DataBase Window.PNG -------------------------------------------------------------------------------- /Documentation/01_Excel to ScriptableObject Asset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k79k06k02k/ClientDataBase/HEAD/Documentation/01_Excel to ScriptableObject Asset.png -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/TableClassProperty.txt: -------------------------------------------------------------------------------- 1 | /// 2 | /// $Summary 3 | /// 4 | $Modifier $Type $Name { get { return _$Name; } set { _$Name = value; } } 5 | [SerializeField] 6 | private $Type _$Name; -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/Scriptable.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 025d9160d1158ff498999e666ce40dd1 3 | timeCreated: 1463470260 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/TableClass.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91daab70a1e6d0a4c9ecc715d1eaee9a 3 | timeCreated: 1463383192 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24b4538ca0941c04d9d2dfbdc72f4335 3 | folderAsset: yes 4 | timeCreated: 1472726503 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/ScriptableEditor.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 569fd3161df574e4e82e54f730b643df 3 | timeCreated: 1463561346 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf995c77da9775247a7a2e6e2e288915 3 | folderAsset: yes 4 | timeCreated: 1463768453 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/TableClassProperty.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4aa9f2f5e0b42214d85e139d69be1857 3 | timeCreated: 1463468450 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/GameTable.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7aa35b937effb8498c453ddbf627da9 3 | folderAsset: yes 4 | timeCreated: 1473144459 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ae6252161c06ff419b0429320cb6d18 3 | folderAsset: yes 4 | timeCreated: 1473133933 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Resources/Client DataBase Config.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec71cb72b7053b549981181f87f2c862 3 | timeCreated: 1472716792 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83701d9ebc84eb948aff4d5adca85acf 3 | folderAsset: yes 4 | timeCreated: 1472930864 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55eb7b6fa62e14345984e3b6ee5a472f 3 | folderAsset: yes 4 | timeCreated: 1463383148 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Config.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 463355a6738b9df41a3db666d2c8a126 3 | folderAsset: yes 4 | timeCreated: 1472930836 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7aa343e68b7d944aaef800a3a23ca05 3 | folderAsset: yes 4 | timeCreated: 1463382554 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 078897440e63a4a48b459d60f445953a 3 | folderAsset: yes 4 | timeCreated: 1470975960 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!292 &1 4 | UnityAdsSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_InitializeOnStartup: 1 8 | m_TestMode: 0 9 | m_EnabledPlatforms: 4294967295 10 | m_IosGameId: 11 | m_AndroidGameId: 12 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Base/TableClassBase.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : TableClassBase.cs 4 | **********************************************************/ 5 | namespace ClientDataBase 6 | { 7 | public class TableClassBase { } 8 | } 9 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/Utility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22dedecb94f134245b51ffac3854c9a6 3 | timeCreated: 1470975946 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Base/TableClassBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c04d73d0bb1888b478d0ab1a2fea47a6 3 | timeCreated: 1472228148 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/ClientDataBaseManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8396b8ef45a31041bd940fc27cefbb4 3 | timeCreated: 1473134207 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/UtilityEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c45296efb4aecd2409e0bc3838bb6ebf 3 | timeCreated: 1470975871 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/Singleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a082ba5efadaad4f8cf0fd3b7a12f68 3 | timeCreated: 1470975952 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Base/ScriptableObjectBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be02cc984091bed4ca343b3428367f71 3 | timeCreated: 1463768298 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseParse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4f4e344e3689e648a638e87bd4fde45 3 | timeCreated: 1463938499 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Config/ClientDataBaseConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e5c24b43a199654aa132f2da4e5ac8a 3 | timeCreated: 1472716910 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/SerializableDictionary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4517f655433205b4db64b221711e8339 3 | timeCreated: 1464036612 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseConfigEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d373a81f9786dc4b96d2d8dbc4f6045 3 | timeCreated: 1472717499 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1232fd08b83b9814396d4310f7de760d 3 | timeCreated: 1463382301 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | UnityPurchasingSettings: 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | UnityAnalyticsSettings: 10 | m_Enabled: 0 11 | m_InitializeOnStartup: 1 12 | m_TestMode: 0 13 | m_TestEventUrl: 14 | m_TestConfigUrl: 15 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Base/ScriptableObjectBase.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ScriptableObjectBase.cs 4 | **********************************************************/ 5 | namespace ClientDataBase 6 | { 7 | public abstract class ScriptableObjectBase : UnityEngine.ScriptableObject 8 | { 9 | public abstract bool LoadGameTable(); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/TableClass.txt: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /****************** Auto Generate Script, Do Not Modify! *********************/ 3 | /*****************************************************************************/ 4 | using UnityEngine; 5 | using System.Collections; 6 | using ClientDataBase; 7 | 8 | [System.Serializable] 9 | public class $ClassName : TableClassBase 10 | { 11 | $MemberFields 12 | } -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 1 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 15 | m_ProjectGenerationRootNamespace: 16 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Client DataBase 本地資料庫系統 V0.0.1b 2 |

3 |
4 | 5 | ## Documentation 6 | + [繁體中文](https://github.com/k79k06k02k/ClientDataBase/blob/master/Documentation/zh-tw/zh-tw.md) 7 | + [Engilsh](https://github.com/k79k06k02k/ClientDataBase/blob/master/Documentation/en/en.md) 8 |

9 | 10 | ## Support & Feedback 11 | Blog:[http://k79k06k02k.com/blog](http://k79k06k02k.com/blog)
12 | Facebook:[https://www.facebook.com/k79k06k02k](https://www.facebook.com/k79k06k02k)
13 | Email:k79k06k02k@gmail.com

14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | [Tt]emp/ 5 | [Oo]bj/ 6 | [Bb]uild 7 | [Ll]ibrary/ 8 | sysinfo.txt 9 | *.stackdump 10 | 11 | # ===================================== # 12 | # Visual Studio / MonoDevelop generated # 13 | # ===================================== # 14 | [Ee]xported[Oo]bj/ 15 | .vs/ 16 | /*.userprefs 17 | /*.csproj 18 | /*.pidb 19 | /*.suo 20 | /*.sln* 21 | /*.user 22 | /*.unityproj 23 | /*.booproj 24 | 25 | # ============ # 26 | # OS generated # 27 | # ============ # 28 | .DS_Store* 29 | ._* 30 | .Spotlight-V100 31 | .Trashes 32 | Icon? 33 | ehthumbs.db 34 | [Tt]humbs.db 35 | 36 | # ===== # 37 | # Other # 38 | # ===== # 39 | *.TMP 40 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/ScriptableEditor.txt: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /****************** Auto Generate Script, Do Not Modify! *********************/ 3 | /*****************************************************************************/ 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | [CustomEditor(typeof($ScriptableName))] 8 | public class $ScriptableEditorName : Editor 9 | { 10 | public override void OnInspectorGUI() 11 | { 12 | $ScriptableName script = ($ScriptableName)target; 13 | 14 | if (GUILayout.Button("Update")) 15 | script.LoadGameTable(); 16 | 17 | GUILayout.Space(20); 18 | 19 | DrawDefaultInspector(); 20 | } 21 | } -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: .00499999989 11 | m_DefaultContactOffset: .00999999978 12 | m_SolverIterationCount: 6 13 | m_QueriesHitTriggers: 1 14 | m_EnableAdaptiveForce: 0 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/Singleton.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : Singleton.cs 4 | // Reference: http://wiki.unity3d.com/index.php/Singleton 5 | **********************************************************/ 6 | 7 | namespace ClientDataBase 8 | { 9 | public class Singleton where T : class, new() 10 | { 11 | private static T _instance; 12 | 13 | private static object _lock = new object(); 14 | 15 | public static T Instance 16 | { 17 | get 18 | { 19 | //多執行緒 20 | lock (_lock) 21 | { 22 | if (_instance == null) 23 | { 24 | _instance = new T(); 25 | } 26 | 27 | return _instance; 28 | } 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/ClientDataBase/Resources/Client DataBase Config.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 0e5c24b43a199654aa132f2da4e5ac8a, type: 3} 12 | m_Name: Client DataBase Config 13 | m_EditorClassIdentifier: 14 | GameTableCheck: '##' 15 | ROOT: Assets/ClientDataBase/ 16 | ScriptTemplatesPath: Templates/ 17 | GameTablePath: GameTable/ 18 | TableClassPath: Generate/TableClass/ 19 | ScriptableAssetPath: Generate/Resources/ClientDataBase/ 20 | ScriptableScriptsPath: Generate/Scriptable/Script/ 21 | ScriptableEditorPath: Generate/Scriptable/Editor/ 22 | ClassNamePrefix: Table 23 | ScriptableAssetSuffix: Asset 24 | ScriptableScriptSuffix: Scriptable 25 | ScriptableEditorSuffix: ScriptableEditor 26 | FileExtensionTXT: .txt 27 | FileExtensionCS: .cs 28 | FileExtensionASSET: .asset 29 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81000042} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: .200000003 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: .00999999978 17 | m_BaumgarteScale: .200000003 18 | m_BaumgarteTimeOfImpactScale: .75 19 | m_TimeToSleep: .5 20 | m_LinearSleepTolerance: .00999999978 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 26 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Arkai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_LegacyDeferred: 14 | m_Mode: 1 15 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 16 | m_AlwaysIncludedShaders: 17 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 20 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 21 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 22 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 23 | m_PreloadedShaders: [] 24 | m_LightmapStripping: 0 25 | m_LightmapKeepPlain: 1 26 | m_LightmapKeepDirCombined: 1 27 | m_LightmapKeepDirSeparate: 1 28 | m_LightmapKeepDynamicPlain: 1 29 | m_LightmapKeepDynamicDirCombined: 1 30 | m_LightmapKeepDynamicDirSeparate: 1 31 | m_FogStripping: 0 32 | m_FogKeepLinear: 1 33 | m_FogKeepExp: 1 34 | m_FogKeepExp2: 1 35 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/ClientDataBaseManager.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ClientDataBaseManager.cs 4 | **********************************************************/ 5 | using System.Collections.Generic; 6 | using System; 7 | using ClientDataBase; 8 | 9 | public class ClientDataBaseManager : Singleton 10 | { 11 | const string c_pathConfig = "Client DataBase Config"; 12 | const string c_pathScriptableAssetRoot = "ClientDataBase/"; 13 | 14 | ClientDataBaseConfig _config; 15 | public ClientDataBaseConfig m_config 16 | { 17 | get 18 | { 19 | if (_config == null) 20 | _config = Utility.AssetRelate.ResourcesLoadCheckNull(c_pathConfig); 21 | 22 | return _config; 23 | } 24 | } 25 | 26 | 27 | public Dictionary m_tableList = new Dictionary(); 28 | 29 | public ClientDataBaseManager() 30 | { 31 | } 32 | 33 | ScriptableObjectBase LoadTable(string fileName) 34 | { 35 | return Utility.AssetRelate.ResourcesLoadCheckNull(c_pathScriptableAssetRoot + m_config.GetScriptableAssetName(fileName)); 36 | } 37 | 38 | void Register(Type type, ScriptableObjectBase dataBase) 39 | { 40 | m_tableList.Add(type, dataBase); 41 | } 42 | 43 | public T GetTable() where T : ScriptableObjectBase, new() 44 | { 45 | if (m_tableList.ContainsKey(typeof(T))) 46 | { 47 | return (T)m_tableList[typeof(T)]; 48 | } 49 | 50 | return default(T); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/Utility.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : Utility.cs 4 | **********************************************************/ 5 | using UnityEngine; 6 | 7 | namespace ClientDataBase 8 | { 9 | public class Utility 10 | { 11 | public struct TypeRelate 12 | { 13 | public static bool StringToBool(string value) 14 | { 15 | if (value == "T") 16 | return true; 17 | else if (value == "F") 18 | return false; 19 | else 20 | { 21 | Debug.LogError(string.Format("Unable to convert value:[{0}]", value)); 22 | return false; 23 | } 24 | } 25 | public static Vector2 StringToVector2(string value) 26 | { 27 | string[] str = value.Split(','); 28 | return new Vector2(float.Parse(str[0]), float.Parse(str[1])); 29 | } 30 | public static Vector3 StringToVector3(string value) 31 | { 32 | string[] str = value.Split(','); 33 | return new Vector3(float.Parse(str[0]), float.Parse(str[1]), float.Parse(str[2])); 34 | } 35 | } 36 | 37 | 38 | public struct AssetRelate 39 | { 40 | /// 41 | /// Resources.Load 並檢查是否null 42 | /// 43 | public static T ResourcesLoadCheckNull(string name) where T : UnityEngine.Object 44 | { 45 | T loadGo = Resources.Load(name); 46 | 47 | if (loadGo == null) 48 | { 49 | Debug.LogError("Resources.Load [ " + name + " ] is Null !!"); 50 | return default(T); 51 | } 52 | 53 | return loadGo; 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/ClientDataBase/Templates/Scriptable.txt: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /****************** Auto Generate Script, Do Not Modify! *********************/ 3 | /*****************************************************************************/ 4 | using System; 5 | using UnityEngine; 6 | using ClientDataBase; 7 | 8 | #if UNITY_EDITOR 9 | using System.IO; 10 | using UnityEditor; 11 | #endif 12 | 13 | [Serializable] 14 | public class Dictionary$ClassName : SerializableDictionary { } 15 | 16 | 17 | public class $ScriptableName : ScriptableObjectBase 18 | { 19 | public static string m_gameTableName = "$GameTableName"; 20 | public Dictionary$ClassName m_tableDict = new Dictionary$ClassName(); 21 | 22 | ClientDataBaseConfig _clientDataBaseConfig; 23 | 24 | #if UNITY_EDITOR 25 | string path; 26 | 27 | public override bool LoadGameTable() 28 | { 29 | m_tableDict.Clear(); 30 | 31 | _clientDataBaseConfig = ClientDataBaseManager.Instance.m_config; 32 | path = _clientDataBaseConfig.GetGameTablePathName(m_gameTableName); 33 | 34 | TextAsset data = AssetDatabase.LoadAssetAtPath(path); 35 | StringReader reader = null; 36 | int index = 0; 37 | string strTemp; 38 | 39 | if (data == null) 40 | { 41 | Debug.LogError(string.Format("Can't found GameTable txt file in [Path:{0}]", path)); 42 | return false; 43 | } 44 | 45 | reader = new StringReader(data.text); 46 | 47 | if (reader != null) 48 | { 49 | while ((strTemp = reader.ReadLine()) != null) 50 | { 51 | if (index <= 2) 52 | { 53 | index++; 54 | continue; 55 | } 56 | 57 | string[] splitStr = strTemp.Split("\t"[0]); 58 | 59 | $ClassName table = new $ClassName(); 60 | try 61 | { 62 | $DataLoad 63 | } 64 | catch (FormatException e) 65 | { 66 | string obvious = string.Empty; 67 | string[] log = e.StackTrace.Split('\n'); 68 | for (int i = 0; i < log.Length; i++) 69 | { 70 | if (log[i].IndexOf(this.GetType().Name) > 0) 71 | { 72 | obvious = log[i]; 73 | break; 74 | } 75 | } 76 | 77 | Debug.LogError(string.Format("{0} \n{1} \n\nStackTrace:{2}", e.Message, obvious, e.StackTrace)); 78 | return false; 79 | } 80 | 81 | m_tableDict.Add(table.id, table); 82 | 83 | index++; 84 | } 85 | 86 | reader.Close(); 87 | } 88 | 89 | EditorUtility.SetDirty(this); 90 | AssetDatabase.SaveAssets(); 91 | 92 | Debug.Log(string.Format("[{0}] GameTable Asset is Update. Source:[{1}]", this.name, path)); 93 | return true; 94 | } 95 | 96 | #else 97 | public override bool LoadGameTable() { return false; } 98 | #endif 99 | 100 | public $ClassName GetData(string id) 101 | { 102 | if (m_tableDict.ContainsKey(id)) 103 | { 104 | return m_tableDict[id]; 105 | } 106 | else 107 | { 108 | Debug.LogWarning(string.Format("[{0}] GameTable Asset Dictionary Can't found key [{1}]", this.name, id)); 109 | return null; 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseConfigEditor.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ClientDataBaseConfigEditor.cs 4 | **********************************************************/ 5 | using UnityEngine; 6 | using UnityEditor; 7 | 8 | namespace ClientDataBase 9 | { 10 | [CustomEditor(typeof(ClientDataBaseConfig))] 11 | public class ClientDataBaseConfigEditor : Editor 12 | { 13 | ClientDataBaseConfig _script; 14 | 15 | public override void OnInspectorGUI() 16 | { 17 | _script = target as ClientDataBaseConfig; 18 | 19 | GUILayout.Space(15); 20 | EditorGUILayout.BeginVertical(GUI.skin.box); 21 | EditorGUILayout.LabelField("Check", EditorStyles.boldLabel); 22 | _script.m_gameTableCheck = DrawNormalField("Game Table Check", _script.m_gameTableCheck); 23 | EditorGUILayout.EndVertical(); 24 | 25 | 26 | GUILayout.Space(15); 27 | EditorGUILayout.BeginVertical(GUI.skin.box); 28 | EditorGUILayout.LabelField("Path", EditorStyles.boldLabel); 29 | _script.m_root = DrawNormalField("ROOT", _script.m_root); 30 | _script.m_pathScriptTemplates = DrawPathField("Script Templates Path", _script.m_pathScriptTemplates); 31 | _script.m_pathGameTable = DrawPathField("Game Table Path", _script.m_pathGameTable); 32 | _script.m_pathTableClass = DrawPathField("Table Class Path", _script.m_pathTableClass); 33 | _script.m_pathScriptableAsset = DrawPathField("Scriptable Asset Path", _script.m_pathScriptableAsset); 34 | _script.m_pathScriptableScripts = DrawPathField("Scriptable Scripts Path", _script.m_pathScriptableScripts); 35 | _script.m_pathScriptableEditor = DrawPathField("Scriptable Editor Path", _script.m_pathScriptableEditor); 36 | EditorGUILayout.EndVertical(); 37 | 38 | 39 | GUILayout.Space(15); 40 | EditorGUILayout.BeginVertical(GUI.skin.box); 41 | EditorGUILayout.LabelField("Name", EditorStyles.boldLabel); 42 | _script.m_nameClassPrefix = DrawNameField("Class Name Prefix", "Preview: " + _script.m_nameClassPrefix + "[FileName]", _script.m_nameClassPrefix); 43 | _script.m_nameScriptableAssetSuffix = DrawNameField("Scriptable Asset Suffix", "Preview: " + _script.m_nameClassPrefix + "[FileName]" + _script.m_nameScriptableAssetSuffix, _script.m_nameScriptableAssetSuffix); 44 | _script.m_nameScriptableScriptSuffix = DrawNameField("Scriptable Script Suffix", "Preview: " + _script.m_nameClassPrefix + "[FileName]" + _script.m_nameScriptableScriptSuffix, _script.m_nameScriptableScriptSuffix); 45 | _script.m_nameScriptableEditorSuffix = DrawNameField("Scriptable Editor Suffix", "Preview: " + _script.m_nameClassPrefix + "[FileName]" + _script.m_nameScriptableEditorSuffix, _script.m_nameScriptableEditorSuffix); 46 | EditorGUILayout.EndVertical(); 47 | 48 | EditorUtility.SetDirty(_script); 49 | } 50 | 51 | string DrawNormalField(string name, string field) 52 | { 53 | EditorGUILayout.BeginHorizontal(); 54 | EditorGUILayout.LabelField(name, GUILayout.Width(160)); 55 | field = EditorGUILayout.TextField(field); 56 | EditorGUILayout.EndHorizontal(); 57 | 58 | return field; 59 | } 60 | 61 | string DrawPathField(string name, string field) 62 | { 63 | EditorGUILayout.BeginHorizontal(); 64 | EditorGUILayout.LabelField(name, GUILayout.Width(160)); 65 | EditorGUILayout.LabelField("ROOT +", GUILayout.Width(50)); 66 | field = EditorGUILayout.TextField(field); 67 | EditorGUILayout.EndHorizontal(); 68 | 69 | return field; 70 | } 71 | 72 | string DrawNameField(string name, string preview, string field) 73 | { 74 | EditorGUILayout.BeginHorizontal(); 75 | EditorGUILayout.LabelField(name, GUILayout.Width(160)); 76 | field = EditorGUILayout.TextField(field); 77 | EditorGUILayout.EndHorizontal(); 78 | 79 | 80 | EditorGUILayout.BeginHorizontal(); 81 | EditorGUILayout.LabelField("", GUILayout.Width(160)); 82 | EditorGUILayout.LabelField(preview); 83 | EditorGUILayout.EndHorizontal(); 84 | 85 | GUILayout.Space(10); 86 | 87 | 88 | return field; 89 | } 90 | 91 | } 92 | } -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Config/ClientDataBaseConfig.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ClientDataBaseConfig.cs 4 | **********************************************************/ 5 | namespace ClientDataBase 6 | { 7 | public class ClientDataBaseConfig : UnityEngine.ScriptableObject 8 | { 9 | /// 10 | /// GameTable 識別字串,判斷方式是與資料一開始的字串做比對 11 | /// 12 | public string m_gameTableCheck = "##"; 13 | 14 | 15 | public string m_root = "Assets/ClientDataBase/"; 16 | 17 | /// 18 | /// Script Templates 存放路徑 19 | /// 20 | public string m_pathScriptTemplates = "Templates/"; 21 | 22 | /// 23 | /// 資料表(txt) 存放路徑 24 | /// 25 | public string m_pathGameTable = "GameTable/"; 26 | 27 | /// 28 | /// 資料類別 存放路徑 29 | /// 30 | public string m_pathTableClass = "Generate/TableClass/"; 31 | 32 | /// 33 | /// Scriptable Asset 存放路徑 34 | /// 35 | public string m_pathScriptableAsset = "Generate/Resources/ClientDataBase/"; 36 | 37 | /// 38 | /// Scriptable Script 存放路徑 39 | /// 40 | public string m_pathScriptableScripts = "Generate/Scriptable/Script/"; 41 | 42 | /// 43 | /// Scriptable Editor Script 存放路徑 44 | /// 45 | public string m_pathScriptableEditor = "Generate/Scriptable/Editor/"; 46 | 47 | 48 | /// 49 | /// 類別名稱 前綴 50 | /// EX: Table[FileName] 51 | /// 52 | public string m_nameClassPrefix = "Table"; 53 | 54 | /// 55 | /// Scriptable Asset 後綴 56 | /// EX: Table[FileName]Asset 57 | /// 58 | public string m_nameScriptableAssetSuffix = "Asset"; 59 | 60 | /// 61 | /// Scriptable Script 後綴 62 | /// EX: Table[FileName]Scriptable 63 | /// 64 | public string m_nameScriptableScriptSuffix = "Scriptable"; 65 | 66 | /// 67 | /// Scriptable Editor 後綴 68 | /// EX: Table[FileName]ScriptableEditor 69 | /// 70 | public string m_nameScriptableEditorSuffix = "ScriptableEditor"; 71 | 72 | 73 | /// 74 | /// 附檔名 .cs 75 | /// 76 | public string m_extensionTxt = ".txt"; 77 | 78 | /// 79 | /// 附檔名 .cs 80 | /// 81 | public string m_extensionCs = ".cs"; 82 | 83 | /// 84 | /// 附檔名 .asset 85 | /// 86 | public string m_extensionAsset = ".asset"; 87 | 88 | 89 | public string GetTemplatePathName(string name) 90 | { 91 | return m_root + m_pathScriptTemplates + name + m_extensionTxt; 92 | } 93 | 94 | public string GetGameTablePathName(string name) 95 | { 96 | return m_root + m_pathGameTable + name + m_extensionTxt; 97 | } 98 | 99 | public string GetGameTablePath() 100 | { 101 | return m_root + m_pathGameTable; 102 | } 103 | 104 | public string GetTableClassPath() 105 | { 106 | return m_root + m_pathTableClass; 107 | } 108 | 109 | public string GetScriptableAssetPath() 110 | { 111 | return m_root + m_pathScriptableAsset; 112 | } 113 | 114 | public string GetScriptableScriptsPath() 115 | { 116 | return m_root + m_pathScriptableScripts; 117 | } 118 | 119 | public string GetScriptableEditorPath() 120 | { 121 | return m_root + m_pathScriptableEditor; 122 | } 123 | 124 | 125 | 126 | public string GetTableClassScriptName(string fileName, bool boolExtension = false) 127 | { 128 | return m_nameClassPrefix + fileName + (boolExtension ? m_extensionCs : ""); 129 | } 130 | 131 | public string GetScriptableScriptName(string fileName, bool boolExtension = false) 132 | { 133 | return m_nameClassPrefix + fileName + m_nameScriptableScriptSuffix + (boolExtension ? m_extensionCs : ""); 134 | } 135 | 136 | public string GetScriptableScriptEditorName(string fileName, bool boolExtension = false) 137 | { 138 | return m_nameClassPrefix + fileName + m_nameScriptableEditorSuffix + (boolExtension ? m_extensionCs : ""); 139 | } 140 | 141 | public string GetScriptableAssetName(string fileName, bool boolExtension = false) 142 | { 143 | return m_nameClassPrefix + fileName + m_nameScriptableAssetSuffix + (boolExtension ? m_extensionAsset : ""); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: .333333343 19 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 20 | blendWeights: 1 21 | textureQuality: 1 22 | anisotropicTextures: 0 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 0 26 | realtimeReflectionProbes: 0 27 | billboardsFaceCameraPosition: 0 28 | vSyncCount: 0 29 | lodBias: .300000012 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 4 32 | excludedTargetPlatforms: [] 33 | - serializedVersion: 2 34 | name: Fast 35 | pixelLightCount: 0 36 | shadows: 0 37 | shadowResolution: 0 38 | shadowProjection: 1 39 | shadowCascades: 1 40 | shadowDistance: 20 41 | shadowNearPlaneOffset: 2 42 | shadowCascade2Split: .333333343 43 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 44 | blendWeights: 2 45 | textureQuality: 0 46 | anisotropicTextures: 0 47 | antiAliasing: 0 48 | softParticles: 0 49 | softVegetation: 0 50 | realtimeReflectionProbes: 0 51 | billboardsFaceCameraPosition: 0 52 | vSyncCount: 0 53 | lodBias: .400000006 54 | maximumLODLevel: 0 55 | particleRaycastBudget: 16 56 | excludedTargetPlatforms: [] 57 | - serializedVersion: 2 58 | name: Simple 59 | pixelLightCount: 1 60 | shadows: 1 61 | shadowResolution: 0 62 | shadowProjection: 1 63 | shadowCascades: 1 64 | shadowDistance: 20 65 | shadowNearPlaneOffset: 2 66 | shadowCascade2Split: .333333343 67 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 68 | blendWeights: 2 69 | textureQuality: 0 70 | anisotropicTextures: 1 71 | antiAliasing: 0 72 | softParticles: 0 73 | softVegetation: 0 74 | realtimeReflectionProbes: 0 75 | billboardsFaceCameraPosition: 0 76 | vSyncCount: 0 77 | lodBias: .699999988 78 | maximumLODLevel: 0 79 | particleRaycastBudget: 64 80 | excludedTargetPlatforms: [] 81 | - serializedVersion: 2 82 | name: Good 83 | pixelLightCount: 2 84 | shadows: 2 85 | shadowResolution: 1 86 | shadowProjection: 1 87 | shadowCascades: 2 88 | shadowDistance: 40 89 | shadowNearPlaneOffset: 2 90 | shadowCascade2Split: .333333343 91 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 92 | blendWeights: 2 93 | textureQuality: 0 94 | anisotropicTextures: 1 95 | antiAliasing: 0 96 | softParticles: 0 97 | softVegetation: 1 98 | realtimeReflectionProbes: 1 99 | billboardsFaceCameraPosition: 1 100 | vSyncCount: 1 101 | lodBias: 1 102 | maximumLODLevel: 0 103 | particleRaycastBudget: 256 104 | excludedTargetPlatforms: [] 105 | - serializedVersion: 2 106 | name: Beautiful 107 | pixelLightCount: 3 108 | shadows: 2 109 | shadowResolution: 2 110 | shadowProjection: 1 111 | shadowCascades: 2 112 | shadowDistance: 70 113 | shadowNearPlaneOffset: 2 114 | shadowCascade2Split: .333333343 115 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 116 | blendWeights: 4 117 | textureQuality: 0 118 | anisotropicTextures: 2 119 | antiAliasing: 2 120 | softParticles: 1 121 | softVegetation: 1 122 | realtimeReflectionProbes: 1 123 | billboardsFaceCameraPosition: 1 124 | vSyncCount: 1 125 | lodBias: 1.5 126 | maximumLODLevel: 0 127 | particleRaycastBudget: 1024 128 | excludedTargetPlatforms: [] 129 | - serializedVersion: 2 130 | name: Fantastic 131 | pixelLightCount: 4 132 | shadows: 2 133 | shadowResolution: 2 134 | shadowProjection: 1 135 | shadowCascades: 4 136 | shadowDistance: 150 137 | shadowNearPlaneOffset: 2 138 | shadowCascade2Split: .333333343 139 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 140 | blendWeights: 4 141 | textureQuality: 0 142 | anisotropicTextures: 2 143 | antiAliasing: 2 144 | softParticles: 1 145 | softVegetation: 1 146 | realtimeReflectionProbes: 1 147 | billboardsFaceCameraPosition: 1 148 | vSyncCount: 1 149 | lodBias: 2 150 | maximumLODLevel: 0 151 | particleRaycastBudget: 4096 152 | excludedTargetPlatforms: [] 153 | m_PerPlatformDefaultQuality: 154 | Android: 2 155 | BlackBerry: 2 156 | GLES Emulation: 5 157 | Nintendo 3DS: 5 158 | PS3: 5 159 | PS4: 5 160 | PSM: 5 161 | PSP2: 2 162 | Samsung TV: 2 163 | Standalone: 5 164 | Tizen: 2 165 | WP8: 5 166 | Web: 5 167 | WebGL: 3 168 | Wii U: 5 169 | Windows Store Apps: 5 170 | XBOX360: 5 171 | XboxOne: 5 172 | iPhone: 2 173 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/UtilityEditor.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : UtilityEditor.cs 4 | **********************************************************/ 5 | using UnityEngine; 6 | using UnityEditor; 7 | 8 | namespace ClientDataBase 9 | { 10 | public class UtilityEditor 11 | { 12 | /// 13 | /// 建立資料夾,自動建子資料夾 14 | /// EX: GameResources/Prefabs/Sprites/Enemy 15 | /// 16 | /// 路徑層級,從 Assets 下一層資料夾開始 17 | /// 資料夾是否存在 18 | public static bool CreateFolder(string name) 19 | { 20 | //路徑字串開頭如果是 Assets,進行剃除 21 | if (name.StartsWith("Assets/")) 22 | name = name.Replace("Assets/", ""); 23 | 24 | //路徑字串最後如果有 / ,進行剃除 25 | if (name[name.Length - 1] == '/') 26 | name = name.Substring(0, name.Length - 1); 27 | 28 | 29 | if (System.IO.Directory.Exists(Application.dataPath + "/" + name)) 30 | { 31 | //Debug.Log("Folder [ Assets/" + name + " ] is Exist!!"); 32 | return false; 33 | } 34 | else 35 | { 36 | System.IO.Directory.CreateDirectory(Application.dataPath + "/" + name); 37 | AssetDatabase.Refresh(); 38 | 39 | //Debug.Log("Folder [ Assets/" + name + " ] is Create!!"); 40 | return true; 41 | } 42 | } 43 | 44 | 45 | /// 46 | /// 通用按鈕 47 | /// 48 | /// 按鈕名稱 49 | /// 是否按下 50 | public static bool GetCommonButton(string btnName) 51 | { 52 | GUIStyle BtnStyle = new GUIStyle(GUI.skin.button); 53 | BtnStyle.fontSize = 25; 54 | BtnStyle.fixedHeight = 50; 55 | 56 | return GUILayout.Button(btnName, BtnStyle); 57 | } 58 | 59 | 60 | /// 61 | /// 橫向頁籤 62 | /// 63 | /// 名稱 64 | /// 選擇的index 65 | /// 選擇的index 66 | public static int Tabs(string[] options, int selected) 67 | { 68 | const float DarkGray = 0.6f; 69 | const float LightGray = 0.9f; 70 | const float StartSpace = 10; 71 | 72 | GUILayout.Space(StartSpace); 73 | Color storeColor = GUI.backgroundColor; 74 | Color highlightCol = new Color(LightGray, LightGray, LightGray); 75 | Color bgCol = new Color(DarkGray, DarkGray, DarkGray); 76 | 77 | GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); 78 | buttonStyle.padding.bottom = 8; 79 | 80 | GUILayout.BeginHorizontal(); 81 | { 82 | for (int i = 0; i < options.Length; ++i) 83 | { 84 | GUI.backgroundColor = i == selected ? highlightCol : bgCol; 85 | if (GUILayout.Button(options[i], buttonStyle)) 86 | { 87 | selected = i; 88 | } 89 | } 90 | } 91 | GUILayout.EndHorizontal(); 92 | 93 | GUI.backgroundColor = storeColor; 94 | 95 | var texture = new Texture2D(1, 1); 96 | texture.SetPixel(0, 0, highlightCol); 97 | texture.Apply(); 98 | GUI.DrawTexture(new Rect(0, buttonStyle.lineHeight + buttonStyle.border.top + buttonStyle.margin.top + StartSpace, Screen.width, 4), texture); 99 | 100 | return selected; 101 | } 102 | 103 | /// 104 | /// 顯示Loading畫面 105 | /// 106 | public static void ShowLoading() 107 | { 108 | var texture = new Texture2D(1, 1); 109 | texture.SetPixel(0, 0, new Color(0, 0, 0, 0.6f)); 110 | texture.Apply(); 111 | GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), texture); 112 | 113 | GUIStyle LableStyle = new GUIStyle(GUI.skin.label); 114 | LableStyle.fontSize = 40; 115 | LableStyle.alignment = TextAnchor.MiddleCenter; 116 | GUI.Label(new Rect(0, 0, Screen.width, Screen.height), "Loading...", LableStyle); 117 | } 118 | 119 | /// 120 | /// 讀取路徑下所有資料 121 | /// 122 | /// 路徑 123 | public static Object[] LoadAllAssetsAtPath(string path) 124 | { 125 | if (path.EndsWith("/")) 126 | { 127 | path = path.TrimEnd('/'); 128 | } 129 | string[] GUIDs = AssetDatabase.FindAssets("", new string[] { path }); 130 | Object[] objectList = new Object[GUIDs.Length]; 131 | for (int index = 0; index < GUIDs.Length; index++) 132 | { 133 | string guid = GUIDs[index]; 134 | string assetPath = AssetDatabase.GUIDToAssetPath(guid); 135 | Object asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)) as Object; 136 | objectList[index] = asset; 137 | } 138 | 139 | return objectList; 140 | } 141 | 142 | } 143 | } 144 | 145 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Utility/SerializableDictionary.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : SerializableDictionary.cs 4 | **********************************************************/ 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace ClientDataBase 9 | { 10 | [System.Serializable()] 11 | public class SerializableDictionary : IDictionary, UnityEngine.ISerializationCallbackReceiver 12 | { 13 | 14 | #region Fields 15 | 16 | [System.NonSerialized()] 17 | private Dictionary _dict; 18 | 19 | #endregion 20 | 21 | #region IDictionary Interface 22 | 23 | public int Count 24 | { 25 | get { return (_dict != null) ? _dict.Count : 0; } 26 | } 27 | 28 | public void Add(TKey key, TValue value) 29 | { 30 | if (_dict == null) _dict = new Dictionary(); 31 | _dict.Add(key, value); 32 | } 33 | 34 | public bool ContainsKey(TKey key) 35 | { 36 | if (_dict == null) return false; 37 | return _dict.ContainsKey(key); 38 | } 39 | 40 | public ICollection Keys 41 | { 42 | get 43 | { 44 | if (_dict == null) _dict = new Dictionary(); 45 | return _dict.Keys; 46 | } 47 | } 48 | 49 | public bool Remove(TKey key) 50 | { 51 | if (_dict == null) return false; 52 | return _dict.Remove(key); 53 | } 54 | 55 | public bool TryGetValue(TKey key, out TValue value) 56 | { 57 | if (_dict == null) 58 | { 59 | value = default(TValue); 60 | return false; 61 | } 62 | return _dict.TryGetValue(key, out value); 63 | } 64 | 65 | public ICollection Values 66 | { 67 | get 68 | { 69 | if (_dict == null) _dict = new Dictionary(); 70 | return _dict.Values; 71 | } 72 | } 73 | 74 | public TValue this[TKey key] 75 | { 76 | get 77 | { 78 | if (_dict == null) throw new KeyNotFoundException(); 79 | return _dict[key]; 80 | } 81 | set 82 | { 83 | if (_dict == null) _dict = new Dictionary(); 84 | _dict[key] = value; 85 | } 86 | } 87 | 88 | public void Clear() 89 | { 90 | if (_dict != null) _dict.Clear(); 91 | } 92 | 93 | void ICollection>.Add(KeyValuePair item) 94 | { 95 | if (_dict == null) _dict = new Dictionary(); 96 | (_dict as ICollection>).Add(item); 97 | } 98 | 99 | bool ICollection>.Contains(KeyValuePair item) 100 | { 101 | if (_dict == null) return false; 102 | return (_dict as ICollection>).Contains(item); 103 | } 104 | 105 | void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) 106 | { 107 | if (_dict == null) return; 108 | (_dict as ICollection>).CopyTo(array, arrayIndex); 109 | } 110 | 111 | bool ICollection>.Remove(KeyValuePair item) 112 | { 113 | if (_dict == null) return false; 114 | return (_dict as ICollection>).Remove(item); 115 | } 116 | 117 | bool ICollection>.IsReadOnly 118 | { 119 | get { return false; } 120 | } 121 | 122 | public Dictionary.Enumerator GetEnumerator() 123 | { 124 | if (_dict == null) return default(Dictionary.Enumerator); 125 | return _dict.GetEnumerator(); 126 | } 127 | 128 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 129 | { 130 | if (_dict == null) return Enumerable.Empty>().GetEnumerator(); 131 | return _dict.GetEnumerator(); 132 | } 133 | 134 | IEnumerator> IEnumerable>.GetEnumerator() 135 | { 136 | if (_dict == null) return Enumerable.Empty>().GetEnumerator(); 137 | return _dict.GetEnumerator(); 138 | } 139 | 140 | #endregion 141 | 142 | #region ISerializationCallbackReceiver 143 | 144 | [UnityEngine.SerializeField()] 145 | private TKey[] _keys; 146 | [UnityEngine.SerializeField()] 147 | private TValue[] _values; 148 | 149 | void UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() 150 | { 151 | if (_keys != null && _values != null) 152 | { 153 | if (_dict == null) _dict = new Dictionary(_keys.Length); 154 | else _dict.Clear(); 155 | for (int i = 0; i < _keys.Length; i++) 156 | { 157 | if (i < _values.Length) 158 | _dict[_keys[i]] = _values[i]; 159 | else 160 | _dict[_keys[i]] = default(TValue); 161 | } 162 | } 163 | 164 | _keys = null; 165 | _values = null; 166 | } 167 | 168 | void UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize() 169 | { 170 | if (_dict == null || _dict.Count == 0) 171 | { 172 | _keys = null; 173 | _values = null; 174 | } 175 | else 176 | { 177 | int cnt = _dict.Count; 178 | _keys = new TKey[cnt]; 179 | _values = new TValue[cnt]; 180 | int i = 0; 181 | var e = _dict.GetEnumerator(); 182 | while (e.MoveNext()) 183 | { 184 | _keys[i] = e.Current.Key; 185 | _values[i] = e.Current.Value; 186 | i++; 187 | } 188 | } 189 | } 190 | 191 | #endregion 192 | 193 | } 194 | } -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: .00100000005 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: .00100000005 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: .00100000005 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: .00100000005 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: .00100000005 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: .00100000005 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: .100000001 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: .100000001 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: .100000001 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: .189999998 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: .189999998 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: .00100000005 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: .00100000005 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: .00100000005 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: .00100000005 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: .00100000005 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: .00100000005 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: .00100000005 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /Documentation/zh-tw/zh-tw.md: -------------------------------------------------------------------------------- 1 | # Client DataBase 本地資料庫系統 V0.0.1b 2 | 方便讀取企劃 Excel 表格,將會自動產生相應程式碼與 [Scriptable Object](https://unity3d.com/cn/learn/tutorials/modules/beginner/live-training-archive/scriptable-objects) Asset 3 | 4 |

5 |

6 | 7 | 8 | ## 資料夾結構 9 | ``` 10 | Assets/ClientDataBase/ 11 | ├── GameTable/ --- Excel 匯出 tab 分隔資料表(txt) 12 | ├── Generate/ --- 自動產出之相關資源 13 | ├── Resources/ --- Scriptable Object Asset 14 | ├── Scriptable/ --- Scriptable Object Script 15 | └── TableClass/ --- 資料列類別 16 | ├── Resources/ --- 設定檔 17 | ├── Scripts/ --- 相關程式碼 18 | ├── Base/ --- 基底類別 19 | ├── Config/ --- 配置設定 20 | ├── Editor/ --- 編輯器工具 21 | └── Utility/ --- 常用工具 22 | └── Templates/ --- 程式碼版型 23 | ``` 24 | 25 | :warning: Generate 資料夾是由工具自動產生 26 |


27 | 28 | ## 配置檔案 29 | 方便修改資源路徑、Script 名稱 30 | ``` 31 | Assets/ClientDataBase/Resources/Client DataBase Config.asset 32 | ``` 33 | 34 | 35 | | 分類 | 名稱 | 描述 | 36 | | ------ | ----------- | ----------- | 37 | | Check || 38 | || Game Table Check | 檢查資料表格式,判斷開頭字串是否相符 | 39 | | Path | | | 40 | || ROOT | 根目錄 | 41 | || Script Templates Path | 程式碼版型路徑 | 42 | || Game Table Path | 資料表路徑 | 43 | || Table Class Path | "自動產出" 資料列類別路徑 | 44 | || Scriptable Asset Path | "自動產出" Scriptable Object Asset 路徑 | 45 | || Scriptable Scripts Path | "自動產出" Scriptable Object Script 路徑 | 46 | || Scriptable Editor Path | "自動產出" Scriptable Object Editor Script 路徑 | 47 | | Name | | | 48 | || Class Name Prefix | "自動產出" 資料列類別名稱 | 49 | || Scriptable Asset Suffix | "自動產出" Scriptable Object Asset 名稱 | 50 | || Scriptable Script Suffix | "自動產出" Scriptable Object Script 名稱 | 51 | || Scriptable Editor Suffix | "自動產出" Scriptable Object Editor Script 名稱 | 52 |


53 | 54 | ## 支援資料型態 55 | + string 56 | + int 57 | + long 58 | + float 59 | + double 60 | + bool 61 | + Vector2 62 | + Vector3 63 | + string[] 64 | + int[] 65 | + long[] 66 | + float[] 67 | + double[] 68 | + bool[] 69 | + Vector2[] 70 | + Vector3[] 71 |


72 | 73 | ## Excel 資料表格式 74 | + [一般 資料表格式範例](https://docs.google.com/spreadsheets/d/1jEI_wGavArBLVHQY89_w7iMdoyuVVtkLDYYXrI_lZsw/edit#gid=1809851094) 75 | 76 | + [陣列 資料表格式範例](https://docs.google.com/spreadsheets/d/1jEI_wGavArBLVHQY89_w7iMdoyuVVtkLDYYXrI_lZsw/edit#gid=0) 77 | 78 |
79 | :warning: 幾個要注意的地方 80 | + 表格 "第一列" 為變數描述 (Summary) 81 | + 表格 "第二列" 為變數名稱 (Variable name) 82 | + 表格 "第三列" 為資料型態 (Data type) 83 | + 表格 "第一行" id 為讀取資料每列的 Key 84 | + bool 類型:T為true,F為false 85 | + Vector2、Vector3 類型:用逗號分隔 86 | + 陣列表示方法:第二列變數名稱最後面加入 "[]",相同名稱為同個陣列數值 87 |


88 | 89 | ## 使用方式 90 | 1. 從 Excel 或是 Google Excel 匯出 Tab分隔資料 (.tsv) 91 | 2. 附檔名改為 .txt 92 | 3. 將 .txt 檔案放入 Assets/ClientDataBase/GameTable 中 93 | 4. 選擇資源產生方式 94 | + 將 GameTable 下所有 .txt 表格資料產出資源
95 | Unity Menu -> Assets -> Client DataBase -> Update All 96 | 97 | + 使用 視窗工具 選擇檔案後,建立或是更新資源
98 | Unity Menu -> Assets -> Client DataBase -> Window 99 | 100 | 101 | 102 | 頁籤 Create:選擇一個或多個 .txt 表格資料後,按下 Create 按鈕建立資源 103 | 104 | 頁籤 Update:選擇一個或多個 資料表 Scriptable Object Asset 後,按下 Update 按鈕重新從 .txt 表格 再次更新資料 105 | 106 | 5. 將會自動產生相應程式碼與 Scriptable Object Asset 107 | 6. 讀取 Scriptable Object Asset 後,呼叫以下方法取得每列資料 108 | 109 | ```cs 110 | public Table[FileName] GetData(string id) 111 | ``` 112 |

113 | 114 | ## 範例實作 (使用Google Excel) 115 | 1. Excel 資料表準備 116 | + [範例資料表](https://docs.google.com/spreadsheets/d/1jEI_wGavArBLVHQY89_w7iMdoyuVVtkLDYYXrI_lZsw/edit#gid=457664276) 117 | 118 | 2. 匯出 Tab分隔資料 (.tsv) 119 | 檔案 -> 下載 -> 定位鍵分隔值檔案(.tsv,目前工作表) 120 | 121 | 122 | 123 | 3. 附檔名改為 .txt,並將 .txt 檔案放入 Assets/ClientDataBase/GameTable 中 124 | 125 | 126 | 127 | 4. 工具自動產出程式碼 & 資源,期間會跳出視窗處理 128 | 129 | Unity Menu -> Assets -> Client DataBase -> Update All 130 | 131 | 處理完成後會產生 Generate 資料夾,檔案結構如下 132 | ``` 133 | Assets/ClientDataBase/ 134 | ├── Generate/ 135 | ├── Resources/ 136 | └── ClientDataBase/ 137 | └── TableSampleAsset.asset --- Scriptable Object Asset 138 | 139 | ├── Scriptable/ 140 | ├── Editor/ 141 | └── TableSampleScriptableEditor.cs --- Scriptable Object Editor Script 142 | └── Script/ 143 | └── TableSampleScriptable.cs --- Scriptable Object Script 144 | 145 | └── TableClass/ 146 | └── TableSample.cs --- 資料列類別 147 | ``` 148 |
149 | 5. 讀取 Scriptable Object Asset 方式 150 | + A. 直接讀取 Scriptable Object Asset,使用 Key 取得資料 151 | ```cs 152 | using UnityEngine; 153 | 154 | public class LoadTableNormal : MonoBehaviour 155 | { 156 | const string c_path = "ClientDataBase/TableSampleAsset"; 157 | const string c_key = "Sample001"; 158 | 159 | void Start() 160 | { 161 | TableSampleScriptable tableSampleScriptable = Resources.Load(c_path); 162 | 163 | TableSample tableSample = tableSampleScriptable.GetData(c_key); 164 | 165 | print(string.Format("{0} : {1}", c_key, tableSample.knowledge)); 166 | print(string.Format("{0} : {1}", c_key, tableSample.pos[0])); 167 | } 168 | } 169 | ``` 170 |
171 | 172 | + B. 使用 ClientDataBaseManager.cs (管理類別),方便讀取與管理 Scriptable Object Asset、設定檔 173 | 174 | ``` 175 | Assets/ClientDataBase/Scripts/ClientDataBaseManager.cs 176 | ``` 177 | 178 | 1.在 ClientDataBaseManager.cs 建構子中註冊 179 | ```cs 180 | public class ClientDataBaseManager : Singleton 181 | { 182 | ... 183 | public ClientDataBaseManager() 184 | { 185 | Register(typeof(TableSampleScriptable), LoadTable(TableSampleScriptable.m_gameTableName)); 186 | } 187 | ... 188 | } 189 | ``` 190 | 2.任意一處取得資料表與資料列 191 | ```cs 192 | using UnityEngine; 193 | 194 | public class LoadTableManager : MonoBehaviour 195 | { 196 | const string c_key = "Sample003"; 197 | 198 | void Start() 199 | { 200 | TableSampleScriptable tableSampleScriptable = ClientDataBaseManager.Instance.GetTable(); 201 | TableSample tableSample = tableSampleScriptable.GetData(c_key); 202 | 203 | print(string.Format("{0} : {1}", c_key, tableSample.knowledge)); 204 | print(string.Format("{0} : {1}", c_key, tableSample.pos[0])); 205 | } 206 | } 207 | ``` 208 | 209 | 210 |

211 | 212 | ##支援 & 問題回報 213 | Blog:[http://k79k06k02k.com/blog](http://k79k06k02k.com/blog)
214 | Facebook:[https://www.facebook.com/k79k06k02k](https://www.facebook.com/k79k06k02k)
215 | Email:k79k06k02k@gmail.com

216 | 217 | [![CC-by-sa.png](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
218 | 本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權。
219 | This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 220 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseEditorWindow.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ClientDataBaseEditorWindow.cs 4 | **********************************************************/ 5 | using UnityEngine; 6 | using UnityEditor; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace ClientDataBase 13 | { 14 | public class ClientDataBaseEditorWindow : EditorWindow 15 | { 16 | //按下執行按鈕 17 | bool _boolExecuteButtonClick = false; 18 | float _floatWaitForExecute = 0.1f; 19 | 20 | //一次執行的開始 21 | bool _boolStartCreate = false; 22 | 23 | //是否是更新全部 24 | bool _boolUpdateAll = false; 25 | 26 | //等待 Application Compiling Script 27 | bool _boolNeedToAttach = false; 28 | float _floatWaitForCompile = 1; 29 | 30 | string[] _types = new string[] { "Create", "Update" }; 31 | int _intTabIndex = 0; 32 | 33 | List _objList; 34 | int _intNowCount = 0; 35 | int _inttotalCount = 0; 36 | 37 | Vector2 _scrollPos; 38 | GUIStyle _btnStyle; 39 | 40 | [MenuItem("Tools/Client DataBase/Window")] 41 | [MenuItem("Assets/Client DataBase/Window", false, 110)] 42 | public static void ShowWindow() 43 | { 44 | EditorWindow editorWindow = EditorWindow.GetWindow(typeof(ClientDataBaseEditorWindow)); 45 | editorWindow.position = new Rect(editorWindow.position.xMin + 100f, editorWindow.position.yMin + 100f, 400f, 400f); 46 | editorWindow.autoRepaintOnSceneChange = true; 47 | editorWindow.Show(); 48 | editorWindow.titleContent = new GUIContent("Client DataBase Tool"); 49 | } 50 | 51 | [MenuItem("Tools/Client DataBase/Update All")] 52 | [MenuItem("Assets/Client DataBase/Update All", false, 110)] 53 | public static void UpdateAll() 54 | { 55 | ClientDataBaseEditorWindow window = EditorWindow.GetWindow(); 56 | window._objList = UtilityEditor.LoadAllAssetsAtPath(ClientDataBaseManager.Instance.m_config.GetGameTablePath()).ToList(); 57 | 58 | if (window._objList.Count == 0) 59 | { 60 | Debug.Log("No GameTable file (.txt)"); 61 | window.Close(); 62 | return; 63 | } 64 | 65 | window._boolUpdateAll = true; 66 | window._boolStartCreate = true; 67 | window._boolExecuteButtonClick = true; 68 | } 69 | 70 | 71 | void Update() 72 | { 73 | //等待 Application Compiling Script,建立 ScriptableObject Asset 74 | if (_boolNeedToAttach) 75 | { 76 | _floatWaitForCompile -= 0.01f; 77 | 78 | if (_floatWaitForCompile <= 0) 79 | { 80 | if (!EditorApplication.isCompiling) 81 | { 82 | foreach (Object go in _objList) 83 | { 84 | string path = AssetDatabase.GetAssetPath(go); 85 | string fileName = Path.GetFileNameWithoutExtension(path); 86 | string scriptableScriptName = ClientDataBaseManager.Instance.m_config.GetScriptableScriptName(fileName, true); 87 | string scriptableAssetName = ClientDataBaseManager.Instance.m_config.GetScriptableAssetName(fileName, true); 88 | 89 | _intNowCount++; 90 | UpdateProgressBar("Generate Scriptable Assets", string.Format("[File Name:{0}]", scriptableAssetName)); 91 | 92 | if (ClientDataBaseParse.Instance.CreateScriptableAssets(scriptableScriptName, scriptableAssetName) == false) 93 | continue; 94 | } 95 | 96 | _boolStartCreate = false; 97 | _boolNeedToAttach = false; 98 | _floatWaitForCompile = 1; 99 | EditorUtility.ClearProgressBar(); 100 | 101 | if (_boolUpdateAll) 102 | this.Close(); 103 | } 104 | } 105 | } 106 | 107 | //點下按鈕後,延遲執行,先讓 Loading 畫面出來 108 | if (_boolExecuteButtonClick) 109 | { 110 | _floatWaitForExecute -= 0.01f; 111 | if (_floatWaitForExecute <= 0) 112 | { 113 | Execute(); 114 | 115 | _boolExecuteButtonClick = false; 116 | _floatWaitForExecute = 0.1f; 117 | } 118 | } 119 | } 120 | 121 | void OnSelectionChange() 122 | { 123 | Repaint(); 124 | } 125 | 126 | void OnGUI() 127 | { 128 | _btnStyle = new GUIStyle(GUI.skin.button); 129 | _btnStyle.fontSize = 16; 130 | _btnStyle.alignment = TextAnchor.MiddleLeft; 131 | 132 | //遮罩 133 | if (_boolStartCreate) 134 | GUI.enabled = false; 135 | 136 | 137 | _intTabIndex = UtilityEditor.Tabs(_types, _intTabIndex); 138 | GUILayout.Space(10); 139 | 140 | //還沒開始時才需要抓物件 141 | if (_boolStartCreate == false && _boolUpdateAll == false) 142 | _objList = Selection.objects.ToList(); 143 | 144 | 145 | //排除 146 | for (int i = _objList.Count - 1; i >= 0; i--) 147 | { 148 | if (GetFiltered(_objList[i])) 149 | _objList.Remove(_objList[i]); 150 | } 151 | EditorGUILayout.BeginHorizontal(); 152 | EditorGUILayout.LabelField("Choose GameTable Asset", EditorStyles.boldLabel, GUILayout.Width(200)); 153 | EditorGUILayout.LabelField("Count : " + _objList.Count, EditorStyles.boldLabel, GUILayout.Width(100)); 154 | if (GUILayout.Button("Update All")) 155 | { 156 | UpdateAll(); 157 | } 158 | EditorGUILayout.EndHorizontal(); 159 | GUILayout.Space(10); 160 | 161 | if (_objList.Count == 0) 162 | { 163 | EditorGUILayout.HelpBox(GetHelpString(), MessageType.Warning); 164 | return; 165 | } 166 | 167 | //字母排序 168 | _objList.Sort(delegate (Object a, Object b) 169 | { 170 | return a.name.CompareTo(b.name); 171 | }); 172 | 173 | EditorGUILayout.BeginVertical(); 174 | _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, false, false); 175 | EditorGUILayout.Space(); 176 | 177 | foreach (Object go in _objList) 178 | { 179 | if (GUILayout.Button(go.name, _btnStyle)) 180 | EditorGUIUtility.PingObject(go); 181 | } 182 | 183 | EditorGUILayout.EndScrollView(); 184 | EditorGUILayout.EndVertical(); 185 | 186 | if (UtilityEditor.GetCommonButton(_types[_intTabIndex])) 187 | { 188 | if (EditorApplication.isCompiling) 189 | { 190 | Debug.LogError("After wait application compiling then try again."); 191 | return; 192 | } 193 | 194 | _boolStartCreate = true; 195 | _boolExecuteButtonClick = true; 196 | } 197 | 198 | if (_boolStartCreate) 199 | { 200 | GUI.enabled = true; 201 | UtilityEditor.ShowLoading(); 202 | } 203 | 204 | } 205 | 206 | void OnDestroy() 207 | { 208 | if (_boolNeedToAttach) 209 | Debug.LogError("Please wait complete, Or may cause a crash..."); 210 | 211 | EditorUtility.ClearProgressBar(); 212 | } 213 | 214 | void Execute() 215 | { 216 | switch (_intTabIndex) 217 | { 218 | case 0: 219 | CreateAsset(); 220 | break; 221 | 222 | case 1: 223 | UpdateAsset(); 224 | break; 225 | } 226 | } 227 | 228 | void CreateAsset() 229 | { 230 | //乘2是因為把 Script 與 Scriptable Asset 分開處理,必須先等 Application Compiling 完,才找的到 Scriptable Class,最後才能透過 Class 建立 Scriptable Asset 231 | //加1是等 Application Compiling 的區間 232 | _inttotalCount = _objList.Count * 2 + 1; 233 | 234 | _intNowCount = 0; 235 | 236 | foreach (Object go in _objList) 237 | { 238 | string path = AssetDatabase.GetAssetPath(go); 239 | 240 | _intNowCount++; 241 | 242 | string fileName = Path.GetFileName(path); 243 | 244 | UpdateProgressBar("Generate GameTable Script", string.Format("[File Name:{0}]", fileName)); 245 | 246 | if (ClientDataBaseParse.Instance.LoadGameTable(go) == false) 247 | continue; 248 | } 249 | 250 | _intNowCount++; 251 | UpdateProgressBar("Please Wait", "Wait Application Compiling...."); 252 | _boolNeedToAttach = true; 253 | } 254 | 255 | void UpdateAsset() 256 | { 257 | foreach (Object go in _objList) 258 | { 259 | ScriptableObjectBase script = (ScriptableObjectBase)go; 260 | 261 | if (script.LoadGameTable() == false) 262 | continue; 263 | } 264 | _boolStartCreate = false; 265 | } 266 | 267 | 268 | bool GetFiltered(Object obj) 269 | { 270 | string path = AssetDatabase.GetAssetPath(obj); 271 | string extension = Path.GetExtension(path); 272 | 273 | switch (_intTabIndex) 274 | { 275 | case 0: 276 | return extension != ClientDataBaseManager.Instance.m_config.m_extensionTxt || ((TextAsset)obj).ToString().StartsWith(ClientDataBaseManager.Instance.m_config.m_gameTableCheck) == false; 277 | 278 | case 1: 279 | return extension != ClientDataBaseManager.Instance.m_config.m_extensionAsset || obj.name == ClientDataBaseManager.Instance.m_config.name; 280 | 281 | default: 282 | return true; 283 | } 284 | } 285 | 286 | 287 | string GetHelpString() 288 | { 289 | StringBuilder sb = new StringBuilder(); 290 | sb.Append("No Source." + "\n\n"); 291 | sb.Append("Please Check Select Asset:" + "\n"); 292 | 293 | switch (_intTabIndex) 294 | { 295 | case 0: 296 | sb.Append("1.Asset in Project" + "\n"); 297 | sb.Append("2.Asset extension must [" + ClientDataBaseManager.Instance.m_config.m_extensionTxt + "]" + "\n"); 298 | sb.Append("3.Asset content must table."); 299 | break; 300 | 301 | case 1: 302 | sb.Append("1.Asset in Project" + "\n"); 303 | sb.Append("2.Asset must ScriptableObject Asset"); 304 | break; 305 | 306 | default: 307 | break; 308 | } 309 | 310 | return sb.ToString(); 311 | } 312 | 313 | 314 | void UpdateProgressBar(string title, string info) 315 | { 316 | float process = _intNowCount / (float)_inttotalCount; 317 | EditorUtility.DisplayProgressBar(title, string.Format("[{0}%] {1}", (int)(process * 100), info), process); 318 | } 319 | } 320 | } -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 8 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 4 9 | targetDevice: 2 10 | useOnDemandResources: 0 11 | accelerometerFrequency: 60 12 | companyName: arkai 13 | productName: ClientDataBase 14 | defaultCursor: {fileID: 0} 15 | cursorHotspot: {x: 0, y: 0} 16 | m_ShowUnitySplashScreen: 1 17 | m_VirtualRealitySplashScreen: {fileID: 0} 18 | defaultScreenWidth: 1024 19 | defaultScreenHeight: 768 20 | defaultScreenWidthWeb: 960 21 | defaultScreenHeightWeb: 600 22 | m_RenderingPath: 1 23 | m_MobileRenderingPath: 1 24 | m_ActiveColorSpace: 0 25 | m_MTRendering: 1 26 | m_MobileMTRendering: 0 27 | m_Stereoscopic3D: 0 28 | iosShowActivityIndicatorOnLoading: -1 29 | androidShowActivityIndicatorOnLoading: -1 30 | iosAppInBackgroundBehavior: 0 31 | displayResolutionDialog: 1 32 | iosAllowHTTPDownload: 1 33 | allowedAutorotateToPortrait: 1 34 | allowedAutorotateToPortraitUpsideDown: 1 35 | allowedAutorotateToLandscapeRight: 1 36 | allowedAutorotateToLandscapeLeft: 1 37 | useOSAutorotation: 1 38 | use32BitDisplayBuffer: 1 39 | disableDepthAndStencilBuffers: 0 40 | defaultIsFullScreen: 1 41 | defaultIsNativeResolution: 1 42 | runInBackground: 0 43 | captureSingleScreen: 0 44 | Override IPod Music: 0 45 | Prepare IOS For Recording: 0 46 | submitAnalytics: 1 47 | usePlayerLog: 1 48 | bakeCollisionMeshes: 0 49 | forceSingleInstance: 0 50 | resizableWindow: 0 51 | useMacAppStoreValidation: 0 52 | gpuSkinning: 0 53 | xboxPIXTextureCapture: 0 54 | xboxEnableAvatar: 0 55 | xboxEnableKinect: 0 56 | xboxEnableKinectAutoTracking: 0 57 | xboxEnableFitness: 0 58 | visibleInBackground: 0 59 | allowFullscreenSwitch: 1 60 | macFullscreenMode: 2 61 | d3d9FullscreenMode: 1 62 | d3d11FullscreenMode: 1 63 | xboxSpeechDB: 0 64 | xboxEnableHeadOrientation: 0 65 | xboxEnableGuest: 0 66 | xboxEnablePIXSampling: 0 67 | xboxEnableEnableRenderThreadRunsJobs: 0 68 | n3dsDisableStereoscopicView: 0 69 | n3dsEnableSharedListOpt: 1 70 | n3dsEnableVSync: 0 71 | uiUse16BitDepthBuffer: 0 72 | ignoreAlphaClear: 0 73 | xboxOneResolution: 0 74 | xboxOneMonoLoggingLevel: 0 75 | ps3SplashScreen: {fileID: 0} 76 | videoMemoryForVertexBuffers: 0 77 | psp2PowerMode: 0 78 | psp2AcquireBGM: 1 79 | wiiUTVResolution: 0 80 | wiiUGamePadMSAA: 1 81 | wiiUSupportsNunchuk: 0 82 | wiiUSupportsClassicController: 0 83 | wiiUSupportsBalanceBoard: 0 84 | wiiUSupportsMotionPlus: 0 85 | wiiUSupportsProController: 0 86 | wiiUAllowScreenCapture: 1 87 | wiiUControllerCount: 0 88 | m_SupportedAspectRatios: 89 | 4:3: 1 90 | 5:4: 1 91 | 16:10: 1 92 | 16:9: 1 93 | Others: 1 94 | bundleIdentifier: com.arkai.ClientDataBase 95 | bundleVersion: 1.0 96 | preloadedAssets: [] 97 | metroEnableIndependentInputSource: 0 98 | metroEnableLowLatencyPresentationAPI: 0 99 | xboxOneDisableKinectGpuReservation: 0 100 | virtualRealitySupported: 0 101 | productGUID: 498efc57f9415c047b80937f4353d0d3 102 | AndroidBundleVersionCode: 1 103 | AndroidMinSdkVersion: 9 104 | AndroidPreferredInstallLocation: 1 105 | aotOptions: 106 | apiCompatibilityLevel: 2 107 | stripEngineCode: 1 108 | iPhoneStrippingLevel: 0 109 | iPhoneScriptCallOptimization: 0 110 | iPhoneBuildNumber: 0 111 | ForceInternetPermission: 0 112 | ForceSDCardPermission: 0 113 | CreateWallpaper: 0 114 | APKExpansionFiles: 0 115 | preloadShaders: 0 116 | StripUnusedMeshComponents: 0 117 | VertexChannelCompressionMask: 118 | serializedVersion: 2 119 | m_Bits: 238 120 | iPhoneSdkVersion: 988 121 | iPhoneTargetOSVersion: 22 122 | tvOSSdkVersion: 0 123 | tvOSTargetOSVersion: 900 124 | uIPrerenderedIcon: 0 125 | uIRequiresPersistentWiFi: 0 126 | uIRequiresFullScreen: 1 127 | uIStatusBarHidden: 1 128 | uIExitOnSuspend: 0 129 | uIStatusBarStyle: 0 130 | iPhoneSplashScreen: {fileID: 0} 131 | iPhoneHighResSplashScreen: {fileID: 0} 132 | iPhoneTallHighResSplashScreen: {fileID: 0} 133 | iPhone47inSplashScreen: {fileID: 0} 134 | iPhone55inPortraitSplashScreen: {fileID: 0} 135 | iPhone55inLandscapeSplashScreen: {fileID: 0} 136 | iPadPortraitSplashScreen: {fileID: 0} 137 | iPadHighResPortraitSplashScreen: {fileID: 0} 138 | iPadLandscapeSplashScreen: {fileID: 0} 139 | iPadHighResLandscapeSplashScreen: {fileID: 0} 140 | appleTVSplashScreen: {fileID: 0} 141 | tvOSSmallIconLayers: [] 142 | tvOSLargeIconLayers: [] 143 | tvOSTopShelfImageLayers: [] 144 | iOSLaunchScreenType: 0 145 | iOSLaunchScreenPortrait: {fileID: 0} 146 | iOSLaunchScreenLandscape: {fileID: 0} 147 | iOSLaunchScreenBackgroundColor: 148 | serializedVersion: 2 149 | rgba: 0 150 | iOSLaunchScreenFillPct: 100 151 | iOSLaunchScreenSize: 100 152 | iOSLaunchScreenCustomXibPath: 153 | iOSLaunchScreeniPadType: 0 154 | iOSLaunchScreeniPadImage: {fileID: 0} 155 | iOSLaunchScreeniPadBackgroundColor: 156 | serializedVersion: 2 157 | rgba: 0 158 | iOSLaunchScreeniPadFillPct: 100 159 | iOSLaunchScreeniPadSize: 100 160 | iOSLaunchScreeniPadCustomXibPath: 161 | iOSDeviceRequirements: [] 162 | AndroidTargetDevice: 0 163 | AndroidSplashScreenScale: 0 164 | androidSplashScreen: {fileID: 0} 165 | AndroidKeystoreName: 166 | AndroidKeyaliasName: 167 | AndroidTVCompatibility: 1 168 | AndroidIsGame: 1 169 | androidEnableBanner: 1 170 | m_AndroidBanners: 171 | - width: 320 172 | height: 180 173 | banner: {fileID: 0} 174 | androidGamepadSupportLevel: 0 175 | resolutionDialogBanner: {fileID: 0} 176 | m_BuildTargetIcons: 177 | - m_BuildTarget: 178 | m_Icons: 179 | - serializedVersion: 2 180 | m_Icon: {fileID: 0} 181 | m_Width: 128 182 | m_Height: 128 183 | m_BuildTargetBatching: [] 184 | m_BuildTargetGraphicsAPIs: [] 185 | webPlayerTemplate: APPLICATION:Default 186 | m_TemplateCustomTags: {} 187 | wiiUTitleID: 0005000011000000 188 | wiiUGroupID: 00010000 189 | wiiUCommonSaveSize: 4096 190 | wiiUAccountSaveSize: 2048 191 | wiiUOlvAccessKey: 0 192 | wiiUTinCode: 0 193 | wiiUJoinGameId: 0 194 | wiiUJoinGameModeMask: 0000000000000000 195 | wiiUCommonBossSize: 0 196 | wiiUAccountBossSize: 0 197 | wiiUAddOnUniqueIDs: [] 198 | wiiUMainThreadStackSize: 3072 199 | wiiULoaderThreadStackSize: 1024 200 | wiiUSystemHeapSize: 128 201 | wiiUTVStartupScreen: {fileID: 0} 202 | wiiUGamePadStartupScreen: {fileID: 0} 203 | wiiUDrcBufferDisabled: 0 204 | wiiUProfilerLibPath: 205 | actionOnDotNetUnhandledException: 1 206 | enableInternalProfiler: 0 207 | logObjCUncaughtExceptions: 1 208 | enableCrashReportAPI: 0 209 | locationUsageDescription: 210 | XboxTitleId: 211 | XboxImageXexPath: 212 | XboxSpaPath: 213 | XboxGenerateSpa: 0 214 | XboxDeployKinectResources: 0 215 | XboxSplashScreen: {fileID: 0} 216 | xboxEnableSpeech: 0 217 | xboxAdditionalTitleMemorySize: 0 218 | xboxDeployKinectHeadOrientation: 0 219 | xboxDeployKinectHeadPosition: 0 220 | ps3TitleConfigPath: 221 | ps3DLCConfigPath: 222 | ps3ThumbnailPath: 223 | ps3BackgroundPath: 224 | ps3SoundPath: 225 | ps3NPAgeRating: 12 226 | ps3TrophyCommId: 227 | ps3NpCommunicationPassphrase: 228 | ps3TrophyPackagePath: 229 | ps3BootCheckMaxSaveGameSizeKB: 128 230 | ps3TrophyCommSig: 231 | ps3SaveGameSlots: 1 232 | ps3TrialMode: 0 233 | ps3VideoMemoryForAudio: 0 234 | ps3EnableVerboseMemoryStats: 0 235 | ps3UseSPUForUmbra: 0 236 | ps3EnableMoveSupport: 1 237 | ps3DisableDolbyEncoding: 0 238 | ps4NPAgeRating: 12 239 | ps4NPTitleSecret: 240 | ps4NPTrophyPackPath: 241 | ps4ParentalLevel: 1 242 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 243 | ps4Category: 0 244 | ps4MasterVersion: 01.00 245 | ps4AppVersion: 01.00 246 | ps4AppType: 0 247 | ps4ParamSfxPath: 248 | ps4VideoOutPixelFormat: 0 249 | ps4VideoOutResolution: 4 250 | ps4PronunciationXMLPath: 251 | ps4PronunciationSIGPath: 252 | ps4BackgroundImagePath: 253 | ps4StartupImagePath: 254 | ps4SaveDataImagePath: 255 | ps4SdkOverride: 256 | ps4BGMPath: 257 | ps4ShareFilePath: 258 | ps4ShareOverlayImagePath: 259 | ps4PrivacyGuardImagePath: 260 | ps4NPtitleDatPath: 261 | ps4RemotePlayKeyAssignment: -1 262 | ps4RemotePlayKeyMappingDir: 263 | ps4PlayTogetherPlayerCount: 0 264 | ps4EnterButtonAssignment: 1 265 | ps4ApplicationParam1: 0 266 | ps4ApplicationParam2: 0 267 | ps4ApplicationParam3: 0 268 | ps4ApplicationParam4: 0 269 | ps4DownloadDataSize: 0 270 | ps4GarlicHeapSize: 2048 271 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 272 | ps4UseDebugIl2cppLibs: 0 273 | ps4pnSessions: 1 274 | ps4pnPresence: 1 275 | ps4pnFriends: 1 276 | ps4pnGameCustomData: 1 277 | playerPrefsSupport: 0 278 | ps4ReprojectionSupport: 0 279 | ps4UseAudio3dBackend: 0 280 | ps4SocialScreenEnabled: 0 281 | ps4Audio3dVirtualSpeakerCount: 14 282 | ps4attribCpuUsage: 0 283 | ps4PatchPkgPath: 284 | ps4PatchLatestPkgPath: 285 | ps4PatchChangeinfoPath: 286 | ps4attribUserManagement: 0 287 | ps4attribMoveSupport: 0 288 | ps4attrib3DSupport: 0 289 | ps4attribShareSupport: 0 290 | ps4attribExclusiveVR: 0 291 | ps4disableAutoHideSplash: 0 292 | ps4IncludedModules: [] 293 | monoEnv: 294 | psp2Splashimage: {fileID: 0} 295 | psp2NPTrophyPackPath: 296 | psp2NPSupportGBMorGJP: 0 297 | psp2NPAgeRating: 12 298 | psp2NPTitleDatPath: 299 | psp2NPCommsID: 300 | psp2NPCommunicationsID: 301 | psp2NPCommsPassphrase: 302 | psp2NPCommsSig: 303 | psp2ParamSfxPath: 304 | psp2ManualPath: 305 | psp2LiveAreaGatePath: 306 | psp2LiveAreaBackroundPath: 307 | psp2LiveAreaPath: 308 | psp2LiveAreaTrialPath: 309 | psp2PatchChangeInfoPath: 310 | psp2PatchOriginalPackage: 311 | psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui 312 | psp2KeystoneFile: 313 | psp2MemoryExpansionMode: 0 314 | psp2DRMType: 0 315 | psp2StorageType: 0 316 | psp2MediaCapacity: 0 317 | psp2DLCConfigPath: 318 | psp2ThumbnailPath: 319 | psp2BackgroundPath: 320 | psp2SoundPath: 321 | psp2TrophyCommId: 322 | psp2TrophyPackagePath: 323 | psp2PackagedResourcesPath: 324 | psp2SaveDataQuota: 10240 325 | psp2ParentalLevel: 1 326 | psp2ShortTitle: Not Set 327 | psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF 328 | psp2Category: 0 329 | psp2MasterVersion: 01.00 330 | psp2AppVersion: 01.00 331 | psp2TVBootMode: 0 332 | psp2EnterButtonAssignment: 2 333 | psp2TVDisableEmu: 0 334 | psp2AllowTwitterDialog: 1 335 | psp2Upgradable: 0 336 | psp2HealthWarning: 0 337 | psp2UseLibLocation: 0 338 | psp2InfoBarOnStartup: 0 339 | psp2InfoBarColor: 0 340 | psp2UseDebugIl2cppLibs: 0 341 | psmSplashimage: {fileID: 0} 342 | spritePackerPolicy: 343 | scriptingDefineSymbols: {} 344 | metroPackageName: KKTools 345 | metroPackageVersion: 346 | metroCertificatePath: 347 | metroCertificatePassword: 348 | metroCertificateSubject: 349 | metroCertificateIssuer: 350 | metroCertificateNotAfter: 0000000000000000 351 | metroApplicationDescription: KKTools 352 | wsaImages: {} 353 | metroTileShortName: 354 | metroCommandLineArgsFile: 355 | metroTileShowName: 0 356 | metroMediumTileShowName: 0 357 | metroLargeTileShowName: 0 358 | metroWideTileShowName: 0 359 | metroDefaultTileSize: 1 360 | metroTileForegroundText: 1 361 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 362 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 363 | metroSplashScreenUseBackgroundColor: 0 364 | platformCapabilities: {} 365 | metroFTAName: 366 | metroFTAFileTypes: [] 367 | metroProtocolName: 368 | metroCompilationOverrides: 1 369 | blackberryDeviceAddress: 370 | blackberryDevicePassword: 371 | blackberryTokenPath: 372 | blackberryTokenExires: 373 | blackberryTokenAuthor: 374 | blackberryTokenAuthorId: 375 | blackberryCskPassword: 376 | blackberrySaveLogPath: 377 | blackberrySharedPermissions: 0 378 | blackberryCameraPermissions: 0 379 | blackberryGPSPermissions: 0 380 | blackberryDeviceIDPermissions: 0 381 | blackberryMicrophonePermissions: 0 382 | blackberryGamepadSupport: 0 383 | blackberryBuildId: 0 384 | blackberryLandscapeSplashScreen: {fileID: 0} 385 | blackberryPortraitSplashScreen: {fileID: 0} 386 | blackberrySquareSplashScreen: {fileID: 0} 387 | tizenProductDescription: 388 | tizenProductURL: 389 | tizenSigningProfileName: 390 | tizenGPSPermissions: 0 391 | tizenMicrophonePermissions: 0 392 | n3dsUseExtSaveData: 0 393 | n3dsCompressStaticMem: 1 394 | n3dsExtSaveDataNumber: 0x12345 395 | n3dsStackSize: 131072 396 | n3dsTargetPlatform: 2 397 | n3dsRegion: 7 398 | n3dsMediaSize: 0 399 | n3dsLogoStyle: 3 400 | n3dsTitle: GameName 401 | n3dsProductCode: 402 | n3dsApplicationId: 0xFF3FF 403 | stvDeviceAddress: 404 | stvProductDescription: 405 | stvProductAuthor: 406 | stvProductAuthorEmail: 407 | stvProductLink: 408 | stvProductCategory: 0 409 | XboxOneProductId: 410 | XboxOneUpdateKey: 411 | XboxOneSandboxId: 412 | XboxOneContentId: 413 | XboxOneTitleId: 414 | XboxOneSCId: 415 | XboxOneGameOsOverridePath: 416 | XboxOnePackagingOverridePath: 417 | XboxOneAppManifestOverridePath: 418 | XboxOnePackageEncryption: 0 419 | XboxOnePackageUpdateGranularity: 2 420 | XboxOneDescription: 421 | XboxOneIsContentPackage: 0 422 | XboxOneEnableGPUVariability: 0 423 | XboxOneSockets: {} 424 | XboxOneSplashScreen: {fileID: 0} 425 | XboxOneAllowedProductIds: [] 426 | XboxOnePersistentLocalStorageSize: 0 427 | intPropertyNames: 428 | - Android::ScriptingBackend 429 | - Metro::ScriptingBackend 430 | - Standalone::ScriptingBackend 431 | - WP8::ScriptingBackend 432 | - WebGL::ScriptingBackend 433 | - WebGL::audioCompressionFormat 434 | - WebGL::exceptionSupport 435 | - WebGL::memorySize 436 | - WebPlayer::ScriptingBackend 437 | - iOS::Architecture 438 | - iOS::EnableIncrementalBuildSupportForIl2cpp 439 | - iOS::ScriptingBackend 440 | Android::ScriptingBackend: 0 441 | Metro::ScriptingBackend: 2 442 | Standalone::ScriptingBackend: 0 443 | WP8::ScriptingBackend: 2 444 | WebGL::ScriptingBackend: 1 445 | WebGL::audioCompressionFormat: 4 446 | WebGL::exceptionSupport: 1 447 | WebGL::memorySize: 256 448 | WebPlayer::ScriptingBackend: 0 449 | iOS::Architecture: 2 450 | iOS::EnableIncrementalBuildSupportForIl2cpp: 1 451 | iOS::ScriptingBackend: 1 452 | boolPropertyNames: 453 | - WebGL::analyzeBuildSize 454 | - WebGL::dataCaching 455 | - WebGL::useEmbeddedResources 456 | - XboxOne::enus 457 | WebGL::analyzeBuildSize: 0 458 | WebGL::dataCaching: 0 459 | WebGL::useEmbeddedResources: 0 460 | XboxOne::enus: 1 461 | stringPropertyNames: 462 | - WebGL::emscriptenArgs 463 | - WebGL::template 464 | - additionalIl2CppArgs::additionalIl2CppArgs 465 | WebGL::emscriptenArgs: 466 | WebGL::template: APPLICATION:Default 467 | additionalIl2CppArgs::additionalIl2CppArgs: 468 | cloudProjectId: 469 | projectName: 470 | organizationId: 471 | cloudEnabled: 0 472 | -------------------------------------------------------------------------------- /Assets/ClientDataBase/Scripts/Editor/ClientDataBaseParse.cs: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | // Author : K.(k79k06k02k) 3 | // FileName : ClientDataBaseParse.cs 4 | **********************************************************/ 5 | using UnityEngine; 6 | using UnityEditor; 7 | using Object = UnityEngine.Object; 8 | using System.IO; 9 | using System.Collections.Generic; 10 | using System.Text.RegularExpressions; 11 | using System.Text; 12 | using System; 13 | 14 | namespace ClientDataBase 15 | { 16 | public class ClientDataBaseParse : Singleton 17 | { 18 | public class TableData 19 | { 20 | public TableData(string summary, string name, string type, bool isArray, bool isEnd) 21 | { 22 | this.summary = summary; 23 | this.name = name; 24 | this.type = type; 25 | this.isArray = isArray; 26 | this.isEnd = isEnd; 27 | } 28 | 29 | public string summary; 30 | public string name; 31 | public string type; 32 | public bool isArray; 33 | public bool isEnd; 34 | } 35 | 36 | string _tableName; 37 | ClientDataBaseConfig _config; 38 | 39 | 40 | /// 41 | /// 讀取GameTable(.txt) 42 | /// 43 | public bool LoadGameTable(Object obj) 44 | { 45 | _config = ClientDataBaseManager.Instance.m_config; 46 | _tableName = obj.name; 47 | 48 | string strTemp; 49 | TextAsset data = (TextAsset)obj; 50 | TextReader reader = null; 51 | 52 | string[] _Summary = null; 53 | string[] _Variable = null; 54 | string[] _Type = null; 55 | int index = 0; 56 | 57 | 58 | if (data == null) 59 | { 60 | Debug.LogError("GameTable is null."); 61 | return false; 62 | } 63 | 64 | if (data.text == string.Empty) 65 | { 66 | Debug.LogError("GameTable is empty."); 67 | return false; 68 | } 69 | 70 | reader = new StringReader(data.text); 71 | if (reader != null) 72 | { 73 | while ((strTemp = reader.ReadLine()) != null) 74 | { 75 | if (index == 0) 76 | { 77 | _Summary = strTemp.Split("\t"[0]); 78 | index++; 79 | continue; 80 | } 81 | 82 | if (index == 1) 83 | { 84 | _Variable = strTemp.Split("\t"[0]); 85 | index++; 86 | continue; 87 | } 88 | 89 | if (index == 2) 90 | { 91 | _Type = strTemp.Split("\t"[0]); 92 | index++; 93 | continue; 94 | } 95 | 96 | if (index == 3) 97 | { 98 | //1.判斷是否是 GameTable(txt),檔案的開始字串是否包含 識別字 99 | if (_Summary[0].IndexOf(_config.m_gameTableCheck) < 0) 100 | { 101 | Debug.LogError("GameTable is not a table. Please Check txt file start string is [" + _config.m_gameTableCheck + "]"); 102 | break; 103 | } 104 | 105 | //2.判斷欄位數量是否一致 106 | int count = _Summary.Length; 107 | if (count != _Variable.Length || count != _Type.Length) 108 | { 109 | Debug.LogError("GameTable column not same."); 110 | break; 111 | } 112 | 113 | if (CreateTableScript(_Summary, _Variable, _Type) == false) 114 | return false; 115 | 116 | if (CreateScriptableScript(_Variable, _Type) == false) 117 | return false; 118 | 119 | if (CreateScriptableScriptEditor() == false) 120 | return false; 121 | 122 | break; 123 | } 124 | } 125 | 126 | reader.Close(); 127 | } 128 | 129 | return true; 130 | } 131 | 132 | 133 | /// 134 | /// 建立 Table Class 135 | /// 136 | /// 是否成功建立 137 | bool CreateTableScript(string[] summary, string[] variable, string[] type) 138 | { 139 | Dictionary dataMap = new Dictionary(); 140 | 141 | string templateDataClass = GetTemplate("TableClass"); 142 | if (string.IsNullOrEmpty(templateDataClass)) 143 | return false; 144 | 145 | templateDataClass = templateDataClass.Replace("$ClassName", _config.GetTableClassScriptName(_tableName)); 146 | 147 | StringBuilder field = new StringBuilder(); 148 | 149 | for (int i = 0; i < variable.Length; i++) 150 | { 151 | //透過字元 '[' ']' 判斷是否是Array 152 | bool isArray = variable[i].EndsWith("[]"); 153 | bool isEnd = i == variable.Length - 1; 154 | 155 | //如果是Array,去除中括號 156 | string fieldName = isArray ? variable[i].Replace("[]", "") : variable[i]; 157 | 158 | if (dataMap.ContainsKey(fieldName)) 159 | dataMap[fieldName].summary += ", " + summary[i]; 160 | else 161 | dataMap.Add(fieldName, new TableData(summary[i], fieldName, type[i], isArray, isEnd)); 162 | } 163 | 164 | foreach (KeyValuePair item in dataMap) 165 | field.Append(GetProperty(item.Value.summary, item.Value.name, item.Value.type, item.Value.isArray, item.Value.isEnd)); 166 | 167 | 168 | templateDataClass = templateDataClass.Replace("$MemberFields", field.ToString()); 169 | 170 | 171 | UtilityEditor.CreateFolder(_config.GetTableClassPath()); 172 | using (var writer = new StreamWriter(_config.GetTableClassPath() + _config.GetTableClassScriptName(_tableName, true))) 173 | { 174 | writer.Write(templateDataClass); 175 | writer.Close(); 176 | } 177 | 178 | AssetDatabase.Refresh(); 179 | Debug.Log(string.Format("[TableClass] is Create.\nFile:[{0}] Path:[{1}]", _config.GetTableClassScriptName(_tableName, true), _config.GetTableClassPath())); 180 | 181 | return true; 182 | } 183 | 184 | /// 185 | /// 建立 Scriptable Script 186 | /// 187 | /// 是否成功建立 188 | bool CreateScriptableScript(string[] variable, string[] type) 189 | { 190 | string template = GetTemplate("Scriptable"); 191 | if (string.IsNullOrEmpty(template)) 192 | return false; 193 | 194 | template = template.Replace("$ScriptableName", _config.GetScriptableScriptName(_tableName)); 195 | template = template.Replace("$GameTableName", _tableName); 196 | template = template.Replace("$ClassName", _config.GetTableClassScriptName(_tableName)); 197 | template = template.Replace("$GameTablePath", "Config.GameTablePath + GameTableName + Config.FILE_EXTENSION_TXT"); 198 | 199 | 200 | Dictionary variableMap = new Dictionary(); 201 | 202 | for (int i = 0; i < variable.Length; i++) 203 | { 204 | string resultStr = string.Empty; 205 | 206 | //透過字元 '[' ']' 判斷是否是Array 207 | bool isArray = variable[i].EndsWith("[]"); 208 | 209 | //如果是Array,去除中括號 210 | string fieldName = isArray ? variable[i].Replace("[]", "") : variable[i]; 211 | 212 | 213 | resultStr = GetDataClassDetial(i, fieldName, type[i], isArray); 214 | 215 | 216 | //如果名稱一樣(只會發生在複數Array) 217 | if (variableMap.ContainsKey(fieldName)) 218 | { 219 | string oldStr = variableMap[fieldName]; 220 | string element = Regex.Match(oldStr, "\\{[^\\}]*\\}").ToString().Trim(new char[] { '{', '}', ' ' }); 221 | 222 | string newStr = element + ", " + GetTypeDataClass(i, type[i]); 223 | 224 | variableMap.Remove(fieldName); 225 | 226 | try 227 | { 228 | variableMap.Add(fieldName, oldStr.Replace(element, newStr)); 229 | } 230 | catch (ArgumentException e) 231 | { 232 | Debug.LogError (string.Format ("Duplicate variable name and is not Array, table:[{0}], variable name:[{1}].", _tableName, fieldName)); 233 | return false; 234 | } 235 | } 236 | else 237 | { 238 | variableMap.Add(fieldName, resultStr); 239 | } 240 | } 241 | 242 | StringBuilder sb = new StringBuilder(); 243 | foreach (KeyValuePair item in variableMap) 244 | { 245 | sb.Append(item.Value); 246 | } 247 | 248 | template = template.Replace("$DataLoad", sb.ToString()); 249 | 250 | 251 | UtilityEditor.CreateFolder(_config.GetScriptableScriptsPath()); 252 | using (var writer = new StreamWriter(_config.GetScriptableScriptsPath() + _config.GetScriptableScriptName(_tableName, true))) 253 | { 254 | writer.Write(template); 255 | writer.Close(); 256 | } 257 | 258 | AssetDatabase.Refresh(); 259 | Debug.Log(string.Format("[Scriptable Script] is Create.\nFile:[{0}] Path:[{1}]", _config.GetScriptableScriptName(_tableName, true), _config.GetScriptableScriptsPath())); 260 | 261 | return true; 262 | } 263 | 264 | /// 265 | /// 建立 Scriptable Script Editor 266 | /// 267 | /// 是否成功建立 268 | bool CreateScriptableScriptEditor() 269 | { 270 | string templateScriptable = GetTemplate("ScriptableEditor"); 271 | if (string.IsNullOrEmpty(templateScriptable)) 272 | return false; 273 | 274 | templateScriptable = templateScriptable.Replace("$ScriptableEditorName", _config.GetScriptableScriptEditorName(_tableName)); 275 | templateScriptable = templateScriptable.Replace("$ScriptableName", _config.GetScriptableScriptName(_tableName)); 276 | 277 | 278 | UtilityEditor.CreateFolder(_config.GetScriptableEditorPath()); 279 | using (var writer = new StreamWriter(_config.GetScriptableEditorPath() + _config.GetScriptableScriptEditorName(_tableName, true))) 280 | { 281 | writer.Write(templateScriptable); 282 | writer.Close(); 283 | } 284 | 285 | AssetDatabase.Refresh(); 286 | Debug.Log(string.Format("[Scriptable Script Editor] is Create.\nFile:[{0}] Path:[{1}]", _config.GetScriptableScriptEditorName(_tableName, true), _config.GetScriptableEditorPath())); 287 | 288 | return true; 289 | } 290 | 291 | /// 292 | /// 建立 Scriptable Asset 293 | /// 294 | /// 是否成功建立 295 | public bool CreateScriptableAssets(string scriptableScriptName, string scriptableAssetName) 296 | { 297 | _config = ClientDataBaseManager.Instance.m_config; 298 | MonoScript script = AssetDatabase.LoadAssetAtPath(_config.GetScriptableScriptsPath() + scriptableScriptName); 299 | 300 | if (script == null || script.GetClass() == null) 301 | { 302 | Debug.LogError(string.Format("Scriptable Script is Null. [Path:{0}]", _config.GetScriptableScriptsPath() + scriptableScriptName)); 303 | return false; 304 | } 305 | 306 | string path = _config.GetScriptableAssetPath() + scriptableAssetName; 307 | UtilityEditor.CreateFolder(_config.GetScriptableAssetPath()); 308 | 309 | Object _Object = ScriptableObject.CreateInstance(script.GetClass()); 310 | AssetDatabase.CreateAsset(_Object, path); 311 | 312 | AssetDatabase.SaveAssets(); 313 | AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); 314 | 315 | Debug.Log(string.Format("[Scriptable Asset] is Create.\nFile:[{0}] Path:[{1}]", scriptableAssetName, _config.GetScriptableAssetPath())); 316 | 317 | //資料讀取 318 | ScriptableObjectBase scriptableObjectBase = AssetDatabase.LoadAssetAtPath(path); 319 | 320 | return scriptableObjectBase.LoadGameTable(); 321 | } 322 | 323 | /// 324 | ///取得 Script Templates 325 | /// 326 | string GetTemplate(string name) 327 | { 328 | string path = _config.GetTemplatePathName(name); 329 | TextAsset textAsset = AssetDatabase.LoadAssetAtPath(path); 330 | 331 | if (textAsset == null) 332 | { 333 | Debug.LogError(string.Format("Can't found Script Templates txt file in [Path:{0}]", path)); 334 | return null; 335 | } 336 | 337 | return textAsset.ToString(); 338 | } 339 | 340 | /// 341 | ///設定各屬性 342 | /// 343 | string GetProperty(string summary, string name, string type, bool isArray, bool isEnd = false) 344 | { 345 | string templateProperty = GetTemplate("TableClassProperty"); 346 | templateProperty = templateProperty.Replace("$Summary", summary); 347 | templateProperty = templateProperty.Replace("$Modifier", "public"); 348 | templateProperty = templateProperty.Replace("$Type", type + (isArray ? "[]" : "")); 349 | templateProperty = templateProperty.Replace("$Name", name); 350 | templateProperty += isEnd ? "" : "\n\n"; 351 | return templateProperty; 352 | } 353 | 354 | /// 355 | /// 實作 TableClass 細部 356 | /// 357 | string GetDataClassDetial(int index, string name, string type, bool isArray) 358 | { 359 | if (isArray) 360 | return string.Format("\t\t\t\t\ttable.{0} = new {1}[] {{ {2} }};\n", name, type, GetTypeDataClass(index, type)); 361 | else 362 | return string.Format("\t\t\t\t\ttable.{0} = {1};\n", name, GetTypeDataClass(index, type)); 363 | } 364 | 365 | 366 | /// 367 | ///取得轉型 368 | /// 369 | string GetTypeDataClass(int index, string type) 370 | { 371 | switch (type) 372 | { 373 | case "Vector2": 374 | case "Vector3": 375 | return string.Format("Utility.TypeRelate.StringToVector{0}(splitStr[{1}])", (type == "Vector2" ? "2" : "3"), index); 376 | 377 | case "bool": 378 | return string.Format("Utility.TypeRelate.StringToBool(splitStr[{0}])", index); 379 | 380 | default: 381 | return string.Format("({0})Convert.ChangeType(splitStr[{1}], typeof({0}))", type, index); 382 | } 383 | } 384 | } 385 | } 386 | --------------------------------------------------------------------------------