├── ProjectSettings ├── ProjectVersion.txt ├── TagManager.asset ├── VFXManager.asset ├── AudioManager.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PresetManager.asset ├── TimeManager.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── NetworkManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── GraphicsSettings.asset ├── Physics2DSettings.asset ├── ClusterInputManager.asset ├── EditorBuildSettings.asset └── UnityConnectSettings.asset ├── .gitignore ├── Assets ├── LaserSword │ ├── Demo │ │ ├── FloorMaterial.mat │ │ ├── FloorTexture.png │ │ ├── WallMaterial.mat │ │ ├── WallTexture.JPG │ │ ├── CeilingMaterial.mat │ │ ├── CeilingTexture.JPG │ │ ├── WallTextureNormalMap.JPG │ │ ├── CeilingTextureNormalMap.JPG │ │ ├── DemoSceneLaserSword.unity │ │ ├── FloorMaterial.mat.meta │ │ ├── WallMaterial.mat.meta │ │ ├── CeilingMaterial.mat.meta │ │ ├── DemoSceneLaserSword.unity.meta │ │ ├── RotateObjectsScript.cs.meta │ │ ├── RotateObjectsScript.cs │ │ ├── FloorTexture.png.meta │ │ ├── WallTexture.JPG.meta │ │ ├── CeilingTexture.JPG.meta │ │ ├── CeilingTextureNormalMap.JPG.meta │ │ └── WallTextureNormalMap.JPG.meta │ ├── Sounds │ │ ├── LaserSwordOn1.mp3 │ │ ├── LaserSwordOn2.mp3 │ │ ├── LaserSwordOff1.mp3 │ │ ├── LaserSwordOff2.mp3 │ │ ├── LaserSwordConstant1.mp3 │ │ ├── LaserSwordConstant2.mp3 │ │ ├── LaserSwordOff1.mp3.meta │ │ ├── LaserSwordOff2.mp3.meta │ │ ├── LaserSwordOn1.mp3.meta │ │ ├── LaserSwordOn2.mp3.meta │ │ ├── LaserSwordConstant1.mp3.meta │ │ └── LaserSwordConstant2.mp3.meta │ ├── Model │ │ ├── LaserSwordMesh.mesh │ │ ├── LaserSwordModel.3DS │ │ ├── LaserSwordMesh.mesh.meta │ │ └── LaserSwordModel.3DS.meta │ ├── Material │ │ ├── LaserSwordMaterial.mat │ │ ├── LaserSwordHiltTexture.jpg │ │ ├── LaserSwordHiltMaterial.mat │ │ ├── LaserSwordHiltNormalMap.jpg │ │ ├── LaserSwordVolumetricGlowMaterial.mat │ │ ├── LaserSwordHiltMaterial.mat.meta │ │ ├── LaserSwordMaterial.mat.meta │ │ ├── LaserSwordVolumetricGlowMaterial.mat.meta │ │ ├── LaserSwordHiltNormalMap.jpg.meta │ │ └── LaserSwordHiltTexture.jpg.meta │ ├── Prefab │ │ ├── LaserSwordPrefab.prefab │ │ └── LaserSwordPrefab.prefab.meta │ ├── Profiles │ │ ├── LaserSwordProfile_Red.asset │ │ ├── LaserSwordProfile_Purple.asset │ │ ├── LaserSwordProfile_White.asset │ │ ├── LaserSwordProfile_Purple.asset.meta │ │ ├── LaserSwordProfile_Red.asset.meta │ │ └── LaserSwordProfile_White.asset.meta │ ├── Model.meta │ ├── Prefab.meta │ ├── Script.meta │ ├── Shader.meta │ ├── Material.meta │ ├── Profiles.meta │ ├── Readme.txt.meta │ ├── Demo.meta │ ├── Sounds.meta │ ├── Shader │ │ ├── LaserSwordShader.shader.meta │ │ ├── LaserSwordVolumetricGlowShader.shader.meta │ │ ├── LaserSwordShader.shader │ │ └── LaserSwordVolumetricGlowShader.shader │ ├── Script │ │ ├── LaserSwordProfileScript.cs.meta │ │ ├── LaserSwordScript.cs.meta │ │ ├── LaserSwordBladeCreatorScript.cs.meta │ │ ├── LaserSwordProfileScript.cs │ │ ├── LaserSwordScript.cs │ │ └── LaserSwordBladeCreatorScript.cs │ └── Readme.txt ├── LaserSword.meta └── AssetStoreTools.meta ├── .github └── FUNDING.yml ├── README.md ├── LICENSE └── Packages └── manifest.json /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.4.34f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/VFXManager.asset -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Library 2 | Temp 3 | Obj 4 | Logs 5 | *.csproj 6 | *.user 7 | *.sln 8 | *.suo 9 | .vs 10 | AssetStoreTools 11 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/FloorMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/FloorMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/FloorTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/FloorTexture.png -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/WallMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallTexture.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/WallTexture.JPG -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/CeilingMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingTexture.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/CeilingTexture.JPG -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOn1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordOn1.mp3 -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOn2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordOn2.mp3 -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Model/LaserSwordMesh.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Model/LaserSwordMesh.mesh -------------------------------------------------------------------------------- /Assets/LaserSword/Model/LaserSwordModel.3DS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Model/LaserSwordModel.3DS -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOff1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordOff1.mp3 -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOff2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordOff2.mp3 -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallTextureNormalMap.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/WallTextureNormalMap.JPG -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingTextureNormalMap.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/CeilingTextureNormalMap.JPG -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/DemoSceneLaserSword.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Demo/DemoSceneLaserSword.unity -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Material/LaserSwordMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Prefab/LaserSwordPrefab.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Prefab/LaserSwordPrefab.prefab -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordConstant1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordConstant1.mp3 -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordConstant2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Sounds/LaserSwordConstant2.mp3 -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Material/LaserSwordHiltTexture.jpg -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Material/LaserSwordHiltMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltNormalMap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Material/LaserSwordHiltNormalMap.jpg -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_Red.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Profiles/LaserSwordProfile_Red.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_Purple.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Profiles/LaserSwordProfile_Purple.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_White.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Profiles/LaserSwordProfile_White.asset -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordVolumetricGlowMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjxtra/UnityLaserSword/HEAD/Assets/LaserSword/Material/LaserSwordVolumetricGlowMaterial.mat -------------------------------------------------------------------------------- /Assets/LaserSword/Model.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0e58d166b03ac74082edcfd77bfafb3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76617d52269fde3408c1d635520a2af8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5864c5f295480c488c95fa20191f629 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9aab92750589df43bb1b13b9ddc21cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26b7803928f011940bb32a6269a11b80 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fba5f778d06993d40acc38a19052adde 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad939a64220e1e84795f1cad3f7e90fc 3 | timeCreated: 1462815258 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/FloorMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 173ef3444b7c4e24aaf5e1194574b262 3 | timeCreated: 1462595133 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ec9fe2d37daf8f47b78fb544a05ae16 3 | timeCreated: 1462726026 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23472d5ea97627b4fa3e12deb2305e93 3 | folderAsset: yes 4 | timeCreated: 1462592849 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4117b44ad466ca148ac0616bd00110b3 3 | timeCreated: 1462726520 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/DemoSceneLaserSword.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 402c585eaf9d70d40b70310935e79846 3 | timeCreated: 1462593021 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d52aeb61b850d4449bafdd66861158b6 3 | folderAsset: yes 4 | timeCreated: 1510760279 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a4633155ca9ce44197911ec306655bc 3 | folderAsset: yes 4 | timeCreated: 1462595341 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Model/LaserSwordMesh.mesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d9cf1553bf06c3468c57334a8972976 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 4300000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Prefab/LaserSwordPrefab.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4055cd0b1c63c62488823f03b99fcde6 3 | timeCreated: 1463082751 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cf1b010c1f4d4141ae8f4d322afa623 3 | folderAsset: yes 4 | timeCreated: 1462727540 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56b138c867418644688d1a55d7f3f1f6 3 | timeCreated: 1462592868 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19e73bd1826976d4ba550315e7ed5615 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_Purple.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 422e2699f8e8d1d409b5f3e7ec0ba7d0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_Red.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3909a5663c619134d90be62a8db5083b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Profiles/LaserSwordProfile_White.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b5a9d6a4f0603545bd7d968cd0c818a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordVolumetricGlowMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6a1bbfabc4211b4281732c52c7b8d79 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/LaserSword/Shader/LaserSwordShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48f75c9902d5b474e9fc5ec7b766231a 3 | timeCreated: 1462641281 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Shader/LaserSwordVolumetricGlowShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e9bc47bd51557c4e90a36e633a46a4b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/RotateObjectsScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9951ffb37e7efd74cb1635a202ec724a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/LaserSword/Script/LaserSwordProfileScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13100a6bc54621e44bb9ef4490f7ccd1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/LaserSword/Script/LaserSwordScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf744ee9883d0e04a8f176084025ef88 3 | timeCreated: 1462593503 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/LaserSword/Script/LaserSwordBladeCreatorScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ffc5c5df4e78ac4383914d33173a86b 3 | timeCreated: 1462728488 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/LaserSword/Sounds/LaserSwordOff1.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70576a72353c59e439f05cbbe0b26d76 3 | timeCreated: 1462806659 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOff2.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74e148c5748cb3b4baeb473bb95ecb03 3 | timeCreated: 1463245198 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOn1.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 819c365123089f843a64bc7ae48db514 3 | timeCreated: 1462806659 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordOn2.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e5b8b0e84ce4274786b4ceb4134e572 3 | timeCreated: 1463245198 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordConstant1.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52c565fe2678e41449f22d3eb014d9d5 3 | timeCreated: 1462766102 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/LaserSword/Sounds/LaserSwordConstant2.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e654dad5826f75439d0b193c671faa2 3 | timeCreated: 1463245198 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 1 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 1 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 1 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: jjxtra 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/RotateObjectsScript.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace DigitalRuby.LaserSword 6 | { 7 | public class RotateObjectsScript : MonoBehaviour 8 | { 9 | public RotationInfo[] ObjectsToRotate; 10 | 11 | private void Update() 12 | { 13 | foreach (var info in ObjectsToRotate) 14 | { 15 | if (info != null && info.Transform != null) 16 | { 17 | info.Transform.Rotate(info.RotationVelocity * Time.deltaTime); 18 | } 19 | } 20 | } 21 | } 22 | 23 | [System.Serializable] 24 | public class RotationInfo 25 | { 26 | public Transform Transform; 27 | public Vector3 RotationVelocity = new Vector3(20.0f, 175.0f, 150.0f); 28 | } 29 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Unity Laser Sword - Volumetric Laser Sword in Unity. 2 | by Jeff Johnson (jjxtra) 3 | http://www.digitalruby.com 4 | 5 | I made every effort to get this on the asset store but it was denied multiple times, even though other "laser sword" assets made it on the store somehow. I love the consistency there... 6 | 7 | I spent a few weeks putting this laser sword together for Unity. The asset store won't host it because of copyright issues, so now it's freely available on GitHub! 8 | 9 | The blade is fully volumetric (including glow), with a nice rim shader. 10 | 11 | Demo Video:

12 | [![Alt text](https://img.youtube.com/vi/qfCQdwYs23I/0.jpg)](https://www.youtube.com/watch?v=qfCQdwYs23I) 13 | 14 | Screenshot: 15 | 16 | ![Lightsaber for Unity Screenshot](https://www.digitalruby.com/wp-content/uploads/2015/04/VolumetricLightsaber.jpg) 17 | 18 | Jeff Johnson 19 | 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Jeff Johnson 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 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/FloorTexture.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02e131fd5f323a443a2532f881d2f138 3 | timeCreated: 1462595121 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallTexture.JPG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e013257bacf49040adba791bbfe04a1 3 | timeCreated: 1462725957 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingTexture.JPG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35ef5d954d708ed40ae77a45cc2d651f 3 | timeCreated: 1462726407 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/CeilingTextureNormalMap.JPG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f05aec3ad8c6c943bcb29564ebc840e 3 | timeCreated: 1462726408 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 1 19 | externalNormalMap: 1 20 | heightScale: 0.088 21 | normalMapFilter: 1 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Demo/WallTextureNormalMap.JPG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52a2f600e0d48c549a36a1db2c7876e4 3 | timeCreated: 1462725959 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 1 19 | externalNormalMap: 1 20 | heightScale: 0.039 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltNormalMap.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44cf6e4b07dbd6a4a8f75b135cb4e3db 3 | timeCreated: 1462592936 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 1 19 | externalNormalMap: 1 20 | heightScale: 0.001 21 | normalMapFilter: 1 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/LaserSword/Material/LaserSwordHiltTexture.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94356e3cd7ec158498301a37c408c48c 3 | timeCreated: 1462592868 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "3.2.3", 5 | "com.unity.collab-proxy": "1.2.15", 6 | "com.unity.package-manager-ui": "2.0.13", 7 | "com.unity.purchasing": "2.2.1", 8 | "com.unity.textmeshpro": "1.4.1", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.animation": "1.0.0", 11 | "com.unity.modules.assetbundle": "1.0.0", 12 | "com.unity.modules.audio": "1.0.0", 13 | "com.unity.modules.cloth": "1.0.0", 14 | "com.unity.modules.director": "1.0.0", 15 | "com.unity.modules.imageconversion": "1.0.0", 16 | "com.unity.modules.imgui": "1.0.0", 17 | "com.unity.modules.jsonserialize": "1.0.0", 18 | "com.unity.modules.particlesystem": "1.0.0", 19 | "com.unity.modules.physics": "1.0.0", 20 | "com.unity.modules.physics2d": "1.0.0", 21 | "com.unity.modules.screencapture": "1.0.0", 22 | "com.unity.modules.terrain": "1.0.0", 23 | "com.unity.modules.terrainphysics": "1.0.0", 24 | "com.unity.modules.tilemap": "1.0.0", 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.uielements": "1.0.0", 27 | "com.unity.modules.umbra": "1.0.0", 28 | "com.unity.modules.unityanalytics": "1.0.0", 29 | "com.unity.modules.unitywebrequest": "1.0.0", 30 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 31 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 32 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 33 | "com.unity.modules.unitywebrequestwww": "1.0.0", 34 | "com.unity.modules.vehicles": "1.0.0", 35 | "com.unity.modules.video": "1.0.0", 36 | "com.unity.modules.vr": "1.0.0", 37 | "com.unity.modules.wind": "1.0.0", 38 | "com.unity.modules.xr": "1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/LaserSword/Model/LaserSwordModel.3DS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7527cc0e3b6359448a84dc6b9670b274 3 | timeCreated: 1462592869 4 | licenseType: Free 5 | ModelImporter: 6 | serializedVersion: 19 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: lightsaber 13 | 6400000: //RootNode 14 | materials: 15 | importMaterials: 0 16 | materialName: 0 17 | materialSearch: 1 18 | animations: 19 | legacyGenerateAnimations: 4 20 | bakeSimulation: 0 21 | resampleRotations: 1 22 | optimizeGameObjects: 0 23 | motionNodeName: 24 | animationImportErrors: 25 | animationImportWarnings: 26 | animationRetargetingWarnings: 27 | animationDoRetargetingWarnings: 0 28 | animationCompression: 1 29 | animationRotationError: 0.5 30 | animationPositionError: 0.5 31 | animationScaleError: 0.5 32 | animationWrapMode: 0 33 | extraExposedTransformPaths: [] 34 | clipAnimations: [] 35 | isReadable: 1 36 | meshes: 37 | lODScreenPercentages: [] 38 | globalScale: 0.025 39 | meshCompression: 0 40 | addColliders: 1 41 | importBlendShapes: 1 42 | swapUVChannels: 0 43 | generateSecondaryUV: 0 44 | useFileUnits: 1 45 | optimizeMeshForGPU: 1 46 | keepQuads: 0 47 | weldVertices: 1 48 | secondaryUVAngleDistortion: 8 49 | secondaryUVAreaDistortion: 15.000001 50 | secondaryUVHardAngle: 88 51 | secondaryUVPackMargin: 4 52 | useFileScale: 1 53 | tangentSpace: 54 | normalSmoothAngle: 60 55 | normalImportMode: 0 56 | tangentImportMode: 3 57 | importAnimation: 0 58 | copyAvatar: 0 59 | humanDescription: 60 | human: [] 61 | skeleton: [] 62 | armTwist: 0.5 63 | foreArmTwist: 0.5 64 | upperLegTwist: 0.5 65 | legTwist: 0.5 66 | armStretch: 0.05 67 | legStretch: 0.05 68 | feetSpacing: 0 69 | rootMotionBoneName: 70 | hasTranslationDoF: 0 71 | lastHumanDescriptionAvatarSource: {instanceID: 0} 72 | animationType: 0 73 | humanoidOversampling: 1 74 | additionalBone: 0 75 | userData: 76 | assetBundleName: 77 | assetBundleVariant: 78 | -------------------------------------------------------------------------------- /Assets/LaserSword/Script/LaserSwordProfileScript.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace DigitalRuby.LaserSword 4 | { 5 | [CreateAssetMenu(fileName = "LaserSwordProfile_", menuName = "LaserSword/Create Profile", order = 1)] 6 | public class LaserSwordProfileScript : ScriptableObject 7 | { 8 | [Header("Blade")] 9 | [Tooltip("Blade texture")] 10 | public Texture2D BladeTexture; 11 | 12 | [Tooltip("Blade color")] 13 | public Color BladeColor = Color.magenta; 14 | 15 | [Range(0.0f, 10.0f)] 16 | [Tooltip("Blade intensity")] 17 | public float BladeIntensity = 1.0f; 18 | 19 | [Tooltip("Blade rim color")] 20 | public Color BladeRimColor = Color.white; 21 | 22 | [Range(0.0f, 8.0f)] 23 | [Tooltip("Blade rim power")] 24 | public float BladeRimPower = 2.0f; 25 | 26 | [Range(0.0f, 10.0f)] 27 | [Tooltip("Blade rim intensity")] 28 | public float BladeRimIntensity = 1.0f; 29 | 30 | [Header("Glow")] 31 | [Tooltip("Glow color")] 32 | public Color GlowColor = Color.red; 33 | 34 | [Tooltip("Glow intensity")] 35 | [Range(0.0f, 100.0f)] 36 | public float GlowIntensity = 3.0f; 37 | 38 | [Tooltip("Glow falloff, control power of glow")] 39 | [Range(0.0f, 64.0f)] 40 | public float GlowFalloff = 1.5f; 41 | 42 | [Tooltip("Glow center falloff, control glow further from center of blade")] 43 | [Range(0.01f, 1.0f)] 44 | public float GlowCenterFalloff = 0.15f; 45 | 46 | [Tooltip("Glow dither")] 47 | [Range(0.0f, 1.0f)] 48 | public float GlowDither = 0.1f; 49 | 50 | [Tooltip("Glow max")] 51 | [Range(0.0f, 10.0f)] 52 | public float GlowMax = 1.0f; 53 | 54 | [Tooltip("Glow scale / width")] 55 | public Vector3 GlowScale = new Vector3(0.35f, 1.5f, 0.35f); 56 | 57 | [Header("Audio")] 58 | [Tooltip("Sound to play when the laser sword turns on")] 59 | public AudioClip StartSound; 60 | 61 | [Tooltip("Sound to play when the laser sword turns off")] 62 | public AudioClip StopSound; 63 | 64 | [Tooltip("Sound to play when the laser sword stays on")] 65 | public AudioClip ConstantSound; 66 | 67 | [Header("Other")] 68 | [Tooltip("How long it takes to turn the laser sword on and off")] 69 | [Range(0.1f, 3.0f)] 70 | public float ActivationTime = 1.0f; 71 | 72 | [Tooltip("Flicker intensity")] 73 | [Range(0.0f, 0.3f)] 74 | public float FlickerIntensity = 0.03f; 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/LaserSword/Readme.txt: -------------------------------------------------------------------------------- 1 | Laser Sword for Unity 2 | (c) 2016 Digital Ruby, LLC 3 | Created by Jeff Johnson 4 | http://www.digitalruby.com 5 | 6 | Laster Sword for Unity is a highly realistic and beautiful representation of a beam sword. With a volumetric blade, glow, sounds and great looking hilt, this laser sword will wow your friends, co-workers and users. 7 | 8 | Instructions: 9 | I've created three prefabs for you: LaserSwordWhite, LaserSwordRed, and LaserSwordPurple. These are ready to be used as is. Simply drag the prefab into your scene and parent it to the appropriate object. 10 | 11 | Scripting: 12 | To turn on / off the weapon, call Activate, Deactivate, SetActive or TurnOn. All will get the job done. The weapon will not turn on or off if it is in progress of turning on or off. 13 | 14 | The demo has added a rotation to the weapons, but you can set this to 0 for your app or game (i.e. script.RotationSpeed = Vector3.zero, or set it in the inspector), or just remove the property entirely. 15 | 16 | Note: LaserSwordBladeCreatorScript is the script that creates the blade, and is a component on the top level of the prefab object, along with LaserSwordScript. 17 | 18 | Physics: 19 | The hilt and blade both have mesh colliders. The blade is a trigger. To allow the weapon to be thrown, you will have to move the LaserSwordRoot transform yourself. 20 | 21 | Customization: 22 | You can easily build your own laser sword by cloning the prefab and changing all the properties. 23 | 24 | How to create your own laser sword: 25 | 1] Swap out the hilt 3D model with one of your own. LaserSwordHilt in the prefab contains the mesh filter and material. You'll need to set these to your own mesh and material. 26 | 1a] For best results, the hilt model should be pointing straight up along the y axis without any additional rotation applied. 27 | 2] Change the hilt position, rotation and scale to be appropriate for your model. 28 | 3] Change the blade height to be appropriate for your usage. 29 | 4] Change the start and end radius of the blade to your liking. 30 | 5] Swap out the mesh renderer material on the LaserSwordBlade (LaserSwordRoot -> LaserSwordHilt -> LaserSwordBlade) to change colors. 31 | 6] The LaserSwordBlade object uses a custom shader, so you probably just want to copy an existing material, such as LaserSwordBladeWhiteMaterial, change the texture and tint colors, and use that. 32 | 7] The LaserSwordBladeGlow object uses volumetric glow with a capsule. 33 | 8] Change the audio clips on LaserSwordScript for on/off/constant to your own if you like. 34 | 9] Set the BladeStart object to the top of your hilt, right where you want the blade to come out. 35 | 10] There is no need to set BladeEnd, it is calculated automatically based off of the blade height. 36 | 11] Change the color of the LaserSwordLight object if you want. The glow color will match. 37 | 12] The rim color changes the color towards the edges of the weapon. For best results, keep this somewhat similar to the regular tint color. 38 | 39 | Rotation: 40 | Set all rotation values to 0 on LaserSwordScript to disable the demo rotation. 41 | 42 | Anti-Aliasing: 43 | If you are using deferred rendering, you should import the anti-aliasing script from the standard effects package, plust anti-aliasing shaders and add the script to your camera. For forward rendering, be sure you enable anti-aliasing for better looking edges on the weapon. 44 | 45 | Please email support@digitalruby.com if you have further questions. 46 | 47 | - Jeff -------------------------------------------------------------------------------- /Assets/LaserSword/Shader/LaserSwordShader.shader: -------------------------------------------------------------------------------- 1 | // Laser Sword for Unity 2 | // (c) 2016 Digital Ruby, LLC 3 | // http://www.digitalruby.com 4 | 5 | Shader "LaserSword/LaserSwordShader" 6 | { 7 | Properties 8 | { 9 | [PerRendererData] _MainTex("Main Texture", 2D) = "white" {} 10 | [PerRendererData] _TintColor ("Tint Color", Color) = (1, 1, 1, 1) 11 | [PerRendererData] _Intensity("Intensity", Float) = 1 12 | [PerRendererData] _RimColor("Rim Color", Color) = (1, 1, 1, 1) 13 | [PerRendererData] _RimPower("Rim Power", Float) = 2 14 | [PerRendererData] _RimIntensity("Rim Intensity", Float) = 1 15 | [PerRendererData] _InvFade("Inv Fade", Range(0.01, 3.0)) = 0.5 16 | } 17 | 18 | SubShader 19 | { 20 | Tags{ "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" "LightMode" = "Always" "PreviewType" = "Plane" } 21 | LOD 100 22 | Cull Back 23 | Lighting Off 24 | ColorMask RGBA 25 | ZWrite Off 26 | Blend SrcAlpha OneMinusSrcAlpha 27 | 28 | Pass 29 | { 30 | CGPROGRAM 31 | 32 | #pragma vertex vert 33 | #pragma fragment frag 34 | #pragma fragmentoption ARB_precision_hint_fastest 35 | #pragma multi_compile_instancing 36 | #pragma multi_compile_particles 37 | 38 | #include "UnityCG.cginc" 39 | 40 | uniform sampler2D _MainTex; 41 | uniform float4 _MainTex_ST; 42 | uniform fixed4 _TintColor; 43 | uniform fixed _Intensity; 44 | uniform fixed4 _RimColor; 45 | uniform fixed _RimPower; 46 | uniform fixed _RimIntensity; 47 | uniform fixed _InvFade; 48 | 49 | #if defined(SOFTPARTICLES_ON) 50 | 51 | uniform sampler2D _CameraDepthTexture; 52 | 53 | #endif 54 | 55 | struct appdata_t 56 | { 57 | float4 vertex : POSITION; 58 | float3 normal : NORMAL; 59 | fixed4 color : COLOR; 60 | float2 texcoord : TEXCOORD0; 61 | }; 62 | 63 | struct v2f 64 | { 65 | float4 vertex : SV_POSITION; 66 | fixed4 color : COLOR; 67 | float2 texcoord : TEXCOORD0; 68 | 69 | #if defined(SOFTPARTICLES_ON) 70 | 71 | float4 worldPos : TEXCOORD1; 72 | float4 projPos : TEXCOORD2; 73 | 74 | #endif 75 | 76 | }; 77 | 78 | #define WM_INSTANCE_VERT(v, type, o) type o; UNITY_SETUP_INSTANCE_ID(v); UNITY_TRANSFER_INSTANCE_ID(v, o); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 79 | #define WM_INSTANCE_FRAG(i) UNITY_SETUP_INSTANCE_ID(i); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); 80 | 81 | inline float3 WorldSpaceVertexPos(float4 vertex) 82 | { 83 | return mul(unity_ObjectToWorld, vertex).xyz; 84 | } 85 | 86 | inline float3 WorldSpaceNormal(float3 normal) 87 | { 88 | return mul((float3x3)unity_ObjectToWorld, normal); 89 | } 90 | 91 | v2f vert (appdata_t v) 92 | { 93 | WM_INSTANCE_VERT(v, v2f, o); 94 | 95 | o.vertex = UnityObjectToClipPos(v.vertex); 96 | o.color = v.color; 97 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 98 | fixed3 viewDir = normalize(_WorldSpaceCameraPos - WorldSpaceVertexPos(v.vertex).xyz); 99 | fixed3 normalDir = normalize(WorldSpaceNormal(v.normal)); 100 | o.color.a = 1.0 - abs(dot(viewDir, normalDir)); 101 | 102 | #if defined(SOFTPARTICLES_ON) 103 | 104 | o.projPos = ComputeScreenPos(o.vertex); 105 | COMPUTE_EYEDEPTH(o.projPos.z); 106 | o.worldPos.xyz = mul(unity_ObjectToWorld, v.vertex).xyz; 107 | o.worldPos.w = distance(_WorldSpaceCameraPos, o.worldPos.xyz); 108 | 109 | #endif 110 | 111 | return o; 112 | } 113 | 114 | fixed4 frag (v2f i) : SV_Target 115 | { 116 | WM_INSTANCE_FRAG(i); 117 | 118 | fixed rim = i.color.a; 119 | fixed3 rimLight = _RimIntensity * pow(rim, _RimPower) * _RimColor.rgb; 120 | fixed3 col = tex2D(_MainTex, i.texcoord).rgb * i.color.rgb * _TintColor.rgb * _Intensity; 121 | col += rimLight; 122 | 123 | #if defined(SOFTPARTICLES_ON) 124 | 125 | float sceneZ = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 126 | float partZ = i.projPos.z; 127 | float fade = saturate(_InvFade * min(partZ * partZ * partZ, (sceneZ - partZ))); 128 | return fixed4(col, fade); 129 | #else 130 | 131 | return fixed4(col, 1.0); 132 | 133 | #endif 134 | 135 | } 136 | 137 | ENDCG 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /Assets/LaserSword/Shader/LaserSwordVolumetricGlowShader.shader: -------------------------------------------------------------------------------- 1 | Shader "LaserSword/LaserSwordVolumetricGlowShader" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0) 6 | [PerRendererData] _CapsuleStart("Start", Vector) = (0.0, 0.0, 0.0, 0.0) 7 | [PerRendererData] _CapsuleEnd("End", Vector) = (0.0, 10.0, 0.0, 0.0) 8 | [PerRendererData] _CapsuleRadius("Radius", Float) = 0.5 9 | [PerRendererData] _GlowIntensity("Intensity", Range(0.0, 10.0)) = 3.0 10 | [PerRendererData] _GlowFalloff("Glow Power", Range(0.01, 8.0)) = 1.5 11 | [PerRendererData] _GlowCenterFalloff("Glow Center Power", Range(0.01, 1.0)) = 0.15 12 | [PerRendererData] _GlowDither("Glow Dither", Range(0.0, 1.0)) = 0.1 13 | [PerRendererData] _GlowMax("Max Glow", Range(0.0, 3.0)) = 1.0 14 | [PerRendererData] _GlowInvFade("Glow inv fade", Range(0.0, 3.0)) = 0.5 15 | } 16 | SubShader 17 | { 18 | Tags{ "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent+1" "LightMode" = "Always" "PreviewType" = "Plane" } 19 | 20 | Pass 21 | { 22 | Blend One One 23 | ZWrite Off 24 | Cull Front 25 | 26 | CGPROGRAM 27 | 28 | #pragma vertex vert 29 | #pragma fragment frag 30 | #pragma fragmentoption ARB_precision_hint_fastest 31 | #pragma multi_compile_instancing 32 | #pragma multi_compile_particles 33 | 34 | #include "UnityCG.cginc" 35 | 36 | uniform fixed3 _Color; 37 | uniform float3 _CapsuleStart; 38 | uniform float3 _CapsuleEnd; 39 | uniform float _CapsuleRadius; 40 | uniform float _CapsuleRadiusInv; 41 | uniform fixed _GlowIntensity; 42 | uniform fixed _GlowFalloff; 43 | uniform fixed _GlowCenterFalloff; 44 | uniform fixed _GlowDither; 45 | uniform fixed _GlowMax; 46 | uniform fixed _GlowInvFade; 47 | 48 | #if defined(SOFTPARTICLES_ON) 49 | 50 | uniform sampler2D _CameraDepthTexture; 51 | 52 | #endif 53 | 54 | static const float3 capsuleDir = normalize(_CapsuleStart - _CapsuleEnd); 55 | static const float3 capsuleCenter = (_CapsuleStart + _CapsuleEnd) * 0.5; 56 | static const float capsuleHeightHalf = 1.0 / (distance(_CapsuleStart, _CapsuleEnd) * 0.5); 57 | 58 | #define WM_INSTANCE_VERT(v, type, o) type o; UNITY_SETUP_INSTANCE_ID(v); UNITY_TRANSFER_INSTANCE_ID(v, o); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 59 | #define WM_INSTANCE_FRAG(i) UNITY_SETUP_INSTANCE_ID(i); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); 60 | 61 | struct appdata_vert 62 | { 63 | float4 vertex : POSITION; 64 | }; 65 | 66 | struct v2f 67 | { 68 | float4 vertex : SV_POSITION; 69 | float3 rayDir : NORMAL; 70 | float4 worldPos : TEXCOORD0; 71 | 72 | #if defined(SOFTPARTICLES_ON) 73 | 74 | float4 projPos : TEXCOORD1; 75 | 76 | #endif 77 | 78 | }; 79 | 80 | // intersect capsule : http://www.iquilezles.org/www/articles/intersectors/intersectors.htm 81 | float CapsuleIntersect(in float3 ro, in float3 rd, in float3 pa, in float3 pb, in float r) 82 | { 83 | float3 ba = pb - pa; 84 | float3 oa = ro - pa; 85 | 86 | float baba = dot(ba, ba); 87 | float bard = dot(ba, rd); 88 | float baoa = dot(ba, oa); 89 | float rdoa = dot(rd, oa); 90 | float oaoa = dot(oa, oa); 91 | 92 | float a = baba - bard * bard; 93 | float b = baba * rdoa - baoa * bard; 94 | float c = baba * oaoa - baoa * baoa - r * r*baba; 95 | float h = b * b - a * c; 96 | 97 | // optimization - we know we hit the capsule 98 | //UNITY_BRANCH 99 | //if (h >= 0.0) 100 | { 101 | float t = (-b - sqrt(h)) / a; 102 | float y = baoa + t * bard; 103 | 104 | UNITY_BRANCH 105 | if (y > 0.0 && y < baba) 106 | { 107 | // body 108 | h = t; 109 | } 110 | else 111 | { 112 | // caps 113 | float3 oc = (y <= 0.0) ? oa : ro - pb; 114 | b = dot(rd, oc); 115 | c = dot(oc, oc) - r * r; 116 | h = b * b - c; 117 | 118 | // optimization - we know we hit the capsule 119 | //UNITY_BRANCH 120 | //if (h > 0.0) 121 | { 122 | h = -b - sqrt(h); 123 | } 124 | //else 125 | //{ 126 | //h = 0.0; 127 | //} 128 | } 129 | } 130 | //else 131 | //{ 132 | //h = 0.0; 133 | //} 134 | 135 | // h is distance to capsule 136 | return h; 137 | } 138 | 139 | inline float RandomFloat(float3 v) 140 | { 141 | return (frac(frac(dot(v.xyz, float3(12.9898, 78.233, 45.5432))) * 43758.5453) - 0.5) * 2.0; 142 | //return frac(sin(dot(v.xyz, float3(12.9898, 78.233, 45.5432))) * 43758.5453); 143 | } 144 | 145 | inline float3 LinePointDistance3(float3 lineStart, float3 lineDir, float3 p) 146 | { 147 | // http://wiki.unity3d.com/index.php?title=3d_Math_functions 148 | 149 | // distance vector from point to line start 150 | float3 linePointToPoint = p - lineStart; 151 | 152 | // distance from line start in lineDir direction where point p is closest 153 | float t = dot(linePointToPoint, lineDir); 154 | 155 | // point on line where p is closest 156 | float3 onLine = lineStart + (lineDir * t); 157 | 158 | // distance from point to line point 159 | onLine = onLine - p; 160 | 161 | return onLine; 162 | } 163 | 164 | inline float LinePointDistance(float3 lineStart, float3 lineDir, float3 p) 165 | { 166 | float3 lp = LinePointDistance3(lineStart, lineDir, p); 167 | return length(lp); 168 | } 169 | 170 | inline float LinePointDistanceSquared(float3 lineStart, float3 lineDir, float3 p) 171 | { 172 | float3 lp = LinePointDistance3(lineStart, lineDir, p); 173 | return dot(lp, lp); 174 | } 175 | 176 | v2f vert(appdata_vert v) 177 | { 178 | WM_INSTANCE_VERT(v, v2f, o); 179 | 180 | o.vertex = UnityObjectToClipPos(v.vertex); 181 | o.worldPos.xyz = mul(unity_ObjectToWorld, v.vertex).xyz; 182 | o.worldPos.w = distance(_WorldSpaceCameraPos, o.worldPos.xyz); 183 | o.rayDir = o.worldPos - _WorldSpaceCameraPos; 184 | 185 | #if defined(SOFTPARTICLES_ON) 186 | 187 | o.projPos = ComputeScreenPos(o.vertex); 188 | COMPUTE_EYEDEPTH(o.projPos.z); 189 | 190 | #endif 191 | 192 | return o; 193 | } 194 | 195 | fixed4 frag (v2f i) : SV_Target 196 | { 197 | WM_INSTANCE_FRAG(i); 198 | 199 | i.rayDir = normalize(i.rayDir); 200 | fixed dither = (1.0 + (_GlowDither * RandomFloat(i.rayDir))); 201 | float toCapsule = CapsuleIntersect(_WorldSpaceCameraPos, i.rayDir, _CapsuleStart, _CapsuleEnd, _CapsuleRadius); 202 | float intersect = i.worldPos.w - toCapsule; 203 | float3 startPos = _WorldSpaceCameraPos + (i.rayDir * toCapsule); 204 | float3 endPos = startPos + (i.rayDir * intersect); 205 | float3 avgPos = (startPos + endPos) * 0.5; 206 | float3 offset = (i.rayDir * intersect * 0.25); 207 | fixed lineDist1 = 1.0 - (_CapsuleRadiusInv * LinePointDistance(_CapsuleStart, capsuleDir, avgPos)); 208 | fixed lineDist2 = 1.0 - (_CapsuleRadiusInv * LinePointDistance(_CapsuleStart, capsuleDir, startPos + offset)); 209 | fixed lineDist3 = 1.0 - (_CapsuleRadiusInv * LinePointDistance(_CapsuleStart, capsuleDir, endPos - offset)); 210 | fixed lineDist = (lineDist1 + lineDist2 + lineDist3) * 0.3333; 211 | fixed centerDist = pow(1.0 - saturate(capsuleHeightHalf * distance(avgPos, capsuleCenter)), _GlowCenterFalloff); 212 | 213 | intersect = min(1.0, lineDist * centerDist * dither); 214 | intersect = pow(intersect, _GlowFalloff); 215 | intersect = min(intersect * _GlowIntensity, _GlowMax); 216 | 217 | #if defined(SOFTPARTICLES_ON) 218 | 219 | float sceneZ = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 220 | float partZ = i.projPos.z; 221 | intersect *= saturate(_GlowInvFade * min(partZ * partZ * partZ, (sceneZ - partZ))); 222 | 223 | #endif 224 | 225 | return fixed4(_Color * intersect, 0.0); 226 | } 227 | ENDCG 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /Assets/LaserSword/Script/LaserSwordScript.cs: -------------------------------------------------------------------------------- 1 | // LaserSword for Unity 2 | // (c) 2016 Digital Ruby, LLC 3 | // http://www.digitalruby.com 4 | 5 | using UnityEngine; 6 | using System.Collections; 7 | 8 | namespace DigitalRuby.LaserSword 9 | { 10 | public class LaserSwordScript : MonoBehaviour 11 | { 12 | [Tooltip("Laser sword profile")] 13 | public LaserSwordProfileScript Profile; 14 | 15 | [Tooltip("Root game object.")] 16 | public GameObject Root; 17 | 18 | [Tooltip("Hilt game object.")] 19 | public GameObject Hilt; 20 | 21 | [Tooltip("Blade sword renderer.")] 22 | public MeshRenderer BladeSwordRenderer; 23 | 24 | [Tooltip("Blade glow renderer.")] 25 | public MeshRenderer BladeGlowRenderer; 26 | 27 | [Tooltip("Blade sword mesh.")] 28 | public MeshFilter BladeSwordMesh; 29 | 30 | [Tooltip("Light game object.")] 31 | public Light Light; 32 | 33 | [Tooltip("Audio source.")] 34 | public AudioSource AudioSource; 35 | 36 | [Tooltip("Audio source for looping.")] 37 | public AudioSource AudioSourceLoop; 38 | 39 | [Tooltip("Blade start")] 40 | public GameObject BladeStart; 41 | 42 | [Tooltip("Blade end")] 43 | public GameObject BladeEnd; 44 | 45 | private float bladeHeight; 46 | private int state; // 0 = off, 1 = on, 2 = turning off, 3 = turning on 47 | private GameObject temporaryBladeStart; 48 | private float bladeDir; // 1 = up, -1 = down 49 | private float bladeTime; 50 | private float bladeIntensity; 51 | private MaterialPropertyBlock swordBlock; 52 | private MaterialPropertyBlock glowBlock; 53 | 54 | private void CheckState() 55 | { 56 | if (state == 2 || state == 3) 57 | { 58 | bladeTime += Time.deltaTime; 59 | float percent = Mathf.Lerp(0.01f, 1.0f, bladeTime / Profile.ActivationTime); 60 | Vector3 end = temporaryBladeStart.transform.position + (Root.transform.up * bladeDir * percent * bladeHeight); 61 | BladeEnd.transform.position = end; 62 | bladeIntensity = Mathf.Pow((state == 3 ? percent : (1.0f - percent)), 0.33f); 63 | 64 | if (bladeTime >= Profile.ActivationTime) 65 | { 66 | GameObject.Destroy(temporaryBladeStart); 67 | bladeTime = 0.0f; 68 | if (state == 2) 69 | { 70 | state = 0; 71 | } 72 | else 73 | { 74 | state = 1; 75 | } 76 | } 77 | } 78 | } 79 | 80 | private void UpdateBlade() 81 | { 82 | float distance = Vector3.Distance(BladeEnd.transform.position, BladeStart.transform.position); 83 | float percent = distance / bladeHeight; 84 | float jitterBladeIntensity = percent * (1.0f + UnityEngine.Random.Range(0.0f, Profile.FlickerIntensity)); 85 | 86 | BladeSwordRenderer.transform.localScale = new Vector3(1.0f, percent, 1.0f); 87 | if (percent < 0.01f) 88 | { 89 | BladeSwordRenderer.gameObject.SetActive(false); 90 | BladeGlowRenderer.gameObject.SetActive(false); 91 | } 92 | else 93 | { 94 | BladeSwordRenderer.gameObject.SetActive(true); 95 | BladeGlowRenderer.gameObject.SetActive(true); 96 | } 97 | 98 | BladeGlowRenderer.transform.position = BladeStart.transform.position + ((BladeEnd.transform.position - BladeStart.transform.position) * 0.5f); 99 | BladeGlowRenderer.transform.up = (BladeEnd.transform.position - BladeStart.transform.position).normalized; 100 | BladeGlowRenderer.transform.localScale = new Vector3(Profile.GlowScale.x, (BladeEnd.transform.position - BladeStart.transform.position).magnitude * 0.5f * Profile.GlowScale.y, Profile.GlowScale.z); 101 | 102 | float halfGlowCapsule = BladeGlowRenderer.transform.lossyScale.y; 103 | Vector3 glowCapsuleTop = BladeGlowRenderer.transform.position - (halfGlowCapsule * BladeGlowRenderer.transform.up); 104 | Vector3 glowCapsuleBottom = BladeGlowRenderer.transform.position + (halfGlowCapsule * BladeGlowRenderer.transform.up); 105 | 106 | Light.intensity = jitterBladeIntensity; 107 | Light.color = Profile.GlowColor; 108 | 109 | BladeSwordRenderer.GetPropertyBlock(swordBlock); 110 | if (Profile.BladeTexture != null) 111 | { 112 | swordBlock.SetTexture("_MainTex", Profile.BladeTexture); 113 | } 114 | 115 | swordBlock.SetColor("_TintColor", Profile.BladeColor * jitterBladeIntensity); 116 | swordBlock.SetFloat("_Intensity", Profile.BladeIntensity * jitterBladeIntensity); 117 | swordBlock.SetColor("_RimColor", Profile.BladeRimColor); 118 | swordBlock.SetFloat("_RimPower", Profile.BladeRimPower); 119 | swordBlock.SetFloat("_RimIntensity", Profile.BladeRimIntensity * jitterBladeIntensity); 120 | BladeSwordRenderer.SetPropertyBlock(swordBlock); 121 | 122 | BladeGlowRenderer.GetPropertyBlock(glowBlock); 123 | float capsuleRadius = (BladeGlowRenderer.transform.lossyScale.x + BladeGlowRenderer.transform.lossyScale.z) * 0.5f; 124 | glowBlock.SetColor("_Color", Profile.GlowColor * jitterBladeIntensity); 125 | glowBlock.SetVector("_CapsuleStart", glowCapsuleTop); 126 | glowBlock.SetVector("_CapsuleEnd", glowCapsuleBottom); 127 | glowBlock.SetFloat("_CapsuleRadius", capsuleRadius); 128 | glowBlock.SetFloat("_CapsuleRadiusInv", 1.0f / capsuleRadius); 129 | glowBlock.SetFloat("_GlowIntensity", Profile.GlowIntensity * jitterBladeIntensity); 130 | glowBlock.SetFloat("_GlowFalloff", Profile.GlowFalloff); 131 | glowBlock.SetFloat("_GlowCenterFalloff", Profile.GlowCenterFalloff); 132 | glowBlock.SetFloat("_GlowDither", Profile.GlowDither); 133 | glowBlock.SetFloat("_GlowMax", Profile.GlowMax); 134 | BladeGlowRenderer.SetPropertyBlock(glowBlock); 135 | } 136 | 137 | private void Start() 138 | { 139 | swordBlock = new MaterialPropertyBlock(); 140 | glowBlock = new MaterialPropertyBlock(); 141 | BladeEnd.transform.position = BladeStart.transform.position; 142 | bladeHeight = BladeSwordMesh.sharedMesh.bounds.extents.y * 2.0f; 143 | 144 | if (Camera.main != null && Camera.main.depthTextureMode == DepthTextureMode.None) 145 | { 146 | Camera.main.depthTextureMode = DepthTextureMode.Depth; 147 | } 148 | } 149 | 150 | private void Update() 151 | { 152 | CheckState(); 153 | UpdateBlade(); 154 | } 155 | 156 | /// 157 | /// Pass true to turn on the laser sword, false to turn it off 158 | /// 159 | /// Whether the laser sword is on or off 160 | /// True if success, false if invalid operation (i.e. laser sword is already on or off) 161 | public bool TurnOn(bool value) 162 | { 163 | if (state == 2 || state == 3 || (state == 1 && value) || (state == 0 && !value)) 164 | { 165 | return false; 166 | } 167 | temporaryBladeStart = new GameObject("LaserSwordTemporaryBladeStart"); 168 | temporaryBladeStart.hideFlags = HideFlags.HideAndDontSave; 169 | temporaryBladeStart.transform.parent = Root.transform; 170 | temporaryBladeStart.transform.position = BladeEnd.transform.position; 171 | 172 | if (value) 173 | { 174 | bladeDir = 1.0f; 175 | state = 3; 176 | AudioSource.PlayOneShot(Profile.StartSound); 177 | AudioSourceLoop.clip = Profile.ConstantSound; 178 | AudioSourceLoop.Play(); 179 | } 180 | else 181 | { 182 | bladeDir = -1.0f; 183 | state = 2; 184 | AudioSource.PlayOneShot(Profile.StopSound); 185 | AudioSourceLoop.Stop(); 186 | } 187 | 188 | return true; 189 | } 190 | 191 | 192 | /// 193 | /// Turn on the laser sword 194 | /// 195 | public void Activate() 196 | { 197 | TurnOn(true); 198 | } 199 | 200 | /// 201 | /// Turn off the laser sword 202 | /// 203 | public void Deactivate() 204 | { 205 | TurnOn(false); 206 | } 207 | 208 | /// 209 | /// Activate or deactivate the laser sword 210 | /// 211 | /// True to activate, false to deactivate 212 | public void SetActive(bool active) 213 | { 214 | if (active) 215 | { 216 | Activate(); 217 | } 218 | else 219 | { 220 | Deactivate(); 221 | } 222 | } 223 | } 224 | } -------------------------------------------------------------------------------- /Assets/LaserSword/Script/LaserSwordBladeCreatorScript.cs: -------------------------------------------------------------------------------- 1 | // LaserSword for Unity 2 | // (c) 2016 Digital Ruby, LLC 3 | // http://www.digitalruby.com 4 | 5 | using UnityEngine; 6 | using System.Collections.Generic; 7 | 8 | namespace DigitalRuby.LaserSword 9 | { 10 | [ExecuteInEditMode] 11 | public class LaserSwordBladeCreatorScript : MonoBehaviour 12 | { 13 | public MeshFilter MeshFilter; 14 | 15 | [Tooltip("The length of the blade.")] 16 | [Range(0.1f, 16.0f)] 17 | public float BladeHeight = 2.73f; 18 | 19 | [Tooltip("The bottom radius.")] 20 | [Range(0.01f, 4.0f)] 21 | public float BottomRadius = 0.05f; 22 | 23 | [Tooltip("The top radius.")] 24 | [Range(0.0f, 4.0f)] 25 | public float TopRadius = 0.04f; 26 | 27 | [Tooltip("What percent of the blade is the tip?")] 28 | [Range(0.0f, 1.0f)] 29 | public float BladeTipPercent = 0.025f; 30 | 31 | [Tooltip("What percent of the TopRadius should the end of the tip radius be? 0 for a single point.")] 32 | [Range(0.0f, 4.0f)] 33 | public float BladeTipRadiusPercent = 0.0f; 34 | 35 | [Range(4, 64)] 36 | public int NumberOfSides = 32; 37 | 38 | private const int numberOfHeightSegments = 1; 39 | private const float twoPI = Mathf.PI * 2f; 40 | 41 | #if UNITY_EDITOR 42 | 43 | [Tooltip("Click to generate mesh asset")] 44 | public bool CreateMeshAsset; 45 | 46 | private Vector3[] CreateVertices() 47 | { 48 | int capVerticesCount = NumberOfSides + 1; 49 | 50 | // bottom + top + sides 51 | Vector3[] vertices = new Vector3[capVerticesCount + capVerticesCount + NumberOfSides * numberOfHeightSegments * 2 + 2]; 52 | int vert = 0; 53 | 54 | // Bottom cap 55 | vertices[vert++] = new Vector3(0f, 0f, 0f); 56 | while (vert <= NumberOfSides) 57 | { 58 | float rad = (float)vert / NumberOfSides * twoPI; 59 | vertices[vert] = new Vector3(Mathf.Cos(rad) * BottomRadius, 0f, Mathf.Sin(rad) * BottomRadius); 60 | vert++; 61 | } 62 | 63 | // Top cap 64 | vertices[vert++] = new Vector3(0f, BladeHeight, 0f); 65 | while (vert <= NumberOfSides * 2 + 1) 66 | { 67 | float rad = (float)(vert - NumberOfSides - 1) / NumberOfSides * twoPI; 68 | vertices[vert] = new Vector3(Mathf.Cos(rad) * TopRadius, BladeHeight, Mathf.Sin(rad) * TopRadius); 69 | vert++; 70 | } 71 | 72 | // Sides 73 | int v = 0; 74 | while (vert <= vertices.Length - 4) 75 | { 76 | float rad = (float)v / NumberOfSides * twoPI; 77 | vertices[vert] = new Vector3(Mathf.Cos(rad) * TopRadius, BladeHeight, Mathf.Sin(rad) * TopRadius); 78 | vertices[vert + 1] = new Vector3(Mathf.Cos(rad) * BottomRadius, 0, Mathf.Sin(rad) * BottomRadius); 79 | vert += 2; 80 | v++; 81 | } 82 | vertices[vert] = vertices[NumberOfSides * 2 + 2]; 83 | vertices[vert + 1] = vertices[NumberOfSides * 2 + 3]; 84 | 85 | return vertices; 86 | } 87 | 88 | private Vector3[] CreateNormals(Vector3[] vertices) 89 | { 90 | // bottom + top + sides 91 | Vector3[] normals = new Vector3[vertices.Length]; 92 | int vert = 0; 93 | 94 | // Bottom cap 95 | while (vert <= NumberOfSides) 96 | { 97 | normals[vert++] = Vector3.down; 98 | } 99 | 100 | // Top cap 101 | while (vert <= NumberOfSides * 2 + 1) 102 | { 103 | normals[vert++] = Vector3.up; 104 | } 105 | 106 | // Sides 107 | int v = 0; 108 | while (vert <= vertices.Length - 4) 109 | { 110 | float rad = (float)v / (float)NumberOfSides * twoPI; 111 | float cos = Mathf.Cos(rad); 112 | float sin = Mathf.Sin(rad); 113 | 114 | normals[vert] = new Vector3(cos, 0f, sin); 115 | normals[vert + 1] = normals[vert]; 116 | 117 | vert += 2; 118 | v++; 119 | } 120 | normals[vert] = normals[NumberOfSides * 2 + 2]; 121 | normals[vert + 1] = normals[NumberOfSides * 2 + 3]; 122 | 123 | return normals; 124 | } 125 | 126 | private Vector2[] CreateUVs(Vector3[] vertices) 127 | { 128 | Vector2[] uvs = new Vector2[vertices.Length]; 129 | 130 | // Bottom cap 131 | int u = 0; 132 | uvs[u++] = new Vector2(0.5f, 0.5f); 133 | while (u <= NumberOfSides) 134 | { 135 | float rad = (float)u / NumberOfSides * twoPI; 136 | uvs[u] = new Vector2(Mathf.Cos(rad) * .5f + .5f, Mathf.Sin(rad) * .5f + .5f); 137 | u++; 138 | } 139 | 140 | // Top cap 141 | uvs[u++] = new Vector2(0.5f, 0.5f); 142 | while (u <= NumberOfSides * 2 + 1) 143 | { 144 | float rad = (float)u / NumberOfSides * twoPI; 145 | uvs[u] = new Vector2(Mathf.Cos(rad) * .5f + .5f, Mathf.Sin(rad) * .5f + .5f); 146 | u++; 147 | } 148 | 149 | // Sides 150 | int u_sides = 0; 151 | while (u <= uvs.Length - 4) 152 | { 153 | float t = (float)u_sides / NumberOfSides; 154 | uvs[u] = new Vector3(t, 1f); 155 | uvs[u + 1] = new Vector3(t, 0f); 156 | u += 2; 157 | u_sides++; 158 | } 159 | uvs[u] = new Vector2(1f, 1f); 160 | uvs[u + 1] = new Vector2(1f, 0f); 161 | 162 | return uvs; 163 | } 164 | 165 | private List CreateTriangles(bool bottom, bool top) 166 | { 167 | int capVerticesCount = NumberOfSides + 1; 168 | int nbTriangles = NumberOfSides + NumberOfSides + NumberOfSides * 2; 169 | List triangles = new List(nbTriangles * 3 + 3); 170 | 171 | // Bottom cap 172 | int tri = 0; 173 | if (bottom) 174 | { 175 | while (tri < NumberOfSides - 1) 176 | { 177 | triangles.Add(0); 178 | triangles.Add(tri + 1); 179 | triangles.Add(tri + 2); 180 | tri++; 181 | } 182 | 183 | triangles.Add(0); 184 | triangles.Add(tri + 1); 185 | triangles.Add(1); 186 | tri++; 187 | } 188 | 189 | if (top) 190 | { 191 | // Top cap 192 | //tri++; 193 | while (tri < NumberOfSides * 2) 194 | { 195 | triangles.Add(tri + 2); 196 | triangles.Add(tri + 1); 197 | triangles.Add(capVerticesCount); 198 | tri++; 199 | } 200 | 201 | triangles.Add(capVerticesCount + 1); 202 | triangles.Add(tri + 1); 203 | triangles.Add(capVerticesCount); 204 | tri++; 205 | tri++; 206 | } 207 | 208 | // Sides 209 | while (tri <= nbTriangles) 210 | { 211 | triangles.Add(tri + 2); 212 | triangles.Add(tri + 1); 213 | triangles.Add(tri); 214 | tri++; 215 | 216 | triangles.Add(tri + 1); 217 | triangles.Add(tri + 2); 218 | triangles.Add(tri); 219 | tri++; 220 | } 221 | 222 | return triangles; 223 | } 224 | 225 | private Mesh CreateBladeBody() 226 | { 227 | float bladeHeight = BladeHeight; 228 | BladeHeight *= 1.0f - BladeTipPercent; 229 | Mesh mesh = new Mesh(); 230 | mesh.name = "LaserSwordMeshBladeBody"; 231 | Vector3[] vertices = CreateVertices(); 232 | Vector3[] normals = CreateNormals(vertices); 233 | Vector2[] uvs = CreateUVs(vertices); 234 | List triangles = CreateTriangles(true, false); 235 | mesh.vertices = vertices; 236 | mesh.normals = normals; 237 | mesh.uv = uvs; 238 | mesh.SetTriangles(triangles, 0); 239 | mesh.RecalculateBounds(); 240 | BladeHeight = bladeHeight; 241 | 242 | return mesh; 243 | } 244 | 245 | private Mesh CreateBladeTip() 246 | { 247 | float bladeHeight = BladeHeight; 248 | float bottomRadius = BottomRadius; 249 | float topRadius = TopRadius; 250 | 251 | BladeHeight = BladeHeight * BladeTipPercent; 252 | BottomRadius = TopRadius; 253 | TopRadius *= BladeTipRadiusPercent; 254 | 255 | Mesh mesh = new Mesh(); 256 | mesh.name = "LaserSwordMeshBladeTip"; 257 | Vector3[] vertices = CreateVertices(); 258 | Vector3[] normals = CreateNormals(vertices); 259 | Vector2[] uvs = CreateUVs(vertices); 260 | List triangles = CreateTriangles(false, true); 261 | mesh.vertices = vertices; 262 | mesh.normals = normals; 263 | mesh.uv = uvs; 264 | mesh.SetTriangles(triangles, 0); 265 | mesh.RecalculateBounds(); 266 | 267 | BladeHeight = bladeHeight; 268 | BottomRadius = bottomRadius; 269 | TopRadius = topRadius; 270 | 271 | return mesh; 272 | } 273 | 274 | private void RecreateBlade() 275 | { 276 | Mesh mesh = MeshFilter.sharedMesh; 277 | if (mesh != null) 278 | { 279 | GameObject.DestroyImmediate(mesh, true); 280 | } 281 | Mesh bladeBody = CreateBladeBody(); 282 | Mesh bladeTip = CreateBladeTip(); 283 | Mesh bladeMesh = new Mesh(); 284 | bladeMesh.name = "LigthsabreMesh"; 285 | { 286 | CombineInstance c1 = new CombineInstance(); 287 | c1.mesh = bladeBody; 288 | c1.transform = Matrix4x4.identity; 289 | CombineInstance c2 = new CombineInstance(); 290 | c2.mesh = bladeTip; 291 | c2.transform = Matrix4x4.TRS(new Vector3(0.0f, BladeHeight - (BladeHeight * BladeTipPercent), 0.0f), Quaternion.identity, Vector3.one); 292 | bladeMesh.CombineMeshes(new CombineInstance[] { c1, c2 }, true, true); 293 | bladeMesh.RecalculateBounds(); 294 | } 295 | { 296 | MeshCollider c = MeshFilter.gameObject.GetComponent(); 297 | if (c != null) 298 | { 299 | c.sharedMesh = bladeMesh; 300 | } 301 | MeshFilter.sharedMesh = bladeMesh; 302 | } 303 | 304 | if (CreateMeshAsset) 305 | { 306 | CreateMeshAsset = false; 307 | string filePath = "Assets/LaserSwordMesh.mesh"; 308 | UnityEditor.AssetDatabase.CreateAsset(Instantiate(bladeMesh), filePath); 309 | } 310 | } 311 | 312 | private void Start() 313 | { 314 | 315 | } 316 | 317 | private void Update() 318 | { 319 | RecreateBlade(); 320 | } 321 | 322 | #endif 323 | 324 | } 325 | } --------------------------------------------------------------------------------