├── .npmignore ├── Project~ ├── ProjectSettings │ ├── boot.config │ ├── ProjectVersion.txt │ ├── ClusterInputManager.asset │ ├── PresetManager.asset │ ├── NetworkManager.asset │ ├── XRSettings.asset │ ├── VersionControlSettings.asset │ ├── TimeManager.asset │ ├── EditorBuildSettings.asset │ ├── VFXManager.asset │ ├── AudioManager.asset │ ├── RiderScriptEditorPersistedState.asset │ ├── TagManager.asset │ ├── UnityConnectSettings.asset │ ├── PackageManagerSettings.asset │ ├── MemorySettings.asset │ ├── DynamicsManager.asset │ ├── EditorSettings.asset │ ├── NavMeshAreas.asset │ ├── Physics2DSettings.asset │ ├── GraphicsSettings.asset │ ├── SceneTemplateSettings.json │ └── QualitySettings.asset ├── .gitignore.meta ├── Assets │ ├── TestImages │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 1.png.meta │ │ ├── 2.png.meta │ │ ├── 3.png.meta │ │ ├── 4.png.meta │ │ └── 5.png.meta │ └── TestImages.meta ├── .vscode │ ├── extensions.json │ ├── launch.json │ └── settings.json ├── Utkaka.ScaleNineSlicer.Editor.csproj.DotSettings ├── Utkaka.ScaleNineSlicer.Editor.Window.csproj.DotSettings ├── Packages │ ├── manifest.json │ └── packages-lock.json └── .gitignore ├── Editor.meta ├── Runtime.meta ├── Tests.meta ├── Editor ├── UI.meta ├── SpriteSlicing.meta ├── UI │ ├── SlicedImageEditor.cs.meta │ ├── SlicedSpriteDrawUtility.cs.meta │ ├── Utkaka.ScaleNineSlicer.Editor.UI.asmdef.meta │ ├── Utkaka.ScaleNineSlicer.Editor.UI.asmdef │ └── SlicedSpriteDrawUtility.cs └── SpriteSlicing │ ├── Window │ ├── Assets │ │ ├── Uxml.meta │ │ ├── Sprites │ │ │ ├── checker.png │ │ │ └── checker.png.meta │ │ ├── Sprites.meta │ │ └── Uxml │ │ │ ├── BordersEditor.uxml.meta │ │ │ ├── SlicePreview.uxml.meta │ │ │ ├── SpriteNineSlicer.uxml.meta │ │ │ ├── SpriteNineSlicer.uss.meta │ │ │ ├── SpriteNineSlicer.uss │ │ │ ├── SpriteNineSlicer.uxml │ │ │ ├── SlicePreview.uxml │ │ │ └── BordersEditor.uxml │ ├── BordersEditor.cs.meta │ ├── SlicePreview.cs.meta │ ├── TiledImageElement.cs.meta │ ├── Assets.meta │ ├── Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.Window.asmdef.meta │ ├── SpriteNineSlicerWindow.cs.meta │ ├── Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.Window.asmdef │ ├── TiledImageElement.cs │ ├── SlicePreview.cs │ └── SpriteNineSlicerWindow.cs │ ├── Window.meta │ ├── Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.asmdef.meta │ ├── SpriteNineSlicerContextMenu.cs.meta │ ├── Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.asmdef │ └── SpriteNineSlicerContextMenu.cs ├── License.md.meta ├── Runtime ├── UI.meta ├── SpriteSlicing.meta ├── UI │ ├── CutLine.cs.meta │ ├── Utils.cs.meta │ ├── CutVertex.cs.meta │ ├── SlicedImage.cs.meta │ ├── CutInputVertex.cs.meta │ ├── SlicedMeshHandler.cs.meta │ ├── SpriteMeshHandler.cs.meta │ ├── ImageWithMeshStatistics.cs.meta │ ├── SlicedImageAtlasTracker.cs.meta │ ├── SlicedImageMeshContext.cs.meta │ ├── SlicedImageCustomFilling.cs.meta │ ├── Utkaka.ScaleNineSlicer.UI.asmdef.meta │ ├── CutInputVertex.cs │ ├── CutVertex.cs │ ├── SlicedImageCustomFilling.cs │ ├── Utkaka.ScaleNineSlicer.UI.asmdef │ ├── CutLine.cs │ ├── ImageWithMeshStatistics.cs │ ├── SlicedImageAtlasTracker.cs │ ├── SpriteMeshHandler.cs │ ├── Utils.cs │ └── SlicedImageMeshContext.cs └── SpriteSlicing │ ├── Utkaka.ScaleNineSlicer.SpriteSlicing.asmdef.meta │ ├── MathUtils.cs.meta │ ├── SpriteInfo.cs.meta │ ├── TrimAlphaJob.cs.meta │ ├── DetectBorderJob.cs.meta │ ├── DetectOpaqueRectJob.cs.meta │ ├── SelectBordersJob.cs.meta │ ├── TrimSliceCenterJob.cs.meta │ ├── ExtendSliceCenterJob.cs.meta │ ├── MathUtils.cs │ ├── Utkaka.ScaleNineSlicer.SpriteSlicing.asmdef │ ├── TrimAlphaJob.cs │ ├── SelectBordersJob.cs │ ├── DetectOpaqueRectJob.cs │ ├── TrimSliceCenterJob.cs │ ├── DetectBorderJob.cs │ └── ExtendSliceCenterJob.cs ├── Tests ├── Editor.meta ├── Resources │ ├── Test.png │ └── Test.png.meta ├── Runtime.meta ├── Editor │ ├── TiledVisualImageTests.cs.meta │ ├── AbstractVisualImageTest.cs.meta │ ├── FilledVisualImageTests.cs.meta │ ├── SimpleVisualImageTests.cs.meta │ ├── SlicedVisualImageTests.cs.meta │ ├── Utkaka.ScaleNineSlicer.Tests.Editor.asmdef.meta │ ├── Utkaka.ScaleNineSlicer.Tests.Editor.asmdef │ ├── SlicedVisualImageTests.cs │ ├── TiledVisualImageTests.cs │ ├── SimpleVisualImageTests.cs │ ├── AbstractVisualImageTest.cs │ └── FilledVisualImageTests.cs ├── Runtime │ ├── AbstractImageTest.cs.meta │ ├── FillAmountChange.cs.meta │ ├── AbstractPerformanceTest.cs.meta │ ├── FilledPerformanceTests.cs.meta │ ├── SlicedPerformanceTests.cs.meta │ ├── Utkaka.ScaleNineSlicer.Tests.Runtime.asmdef.meta │ ├── Utkaka.ScaleNineSlicer.Tests.Runtime.asmdef │ ├── FillAmountChange.cs │ ├── SlicedPerformanceTests.cs │ ├── FilledPerformanceTests.cs │ ├── AbstractPerformanceTest.cs │ └── AbstractImageTest.cs └── Resources.meta ├── .github ├── workflows.meta └── workflows │ ├── ci.yml.meta │ └── ci.yml ├── Samples~ ├── DiamondImageFilling.cs.meta ├── Sliced Sprite Sample.png ├── SlicedImage Sample Scene.unity.meta ├── Diamond Image Filling.asset.meta ├── Diamond Image Filling.asset ├── DiamondImageFilling.cs └── Sliced Sprite Sample.png.meta ├── Documentation~ └── images │ ├── trim-alpha.gif │ ├── trim-center.gif │ ├── autodetection.gif │ ├── custom-filling.png │ ├── sliced-filled.png │ ├── sliced-tiled-filled.png │ ├── project-view-context.png │ └── sprite-nine-slicer-editor.png ├── LICENSE.meta ├── CHANGELOG.md.meta ├── README.md.meta ├── package.json.meta ├── .releaserc.json ├── package.json ├── .gitignore ├── LICENSE ├── License.md ├── CHANGELOG.md └── README.md /.npmignore: -------------------------------------------------------------------------------- 1 | Project~/ -------------------------------------------------------------------------------- /Project~/ProjectSettings/boot.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3724a55efb664d98aa1d4a39d87b5753 3 | timeCreated: 1657276187 -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ce762b380de47d5a53306742ab7cbd8 3 | timeCreated: 1657276197 -------------------------------------------------------------------------------- /Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bc1690e3eba4a708b01d99eb6cdc873 3 | timeCreated: 1764837890 -------------------------------------------------------------------------------- /Editor/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d3ef0f12ad145aa88091e7bc1f72b7d 3 | timeCreated: 1764842896 -------------------------------------------------------------------------------- /License.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b8b676270df412eb23c3edbf82f7666 3 | timeCreated: 1657293186 -------------------------------------------------------------------------------- /Runtime/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af3dec9912254ade8f1375d34c713292 3 | timeCreated: 1764826592 -------------------------------------------------------------------------------- /Tests/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d391fa8ce8a44459360ab520691c62c 3 | timeCreated: 1764837898 -------------------------------------------------------------------------------- /Tests/Resources/Test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Tests/Resources/Test.png -------------------------------------------------------------------------------- /.github/workflows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50be265f329e44d7b097e005afae49c4 3 | timeCreated: 1657529083 -------------------------------------------------------------------------------- /Tests/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: babca9f344d946ec940f418f7f123e86 3 | timeCreated: 1765421404 -------------------------------------------------------------------------------- /Editor/SpriteSlicing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b72b35758b494bebb059e64867cfd911 3 | timeCreated: 1764827595 -------------------------------------------------------------------------------- /Project~/.gitignore.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ced6f68bc124ea0877f46ef6d3879f5 3 | timeCreated: 1647253781 -------------------------------------------------------------------------------- /Runtime/SpriteSlicing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b85ec00fd0248b7b5409f22ce3b4cbc 3 | timeCreated: 1764823342 -------------------------------------------------------------------------------- /Runtime/UI/CutLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c886daa9cfda4b68a9ecd2caf2c3bdc2 3 | timeCreated: 1763708291 -------------------------------------------------------------------------------- /Runtime/UI/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db2f1cd0dbb34ec09335357999525027 3 | timeCreated: 1764745343 -------------------------------------------------------------------------------- /.github/workflows/ci.yml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c0822cbd0b24571905a3a4c84ca6f24 3 | timeCreated: 1657529091 -------------------------------------------------------------------------------- /Project~/Assets/TestImages/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Project~/Assets/TestImages/1.png -------------------------------------------------------------------------------- /Project~/Assets/TestImages/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Project~/Assets/TestImages/2.png -------------------------------------------------------------------------------- /Project~/Assets/TestImages/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Project~/Assets/TestImages/3.png -------------------------------------------------------------------------------- /Project~/Assets/TestImages/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Project~/Assets/TestImages/4.png -------------------------------------------------------------------------------- /Project~/Assets/TestImages/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Project~/Assets/TestImages/5.png -------------------------------------------------------------------------------- /Runtime/UI/CutVertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a348d9b2ed24a99aa242bc9c68a413c 3 | timeCreated: 1763698594 -------------------------------------------------------------------------------- /Runtime/UI/SlicedImage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17e0cdbb5dcf437f91e163cdbb48d3dc 3 | timeCreated: 1763951659 -------------------------------------------------------------------------------- /Editor/UI/SlicedImageEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d71a97af80b4e219cba2d4e2237c080 3 | timeCreated: 1764821138 -------------------------------------------------------------------------------- /Project~/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "visualstudiotoolsforunity.vstuc" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /Runtime/UI/CutInputVertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d990f7d1c646fb8386c5c6859eeac2 3 | timeCreated: 1763708193 -------------------------------------------------------------------------------- /Runtime/UI/SlicedMeshHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1af019da13e3494cbe8f816da2c22334 3 | timeCreated: 1763997619 -------------------------------------------------------------------------------- /Runtime/UI/SpriteMeshHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53f7110d80004ed2987ea4fa5dd35235 3 | timeCreated: 1764739834 -------------------------------------------------------------------------------- /Samples~/DiamondImageFilling.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4778ab4b4d554be89eb0bc3523486c36 3 | timeCreated: 1765273768 -------------------------------------------------------------------------------- /Samples~/Sliced Sprite Sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Samples~/Sliced Sprite Sample.png -------------------------------------------------------------------------------- /Documentation~/images/trim-alpha.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/trim-alpha.gif -------------------------------------------------------------------------------- /Documentation~/images/trim-center.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/trim-center.gif -------------------------------------------------------------------------------- /Editor/UI/SlicedSpriteDrawUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8afde7ac7eb46f1a202c1ec98977c7b 3 | timeCreated: 1764822622 -------------------------------------------------------------------------------- /Runtime/UI/ImageWithMeshStatistics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9201c857b2184908ad1e90dbc69fe401 3 | timeCreated: 1764726547 -------------------------------------------------------------------------------- /Runtime/UI/SlicedImageAtlasTracker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62d3995ee359412e97b5ea8ce2e7174b 3 | timeCreated: 1763955828 -------------------------------------------------------------------------------- /Runtime/UI/SlicedImageMeshContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04c1491ee60247f1ac7e49bc4e391307 3 | timeCreated: 1765168374 -------------------------------------------------------------------------------- /Tests/Editor/TiledVisualImageTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a19b1c2d03cd4389ab0a97327ca0d512 3 | timeCreated: 1764732040 -------------------------------------------------------------------------------- /Tests/Runtime/AbstractImageTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e819301d0c3d4bb999e17df61fbbb856 3 | timeCreated: 1765427535 -------------------------------------------------------------------------------- /Tests/Runtime/FillAmountChange.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e6a0629d3634d8f9bda77e2359c6f48 3 | timeCreated: 1765438142 -------------------------------------------------------------------------------- /Documentation~/images/autodetection.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/autodetection.gif -------------------------------------------------------------------------------- /Documentation~/images/custom-filling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/custom-filling.png -------------------------------------------------------------------------------- /Documentation~/images/sliced-filled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/sliced-filled.png -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6099a8882f634f9da20ed55691440168 3 | timeCreated: 1652757843 -------------------------------------------------------------------------------- /Project~/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.3.45f2 2 | m_EditorVersionWithRevision: 2021.3.45f2 (88f88f591b2e) 3 | -------------------------------------------------------------------------------- /Runtime/UI/SlicedImageCustomFilling.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ea43fb4344c4cb685d6421db3fcb700 3 | timeCreated: 1765273427 -------------------------------------------------------------------------------- /Tests/Editor/AbstractVisualImageTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a92c7dc920484df7b76a89995e70ddb4 3 | timeCreated: 1764589333 -------------------------------------------------------------------------------- /Tests/Editor/FilledVisualImageTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 100a37865a974f83a6a57469bcafa754 3 | timeCreated: 1764297979 -------------------------------------------------------------------------------- /Tests/Editor/SimpleVisualImageTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24bba5f586f44cf2bdef70c7ee3ceabf 3 | timeCreated: 1764591479 -------------------------------------------------------------------------------- /Tests/Editor/SlicedVisualImageTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ea83313474d4df7af092cc256024152 3 | timeCreated: 1764731465 -------------------------------------------------------------------------------- /Tests/Runtime/AbstractPerformanceTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c53aa5f3f01446c886bdf3eb2abec18 3 | timeCreated: 1765764703 -------------------------------------------------------------------------------- /Tests/Runtime/FilledPerformanceTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e352e3ef055a4855bab1436c9d826d52 3 | timeCreated: 1765766154 -------------------------------------------------------------------------------- /Tests/Runtime/SlicedPerformanceTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab0f70e4fc5e48dd8a306f74ae46dad8 3 | timeCreated: 1765421524 -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/BordersEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73d1021029284424b4e337b3dda631b6 3 | timeCreated: 1652766429 -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/SlicePreview.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6380b05f4eca4fdc9a916ae0be31f5d1 3 | timeCreated: 1653905399 -------------------------------------------------------------------------------- /Runtime/UI/Utkaka.ScaleNineSlicer.UI.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fad6f1633be04d7da950032a41210948 3 | timeCreated: 1764827233 -------------------------------------------------------------------------------- /Documentation~/images/sliced-tiled-filled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/sliced-tiled-filled.png -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/TiledImageElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5280f7b3576e4bf9a96bec3baae7291b 3 | timeCreated: 1652348911 -------------------------------------------------------------------------------- /Documentation~/images/project-view-context.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/project-view-context.png -------------------------------------------------------------------------------- /Tests/Runtime/Utkaka.ScaleNineSlicer.Tests.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a1e4d6843144f078735cb36b59ec668 3 | timeCreated: 1765421421 -------------------------------------------------------------------------------- /Documentation~/images/sprite-nine-slicer-editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Documentation~/images/sprite-nine-slicer-editor.png -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Sprites/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utkaka/ScaleNineSlicer/HEAD/Editor/SpriteSlicing/Window/Assets/Sprites/checker.png -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c771f7a76fd4545ca84e4f6346ee27cc 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19fee1a7472254c4eb4435c2e8a523d2 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad880ff852b56443c89706c7d602a661 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b014420daa2d74f65844b5802a34f76f 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /Samples~/SlicedImage Sample Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cda990e2423bbf4892e6590ba056729 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfab2a4d1a577432fbb37eca5f04acd3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 719116da6a7284144ae79f894cdfba83 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Project~/Assets/TestImages.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 382bdd6c30d3c41689f1f641cb988c0c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Project~/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 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73094ffaf3ebc40869a74ab1bed479d4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/UI/Utkaka.ScaleNineSlicer.Editor.UI.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2f44d01d21504aadac3e2fc3de934b2 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Sprites.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d51f8b2e6110a486dbed1506cde810c8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Project~/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Attach to Unity", 6 | "type": "vstuc", 7 | "request": "attach" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /Tests/Editor/Utkaka.ScaleNineSlicer.Tests.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0ae7e1bbc9f4cccb25f13c0bc2b659b 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Diamond Image Filling.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6c807874ff024d86b010fc606a9f965 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/Utkaka.ScaleNineSlicer.SpriteSlicing.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6479a99ba786a4966bc42c4feb384a67 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5287ddc07a38244d6979efaf959f4ed4 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UI/CutInputVertex.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Utkaka.ScaleNineSlicer.UI 4 | { 5 | public struct CutInputVertex 6 | { 7 | public Vector2 Position; 8 | public Vector2 UV; 9 | public int VertexIndex; 10 | } 11 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.Window.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22b6e02d073314c3e831b12697e63d6a 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Project~/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: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/MathUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e327d03d7edd471c94798c866cc5ace 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/SpriteInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83be0b0b7405a4d579fc6588e6df7bd3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/TrimAlphaJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d34150e28f88429aa3f539a55e766fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/DetectBorderJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 235dcacb8c8704da4a3867af01459359 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/DetectOpaqueRectJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab95beee8dcb74c908bdae285956fc95 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/SelectBordersJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f2026f7549a34158ae3fe5bddbf0da8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/TrimSliceCenterJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5a7dfcb3b31541acb19900d0a6d7007 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/ExtendSliceCenterJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60363932cafb94b16becfc4d26519197 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/SpriteNineSlicerContextMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c15ad76422c4342ef8009a4ace2a5ea1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/CutVertex.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Utkaka.ScaleNineSlicer.UI 4 | { 5 | public struct CutVertex 6 | { 7 | public Vector2 Position; 8 | public Vector2 UV; 9 | public int IntersectionIndex; 10 | public int EdgeX; 11 | public int EdgeY; 12 | public int VertIndex; 13 | } 14 | } -------------------------------------------------------------------------------- /Project~/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 | - enabled: 1 9 | path: Assets/Samples/SlicedImage Sample Scene.unity 10 | guid: 2cda990e2423bbf4892e6590ba056729 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/BordersEditor.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63fbca8dfd098487880d36b5537274b5 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} 11 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/SlicePreview.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01a9493f27b0a48878cf643b01ac376f 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} 11 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/SpriteNineSlicer.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45ac467776a354b5cbede969521e0e4c 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} 11 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/SpriteNineSlicer.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebe5815569ba44fd293aecda111fcb9e 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | m_CompiledVersion: 0 14 | m_RuntimeVersion: 0 15 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/MathUtils.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using UnityEngine; 3 | 4 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 5 | public static class MathUtils { 6 | public static int4 ToInt4(this Vector4 vector4) { 7 | return new int4((int)vector4.x, (int)vector4.y, (int)vector4.z, (int)vector4.w); 8 | } 9 | 10 | public static Vector4 ToVector4(this int4 int4) { 11 | return new Vector4(int4.x, int4.y, int4.z, int4.w); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Samples~/Diamond Image Filling.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 4778ab4b4d554be89eb0bc3523486c36, type: 3} 13 | m_Name: Diamond Image Filling 14 | m_EditorClassIdentifier: 15 | -------------------------------------------------------------------------------- /Runtime/UI/SlicedImageCustomFilling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Utkaka.ScaleNineSlicer.UI 5 | { 6 | public abstract class SlicedImageCustomFilling : ScriptableObject 7 | { 8 | public abstract int GetPolygonsCount(float fillAmount); 9 | public abstract int GetPolygonCutLinesCount(int polygonIndex, float fillAmount); 10 | public abstract void FillPolygonCutLines(Span cutLines, float fillAmount, Rect rect, int polygonIndex); 11 | } 12 | } -------------------------------------------------------------------------------- /Project~/Utkaka.ScaleNineSlicer.Editor.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /Project~/Utkaka.ScaleNineSlicer.Editor.Window.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /Runtime/UI/Utkaka.ScaleNineSlicer.UI.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.UI", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer", 4 | "references": [ 5 | "GUID:d8b63aba1907145bea998dd612889d6b" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Project~/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 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 0 20 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/RiderScriptEditorPersistedState.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState 15 | lastWriteTicks: -8585440902628615432 16 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tagFormat": "v${version}", 3 | "plugins": [ 4 | ["@semantic-release/commit-analyzer", { "preset": "angular" }], 5 | "@semantic-release/release-notes-generator", 6 | ["@semantic-release/changelog", { "preset": "angular" }], 7 | ["@semantic-release/npm", { "npmPublish": false }], 8 | ["@semantic-release/git", { 9 | "assets": ["package.json", "CHANGELOG.md"], 10 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 11 | }], 12 | "@semantic-release/github" 13 | ] 14 | } -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/Utkaka.ScaleNineSlicer.SpriteSlicing.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.SpriteSlicing", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer", 4 | "references": [ 5 | "GUID:d8b63aba1907145bea998dd612889d6b" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | release: 8 | name: release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | with: 13 | fetch-depth: 0 14 | - name: Release 15 | uses: cycjimmy/semantic-release-action@v3 16 | with: 17 | extra_plugins: | 18 | @semantic-release/changelog 19 | @semantic-release/git 20 | branch: main 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /Project~/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": "1.0.0", 4 | "com.unity.ide.rider": "3.0.38", 5 | "com.unity.ide.vscode": "1.2.5", 6 | "com.unity.test-framework.performance": "3.2.0", 7 | "com.unity.ugui": "2.0.0", 8 | "com.utkaka.scale-nine-slicer": "file:../..", 9 | "com.unity.modules.imageconversion": "1.0.0", 10 | "com.unity.modules.imgui": "1.0.0", 11 | "com.unity.modules.ui": "1.0.0", 12 | "com.unity.modules.uielements": "1.0.0" 13 | }, 14 | "testables": [ 15 | "com.utkaka.scale-nine-slicer" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Runtime/UI/CutLine.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Utkaka.ScaleNineSlicer.UI 4 | { 5 | public struct CutLine 6 | { 7 | public readonly Vector2 Start; 8 | public readonly Vector2 Normal; 9 | 10 | public static CutLine FromLine(Vector2 start, Vector2 end) 11 | { 12 | var lineVector = end - start; 13 | return new CutLine(start, new Vector2(lineVector.y, -lineVector.x)); 14 | } 15 | 16 | public CutLine(Vector2 start, Vector2 normal) 17 | { 18 | Start = start; 19 | Normal = normal; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Editor/UI/Utkaka.ScaleNineSlicer.Editor.UI.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.Editor.UI", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer.Editor", 4 | "references": [ 5 | "GUID:20e2c3d5a514348c186230559fb54725", 6 | "GUID:fad6f1633be04d7da950032a41210948" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": false, 14 | "precompiledReferences": [], 15 | "autoReferenced": true, 16 | "defineConstraints": [], 17 | "versionDefines": [], 18 | "noEngineReferences": false 19 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.utkaka.scale-nine-slicer", 3 | "version": "2.0.1", 4 | "displayName": "SlicedImage", 5 | "description": "A tool for automating work with 9 slice scaling in Unity.", 6 | "unity": "2021.3", 7 | "unityRelease": "45f2", 8 | "dependencies": { 9 | "com.unity.mathematics": "1.0.1" 10 | }, 11 | "samples": [ 12 | { 13 | "displayName": "Samples", 14 | "description": "Scene with samples & custom filling sample", 15 | "path": "Samples~" 16 | } 17 | ], 18 | "author": { 19 | "name": "Anton Alexeyev", 20 | "email": "alexeyev.anton@gmail.com" 21 | }, 22 | "license": "MIT" 23 | } 24 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.Editor.SpriteSlicing", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer.Editor", 4 | "references": [ 5 | "GUID:6479a99ba786a4966bc42c4feb384a67", 6 | "GUID:d8b63aba1907145bea998dd612889d6b" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": false, 14 | "precompiledReferences": [], 15 | "autoReferenced": true, 16 | "defineConstraints": [], 17 | "versionDefines": [], 18 | "noEngineReferences": false 19 | } -------------------------------------------------------------------------------- /Tests/Runtime/Utkaka.ScaleNineSlicer.Tests.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.Tests.Runtime", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer.Tests", 4 | "references": [ 5 | "Unity.PerformanceTesting", 6 | "UnityEngine.TestRunner", 7 | "Utkaka.ScaleNineSlicer.UI" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [ 14 | "nunit.framework.dll" 15 | ], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_INCLUDE_TESTS" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/SpriteNineSlicerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51b3003487b494e01a7a109e20c2fc06 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - m_ViewDataDictionary: {instanceID: 0} 8 | - _uxmlRoot: {fileID: 9197481963319205126, guid: 45ac467776a354b5cbede969521e0e4c, type: 3} 9 | - _uxmlBorderEditor: {fileID: 9197481963319205126, guid: 63fbca8dfd098487880d36b5537274b5, type: 3} 10 | - _uxmlSlicePreview: {fileID: 9197481963319205126, guid: 01a9493f27b0a48878cf643b01ac376f, type: 3} 11 | executionOrder: 0 12 | icon: {instanceID: 0} 13 | userData: 14 | assetBundleName: 15 | assetBundleVariant: 16 | -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.Window.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.Editor.SpriteSlicing.Window", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer.Editor", 4 | "references": [ 5 | "GUID:5287ddc07a38244d6979efaf959f4ed4", 6 | "GUID:6479a99ba786a4966bc42c4feb384a67", 7 | "GUID:d8b63aba1907145bea998dd612889d6b" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": false, 15 | "precompiledReferences": [], 16 | "autoReferenced": true, 17 | "defineConstraints": [ 18 | "UNITY_2021_2_OR_NEWER" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /Tests/Editor/Utkaka.ScaleNineSlicer.Tests.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Utkaka.ScaleNineSlicer.Tests.Editor", 3 | "rootNamespace": "Utkaka.ScaleNineSlicer.Tests", 4 | "references": [ 5 | "UnityEditor.TestRunner", 6 | "Utkaka.ScaleNineSlicer.UI", 7 | "Utkaka.ScaleNineSlicer.Tests.Runtime" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [ 16 | "nunit.framework.dll" 17 | ], 18 | "autoReferenced": false, 19 | "defineConstraints": [ 20 | "UNITY_INCLUDE_TESTS" 21 | ], 22 | "versionDefines": [], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /Tests/Runtime/FillAmountChange.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | using Utkaka.ScaleNineSlicer.UI; 5 | 6 | namespace Utkaka.ScaleNineSlicer.Tests.Runtime 7 | { 8 | public class FillAmountChange : MonoBehaviour 9 | { 10 | private SlicedImage _slicedImage; 11 | private Image _image; 12 | private bool _isSliced; 13 | 14 | private void Awake() 15 | { 16 | _slicedImage = GetComponent(); 17 | _image = GetComponent(); 18 | _isSliced = _slicedImage != null; 19 | } 20 | 21 | private void Update() 22 | { 23 | if (_isSliced) 24 | { 25 | _slicedImage.fillAmount += 0.01f; 26 | } 27 | else 28 | { 29 | _image.fillAmount += 0.01f; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows thumbnail cache files 2 | Thumbs.db 3 | Thumbs.db:encryptable 4 | ehthumbs.db 5 | ehthumbs_vista.db 6 | 7 | # Dump file 8 | *.stackdump 9 | 10 | # Folder config file 11 | [Dd]esktop.ini 12 | 13 | # Recycle Bin used on file shares 14 | $RECYCLE.BIN/ 15 | 16 | # Windows Installer files 17 | *.cab 18 | *.msi 19 | *.msix 20 | *.msm 21 | *.msp 22 | 23 | # Windows shortcuts 24 | *.lnk 25 | 26 | # General 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Icon must end with two \r 32 | Icon 33 | 34 | 35 | # Thumbnails 36 | ._* 37 | 38 | # Files that might appear in the root of a volume 39 | .DocumentRevisions-V100 40 | .fseventsd 41 | .Spotlight-V100 42 | .TemporaryItems 43 | .Trashes 44 | .VolumeIcon.icns 45 | .com.apple.timemachine.donotpresent 46 | 47 | # Directories potentially created on remote AFP share 48 | .AppleDB 49 | .AppleDesktop 50 | Network Trash Folder 51 | Temporary Items 52 | .apdisk 53 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 utkaka 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 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Anton Alexeyev 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. -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/TrimAlphaJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 7 | public struct TrimAlphaJob : IJobParallelFor { 8 | [ReadOnly, NativeDisableParallelForRestriction] 9 | private NativeArray _originalPixels; 10 | [WriteOnly] 11 | private NativeArray _trimmedPixels; 12 | 13 | private readonly int _opaqueAreaStartIndex; 14 | private readonly int _opaqueAreaWidth; 15 | private int _widthDiff; 16 | 17 | public TrimAlphaJob(NativeArray originalPixels, NativeArray trimmedPixels, int4 opaqueRect, int originalWidth) { 18 | _originalPixels = originalPixels; 19 | _trimmedPixels = trimmedPixels; 20 | _opaqueAreaStartIndex = originalWidth * opaqueRect.y + opaqueRect.x; 21 | _opaqueAreaWidth = opaqueRect.z; 22 | _widthDiff = originalWidth - _opaqueAreaWidth; 23 | } 24 | 25 | public void Execute(int index) { 26 | var y = (int)math.floor((float)index / _opaqueAreaWidth); 27 | var originalIndex = index + _opaqueAreaStartIndex + y * _widthDiff; 28 | _trimmedPixels[index] = _originalPixels[originalIndex]; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Runtime/UI/ImageWithMeshStatistics.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.UI; 2 | 3 | namespace Utkaka.ScaleNineSlicer.UI 4 | { 5 | public interface IMeshStatistics 6 | { 7 | int VertexCount { get; } 8 | int TrianglesCount { get; } 9 | } 10 | 11 | public class ImageWithMeshStatistics: Image, IMeshStatistics 12 | { 13 | public int VertexCount { get; private set; } 14 | public int TrianglesCount { get; private set; } 15 | protected override void OnPopulateMesh(VertexHelper toFill) 16 | { 17 | base.OnPopulateMesh(toFill); 18 | VertexCount = toFill.currentVertCount; 19 | TrianglesCount = toFill.currentIndexCount; 20 | } 21 | } 22 | 23 | public class SlicedImageWithMeshStatistics: SlicedImage, IMeshStatistics 24 | { 25 | public int VertexCount { get; private set; } 26 | public int TrianglesCount { get; private set; } 27 | protected override void OnPopulateMesh(VertexHelper toFill) 28 | { 29 | base.OnPopulateMesh(toFill); 30 | VertexCount = toFill.currentVertCount; 31 | TrianglesCount = toFill.currentIndexCount; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_ErrorMessage: 32 | m_Original: 33 | m_Id: 34 | m_Name: 35 | m_Url: 36 | m_Scopes: [] 37 | m_IsDefault: 0 38 | m_Capabilities: 0 39 | m_Modified: 0 40 | m_Name: 41 | m_Url: 42 | m_Scopes: 43 | - 44 | m_SelectedScopeIndex: 0 45 | -------------------------------------------------------------------------------- /Project~/ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /Runtime/UI/SlicedImageAtlasTracker.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine.U2D; 3 | 4 | namespace Utkaka.ScaleNineSlicer.UI 5 | { 6 | public static class SlicedImageAtlasTracker 7 | { 8 | // To track textureless images, which will be rebuild if sprite atlas manager registered a Sprite Atlas that will give this image new texture 9 | private static readonly List TrackedTexturelessImages = new(); 10 | private static bool _initialized; 11 | 12 | private static void RebuildImage(SpriteAtlas spriteAtlas) 13 | { 14 | for (var i = TrackedTexturelessImages.Count - 1; i >= 0; i--) 15 | { 16 | var slicedImage = TrackedTexturelessImages[i]; 17 | if (null == slicedImage.activeSprite || !spriteAtlas.CanBindTo(slicedImage.activeSprite)) continue; 18 | slicedImage.SetAllDirty(); 19 | TrackedTexturelessImages.RemoveAt(i); 20 | } 21 | } 22 | 23 | public static void TrackImage(SlicedImage g) 24 | { 25 | if (!_initialized) 26 | { 27 | SpriteAtlasManager.atlasRegistered += RebuildImage; 28 | _initialized = true; 29 | } 30 | 31 | TrackedTexturelessImages.Add(g); 32 | } 33 | 34 | public static void UnTrackImage(SlicedImage g) 35 | { 36 | TrackedTexturelessImages.Remove(g); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_DefaultMaxDepenetrationVelocity: 10 11 | m_SleepThreshold: 0.005 12 | m_DefaultContactOffset: 0.01 13 | m_DefaultSolverIterations: 6 14 | m_DefaultSolverVelocityIterations: 1 15 | m_QueriesHitBackfaces: 0 16 | m_QueriesHitTriggers: 1 17 | m_EnableAdaptiveForce: 0 18 | m_ClothInterCollisionDistance: 0.1 19 | m_ClothInterCollisionStiffness: 0.2 20 | m_ContactsGeneration: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | m_AutoSimulation: 1 23 | m_AutoSyncTransforms: 0 24 | m_ReuseCollisionCallbacks: 1 25 | m_ClothInterCollisionSettingsToggle: 0 26 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 27 | m_ContactPairsMode: 0 28 | m_BroadphaseType: 0 29 | m_WorldBounds: 30 | m_Center: {x: 0, y: 0, z: 0} 31 | m_Extent: {x: 250, y: 250, z: 250} 32 | m_WorldSubdivisions: 8 33 | m_FrictionType: 0 34 | m_EnableEnhancedDeterminism: 0 35 | m_EnableUnifiedHeightmaps: 1 36 | m_SolverType: 0 37 | m_DefaultMaxAngularSpeed: 50 38 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/SelectBordersJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | 5 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 6 | public struct Border { 7 | public int2 SelectedBorder; 8 | public int2 CurrentBorder; 9 | } 10 | 11 | public struct SelectBordersJob : IJobFor { 12 | public float PreferablePosition; 13 | public int2 AlphaBounds; 14 | [ReadOnly, DeallocateOnJobCompletion] 15 | public NativeArray AllBorders; 16 | public NativeArray Border; 17 | 18 | public void Execute(int index) { 19 | var border = Border[0]; 20 | if (index < AlphaBounds.x || index > AlphaBounds.y) return; 21 | var selectedBorder = border.SelectedBorder; 22 | var currentBorder = border.CurrentBorder; 23 | currentBorder = new int2(AllBorders[index] ? index : currentBorder.x, index + 1); 24 | if (selectedBorder.x == currentBorder.x) { 25 | selectedBorder = currentBorder; 26 | } else { 27 | var selectedBorderLength = selectedBorder.y - selectedBorder.x; 28 | var currentBorderLength = currentBorder.y - currentBorder.x; 29 | if (currentBorderLength > selectedBorderLength || 30 | currentBorderLength == selectedBorderLength && 31 | math.abs(currentBorder.x + currentBorderLength / 2.0f - PreferablePosition) < 32 | math.abs(selectedBorder.x + selectedBorderLength / 2.0f - PreferablePosition)) { 33 | selectedBorder = currentBorder; 34 | } 35 | } 36 | Border[0] = new Border() { SelectedBorder = selectedBorder, CurrentBorder = currentBorder}; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Project~/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: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 1 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 5 13 | m_SpritePackerPaddingPower: 1 14 | m_Bc7TextureCompressor: 0 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp 20 | m_ProjectGenerationRootNamespace: 21 | m_EnableTextureStreamingInEditMode: 1 22 | m_EnableTextureStreamingInPlayMode: 1 23 | m_AsyncShaderCompilation: 1 24 | m_CachingShaderPreprocessor: 1 25 | m_PrefabModeAllowAutoSave: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_GameObjectNamingDigits: 1 29 | m_GameObjectNamingScheme: 0 30 | m_AssetNamingUsesSpace: 1 31 | m_UseLegacyProbeSampleCount: 0 32 | m_SerializeInlineMappingsOnOneLine: 1 33 | m_DisableCookiesInLightmapper: 1 34 | m_AssetPipelineMode: 1 35 | m_RefreshImportMode: 0 36 | m_CacheServerMode: 0 37 | m_CacheServerEndpoint: 38 | m_CacheServerNamespacePrefix: default 39 | m_CacheServerEnableDownload: 1 40 | m_CacheServerEnableUpload: 1 41 | m_CacheServerEnableAuth: 0 42 | m_CacheServerEnableTls: 0 43 | m_CacheServerValidationMode: 2 44 | m_CacheServerDownloadBatchSize: 128 45 | -------------------------------------------------------------------------------- /Project~/.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | .idea/ -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/DetectOpaqueRectJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 7 | public struct DetectOpaqueRectJob : IJobFor { 8 | [ReadOnly] 9 | private NativeArray _pixels; 10 | private NativeArray _opaqueRect; 11 | private int _width; 12 | private int _pixelsCountMinusOne; 13 | 14 | public DetectOpaqueRectJob(NativeArray pixels, NativeArray opaqueRect, int width) { 15 | _pixels = pixels; 16 | _opaqueRect = opaqueRect; 17 | _width = width; 18 | _pixelsCountMinusOne = _pixels.Length - 1; 19 | } 20 | 21 | public void Execute(int index) { 22 | _opaqueRect[0] = CheckIndex(_pixels, index, _opaqueRect[0], _width, _pixelsCountMinusOne); 23 | } 24 | 25 | public static int4 CheckIndex(NativeArray pixels, int index, int4 rect, int width, int pixelsCountMinusOne) { 26 | if (pixels[index].a > 0.0f) { 27 | var x = index % width; 28 | var y = (int)math.floor((float)index / width); 29 | if (rect.x == -1 || x < rect.x) { 30 | rect.x = x; 31 | } 32 | if (rect.y == -1 || y < rect.y) { 33 | rect.y = y; 34 | } 35 | } 36 | var reversedIndex = pixelsCountMinusOne - index; 37 | if (pixels[reversedIndex].a > 0.0f) { 38 | var x = reversedIndex % width; 39 | var y = (int)math.floor((float)reversedIndex / width); 40 | if (rect.z == -1 || x > rect.z) { 41 | rect.z = x; 42 | } 43 | 44 | if (rect.w == -1 || y > rect.w) { 45 | rect.w = y; 46 | } 47 | } 48 | return rect; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/TrimSliceCenterJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 7 | public struct TrimSliceCenterJob : IJobParallelFor { 8 | [ReadOnly, DeallocateOnJobCompletion, NativeDisableParallelForRestriction] 9 | private NativeArray _originalPixels; 10 | [WriteOnly] 11 | private NativeArray _trimmedPixels; 12 | 13 | private readonly int _trimmedWidth; 14 | private readonly int4 _centerPart; 15 | private readonly int _innerRectWidth; 16 | private readonly int _innerHorizontalArea; 17 | 18 | public TrimSliceCenterJob(NativeArray originalPixels, NativeArray trimmedPixels, 19 | int originalWidth, int4 centerPart, int2 centerPartSize) { 20 | _originalPixels = originalPixels; 21 | _trimmedPixels = trimmedPixels; 22 | _centerPart = centerPart; 23 | _innerRectWidth = centerPartSize.x; 24 | _trimmedWidth = originalWidth - centerPartSize.x; 25 | _centerPart.z -= centerPartSize.x; 26 | _centerPart.w -= centerPartSize.y; 27 | _innerHorizontalArea = centerPartSize.y * originalWidth; 28 | } 29 | 30 | public void Execute(int index) { 31 | var originalIndex = index; 32 | var x = index % _trimmedWidth; 33 | var y = (int)math.floor((float)index / _trimmedWidth); 34 | originalIndex += y * _innerRectWidth; 35 | if (x >= _centerPart.z) originalIndex += _innerRectWidth; 36 | if (y >= _centerPart.w) { 37 | originalIndex += _innerHorizontalArea; 38 | } 39 | _trimmedPixels[index] = _originalPixels[originalIndex]; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Samples~/DiamondImageFilling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Utkaka.ScaleNineSlicer.UI; 4 | 5 | [CreateAssetMenu(menuName = "ScaleNineSlicer/Samples/DiamondImageFilling")] 6 | public class DiamondImageFilling : SlicedImageCustomFilling 7 | { 8 | public override int GetPolygonsCount(float fillAmount) 9 | { 10 | return Mathf.Approximately(fillAmount, 0.0f) ? 0 : 1; 11 | } 12 | 13 | public override int GetPolygonCutLinesCount(int polygonIndex, float fillAmount) => 4; 14 | 15 | public override void FillPolygonCutLines(Span cutLines, float fillAmount, Rect rect, int polygonIndex) 16 | { 17 | var cutLineIndex = 0; 18 | 19 | cutLines[cutLineIndex++] = 20 | CutLine.FromLine(new Vector2(Mathf.Lerp(rect.xMax, rect.xMin, fillAmount), rect.yMin), 21 | new Vector2(rect.xMin, Mathf.Lerp(rect.yMax, rect.yMin, fillAmount))); 22 | 23 | cutLines[cutLineIndex++] = 24 | CutLine.FromLine(new Vector2(rect.xMax, Mathf.Lerp(rect.yMax, rect.yMin, fillAmount)), 25 | new Vector2(Mathf.Lerp(rect.xMin, rect.xMax, fillAmount), rect.yMin)); 26 | 27 | cutLines[cutLineIndex++] = 28 | CutLine.FromLine(new Vector2(rect.xMin, Mathf.Lerp(rect.yMin, rect.yMax, fillAmount)), 29 | new Vector2(Mathf.Lerp(rect.xMax, rect.xMin, fillAmount), rect.yMax)); 30 | 31 | cutLines[cutLineIndex] = 32 | CutLine.FromLine(new Vector2(Mathf.Lerp(rect.xMin, rect.xMax, fillAmount), rect.yMax), 33 | new Vector2(rect.xMax, Mathf.Lerp(rect.yMin, rect.yMax, fillAmount))); 34 | } 35 | } -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/DetectBorderJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 7 | public struct DetectBorderJob : IJobFor { 8 | private const float DiffConstant = 256.0f / 255.0f; 9 | private const float MaxDifference = 3.16f; 10 | 11 | public float Tolerance; 12 | public int Width; 13 | [ReadOnly, DeallocateOnJobCompletion] 14 | public NativeArray Pixels; 15 | [WriteOnly] 16 | public NativeArray HorizontalBorders; 17 | [WriteOnly] 18 | public NativeArray VerticalBorders; 19 | public NativeArray AlphaRect; 20 | public int PixelsCountMinusOne; 21 | 22 | public void Execute(int index) { 23 | var x = index % Width; 24 | var y = (int)math.floor((float)index / Width); 25 | if (x > 0 && ColorDifference(Pixels[index], Pixels[index - 1]) > MaxDifference * Tolerance) { 26 | VerticalBorders[x] = true; 27 | } 28 | if (y > 0 && ColorDifference(Pixels[index], Pixels[(y - 1) * Width + x]) > MaxDifference * Tolerance) { 29 | HorizontalBorders[y] = true; 30 | } 31 | AlphaRect[0] = DetectOpaqueRectJob.CheckIndex(Pixels, index, AlphaRect[0], Width, PixelsCountMinusOne); 32 | } 33 | 34 | private float ColorDifference(Color color1, Color color2) { 35 | var r = 0.5f * (color1.r + color2.r); 36 | var deltaR = color1.r - color2.r; 37 | var deltaG = color1.g - color2.g; 38 | var deltaB = color1.b - color2.b; 39 | var deltaA = color1.a - color2.a; 40 | var delta = math.sqrt((2.0f + r / DiffConstant) * deltaR * deltaR + 4.0f * deltaG * deltaG + 41 | (2.0f + (1.0f - r) / DiffConstant) * deltaB * deltaB + deltaA * deltaA); 42 | return delta; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Project~/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.DS_Store": true, 4 | "**/.git": true, 5 | "**/.vs": true, 6 | "**/.gitmodules": true, 7 | "**/.vsconfig": true, 8 | "**/*.booproj": true, 9 | "**/*.pidb": true, 10 | "**/*.suo": true, 11 | "**/*.user": true, 12 | "**/*.userprefs": true, 13 | "**/*.unityproj": true, 14 | "**/*.dll": true, 15 | "**/*.exe": true, 16 | "**/*.pdf": true, 17 | "**/*.mid": true, 18 | "**/*.midi": true, 19 | "**/*.wav": true, 20 | "**/*.gif": true, 21 | "**/*.ico": true, 22 | "**/*.jpg": true, 23 | "**/*.jpeg": true, 24 | "**/*.png": true, 25 | "**/*.psd": true, 26 | "**/*.tga": true, 27 | "**/*.tif": true, 28 | "**/*.tiff": true, 29 | "**/*.3ds": true, 30 | "**/*.3DS": true, 31 | "**/*.fbx": true, 32 | "**/*.FBX": true, 33 | "**/*.lxo": true, 34 | "**/*.LXO": true, 35 | "**/*.ma": true, 36 | "**/*.MA": true, 37 | "**/*.obj": true, 38 | "**/*.OBJ": true, 39 | "**/*.asset": true, 40 | "**/*.cubemap": true, 41 | "**/*.flare": true, 42 | "**/*.mat": true, 43 | "**/*.meta": true, 44 | "**/*.prefab": true, 45 | "**/*.unity": true, 46 | "build/": true, 47 | "Build/": true, 48 | "Library/": true, 49 | "library/": true, 50 | "obj/": true, 51 | "Obj/": true, 52 | "Logs/": true, 53 | "logs/": true, 54 | "ProjectSettings/": true, 55 | "UserSettings/": true, 56 | "temp/": true, 57 | "Temp/": true 58 | }, 59 | "dotnet.defaultSolution": "Project~.sln" 60 | } -------------------------------------------------------------------------------- /Runtime/UI/SpriteMeshHandler.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace Utkaka.ScaleNineSlicer.UI 5 | { 6 | public class SpriteMeshHandler 7 | { 8 | public static void PrepareMesh(VertexHelper vertexHelper, Sprite sprite, Color32 color, Rect adjustedRect, Vector2 rectPivot) 9 | { 10 | var spriteSize = new Vector2(sprite.rect.width, sprite.rect.height); 11 | 12 | // Covert sprite pivot into normalized space. 13 | var spritePivot = sprite.pivot / spriteSize; 14 | /*Rect r = GetPixelAdjustedRect(); 15 | if (lPreserveAspect & spriteSize.sqrMagnitude > 0.0f) 16 | { 17 | PreserveSpriteAspectRatio(ref r, spriteSize); 18 | }*/ 19 | 20 | var drawingSize = new Vector2(adjustedRect.width, adjustedRect.height); 21 | var spriteBoundSize = sprite.bounds.size; 22 | 23 | // Calculate the drawing offset based on the difference between the two pivots. 24 | var drawOffset = (rectPivot - spritePivot) * drawingSize; 25 | 26 | vertexHelper.Clear(); 27 | 28 | var vertices = sprite.vertices; 29 | var uvs = sprite.uv; 30 | for (var i = 0; i < vertices.Length; ++i) 31 | { 32 | vertexHelper.AddVert(new Vector3((vertices[i].x / spriteBoundSize.x) * drawingSize.x - drawOffset.x, (vertices[i].y / spriteBoundSize.y) * drawingSize.y - drawOffset.y), color, new Vector2(uvs[i].x, uvs[i].y)); 33 | } 34 | 35 | var triangles = sprite.triangles; 36 | for (var i = 0; i < triangles.Length; i += 3) 37 | { 38 | vertexHelper.AddTriangle(triangles[i + 0], triangles[i + 1], triangles[i + 2]); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/SpriteNineSlicer.uss: -------------------------------------------------------------------------------- 1 | .unity-scroll-view__content-viewport{ 2 | width: 100%; 3 | height: 100%; 4 | } 5 | 6 | .main-area { 7 | flex-grow: 1; 8 | flex-shrink: 1; 9 | background-color: rgb(56, 56, 56); 10 | width: 100%; 11 | height: 100%; 12 | } 13 | 14 | .trim-toggle { 15 | flex-shrink: 0; 16 | } 17 | 18 | .trim-toggle > .unity-label { 19 | min-width: 70px; 20 | } 21 | 22 | .overlay-window { 23 | position: absolute; 24 | background-color: #3C3C3C; 25 | border-color: #232323; 26 | border-width: 1px; 27 | border-radius: 2px; 28 | bottom: 4px; 29 | right: 4px; 30 | height: 100px; 31 | } 32 | 33 | .overlay-window__input > .unity-base-field__label { 34 | min-width: auto; 35 | } 36 | 37 | .overlay-window__input > .unity-base-text-field__input { 38 | width: 60px; 39 | } 40 | 41 | .tolerance-slider { 42 | margin-left: 17px; 43 | margin-right: 7px; 44 | } 45 | 46 | .tolerance-slider > .unity-label { 47 | min-width: 70px; 48 | } 49 | 50 | .guide { 51 | position: absolute; 52 | align-items: center; 53 | justify-content: center; 54 | background-color: rgb(1, 255, 0); 55 | } 56 | 57 | .guide.active { 58 | background-color: rgb(255, 1, 0); 59 | } 60 | 61 | .bottom-left { 62 | left: 0; 63 | bottom: 0; 64 | } 65 | 66 | .top-right { 67 | right: 0; 68 | top: 0; 69 | } 70 | 71 | .guide.horizontal { 72 | width: 100%; 73 | height: 1px; 74 | } 75 | 76 | .guide.vertical { 77 | width: 1px; 78 | height: 100%; 79 | } 80 | 81 | .guide-bar { 82 | flex-grow: 1; 83 | flex-shrink: 0; 84 | } 85 | 86 | .horizontal > .guide-bar { 87 | width: 100%; 88 | height: 10px; 89 | cursor: resize-vertical; 90 | } 91 | 92 | .vertical > .guide-bar { 93 | width: 10px; 94 | height: 100%; 95 | cursor: resize-horizontal; 96 | } -------------------------------------------------------------------------------- /Project~/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | maxJobWorkers: 0 89 | preserveTilesOutsideBounds: 0 90 | debug: 91 | m_Flags: 0 92 | m_SettingNames: 93 | - Humanoid 94 | -------------------------------------------------------------------------------- /Runtime/SpriteSlicing/ExtendSliceCenterJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Jobs; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace Utkaka.ScaleNineSlicer.SpriteSlicing { 7 | public struct ExtendSliceCenterJob : IJobParallelFor{ 8 | [ReadOnly, DeallocateOnJobCompletion, NativeDisableParallelForRestriction] 9 | private NativeArray _originalPixels; 10 | [WriteOnly] 11 | private NativeArray _extendedPixels; 12 | 13 | private readonly int _originalWidth; 14 | private readonly int _extendedWidth; 15 | private readonly int2 _extensionSize; 16 | private readonly int4 _extendedCenterPart; 17 | 18 | public ExtendSliceCenterJob(NativeArray originalPixels, NativeArray extendedPixels, int2 originalSize, 19 | int2 extendedSize, int4 originalBorders) { 20 | _originalPixels = originalPixels; 21 | _extendedPixels = extendedPixels; 22 | _originalWidth = originalSize.x; 23 | _extendedWidth = extendedSize.x; 24 | _extensionSize = extendedSize - originalSize; 25 | _extendedCenterPart = new int4(originalBorders.x, originalBorders.y, 26 | originalSize.x - originalBorders.z + _extensionSize.x, 27 | originalSize.y - originalBorders.w + _extensionSize.y); 28 | } 29 | 30 | public void Execute(int index) { 31 | var x = index % _extendedWidth; 32 | var y = (int)math.floor((float)index / _extendedWidth); 33 | 34 | var below = y < _extendedCenterPart.y; 35 | var above = y >= _extendedCenterPart.w; 36 | var left = x < _extendedCenterPart.x; 37 | var right = x >= _extendedCenterPart.z; 38 | 39 | if (!left && !right) { 40 | x = _extendedCenterPart.x; 41 | } else if (right) { 42 | x -= _extensionSize.x; 43 | } 44 | 45 | if (!below && !above) { 46 | y = _extendedCenterPart.y; 47 | } else if (above) { 48 | y -= _extensionSize.y; 49 | } 50 | 51 | var originalIndex = _originalWidth * y + x; 52 | _extendedPixels[index] = _originalPixels[originalIndex]; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.0.1](https://github.com/utkaka/ScaleNineSlicer/compare/v2.0.0...v2.0.1) (2025-12-24) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * performance improvements ([9331a4f](https://github.com/utkaka/ScaleNineSlicer/commit/9331a4f86091d1512a08504d9c8a544340fc7561)) 7 | 8 | # [2.0.0](https://github.com/utkaka/ScaleNineSlicer/compare/v1.0.4...v2.0.0) (2025-12-15) 9 | 10 | 11 | ### Features 12 | 13 | * add SlicedImage component ([f867f41](https://github.com/utkaka/ScaleNineSlicer/commit/f867f41e174d88451914d6af305faffb318ee0d3)) 14 | 15 | 16 | ### BREAKING CHANGES 17 | 18 | * package has been slightly refactored 19 | 20 | ## [1.0.4](https://github.com/utkaka/ScaleNineSlicer/compare/v1.0.3...v1.0.4) (2025-12-15) 21 | 22 | 23 | ### Bug Fixes 24 | 25 | * checker references in uxml ([2c4ffe7](https://github.com/utkaka/ScaleNineSlicer/commit/2c4ffe7bf519dc7629128f936eb70717bce39ce1)) 26 | 27 | ## [1.0.3](https://github.com/utkaka/ScaleNineSlicer/compare/v1.0.2...v1.0.3) (2023-08-15) 28 | 29 | 30 | ### Bug Fixes 31 | 32 | * correct mathematics version, remove wrong style from SpriteNineSlicer.uxml, unsubcribe from events in SpriteNineSlicerWindow ([38ad931](https://github.com/utkaka/ScaleNineSlicer/commit/38ad931887c7f5d8220c5c79e1f33fe252f86c07)) 33 | * Update ci.yml ([3899c63](https://github.com/utkaka/ScaleNineSlicer/commit/3899c63cc18294752dbf0cde5a161c3d82fbf046)) 34 | 35 | ## [1.0.2](https://github.com/utkaka/ScaleNineSlicer/compare/v1.0.1...v1.0.2) (2022-07-11) 36 | 37 | 38 | ### Bug Fixes 39 | 40 | * fix npm ignore ([910a4ad](https://github.com/utkaka/ScaleNineSlicer/commit/910a4ad2c004a76173e4c557916abdec22fa3fab)) 41 | 42 | ## [1.0.1](https://github.com/utkaka/ScaleNineSlicer/compare/v1.0.0...v1.0.1) (2022-07-11) 43 | 44 | 45 | ### Bug Fixes 46 | 47 | * add changelog .meta ([d33b374](https://github.com/utkaka/ScaleNineSlicer/commit/d33b374f24aba87b974adfd5abd75ef8da3f31a1)) 48 | 49 | # 1.0.0 (2022-07-11) 50 | 51 | 52 | ### Bug Fixes 53 | 54 | * change package description in package.json ([5fe69e9](https://github.com/utkaka/ScaleNineSlicer/commit/5fe69e9f40950d7d3fc1d6843b74bd5256eedf23)) 55 | -------------------------------------------------------------------------------- /Tests/Runtime/SlicedPerformanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using NUnit.Framework; 3 | using Unity.PerformanceTesting; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | using UnityEngine.UI; 7 | using Object = UnityEngine.Object; 8 | 9 | namespace Utkaka.ScaleNineSlicer.Tests.Runtime 10 | { 11 | public class SlicedPerformanceTests : AbstractPerformanceTest 12 | { 13 | private static readonly Vector4 Border = new(33f, 37f, 33f, 37f); 14 | 15 | [UnityTest, Performance] 16 | public IEnumerator ImagePerformanceTest( 17 | [ValueSource(nameof(SpritesCount))] int spritesCount, 18 | [ValueSource(nameof(ChangeGridSize))] bool changeGridSize) 19 | { 20 | AdjustGridSize(spritesCount); 21 | var sprite = CreateSprite(TextureWrapMode.Clamp, SpriteMeshType.FullRect, Border); 22 | for (var i = 0; i < spritesCount; i++) 23 | { 24 | var image = CreateImage(sprite, false, false, true, 100, Vector2Int.one); 25 | image.type = Image.Type.Sliced; 26 | } 27 | 28 | yield return CollectStatistics(changeGridSize); 29 | 30 | Object.DestroyImmediate(sprite.texture); 31 | Object.DestroyImmediate(sprite); 32 | } 33 | 34 | [UnityTest, Performance] 35 | public IEnumerator SlicedImagePerformanceTest( 36 | [ValueSource(nameof(SpritesCount))] int spritesCount, 37 | [ValueSource(nameof(ChangeGridSize))] bool changeGridSize) 38 | { 39 | AdjustGridSize(spritesCount); 40 | var sprite = CreateSprite(TextureWrapMode.Clamp, SpriteMeshType.FullRect, Border); 41 | for (var i = 0; i < spritesCount; i++) 42 | { 43 | var slicedImage = CreateSlicedImage(sprite, false, false, true, 100, Vector2Int.one); 44 | slicedImage.sliced = true; 45 | } 46 | 47 | yield return CollectStatistics(changeGridSize); 48 | 49 | Object.DestroyImmediate(sprite.texture); 50 | Object.DestroyImmediate(sprite); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Editor/SpriteSlicing/Window/Assets/Uxml/SpriteNineSlicer.uxml: -------------------------------------------------------------------------------- 1 | 2 |