├── .gitignore ├── Assets ├── LogAttribute.cs ├── test.unity.meta ├── Editor │ ├── Cecil │ │ ├── Mono.Cecil.dll │ │ ├── Mono.Cecil.Mdb.dll │ │ ├── Mono.Cecil.Pdb.dll │ │ ├── Mono.Cecil.dll.meta │ │ ├── Mono.Cecil.Mdb.dll.meta │ │ └── Mono.Cecil.Pdb.dll.meta │ ├── Cecil.meta │ ├── AssemblyPostProcessor.cs.meta │ └── AssemblyPostProcessor.cs ├── Editor.meta ├── Test.cs.meta ├── LogAttribute.cs.meta ├── Test.cs └── test.unity ├── README.md ├── ProjectSettings ├── EditorBuildSettings.asset ├── NetworkManager.asset ├── TimeManager.asset ├── GraphicsSettings.asset ├── AudioManager.asset ├── EditorSettings.asset ├── DynamicsManager.asset ├── Physics2DSettings.asset ├── TagManager.asset ├── NavMeshLayers.asset ├── QualitySettings.asset ├── InputManager.asset └── ProjectSettings.asset └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /Library 2 | /obj 3 | *.csproj 4 | *.unityproj 5 | *.sln 6 | *.suo 7 | *.userprefs -------------------------------------------------------------------------------- /Assets/LogAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class LogAttribute : Attribute 4 | { 5 | } -------------------------------------------------------------------------------- /Assets/test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99b1cf591f46da24fb986e74fb43daeb 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unity_cecil_example 2 | Proof of concept to show how Mono.Cecil can be used with Unity for metaprogramming 3 | 4 | -------------------------------------------------------------------------------- /Assets/Editor/Cecil/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spectre1989/unity_cecil_example/HEAD/Assets/Editor/Cecil/Mono.Cecil.dll -------------------------------------------------------------------------------- /Assets/Editor/Cecil/Mono.Cecil.Mdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spectre1989/unity_cecil_example/HEAD/Assets/Editor/Cecil/Mono.Cecil.Mdb.dll -------------------------------------------------------------------------------- /Assets/Editor/Cecil/Mono.Cecil.Pdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spectre1989/unity_cecil_example/HEAD/Assets/Editor/Cecil/Mono.Cecil.Pdb.dll -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3a32b7b3a66f6a40825ad54b04f5ce3 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/Cecil.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 631dd71861b927d4fa3b4d4ff5c7ec99 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Assets/Editor/Cecil/Mono.Cecil.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e31a893e3d832b74baafce9982a542b4 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 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/Editor/Cecil/Mono.Cecil.Mdb.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e4f1f0fdb00a9d448de15eb450973cb 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/Editor/Cecil/Mono.Cecil.Pdb.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6f3caace1f255949a1499fbaf72dc14 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/Test.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53f407e81399169428862c684f8297df 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/LogAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 423c4a8f891abeb4289cfa3d6b199a6c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /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/Editor/AssemblyPostProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecd52cc7a6f7d724ab625e8118678784 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /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 | m_AlwaysIncludedShaders: 7 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 8 | -------------------------------------------------------------------------------- /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 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /Assets/Test.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Test : MonoBehaviour 5 | { 6 | private void Start() 7 | { 8 | this.LogTest(); 9 | } 10 | 11 | [Log] 12 | private void LogTest() 13 | { 14 | Debug.Log( "Here's some logic" ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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: 0 12 | m_SpritePackerMode: 0 13 | -------------------------------------------------------------------------------- /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 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepVelocity: .150000006 10 | m_SleepAngularVelocity: .140000001 11 | m_MaxAngularVelocity: 7 12 | m_MinPenetrationForPenalty: .00999999978 13 | m_SolverIterationCount: 6 14 | m_RaycastsHitTriggers: 1 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /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 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_VelocityThreshold: 1 11 | m_MaxLinearCorrection: .200000003 12 | m_MaxAngularCorrection: 8 13 | m_MaxTranslationSpeed: 100 14 | m_MaxRotationSpeed: 360 15 | m_BaumgarteScale: .200000003 16 | m_BaumgarteTimeOfImpactScale: .75 17 | m_TimeToSleep: .5 18 | m_LinearSleepTolerance: .00999999978 19 | m_AngularSleepTolerance: 2 20 | m_RaycastsHitTriggers: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: UI 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Joe Best-Rotheray 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/NavMeshLayers.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /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: 3 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 | blendWeights: 1 18 | textureQuality: 1 19 | anisotropicTextures: 0 20 | antiAliasing: 0 21 | softParticles: 0 22 | softVegetation: 0 23 | vSyncCount: 0 24 | lodBias: .300000012 25 | maximumLODLevel: 0 26 | particleRaycastBudget: 4 27 | excludedTargetPlatforms: [] 28 | - serializedVersion: 2 29 | name: Fast 30 | pixelLightCount: 0 31 | shadows: 0 32 | shadowResolution: 0 33 | shadowProjection: 1 34 | shadowCascades: 1 35 | shadowDistance: 20 36 | blendWeights: 2 37 | textureQuality: 0 38 | anisotropicTextures: 0 39 | antiAliasing: 0 40 | softParticles: 0 41 | softVegetation: 0 42 | vSyncCount: 0 43 | lodBias: .400000006 44 | maximumLODLevel: 0 45 | particleRaycastBudget: 16 46 | excludedTargetPlatforms: [] 47 | - serializedVersion: 2 48 | name: Simple 49 | pixelLightCount: 1 50 | shadows: 1 51 | shadowResolution: 0 52 | shadowProjection: 1 53 | shadowCascades: 1 54 | shadowDistance: 20 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 1 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | vSyncCount: 0 62 | lodBias: .699999988 63 | maximumLODLevel: 0 64 | particleRaycastBudget: 64 65 | excludedTargetPlatforms: [] 66 | - serializedVersion: 2 67 | name: Good 68 | pixelLightCount: 2 69 | shadows: 2 70 | shadowResolution: 1 71 | shadowProjection: 1 72 | shadowCascades: 2 73 | shadowDistance: 40 74 | blendWeights: 2 75 | textureQuality: 0 76 | anisotropicTextures: 1 77 | antiAliasing: 0 78 | softParticles: 0 79 | softVegetation: 1 80 | vSyncCount: 1 81 | lodBias: 1 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 256 84 | excludedTargetPlatforms: [] 85 | - serializedVersion: 2 86 | name: Beautiful 87 | pixelLightCount: 3 88 | shadows: 2 89 | shadowResolution: 2 90 | shadowProjection: 1 91 | shadowCascades: 2 92 | shadowDistance: 70 93 | blendWeights: 4 94 | textureQuality: 0 95 | anisotropicTextures: 2 96 | antiAliasing: 2 97 | softParticles: 1 98 | softVegetation: 1 99 | vSyncCount: 1 100 | lodBias: 1.5 101 | maximumLODLevel: 0 102 | particleRaycastBudget: 1024 103 | excludedTargetPlatforms: [] 104 | - serializedVersion: 2 105 | name: Fantastic 106 | pixelLightCount: 4 107 | shadows: 2 108 | shadowResolution: 2 109 | shadowProjection: 1 110 | shadowCascades: 4 111 | shadowDistance: 150 112 | blendWeights: 4 113 | textureQuality: 0 114 | anisotropicTextures: 2 115 | antiAliasing: 2 116 | softParticles: 1 117 | softVegetation: 1 118 | vSyncCount: 1 119 | lodBias: 2 120 | maximumLODLevel: 0 121 | particleRaycastBudget: 4096 122 | excludedTargetPlatforms: [] 123 | m_PerPlatformDefaultQuality: 124 | Android: 2 125 | BlackBerry: 2 126 | FlashPlayer: 3 127 | GLES Emulation: 3 128 | PS3: 3 129 | PS4: 3 130 | PSM: 3 131 | PSP2: 3 132 | Samsung TV: 2 133 | Standalone: 3 134 | Tizen: 2 135 | WP8: 3 136 | Web: 3 137 | Windows Store Apps: 3 138 | XBOX360: 3 139 | XboxOne: 3 140 | iPhone: 2 141 | -------------------------------------------------------------------------------- /Assets/test.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | SceneSettings: 5 | m_ObjectHideFlags: 0 6 | m_PVSData: 7 | m_PVSObjectsArray: [] 8 | m_PVSPortalsArray: [] 9 | m_OcclusionBakeSettings: 10 | smallestOccluder: 5 11 | smallestHole: .25 12 | backfaceThreshold: 100 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_Fog: 0 16 | m_FogColor: {r: .5, g: .5, b: .5, a: 1} 17 | m_FogMode: 3 18 | m_FogDensity: .00999999978 19 | m_LinearFogStart: 0 20 | m_LinearFogEnd: 300 21 | m_AmbientLight: {r: .200000003, g: .200000003, b: .200000003, a: 1} 22 | m_SkyboxMaterial: {fileID: 0} 23 | m_HaloStrength: .5 24 | m_FlareStrength: 1 25 | m_FlareFadeSpeed: 3 26 | m_HaloTexture: {fileID: 0} 27 | m_SpotCookie: {fileID: 0} 28 | m_ObjectHideFlags: 0 29 | --- !u!127 &3 30 | LevelGameManager: 31 | m_ObjectHideFlags: 0 32 | --- !u!157 &4 33 | LightmapSettings: 34 | m_ObjectHideFlags: 0 35 | m_LightProbes: {fileID: 0} 36 | m_Lightmaps: [] 37 | m_LightmapsMode: 1 38 | m_BakedColorSpace: 0 39 | m_UseDualLightmapsInForward: 0 40 | m_LightmapEditorSettings: 41 | m_Resolution: 50 42 | m_LastUsedResolution: 0 43 | m_TextureWidth: 1024 44 | m_TextureHeight: 1024 45 | m_BounceBoost: 1 46 | m_BounceIntensity: 1 47 | m_SkyLightColor: {r: .860000014, g: .930000007, b: 1, a: 1} 48 | m_SkyLightIntensity: 0 49 | m_Quality: 0 50 | m_Bounces: 1 51 | m_FinalGatherRays: 1000 52 | m_FinalGatherContrastThreshold: .0500000007 53 | m_FinalGatherGradientThreshold: 0 54 | m_FinalGatherInterpolationPoints: 15 55 | m_AOAmount: 0 56 | m_AOMaxDistance: .100000001 57 | m_AOContrast: 1 58 | m_LODSurfaceMappingDistance: 1 59 | m_Padding: 0 60 | m_TextureCompression: 0 61 | m_LockAtlas: 0 62 | --- !u!196 &5 63 | NavMeshSettings: 64 | m_ObjectHideFlags: 0 65 | m_BuildSettings: 66 | agentRadius: .5 67 | agentHeight: 2 68 | agentSlope: 45 69 | agentClimb: .400000006 70 | ledgeDropHeight: 0 71 | maxJumpAcrossDistance: 0 72 | accuratePlacement: 0 73 | minRegionArea: 2 74 | widthInaccuracy: 16.666666 75 | heightInaccuracy: 10 76 | m_NavMesh: {fileID: 0} 77 | --- !u!1 &570290186 78 | GameObject: 79 | m_ObjectHideFlags: 0 80 | m_PrefabParentObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 0} 82 | serializedVersion: 4 83 | m_Component: 84 | - 4: {fileID: 570290192} 85 | - 20: {fileID: 570290191} 86 | - 92: {fileID: 570290190} 87 | - 124: {fileID: 570290189} 88 | - 81: {fileID: 570290188} 89 | - 114: {fileID: 570290187} 90 | m_Layer: 0 91 | m_Name: Main Camera 92 | m_TagString: MainCamera 93 | m_Icon: {fileID: 0} 94 | m_NavMeshLayer: 0 95 | m_StaticEditorFlags: 0 96 | m_IsActive: 1 97 | --- !u!114 &570290187 98 | MonoBehaviour: 99 | m_ObjectHideFlags: 0 100 | m_PrefabParentObject: {fileID: 0} 101 | m_PrefabInternal: {fileID: 0} 102 | m_GameObject: {fileID: 570290186} 103 | m_Enabled: 1 104 | m_EditorHideFlags: 0 105 | m_Script: {fileID: 11500000, guid: 53f407e81399169428862c684f8297df, type: 3} 106 | m_Name: 107 | m_EditorClassIdentifier: 108 | --- !u!81 &570290188 109 | AudioListener: 110 | m_ObjectHideFlags: 0 111 | m_PrefabParentObject: {fileID: 0} 112 | m_PrefabInternal: {fileID: 0} 113 | m_GameObject: {fileID: 570290186} 114 | m_Enabled: 1 115 | --- !u!124 &570290189 116 | Behaviour: 117 | m_ObjectHideFlags: 0 118 | m_PrefabParentObject: {fileID: 0} 119 | m_PrefabInternal: {fileID: 0} 120 | m_GameObject: {fileID: 570290186} 121 | m_Enabled: 1 122 | --- !u!92 &570290190 123 | Behaviour: 124 | m_ObjectHideFlags: 0 125 | m_PrefabParentObject: {fileID: 0} 126 | m_PrefabInternal: {fileID: 0} 127 | m_GameObject: {fileID: 570290186} 128 | m_Enabled: 1 129 | --- !u!20 &570290191 130 | Camera: 131 | m_ObjectHideFlags: 0 132 | m_PrefabParentObject: {fileID: 0} 133 | m_PrefabInternal: {fileID: 0} 134 | m_GameObject: {fileID: 570290186} 135 | m_Enabled: 1 136 | serializedVersion: 2 137 | m_ClearFlags: 1 138 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 139 | m_NormalizedViewPortRect: 140 | serializedVersion: 2 141 | x: 0 142 | y: 0 143 | width: 1 144 | height: 1 145 | near clip plane: .300000012 146 | far clip plane: 1000 147 | field of view: 60 148 | orthographic: 0 149 | orthographic size: 5 150 | m_Depth: -1 151 | m_CullingMask: 152 | serializedVersion: 2 153 | m_Bits: 4294967295 154 | m_RenderingPath: -1 155 | m_TargetTexture: {fileID: 0} 156 | m_TargetDisplay: 0 157 | m_HDR: 0 158 | m_OcclusionCulling: 1 159 | m_StereoConvergence: 10 160 | m_StereoSeparation: .0219999999 161 | --- !u!4 &570290192 162 | Transform: 163 | m_ObjectHideFlags: 0 164 | m_PrefabParentObject: {fileID: 0} 165 | m_PrefabInternal: {fileID: 0} 166 | m_GameObject: {fileID: 570290186} 167 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 168 | m_LocalPosition: {x: 0, y: 1, z: -10} 169 | m_LocalScale: {x: 1, y: 1, z: 1} 170 | m_Children: [] 171 | m_Father: {fileID: 0} 172 | m_RootOrder: 0 173 | -------------------------------------------------------------------------------- /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 | m_Axes: 7 | - serializedVersion: 3 8 | m_Name: Horizontal 9 | descriptiveName: 10 | descriptiveNegativeName: 11 | negativeButton: left 12 | positiveButton: right 13 | altNegativeButton: a 14 | altPositiveButton: d 15 | gravity: 3 16 | dead: .00100000005 17 | sensitivity: 3 18 | snap: 1 19 | invert: 0 20 | type: 0 21 | axis: 0 22 | joyNum: 0 23 | - serializedVersion: 3 24 | m_Name: Vertical 25 | descriptiveName: 26 | descriptiveNegativeName: 27 | negativeButton: down 28 | positiveButton: up 29 | altNegativeButton: s 30 | altPositiveButton: w 31 | gravity: 3 32 | dead: .00100000005 33 | sensitivity: 3 34 | snap: 1 35 | invert: 0 36 | type: 0 37 | axis: 0 38 | joyNum: 0 39 | - serializedVersion: 3 40 | m_Name: Fire1 41 | descriptiveName: 42 | descriptiveNegativeName: 43 | negativeButton: 44 | positiveButton: left ctrl 45 | altNegativeButton: 46 | altPositiveButton: mouse 0 47 | gravity: 1000 48 | dead: .00100000005 49 | sensitivity: 1000 50 | snap: 0 51 | invert: 0 52 | type: 0 53 | axis: 0 54 | joyNum: 0 55 | - serializedVersion: 3 56 | m_Name: Fire2 57 | descriptiveName: 58 | descriptiveNegativeName: 59 | negativeButton: 60 | positiveButton: left alt 61 | altNegativeButton: 62 | altPositiveButton: mouse 1 63 | gravity: 1000 64 | dead: .00100000005 65 | sensitivity: 1000 66 | snap: 0 67 | invert: 0 68 | type: 0 69 | axis: 0 70 | joyNum: 0 71 | - serializedVersion: 3 72 | m_Name: Fire3 73 | descriptiveName: 74 | descriptiveNegativeName: 75 | negativeButton: 76 | positiveButton: left cmd 77 | altNegativeButton: 78 | altPositiveButton: mouse 2 79 | gravity: 1000 80 | dead: .00100000005 81 | sensitivity: 1000 82 | snap: 0 83 | invert: 0 84 | type: 0 85 | axis: 0 86 | joyNum: 0 87 | - serializedVersion: 3 88 | m_Name: Jump 89 | descriptiveName: 90 | descriptiveNegativeName: 91 | negativeButton: 92 | positiveButton: space 93 | altNegativeButton: 94 | altPositiveButton: 95 | gravity: 1000 96 | dead: .00100000005 97 | sensitivity: 1000 98 | snap: 0 99 | invert: 0 100 | type: 0 101 | axis: 0 102 | joyNum: 0 103 | - serializedVersion: 3 104 | m_Name: Mouse X 105 | descriptiveName: 106 | descriptiveNegativeName: 107 | negativeButton: 108 | positiveButton: 109 | altNegativeButton: 110 | altPositiveButton: 111 | gravity: 0 112 | dead: 0 113 | sensitivity: .100000001 114 | snap: 0 115 | invert: 0 116 | type: 1 117 | axis: 0 118 | joyNum: 0 119 | - serializedVersion: 3 120 | m_Name: Mouse Y 121 | descriptiveName: 122 | descriptiveNegativeName: 123 | negativeButton: 124 | positiveButton: 125 | altNegativeButton: 126 | altPositiveButton: 127 | gravity: 0 128 | dead: 0 129 | sensitivity: .100000001 130 | snap: 0 131 | invert: 0 132 | type: 1 133 | axis: 1 134 | joyNum: 0 135 | - serializedVersion: 3 136 | m_Name: Mouse ScrollWheel 137 | descriptiveName: 138 | descriptiveNegativeName: 139 | negativeButton: 140 | positiveButton: 141 | altNegativeButton: 142 | altPositiveButton: 143 | gravity: 0 144 | dead: 0 145 | sensitivity: .100000001 146 | snap: 0 147 | invert: 0 148 | type: 1 149 | axis: 2 150 | joyNum: 0 151 | - serializedVersion: 3 152 | m_Name: Horizontal 153 | descriptiveName: 154 | descriptiveNegativeName: 155 | negativeButton: 156 | positiveButton: 157 | altNegativeButton: 158 | altPositiveButton: 159 | gravity: 0 160 | dead: .189999998 161 | sensitivity: 1 162 | snap: 0 163 | invert: 0 164 | type: 2 165 | axis: 0 166 | joyNum: 0 167 | - serializedVersion: 3 168 | m_Name: Vertical 169 | descriptiveName: 170 | descriptiveNegativeName: 171 | negativeButton: 172 | positiveButton: 173 | altNegativeButton: 174 | altPositiveButton: 175 | gravity: 0 176 | dead: .189999998 177 | sensitivity: 1 178 | snap: 0 179 | invert: 1 180 | type: 2 181 | axis: 1 182 | joyNum: 0 183 | - serializedVersion: 3 184 | m_Name: Fire1 185 | descriptiveName: 186 | descriptiveNegativeName: 187 | negativeButton: 188 | positiveButton: joystick button 0 189 | altNegativeButton: 190 | altPositiveButton: 191 | gravity: 1000 192 | dead: .00100000005 193 | sensitivity: 1000 194 | snap: 0 195 | invert: 0 196 | type: 0 197 | axis: 0 198 | joyNum: 0 199 | - serializedVersion: 3 200 | m_Name: Fire2 201 | descriptiveName: 202 | descriptiveNegativeName: 203 | negativeButton: 204 | positiveButton: joystick button 1 205 | altNegativeButton: 206 | altPositiveButton: 207 | gravity: 1000 208 | dead: .00100000005 209 | sensitivity: 1000 210 | snap: 0 211 | invert: 0 212 | type: 0 213 | axis: 0 214 | joyNum: 0 215 | - serializedVersion: 3 216 | m_Name: Fire3 217 | descriptiveName: 218 | descriptiveNegativeName: 219 | negativeButton: 220 | positiveButton: joystick button 2 221 | altNegativeButton: 222 | altPositiveButton: 223 | gravity: 1000 224 | dead: .00100000005 225 | sensitivity: 1000 226 | snap: 0 227 | invert: 0 228 | type: 0 229 | axis: 0 230 | joyNum: 0 231 | - serializedVersion: 3 232 | m_Name: Jump 233 | descriptiveName: 234 | descriptiveNegativeName: 235 | negativeButton: 236 | positiveButton: joystick button 3 237 | altNegativeButton: 238 | altPositiveButton: 239 | gravity: 1000 240 | dead: .00100000005 241 | sensitivity: 1000 242 | snap: 0 243 | invert: 0 244 | type: 0 245 | axis: 0 246 | joyNum: 0 247 | -------------------------------------------------------------------------------- /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: 3 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 0 9 | targetDevice: 2 10 | targetGlesGraphics: 1 11 | targetResolution: 0 12 | accelerometerFrequency: 60 13 | companyName: DefaultCompany 14 | productName: UnityCecilExample 15 | defaultCursor: {fileID: 0} 16 | cursorHotspot: {x: 0, y: 0} 17 | defaultScreenWidth: 1024 18 | defaultScreenHeight: 768 19 | defaultScreenWidthWeb: 960 20 | defaultScreenHeightWeb: 600 21 | m_RenderingPath: 1 22 | m_MobileRenderingPath: 1 23 | m_ActiveColorSpace: 0 24 | m_MTRendering: 1 25 | m_MobileMTRendering: 0 26 | m_UseDX11: 1 27 | m_Stereoscopic3D: 0 28 | iosShowActivityIndicatorOnLoading: -1 29 | androidShowActivityIndicatorOnLoading: -1 30 | displayResolutionDialog: 1 31 | allowedAutorotateToPortrait: 1 32 | allowedAutorotateToPortraitUpsideDown: 1 33 | allowedAutorotateToLandscapeRight: 1 34 | allowedAutorotateToLandscapeLeft: 1 35 | useOSAutorotation: 1 36 | use32BitDisplayBuffer: 1 37 | use24BitDepthBuffer: 1 38 | defaultIsFullScreen: 1 39 | defaultIsNativeResolution: 1 40 | runInBackground: 0 41 | captureSingleScreen: 0 42 | Override IPod Music: 0 43 | Prepare IOS For Recording: 0 44 | enableHWStatistics: 1 45 | usePlayerLog: 1 46 | stripPhysics: 0 47 | forceSingleInstance: 0 48 | resizableWindow: 0 49 | useMacAppStoreValidation: 0 50 | gpuSkinning: 0 51 | xboxPIXTextureCapture: 0 52 | xboxEnableAvatar: 0 53 | xboxEnableKinect: 0 54 | xboxEnableKinectAutoTracking: 0 55 | xboxEnableFitness: 0 56 | macFullscreenMode: 2 57 | xboxSpeechDB: 0 58 | xboxEnableHeadOrientation: 0 59 | xboxEnableGuest: 0 60 | videoMemoryForVertexBuffers: 0 61 | m_SupportedAspectRatios: 62 | 4:3: 1 63 | 5:4: 1 64 | 16:10: 1 65 | 16:9: 1 66 | Others: 1 67 | iPhoneBundleIdentifier: com.Company.ProductName 68 | metroEnableIndependentInputSource: 0 69 | metroEnableLowLatencyPresentationAPI: 0 70 | productGUID: 9928b3ed134b1b34a9b265202445a7ea 71 | iPhoneBundleVersion: 1.0 72 | AndroidBundleVersionCode: 1 73 | AndroidMinSdkVersion: 9 74 | AndroidPreferredInstallLocation: 1 75 | aotOptions: 76 | apiCompatibilityLevel: 2 77 | iPhoneStrippingLevel: 0 78 | iPhoneScriptCallOptimization: 0 79 | ForceInternetPermission: 0 80 | ForceSDCardPermission: 0 81 | CreateWallpaper: 0 82 | APKExpansionFiles: 0 83 | StripUnusedMeshComponents: 0 84 | iPhoneSdkVersion: 988 85 | iPhoneTargetOSVersion: 16 86 | uIPrerenderedIcon: 0 87 | uIRequiresPersistentWiFi: 0 88 | uIStatusBarHidden: 1 89 | uIExitOnSuspend: 0 90 | uIStatusBarStyle: 0 91 | iPhoneSplashScreen: {fileID: 0} 92 | iPhoneHighResSplashScreen: {fileID: 0} 93 | iPhoneTallHighResSplashScreen: {fileID: 0} 94 | iPadPortraitSplashScreen: {fileID: 0} 95 | iPadHighResPortraitSplashScreen: {fileID: 0} 96 | iPadLandscapeSplashScreen: {fileID: 0} 97 | iPadHighResLandscapeSplashScreen: {fileID: 0} 98 | AndroidTargetDevice: 0 99 | AndroidSplashScreenScale: 0 100 | AndroidKeystoreName: 101 | AndroidKeyaliasName: 102 | resolutionDialogBanner: {fileID: 0} 103 | m_BuildTargetIcons: [] 104 | m_BuildTargetBatching: [] 105 | webPlayerTemplate: APPLICATION:Default 106 | m_TemplateCustomTags: {} 107 | XboxTitleId: 108 | XboxImageXexPath: 109 | XboxSpaPath: 110 | XboxGenerateSpa: 0 111 | XboxDeployKinectResources: 0 112 | XboxSplashScreen: {fileID: 0} 113 | xboxEnableSpeech: 0 114 | xboxAdditionalTitleMemorySize: 0 115 | xboxDeployKinectHeadOrientation: 0 116 | xboxDeployKinectHeadPosition: 0 117 | ps3TitleConfigPath: 118 | ps3DLCConfigPath: 119 | ps3ThumbnailPath: 120 | ps3BackgroundPath: 121 | ps3SoundPath: 122 | ps3TrophyCommId: 123 | ps3NpCommunicationPassphrase: 124 | ps3TrophyPackagePath: 125 | ps3BootCheckMaxSaveGameSizeKB: 128 126 | ps3TrophyCommSig: 127 | ps3SaveGameSlots: 1 128 | ps3TrialMode: 0 129 | psp2Splashimage: {fileID: 0} 130 | psp2LiveAreaGate: {fileID: 0} 131 | psp2LiveAreaBackround: {fileID: 0} 132 | psp2NPTrophyPackPath: 133 | psp2NPCommsID: 134 | psp2NPCommsPassphrase: 135 | psp2NPCommsSig: 136 | psp2ParamSfxPath: 137 | psp2PackagePassword: 138 | psp2DLCConfigPath: 139 | psp2ThumbnailPath: 140 | psp2BackgroundPath: 141 | psp2SoundPath: 142 | psp2TrophyCommId: 143 | psp2TrophyPackagePath: 144 | psp2PackagedResourcesPath: 145 | flashStrippingLevel: 2 146 | spritePackerPolicy: 147 | scriptingDefineSymbols: {} 148 | metroPackageName: UnityCecilExample 149 | metroPackageLogo: 150 | metroPackageLogo140: 151 | metroPackageLogo180: 152 | metroPackageVersion: 153 | metroCertificatePath: 154 | metroCertificatePassword: 155 | metroCertificateSubject: 156 | metroCertificateIssuer: 157 | metroCertificateNotAfter: 0000000000000000 158 | metroApplicationDescription: UnityCecilExample 159 | metroTileLogo80: 160 | metroTileLogo: 161 | metroTileLogo140: 162 | metroTileLogo180: 163 | metroTileWideLogo80: 164 | metroTileWideLogo: 165 | metroTileWideLogo140: 166 | metroTileWideLogo180: 167 | metroTileSmallLogo80: 168 | metroTileSmallLogo: 169 | metroTileSmallLogo140: 170 | metroTileSmallLogo180: 171 | metroSmallTile80: 172 | metroSmallTile: 173 | metroSmallTile140: 174 | metroSmallTile180: 175 | metroLargeTile80: 176 | metroLargeTile: 177 | metroLargeTile140: 178 | metroLargeTile180: 179 | metroTileShortName: 180 | metroCommandLineArgsFile: 181 | metroTileShowName: 0 182 | metroMediumTileShowName: 0 183 | metroLargeTileShowName: 0 184 | metroWideTileShowName: 0 185 | metroDefaultTileSize: 1 186 | metroTileForegroundText: 1 187 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 188 | metroSplashScreenImage: 189 | metroSplashScreenImage140: 190 | metroSplashScreenImage180: 191 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 192 | metroSplashScreenUseBackgroundColor: 0 193 | metroCapabilities: {} 194 | metroUnprocessedPlugins: [] 195 | metroCompilationOverrides: 1 196 | blackberryDeviceAddress: 197 | blackberryDevicePassword: 198 | blackberryTokenPath: 199 | blackberryTokenExires: 200 | blackberryTokenAuthor: 201 | blackberryTokenAuthorId: 202 | blackberryAuthorId: 203 | blackberryCskPassword: 204 | blackberrySaveLogPath: 205 | blackberryAuthorIdOveride: 0 206 | blackberrySharedPermissions: 0 207 | blackberryCameraPermissions: 0 208 | blackberryGPSPermissions: 0 209 | blackberryDeviceIDPermissions: 0 210 | blackberryMicrophonePermissions: 0 211 | blackberryGamepadSupport: 0 212 | blackberryBuildId: 0 213 | blackberryLandscapeSplashScreen: {fileID: 0} 214 | blackberryPortraitSplashScreen: {fileID: 0} 215 | blackberrySquareSplashScreen: {fileID: 0} 216 | tizenProductDescription: 217 | tizenProductURL: 218 | tizenCertificatePath: 219 | tizenCertificatePassword: 220 | tizenGPSPermissions: 0 221 | tizenMicrophonePermissions: 0 222 | stvDeviceAddress: 223 | firstStreamedLevelWithResources: 0 224 | unityRebuildLibraryVersion: 9 225 | unityForwardCompatibleVersion: 39 226 | unityStandardAssetsVersion: 0 227 | -------------------------------------------------------------------------------- /Assets/Editor/AssemblyPostProcessor.cs: -------------------------------------------------------------------------------- 1 | using Mono.Cecil; 2 | using Mono.Cecil.Cil; 3 | using System; 4 | using System.IO; 5 | using System.Collections.Generic; 6 | using UnityEditor; 7 | using UnityEngine; 8 | 9 | [InitializeOnLoad] 10 | public static class AssemblyPostProcessor 11 | { 12 | static AssemblyPostProcessor() 13 | { 14 | try 15 | { 16 | Debug.Log( "AssemblyPostProcessor running" ); 17 | 18 | // Lock assemblies while they may be altered 19 | EditorApplication.LockReloadAssemblies(); 20 | 21 | // This will hold the paths to all the assemblies that will be processed 22 | HashSet assemblyPaths = new HashSet(); 23 | // This will hold the search directories for the resolver 24 | HashSet assemblySearchDirectories = new HashSet(); 25 | 26 | // Add all assemblies in the project to be processed, and add their directory to 27 | // the resolver search directories. 28 | foreach( System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() ) 29 | { 30 | // Only process assemblies which are in the project 31 | if( assembly.Location.Replace( '\\', '/' ).StartsWith( Application.dataPath.Substring( 0, Application.dataPath.Length - 7 ) ) ) 32 | { 33 | assemblyPaths.Add( assembly.Location ); 34 | } 35 | // But always add the assembly folder to the search directories 36 | assemblySearchDirectories.Add( Path.GetDirectoryName( assembly.Location ) ); 37 | } 38 | 39 | // Create resolver 40 | DefaultAssemblyResolver assemblyResolver = new DefaultAssemblyResolver(); 41 | // Add all directories found in the project folder 42 | foreach( String searchDirectory in assemblySearchDirectories ) 43 | { 44 | assemblyResolver.AddSearchDirectory( searchDirectory ); 45 | } 46 | // Add path to the Unity managed dlls 47 | assemblyResolver.AddSearchDirectory( Path.GetDirectoryName( EditorApplication.applicationPath ) + "/Data/Managed" ); 48 | 49 | // Create reader parameters with resolver 50 | ReaderParameters readerParameters = new ReaderParameters(); 51 | readerParameters.AssemblyResolver = assemblyResolver; 52 | 53 | // Create writer parameters 54 | WriterParameters writerParameters = new WriterParameters(); 55 | 56 | // Process any assemblies which need it 57 | foreach( String assemblyPath in assemblyPaths ) 58 | { 59 | // mdbs have the naming convention myDll.dll.mdb whereas pdbs have myDll.pdb 60 | String mdbPath = assemblyPath + ".mdb"; 61 | String pdbPath = assemblyPath.Substring( 0, assemblyPath.Length - 3 ) + "pdb"; 62 | 63 | // Figure out if there's an pdb/mdb to go with it 64 | if( File.Exists( pdbPath ) ) 65 | { 66 | readerParameters.ReadSymbols = true; 67 | readerParameters.SymbolReaderProvider = new Mono.Cecil.Pdb.PdbReaderProvider(); 68 | writerParameters.WriteSymbols = true; 69 | writerParameters.SymbolWriterProvider = new Mono.Cecil.Mdb.MdbWriterProvider(); // pdb written out as mdb, as mono can't work with pdbs 70 | } 71 | else if( File.Exists( mdbPath ) ) 72 | { 73 | readerParameters.ReadSymbols = true; 74 | readerParameters.SymbolReaderProvider = new Mono.Cecil.Mdb.MdbReaderProvider(); 75 | writerParameters.WriteSymbols = true; 76 | writerParameters.SymbolWriterProvider = new Mono.Cecil.Mdb.MdbWriterProvider(); 77 | } 78 | else 79 | { 80 | readerParameters.ReadSymbols = false; 81 | readerParameters.SymbolReaderProvider = null; 82 | writerParameters.WriteSymbols = false; 83 | writerParameters.SymbolWriterProvider = null; 84 | } 85 | 86 | // Read assembly 87 | AssemblyDefinition assemblyDefinition = AssemblyDefinition.ReadAssembly( assemblyPath, readerParameters ); 88 | 89 | // Process it if it hasn't already 90 | Debug.Log( "Processing " + Path.GetFileName( assemblyPath ) ); 91 | if( AssemblyPostProcessor.ProcessAssembly( assemblyDefinition ) ) 92 | { 93 | Debug.Log( "Writing to " + assemblyPath ); 94 | assemblyDefinition.Write( assemblyPath, writerParameters ); 95 | Debug.Log( "Done writing" ); 96 | } 97 | else 98 | { 99 | Debug.Log( Path.GetFileName( assemblyPath ) + " didn't need to be processed" ); 100 | } 101 | } 102 | 103 | // Unlock now that we're done 104 | EditorApplication.UnlockReloadAssemblies(); 105 | } 106 | catch( Exception e ) 107 | { 108 | Debug.LogWarning( e ); 109 | } 110 | } 111 | 112 | private static bool ProcessAssembly( AssemblyDefinition assemblyDefinition ) 113 | { 114 | bool wasProcessed = false; 115 | 116 | foreach( ModuleDefinition moduleDefinition in assemblyDefinition.Modules ) 117 | { 118 | foreach( TypeDefinition typeDefinition in moduleDefinition.Types ) 119 | { 120 | foreach( MethodDefinition methodDefinition in typeDefinition.Methods ) 121 | { 122 | CustomAttribute logAttribute = null; 123 | 124 | foreach( CustomAttribute customAttribute in methodDefinition.CustomAttributes ) 125 | { 126 | if( customAttribute.AttributeType.FullName == "LogAttribute" ) 127 | { 128 | MethodReference logMethodReference = moduleDefinition.Import( typeof( Debug ).GetMethod( "Log", new Type[] { typeof( object ) } ) ); 129 | 130 | ILProcessor ilProcessor = methodDefinition.Body.GetILProcessor(); 131 | 132 | Instruction first = methodDefinition.Body.Instructions[0]; 133 | ilProcessor.InsertBefore( first, Instruction.Create( OpCodes.Ldstr, "Enter " + typeDefinition.FullName + "." + methodDefinition.Name ) ); 134 | ilProcessor.InsertBefore( first, Instruction.Create( OpCodes.Call, logMethodReference ) ); 135 | 136 | Instruction last = methodDefinition.Body.Instructions[methodDefinition.Body.Instructions.Count - 1]; 137 | ilProcessor.InsertBefore( last, Instruction.Create( OpCodes.Ldstr, "Exit " + typeDefinition.FullName + "." + methodDefinition.Name ) ); 138 | ilProcessor.InsertBefore( last, Instruction.Create( OpCodes.Call, logMethodReference ) ); 139 | 140 | wasProcessed = true; 141 | logAttribute = customAttribute; 142 | break; 143 | } 144 | } 145 | 146 | // Remove the attribute so it won't be processed again 147 | if( logAttribute != null ) 148 | { 149 | methodDefinition.CustomAttributes.Remove( logAttribute ); 150 | } 151 | } 152 | } 153 | } 154 | 155 | return wasProcessed; 156 | } 157 | } 158 | --------------------------------------------------------------------------------