Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/Assets/LayoutOverlay.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/Assets/SkinningModule.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/BoneDrawingUtility.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/Cache.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CharacterModeTool.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ColorExtensions.cs +13 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ColorExtensions.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CopyTool.cs +661 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CopyTool.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DefaultPoseScope.cs +55 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DefaultPoseScope.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DrawingUtility.cs +261 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DrawingUtility.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateGeometryTool.cs +215 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateGeometryTool.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateWeightsTool.cs +147 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateWeightsTool.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/HorizontalToggleTools.cs +166 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/HorizontalToggleTools.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/IconUtility.cs +30 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MathUtility.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MeshPreviewTool.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MeshTool.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleToolGroup.cs +98 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleToolGroup.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleUtility.cs +128 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModule.cs +570 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModule.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModuleView.cs +394 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModuleView.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningSerializer.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SpriteBoneInfluence.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SpriteMeshData.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/TextContent.cs +107 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/CCDSolver2DEditor.cs +63 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/CCDSolver2DEditor.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/FabrikSolver2DEditor.cs +59 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/FabrikSolver2DEditor.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/IKManager2DEditor.cs +219 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/IKManager2DEditor.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/LimbSolver2DEditor.cs +44 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/LimbSolver2DEditor.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/Solver2DEditor.cs +164 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/Solver2DEditor.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/IKUtility.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/LimbSolver2D.cs +91 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/LimbSolver2D.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2D.cs +297 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2D.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2DMenuAttribute.cs +33 -0
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/Assets/LayoutOverlay.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4817dc4ea8764f74298414d8ac0bb8d5
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/Assets/SkinningModule.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4fccdb4aa9dd0db43becdec2eea211af
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/BoneDrawingUtility.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4e0025ed472de854692946726304a452
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/Cache.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: d59ac20961f9b95419fd53d6c9663903
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CharacterModeTool.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 6735c3e859fb15b4191b28f225534760
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ColorExtensions.cs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.Animation
|
| 5 |
+
{
|
| 6 |
+
internal static class ColorExtensions
|
| 7 |
+
{
|
| 8 |
+
public static Color AlphaMultiplied(this Color c, float multiplier)
|
| 9 |
+
{
|
| 10 |
+
return new Color(c.r, c.g, c.b, c.a * multiplier);
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ColorExtensions.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 10889aecec5b6ee41a2a1626c4cfc07c
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CopyTool.cs
ADDED
|
@@ -0,0 +1,661 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using System.Collections.Generic;
|
| 3 |
+
using System.Linq;
|
| 4 |
+
using UnityEngine;
|
| 5 |
+
|
| 6 |
+
using UnityEditor.U2D.Layout;
|
| 7 |
+
using UnityEngine.U2D;
|
| 8 |
+
|
| 9 |
+
namespace UnityEditor.U2D.Animation
|
| 10 |
+
{
|
| 11 |
+
internal interface ICopyToolStringStore
|
| 12 |
+
{
|
| 13 |
+
string stringStore
|
| 14 |
+
{
|
| 15 |
+
get;
|
| 16 |
+
set;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
internal class SystemCopyBufferStringStore : ICopyToolStringStore
|
| 21 |
+
{
|
| 22 |
+
public string stringStore
|
| 23 |
+
{
|
| 24 |
+
get { return EditorGUIUtility.systemCopyBuffer; }
|
| 25 |
+
set { EditorGUIUtility.systemCopyBuffer = value; }
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
internal class CopyTool : MeshToolWrapper
|
| 30 |
+
{
|
| 31 |
+
public class NewBonesStore
|
| 32 |
+
{
|
| 33 |
+
public BoneCache[] newBones;
|
| 34 |
+
public Dictionary<string, string> newBoneNameDict;
|
| 35 |
+
public NewBonesStore()
|
| 36 |
+
{
|
| 37 |
+
newBones = null;
|
| 38 |
+
newBoneNameDict = new Dictionary<string, string>();
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public void MapAllExistingBones()
|
| 42 |
+
{
|
| 43 |
+
foreach (var bone in newBones)
|
| 44 |
+
newBoneNameDict.Add(bone.name, bone.name);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
private ICopyToolStringStore m_CopyToolStringStore;
|
| 49 |
+
private CopyToolView m_CopyToolView;
|
| 50 |
+
|
| 51 |
+
public float pixelsPerUnit
|
| 52 |
+
{
|
| 53 |
+
private get;
|
| 54 |
+
set;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
public ICopyToolStringStore copyToolStringStore
|
| 58 |
+
{
|
| 59 |
+
set { m_CopyToolStringStore = value; }
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
internal override void OnCreate()
|
| 63 |
+
{
|
| 64 |
+
m_CopyToolView = new CopyToolView();
|
| 65 |
+
m_CopyToolView.onPasteActivated += OnPasteActivated;
|
| 66 |
+
m_CopyToolStringStore = new SystemCopyBufferStringStore();
|
| 67 |
+
disableMeshEditor = true;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
public override void Initialize(LayoutOverlay layout)
|
| 71 |
+
{
|
| 72 |
+
m_CopyToolView.Initialize(layout);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
protected override void OnActivate()
|
| 76 |
+
{
|
| 77 |
+
base.OnActivate();
|
| 78 |
+
m_CopyToolView.Show();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
protected override void OnDeactivate()
|
| 82 |
+
{
|
| 83 |
+
base.OnDeactivate();
|
| 84 |
+
m_CopyToolView.Hide();
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
private void CopyMeshFromSpriteCache(SpriteCache sprite, SkinningCopySpriteData skinningSpriteData)
|
| 88 |
+
{
|
| 89 |
+
if (meshTool == null)
|
| 90 |
+
return;
|
| 91 |
+
|
| 92 |
+
meshTool.SetupSprite(sprite);
|
| 93 |
+
skinningSpriteData.vertices = meshTool.mesh.vertices;
|
| 94 |
+
skinningSpriteData.indices = meshTool.mesh.indices;
|
| 95 |
+
skinningSpriteData.edges = meshTool.mesh.edges;
|
| 96 |
+
skinningSpriteData.boneWeightNames = new List<string>();
|
| 97 |
+
foreach (var bone in meshTool.mesh.bones)
|
| 98 |
+
{
|
| 99 |
+
skinningSpriteData.boneWeightNames.Add(bone.name);
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
public void OnCopyActivated()
|
| 104 |
+
{
|
| 105 |
+
SkinningCopyData skinningCopyData;
|
| 106 |
+
var selectedSprite = skinningCache.selectedSprite;
|
| 107 |
+
if (selectedSprite == null)
|
| 108 |
+
{
|
| 109 |
+
skinningCopyData = CopyAll();
|
| 110 |
+
}
|
| 111 |
+
else
|
| 112 |
+
{
|
| 113 |
+
skinningCopyData = CopySingle(selectedSprite);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
if (skinningCopyData != null)
|
| 117 |
+
m_CopyToolStringStore.stringStore = SkinningCopyUtility.SerializeSkinningCopyDataToString(skinningCopyData);
|
| 118 |
+
skinningCache.events.copy.Invoke();
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
public SkinningCopyData CopyAll()
|
| 122 |
+
{
|
| 123 |
+
var skinningCopyData = new SkinningCopyData();
|
| 124 |
+
skinningCopyData.pixelsPerUnit = pixelsPerUnit;
|
| 125 |
+
|
| 126 |
+
var sprites = skinningCache.GetSprites();
|
| 127 |
+
foreach (var sprite in sprites)
|
| 128 |
+
{
|
| 129 |
+
var skinningSpriteData = new SkinningCopySpriteData();
|
| 130 |
+
skinningSpriteData.spriteName = sprite.name;
|
| 131 |
+
|
| 132 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(sprite);
|
| 133 |
+
if (skeleton != null && skeleton.BoneCount > 0)
|
| 134 |
+
{
|
| 135 |
+
if (skinningCache.hasCharacter)
|
| 136 |
+
{
|
| 137 |
+
// Order doesn't matter for character bones
|
| 138 |
+
skinningSpriteData.spriteBones = skeleton.bones.ToSpriteBone(Matrix4x4.identity).Select(x => new SpriteBoneCopyData()
|
| 139 |
+
{
|
| 140 |
+
spriteBone = x,
|
| 141 |
+
order = -1
|
| 142 |
+
}).ToList();
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
else
|
| 146 |
+
{
|
| 147 |
+
skinningSpriteData.spriteBones = new List<SpriteBoneCopyData>();
|
| 148 |
+
var bones = skeleton.bones.FindRoots();
|
| 149 |
+
foreach (var bone in bones)
|
| 150 |
+
GetSpriteBoneDataRecursively(skinningSpriteData.spriteBones, bone, skeleton.bones.ToList());
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
if (meshTool != null)
|
| 154 |
+
{
|
| 155 |
+
CopyMeshFromSpriteCache(sprite, skinningSpriteData);
|
| 156 |
+
}
|
| 157 |
+
skinningCopyData.copyData.Add(skinningSpriteData);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if (meshTool != null)
|
| 161 |
+
{
|
| 162 |
+
meshTool.SetupSprite(null);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
return skinningCopyData;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
public SkinningCopyData CopySingle(SpriteCache sprite)
|
| 169 |
+
{
|
| 170 |
+
var skinningCopyData = new SkinningCopyData();
|
| 171 |
+
skinningCopyData.pixelsPerUnit = pixelsPerUnit;
|
| 172 |
+
|
| 173 |
+
// Mesh
|
| 174 |
+
var skinningSpriteData = new SkinningCopySpriteData();
|
| 175 |
+
skinningCopyData.copyData.Add(skinningSpriteData);
|
| 176 |
+
|
| 177 |
+
CopyMeshFromSpriteCache(sprite, skinningSpriteData);
|
| 178 |
+
|
| 179 |
+
// Bones
|
| 180 |
+
var rootBones = new List<BoneCache>();
|
| 181 |
+
BoneCache[] boneCache = null;
|
| 182 |
+
if (skinningCache.hasCharacter)
|
| 183 |
+
{
|
| 184 |
+
var characterPart = skinningCache.GetCharacterPart(sprite);
|
| 185 |
+
if (characterPart != null && characterPart.bones != null)
|
| 186 |
+
{
|
| 187 |
+
boneCache = characterPart.bones;
|
| 188 |
+
var bones = characterPart.bones.FindRoots();
|
| 189 |
+
foreach (var bone in bones)
|
| 190 |
+
rootBones.Add(bone);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
else
|
| 194 |
+
{
|
| 195 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(sprite);
|
| 196 |
+
if (skeleton != null && skeleton.BoneCount > 0)
|
| 197 |
+
{
|
| 198 |
+
boneCache = skeleton.bones;
|
| 199 |
+
var bones = boneCache.FindRoots();
|
| 200 |
+
foreach (var bone in bones)
|
| 201 |
+
rootBones.Add(bone);
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
if (rootBones.Count > 0)
|
| 206 |
+
{
|
| 207 |
+
skinningSpriteData.spriteBones = new List<SpriteBoneCopyData>();
|
| 208 |
+
foreach (var rootBone in rootBones)
|
| 209 |
+
{
|
| 210 |
+
var rootBoneIndex = skinningSpriteData.spriteBones.Count;
|
| 211 |
+
GetSpriteBoneDataRecursively(skinningSpriteData.spriteBones, rootBone, boneCache.ToList());
|
| 212 |
+
if (skinningCache.hasCharacter)
|
| 213 |
+
{
|
| 214 |
+
// Offset the bones based on the currently selected Sprite in Character mode
|
| 215 |
+
var characterPart = sprite.GetCharacterPart();
|
| 216 |
+
if (characterPart != null)
|
| 217 |
+
{
|
| 218 |
+
var offset = characterPart.position;
|
| 219 |
+
var rootSpriteBone = skinningSpriteData.spriteBones[rootBoneIndex];
|
| 220 |
+
rootSpriteBone.spriteBone.position = rootSpriteBone.spriteBone.position - offset;
|
| 221 |
+
skinningSpriteData.spriteBones[rootBoneIndex] = rootSpriteBone;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
return skinningCopyData;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
private void GetSpriteBoneDataRecursively(List<SpriteBoneCopyData> bones, BoneCache rootBone, List<BoneCache> boneCache)
|
| 231 |
+
{
|
| 232 |
+
AppendSpriteBoneDataRecursively(bones, rootBone, -1, boneCache);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
private void AppendSpriteBoneDataRecursively(List<SpriteBoneCopyData> spriteBones, BoneCache bone, int parentIndex, List<BoneCache> boneCache)
|
| 236 |
+
{
|
| 237 |
+
int currentParentIndex = spriteBones.Count;
|
| 238 |
+
|
| 239 |
+
var boneCopyData = new SpriteBoneCopyData()
|
| 240 |
+
{
|
| 241 |
+
spriteBone = new SpriteBone()
|
| 242 |
+
{
|
| 243 |
+
name = bone.name,
|
| 244 |
+
parentId = parentIndex
|
| 245 |
+
},
|
| 246 |
+
order = boneCache.FindIndex(x => x == bone)
|
| 247 |
+
};
|
| 248 |
+
if (boneCopyData.order < 0)
|
| 249 |
+
{
|
| 250 |
+
boneCopyData.order = boneCache.Count;
|
| 251 |
+
boneCache.Add(bone);
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
if (parentIndex == -1 && bone.parentBone != null)
|
| 255 |
+
{
|
| 256 |
+
boneCopyData.spriteBone.position = bone.position;
|
| 257 |
+
boneCopyData.spriteBone.rotation = bone.rotation;
|
| 258 |
+
}
|
| 259 |
+
else
|
| 260 |
+
{
|
| 261 |
+
boneCopyData.spriteBone.position = bone.localPosition;
|
| 262 |
+
boneCopyData.spriteBone.rotation = bone.localRotation;
|
| 263 |
+
}
|
| 264 |
+
boneCopyData.spriteBone.position = new Vector3(boneCopyData.spriteBone.position.x, boneCopyData.spriteBone.position.y, bone.depth);
|
| 265 |
+
|
| 266 |
+
boneCopyData.spriteBone.length = bone.localLength;
|
| 267 |
+
spriteBones.Add(boneCopyData);
|
| 268 |
+
foreach (var child in bone)
|
| 269 |
+
{
|
| 270 |
+
var childBone = child as BoneCache;
|
| 271 |
+
if (childBone != null)
|
| 272 |
+
AppendSpriteBoneDataRecursively(spriteBones, childBone, currentParentIndex, boneCache);
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
public void OnPasteActivated(bool bone, bool mesh, bool flipX, bool flipY)
|
| 277 |
+
{
|
| 278 |
+
var copyBuffer = m_CopyToolStringStore.stringStore;
|
| 279 |
+
if (!SkinningCopyUtility.CanDeserializeStringToSkinningCopyData(copyBuffer))
|
| 280 |
+
{
|
| 281 |
+
Debug.LogError(TextContent.copyError1);
|
| 282 |
+
return;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
var skinningCopyData = SkinningCopyUtility.DeserializeStringToSkinningCopyData(copyBuffer);
|
| 286 |
+
if (skinningCopyData == null || skinningCopyData.copyData.Count == 0)
|
| 287 |
+
{
|
| 288 |
+
Debug.LogError(TextContent.copyError2);
|
| 289 |
+
return;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
var scale = 1f;
|
| 293 |
+
if (skinningCopyData.pixelsPerUnit > 0f)
|
| 294 |
+
scale = pixelsPerUnit / skinningCopyData.pixelsPerUnit;
|
| 295 |
+
|
| 296 |
+
var sprites = skinningCache.GetSprites();
|
| 297 |
+
var copyMultiple = skinningCopyData.copyData.Count > 1;
|
| 298 |
+
if (copyMultiple && skinningCopyData.copyData.Count != sprites.Length && mesh)
|
| 299 |
+
{
|
| 300 |
+
Debug.LogError(String.Format(TextContent.copyError3, sprites.Length, skinningCopyData.copyData.Count));
|
| 301 |
+
return;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
using (skinningCache.UndoScope(TextContent.pasteData))
|
| 305 |
+
{
|
| 306 |
+
NewBonesStore newBonesStore = null;
|
| 307 |
+
if (bone && copyMultiple && skinningCache.hasCharacter)
|
| 308 |
+
{
|
| 309 |
+
newBonesStore = new NewBonesStore();
|
| 310 |
+
var skinningSpriteData = skinningCopyData.copyData[0];
|
| 311 |
+
newBonesStore.newBones = skinningCache.CreateBoneCacheFromSpriteBones(skinningSpriteData.spriteBones.Select(y => y.spriteBone).ToArray(), scale);
|
| 312 |
+
if (flipX || flipY)
|
| 313 |
+
{
|
| 314 |
+
var characterRect = new Rect(Vector2.zero, skinningCache.character.dimension);
|
| 315 |
+
var newPositions = new Vector3[newBonesStore.newBones.Length];
|
| 316 |
+
var newRotations = new Quaternion[newBonesStore.newBones.Length];
|
| 317 |
+
for (var i = 0; i < newBonesStore.newBones.Length; ++i)
|
| 318 |
+
{
|
| 319 |
+
newPositions[i] = GetFlippedBonePosition(newBonesStore.newBones[i], Vector2.zero, characterRect, flipX, flipY);
|
| 320 |
+
newRotations[i] = GetFlippedBoneRotation(newBonesStore.newBones[i], flipX, flipY);
|
| 321 |
+
}
|
| 322 |
+
for (var i = 0; i < newBonesStore.newBones.Length; ++i)
|
| 323 |
+
{
|
| 324 |
+
newBonesStore.newBones[i].position = newPositions[i];
|
| 325 |
+
newBonesStore.newBones[i].rotation = newRotations[i];
|
| 326 |
+
}
|
| 327 |
+
}
|
| 328 |
+
newBonesStore.MapAllExistingBones();
|
| 329 |
+
var skeleton = skinningCache.character.skeleton;
|
| 330 |
+
skeleton.SetBones(newBonesStore.newBones);
|
| 331 |
+
skinningCache.events.skeletonTopologyChanged.Invoke(skeleton);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
foreach (var skinningSpriteData in skinningCopyData.copyData)
|
| 335 |
+
{
|
| 336 |
+
SpriteCache sprite = null;
|
| 337 |
+
if (!String.IsNullOrEmpty(skinningSpriteData.spriteName))
|
| 338 |
+
{
|
| 339 |
+
sprite = sprites.FirstOrDefault(x => x.name == skinningSpriteData.spriteName);
|
| 340 |
+
}
|
| 341 |
+
if (sprite == null && (skinningCopyData.copyData.Count == 1 || String.IsNullOrEmpty(skinningSpriteData.spriteName)))
|
| 342 |
+
{
|
| 343 |
+
sprite = skinningCache.selectedSprite;
|
| 344 |
+
}
|
| 345 |
+
if (sprite == null)
|
| 346 |
+
continue;
|
| 347 |
+
|
| 348 |
+
if (bone && (!skinningCache.hasCharacter || !copyMultiple))
|
| 349 |
+
{
|
| 350 |
+
var spriteBones = new SpriteBone[skinningSpriteData.spriteBones.Count];
|
| 351 |
+
for (int i = 0; i < skinningSpriteData.spriteBones.Count; ++i)
|
| 352 |
+
{
|
| 353 |
+
var order = skinningSpriteData.spriteBones[i].order;
|
| 354 |
+
spriteBones[order] = skinningSpriteData.spriteBones[i].spriteBone;
|
| 355 |
+
var parentId = spriteBones[order].parentId;
|
| 356 |
+
if (parentId >= 0)
|
| 357 |
+
{
|
| 358 |
+
spriteBones[order].parentId = skinningSpriteData.spriteBones[parentId].order;
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
newBonesStore = PasteSkeletonBones(sprite, spriteBones.ToList(), flipX, flipY, scale);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
if (mesh && meshTool != null)
|
| 365 |
+
{
|
| 366 |
+
PasteMesh(sprite, skinningSpriteData, flipX, flipY, scale, newBonesStore);
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
if (newBonesStore != null && newBonesStore.newBones != null)
|
| 371 |
+
{
|
| 372 |
+
skinningCache.skeletonSelection.elements = newBonesStore.newBones;
|
| 373 |
+
skinningCache.events.boneSelectionChanged.Invoke();
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
skinningCache.events.paste.Invoke(bone, mesh, flipX, flipY);
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
private Vector3 GetFlippedBonePosition(BoneCache bone, Vector2 startPosition, Rect spriteRect
|
| 380 |
+
, bool flipX, bool flipY)
|
| 381 |
+
{
|
| 382 |
+
Vector3 position = startPosition;
|
| 383 |
+
if (flipX)
|
| 384 |
+
{
|
| 385 |
+
position.x += spriteRect.width - bone.position.x;
|
| 386 |
+
}
|
| 387 |
+
else
|
| 388 |
+
{
|
| 389 |
+
position.x += bone.position.x;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
if (flipY)
|
| 393 |
+
{
|
| 394 |
+
position.y += spriteRect.height - bone.position.y;
|
| 395 |
+
}
|
| 396 |
+
else
|
| 397 |
+
{
|
| 398 |
+
position.y += bone.position.y;
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
position.z = bone.position.z;
|
| 402 |
+
return position;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
private Quaternion GetFlippedBoneRotation(BoneCache bone, bool flipX, bool flipY)
|
| 406 |
+
{
|
| 407 |
+
var euler = bone.rotation.eulerAngles;
|
| 408 |
+
if (flipX)
|
| 409 |
+
{
|
| 410 |
+
if (euler.z <= 180)
|
| 411 |
+
{
|
| 412 |
+
euler.z = 180 - euler.z;
|
| 413 |
+
}
|
| 414 |
+
else
|
| 415 |
+
{
|
| 416 |
+
euler.z = 540 - euler.z;
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
if (flipY)
|
| 420 |
+
{
|
| 421 |
+
euler.z = 360 - euler.z;
|
| 422 |
+
}
|
| 423 |
+
return Quaternion.Euler(euler);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
void SetBonePositionAndRotation(BoneCache[] boneCache, TransformCache bone, Vector3[] position, Quaternion[] rotation)
|
| 427 |
+
{
|
| 428 |
+
var index = Array.FindIndex(boneCache, x => x == bone);
|
| 429 |
+
if (index >= 0)
|
| 430 |
+
{
|
| 431 |
+
bone.position = position[index];
|
| 432 |
+
bone.rotation = rotation[index];
|
| 433 |
+
}
|
| 434 |
+
foreach (var child in bone.children)
|
| 435 |
+
{
|
| 436 |
+
SetBonePositionAndRotation(boneCache, child, position, rotation);
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
public NewBonesStore PasteSkeletonBones(SpriteCache sprite, List<SpriteBone> spriteBones, bool flipX, bool flipY, float scale = 1.0f)
|
| 441 |
+
{
|
| 442 |
+
NewBonesStore newBonesStore = new NewBonesStore();
|
| 443 |
+
newBonesStore.newBones = skinningCache.CreateBoneCacheFromSpriteBones(spriteBones.ToArray(), scale);
|
| 444 |
+
if (newBonesStore.newBones.Length == 0)
|
| 445 |
+
return null;
|
| 446 |
+
|
| 447 |
+
if (sprite == null || (skinningCache.mode == SkinningMode.SpriteSheet && skinningCache.hasCharacter))
|
| 448 |
+
return null;
|
| 449 |
+
|
| 450 |
+
var spriteRect = sprite.textureRect;
|
| 451 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(sprite);
|
| 452 |
+
|
| 453 |
+
var rectPosition = spriteRect.position;
|
| 454 |
+
if (skinningCache.mode == SkinningMode.Character)
|
| 455 |
+
{
|
| 456 |
+
var characterPart = sprite.GetCharacterPart();
|
| 457 |
+
if (characterPart == null)
|
| 458 |
+
return null;
|
| 459 |
+
rectPosition = characterPart.position;
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
var newPositions = new Vector3[newBonesStore.newBones.Length];
|
| 463 |
+
var newRotations = new Quaternion[newBonesStore.newBones.Length];
|
| 464 |
+
for (var i = 0; i < newBonesStore.newBones.Length; ++i)
|
| 465 |
+
{
|
| 466 |
+
newPositions[i] = GetFlippedBonePosition(newBonesStore.newBones[i], rectPosition, spriteRect, flipX, flipY);
|
| 467 |
+
newRotations[i] = GetFlippedBoneRotation(newBonesStore.newBones[i], flipX, flipY);
|
| 468 |
+
}
|
| 469 |
+
for (var i = 0; i < newBonesStore.newBones.Length; ++i)
|
| 470 |
+
{
|
| 471 |
+
if(newBonesStore.newBones[i].parent == null)
|
| 472 |
+
SetBonePositionAndRotation(newBonesStore.newBones, newBonesStore.newBones[i], newPositions, newRotations);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
if (skinningCache.mode == SkinningMode.SpriteSheet)
|
| 476 |
+
{
|
| 477 |
+
newBonesStore.MapAllExistingBones();
|
| 478 |
+
skeleton.SetBones(newBonesStore.newBones);
|
| 479 |
+
}
|
| 480 |
+
else
|
| 481 |
+
{
|
| 482 |
+
var existingBoneNames = skeleton.bones.Select(x => x.name).ToList();
|
| 483 |
+
|
| 484 |
+
skeleton.AddBones(newBonesStore.newBones);
|
| 485 |
+
|
| 486 |
+
var bones = skeleton.bones;
|
| 487 |
+
|
| 488 |
+
// Update names of all newly pasted bones
|
| 489 |
+
foreach (var bone in newBonesStore.newBones)
|
| 490 |
+
{
|
| 491 |
+
if (existingBoneNames.Contains(bone.name))
|
| 492 |
+
{
|
| 493 |
+
var oldBoneName = bone.name;
|
| 494 |
+
bone.name = SkeletonController.AutoBoneName(bone.parentBone, bones);
|
| 495 |
+
existingBoneNames.Add(bone.name);
|
| 496 |
+
newBonesStore.newBoneNameDict.Add(oldBoneName, bone.name);
|
| 497 |
+
}
|
| 498 |
+
else
|
| 499 |
+
{
|
| 500 |
+
newBonesStore.newBoneNameDict.Add(bone.name, bone.name);
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
skeleton.SetDefaultPose();
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
skinningCache.events.skeletonTopologyChanged.Invoke(skeleton);
|
| 508 |
+
return newBonesStore;
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
public void PasteMesh(SpriteCache sprite, SkinningCopySpriteData skinningSpriteData, bool flipX, bool flipY, float scale, NewBonesStore newBonesStore)
|
| 512 |
+
{
|
| 513 |
+
if (sprite == null)
|
| 514 |
+
return;
|
| 515 |
+
|
| 516 |
+
meshTool.SetupSprite(sprite);
|
| 517 |
+
meshTool.mesh.vertices = skinningSpriteData.vertices;
|
| 518 |
+
if (!Mathf.Approximately(scale, 1f) || flipX || flipY)
|
| 519 |
+
{
|
| 520 |
+
var spriteRect = sprite.textureRect;
|
| 521 |
+
foreach (var vertex in meshTool.mesh.vertices)
|
| 522 |
+
{
|
| 523 |
+
var position = vertex.position;
|
| 524 |
+
if (!Mathf.Approximately(scale, 1f))
|
| 525 |
+
position = position * scale;
|
| 526 |
+
if (flipX)
|
| 527 |
+
position.x = spriteRect.width - vertex.position.x;
|
| 528 |
+
if (flipY)
|
| 529 |
+
position.y = spriteRect.height - vertex.position.y;
|
| 530 |
+
vertex.position = position;
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
meshTool.mesh.indices = skinningSpriteData.indices;
|
| 534 |
+
meshTool.mesh.edges = skinningSpriteData.edges;
|
| 535 |
+
|
| 536 |
+
int[] copyBoneToNewBones = new int[skinningSpriteData.boneWeightNames.Count];
|
| 537 |
+
BoneCache[] setBones = null;
|
| 538 |
+
|
| 539 |
+
if (newBonesStore != null && newBonesStore.newBones != null)
|
| 540 |
+
{
|
| 541 |
+
// Update bone weights with new bone indices
|
| 542 |
+
var setBonesList = new List<BoneCache>();
|
| 543 |
+
copyBoneToNewBones = new int[skinningSpriteData.boneWeightNames.Count];
|
| 544 |
+
int index = 0;
|
| 545 |
+
for (int i = 0; i < skinningSpriteData.boneWeightNames.Count; ++i)
|
| 546 |
+
{
|
| 547 |
+
string oldBoneName = skinningSpriteData.boneWeightNames[i];
|
| 548 |
+
string newBoneName;
|
| 549 |
+
newBonesStore.newBoneNameDict.TryGetValue(oldBoneName, out newBoneName);
|
| 550 |
+
var newBone = newBonesStore.newBones.FirstOrDefault(bone => bone.name == newBoneName);
|
| 551 |
+
copyBoneToNewBones[i] = -1;
|
| 552 |
+
if (newBone == null)
|
| 553 |
+
continue;
|
| 554 |
+
|
| 555 |
+
for (int j = 0; j < skinningSpriteData.spriteBones.Count; ++j)
|
| 556 |
+
{
|
| 557 |
+
if (skinningSpriteData.spriteBones[j].spriteBone.name == oldBoneName)
|
| 558 |
+
{
|
| 559 |
+
copyBoneToNewBones[i] = index++;
|
| 560 |
+
setBonesList.Add(newBone);
|
| 561 |
+
break;
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
}
|
| 565 |
+
setBones = setBonesList.ToArray();
|
| 566 |
+
}
|
| 567 |
+
else
|
| 568 |
+
{
|
| 569 |
+
// Attempt to link weights based on existing bone names
|
| 570 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(sprite);
|
| 571 |
+
var characterBones = new List<BoneCache>();
|
| 572 |
+
for (int i = 0; i < skinningSpriteData.boneWeightNames.Count; ++i)
|
| 573 |
+
{
|
| 574 |
+
copyBoneToNewBones[i] = -1;
|
| 575 |
+
var boneName = skinningSpriteData.boneWeightNames[i];
|
| 576 |
+
for (int j = 0; j < skeleton.bones.Length; ++j)
|
| 577 |
+
{
|
| 578 |
+
if (skeleton.bones[j].name == boneName)
|
| 579 |
+
{
|
| 580 |
+
copyBoneToNewBones[i] = characterBones.Count;
|
| 581 |
+
characterBones.Add(skeleton.bones[j]);
|
| 582 |
+
break;
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
setBones = characterBones.ToArray();
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
// Remap new bone indexes from copied bone indexes
|
| 590 |
+
foreach (var vertex in meshTool.mesh.vertices)
|
| 591 |
+
{
|
| 592 |
+
var editableBoneWeight = vertex.editableBoneWeight;
|
| 593 |
+
|
| 594 |
+
for (var i = 0; i < editableBoneWeight.Count; ++i)
|
| 595 |
+
{
|
| 596 |
+
if (!editableBoneWeight[i].enabled)
|
| 597 |
+
continue;
|
| 598 |
+
|
| 599 |
+
if (copyBoneToNewBones.Length > editableBoneWeight[i].boneIndex)
|
| 600 |
+
{
|
| 601 |
+
var boneIndex = copyBoneToNewBones[editableBoneWeight[i].boneIndex];
|
| 602 |
+
if (boneIndex != -1)
|
| 603 |
+
editableBoneWeight[i].boneIndex = boneIndex;
|
| 604 |
+
}
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
// Update associated bones for mesh
|
| 609 |
+
meshTool.mesh.SetCompatibleBoneSet(setBones);
|
| 610 |
+
meshTool.mesh.bones = setBones; // Fixes weights for bones that do not exist
|
| 611 |
+
|
| 612 |
+
// Update associated bones for character
|
| 613 |
+
if (skinningCache.hasCharacter)
|
| 614 |
+
{
|
| 615 |
+
var characterPart = sprite.GetCharacterPart();
|
| 616 |
+
if (characterPart != null)
|
| 617 |
+
{
|
| 618 |
+
characterPart.bones = setBones;
|
| 619 |
+
skinningCache.events.characterPartChanged.Invoke(characterPart);
|
| 620 |
+
}
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
meshTool.UpdateMesh();
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
internal class CopyToolView
|
| 628 |
+
{
|
| 629 |
+
private PastePanel m_PastePanel;
|
| 630 |
+
|
| 631 |
+
public event Action<bool, bool, bool, bool> onPasteActivated = (bone, mesh, flipX, flipY) => {};
|
| 632 |
+
|
| 633 |
+
public void Show()
|
| 634 |
+
{
|
| 635 |
+
m_PastePanel.SetHiddenFromLayout(false);
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
public void Hide()
|
| 639 |
+
{
|
| 640 |
+
m_PastePanel.SetHiddenFromLayout(true);
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
public void Initialize(LayoutOverlay layoutOverlay)
|
| 644 |
+
{
|
| 645 |
+
m_PastePanel = PastePanel.GenerateFromUXML();
|
| 646 |
+
BindElements();
|
| 647 |
+
layoutOverlay.rightOverlay.Add(m_PastePanel);
|
| 648 |
+
m_PastePanel.SetHiddenFromLayout(true);
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
void BindElements()
|
| 652 |
+
{
|
| 653 |
+
m_PastePanel.onPasteActivated += OnPasteActivated;
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
void OnPasteActivated(bool bone, bool mesh, bool flipX, bool flipY)
|
| 657 |
+
{
|
| 658 |
+
onPasteActivated(bone, mesh, flipX, flipY);
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/CopyTool.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 311e00422db8e4949bf926b0d039e05e
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DefaultPoseScope.cs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.Animation
|
| 5 |
+
{
|
| 6 |
+
internal class DefaultPoseScope : IDisposable
|
| 7 |
+
{
|
| 8 |
+
private bool m_Disposed;
|
| 9 |
+
private SkeletonCache m_Skeleton;
|
| 10 |
+
private BonePose[] m_Pose;
|
| 11 |
+
private bool m_DoRestorePose = false;
|
| 12 |
+
private bool m_UseLocalPose;
|
| 13 |
+
|
| 14 |
+
public DefaultPoseScope(SkeletonCache skeleton, bool useLocalPose = true)
|
| 15 |
+
{
|
| 16 |
+
Debug.Assert(skeleton != null);
|
| 17 |
+
|
| 18 |
+
m_Skeleton = skeleton;
|
| 19 |
+
m_UseLocalPose = useLocalPose;
|
| 20 |
+
|
| 21 |
+
if (m_Skeleton.isPosePreview)
|
| 22 |
+
{
|
| 23 |
+
m_DoRestorePose = true;
|
| 24 |
+
|
| 25 |
+
if(useLocalPose)
|
| 26 |
+
m_Pose = m_Skeleton.GetLocalPose();
|
| 27 |
+
else
|
| 28 |
+
m_Pose = m_Skeleton.GetWorldPose();
|
| 29 |
+
|
| 30 |
+
m_Skeleton.RestoreDefaultPose();
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
~DefaultPoseScope()
|
| 35 |
+
{
|
| 36 |
+
if (!m_Disposed)
|
| 37 |
+
Debug.LogError("Scope was not disposed! You should use the 'using' keyword or manually call Dispose.");
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public void Dispose()
|
| 41 |
+
{
|
| 42 |
+
if (m_Disposed)
|
| 43 |
+
return;
|
| 44 |
+
|
| 45 |
+
m_Disposed = true;
|
| 46 |
+
if (m_Skeleton != null && m_DoRestorePose)
|
| 47 |
+
{
|
| 48 |
+
if(m_UseLocalPose)
|
| 49 |
+
m_Skeleton.SetLocalPose(m_Pose);
|
| 50 |
+
else
|
| 51 |
+
m_Skeleton.SetWorldPose(m_Pose);
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DefaultPoseScope.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: bee8f4b5ba5b4ee46a3b10bad91b8c97
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DrawingUtility.cs
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEditor.U2D.Common;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.Animation
|
| 5 |
+
{
|
| 6 |
+
internal class DrawingUtility
|
| 7 |
+
{
|
| 8 |
+
public static readonly Color kSpriteBorderColor = new Color(0.25f, 0.5f, 1f, 0.75f);
|
| 9 |
+
|
| 10 |
+
public static void DrawLine(Vector3 p1, Vector3 p2, Vector3 normal, float width)
|
| 11 |
+
{
|
| 12 |
+
DrawLine(p1, p2, normal, width, width);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public static void DrawLine(Vector3 p1, Vector3 p2, Vector3 normal, float widthP1, float widthP2)
|
| 16 |
+
{
|
| 17 |
+
DrawLine(p1, p2, normal, widthP1, widthP2, Handles.color);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public static void DrawLine(Vector3 p1, Vector3 p2, Vector3 normal, float widthP1, float widthP2, Color color)
|
| 21 |
+
{
|
| 22 |
+
if (Event.current.type != EventType.Repaint)
|
| 23 |
+
return;
|
| 24 |
+
|
| 25 |
+
Vector3 up = Vector3.Cross(normal, p2 - p1).normalized;
|
| 26 |
+
|
| 27 |
+
Shader.SetGlobalFloat("_HandleSize", 1);
|
| 28 |
+
|
| 29 |
+
InternalEditorBridge.ApplyWireMaterial();
|
| 30 |
+
GL.PushMatrix();
|
| 31 |
+
GL.MultMatrix(Handles.matrix);
|
| 32 |
+
GL.Begin(4);
|
| 33 |
+
GL.Color(color);
|
| 34 |
+
GL.Vertex(p1 + up * widthP1 * 0.5f);
|
| 35 |
+
GL.Vertex(p1 - up * widthP1 * 0.5f);
|
| 36 |
+
GL.Vertex(p2 - up * widthP2 * 0.5f);
|
| 37 |
+
GL.Vertex(p1 + up * widthP1 * 0.5f);
|
| 38 |
+
GL.Vertex(p2 - up * widthP2 * 0.5f);
|
| 39 |
+
GL.Vertex(p2 + up * widthP2 * 0.5f);
|
| 40 |
+
GL.End();
|
| 41 |
+
GL.PopMatrix();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
public static void BeginLines(Color color)
|
| 45 |
+
{
|
| 46 |
+
InternalEditorBridge.ApplyWireMaterial();
|
| 47 |
+
GL.PushMatrix();
|
| 48 |
+
GL.MultMatrix(Handles.matrix);
|
| 49 |
+
GL.Begin(GL.LINES);
|
| 50 |
+
GL.Color(color);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public static void BeginSolidLines()
|
| 54 |
+
{
|
| 55 |
+
InternalEditorBridge.ApplyWireMaterial();
|
| 56 |
+
GL.PushMatrix();
|
| 57 |
+
GL.MultMatrix(Handles.matrix);
|
| 58 |
+
GL.Begin(GL.TRIANGLES);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
public static void EndLines()
|
| 62 |
+
{
|
| 63 |
+
GL.End();
|
| 64 |
+
GL.PopMatrix();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
public static void DrawLine(Vector3 p1, Vector3 p2)
|
| 68 |
+
{
|
| 69 |
+
GL.Vertex(p1);
|
| 70 |
+
GL.Vertex(p2);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public static void DrawSolidLine(float width, Vector3 p1, Vector3 p2)
|
| 74 |
+
{
|
| 75 |
+
DrawSolidLine(p1, p2, Vector3.forward, width, width);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public static void DrawSolidLine(Vector3 p1, Vector3 p2, Vector3 normal, float widthP1, float widthP2)
|
| 79 |
+
{
|
| 80 |
+
GL.Color(Handles.color);
|
| 81 |
+
|
| 82 |
+
Vector3 right = Vector3.Cross(normal, p2 - p1).normalized;
|
| 83 |
+
|
| 84 |
+
GL.Vertex(p1 + right * widthP1 * 0.5f);
|
| 85 |
+
GL.Vertex(p1 - right * widthP1 * 0.5f);
|
| 86 |
+
GL.Vertex(p2 - right * widthP2 * 0.5f);
|
| 87 |
+
GL.Vertex(p1 + right * widthP1 * 0.5f);
|
| 88 |
+
GL.Vertex(p2 - right * widthP2 * 0.5f);
|
| 89 |
+
GL.Vertex(p2 + right * widthP2 * 0.5f);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
public static void DrawBox(Rect position)
|
| 93 |
+
{
|
| 94 |
+
Vector3[] points = new Vector3[5];
|
| 95 |
+
int i = 0;
|
| 96 |
+
points[i++] = new Vector3(position.xMin, position.yMin, 0f);
|
| 97 |
+
points[i++] = new Vector3(position.xMax, position.yMin, 0f);
|
| 98 |
+
points[i++] = new Vector3(position.xMax, position.yMax, 0f);
|
| 99 |
+
points[i++] = new Vector3(position.xMin, position.yMax, 0f);
|
| 100 |
+
|
| 101 |
+
DrawLine(points[0], points[1]);
|
| 102 |
+
DrawLine(points[1], points[2]);
|
| 103 |
+
DrawLine(points[2], points[3]);
|
| 104 |
+
DrawLine(points[3], points[0]);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
public static void DrawMesh(Mesh mesh, Material material, Matrix4x4 matrix)
|
| 108 |
+
{
|
| 109 |
+
Debug.Assert(mesh != null);
|
| 110 |
+
Debug.Assert(material != null);
|
| 111 |
+
|
| 112 |
+
if (Event.current.type != EventType.Repaint)
|
| 113 |
+
return;
|
| 114 |
+
|
| 115 |
+
material.SetFloat("_AdjustLinearForGamma", PlayerSettings.colorSpace == ColorSpace.Linear ? 1.0f : 0.0f);
|
| 116 |
+
material.SetPass(0);
|
| 117 |
+
Graphics.DrawMeshNow(mesh, Handles.matrix * matrix);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
public static void DrawGUIStyleCap(int controlID, Vector3 position, Quaternion rotation, float size, GUIStyle guiStyle)
|
| 121 |
+
{
|
| 122 |
+
if (Event.current.type != EventType.Repaint)
|
| 123 |
+
return;
|
| 124 |
+
|
| 125 |
+
if (Camera.current && Vector3.Dot(position - Camera.current.transform.position, Camera.current.transform.forward) < 0f)
|
| 126 |
+
return;
|
| 127 |
+
|
| 128 |
+
Handles.BeginGUI();
|
| 129 |
+
guiStyle.Draw(GetGUIStyleRect(guiStyle, position), GUIContent.none, controlID);
|
| 130 |
+
Handles.EndGUI();
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
private static Rect GetGUIStyleRect(GUIStyle style, Vector3 position)
|
| 134 |
+
{
|
| 135 |
+
Vector2 vector = HandleUtility.WorldToGUIPoint(position);
|
| 136 |
+
|
| 137 |
+
float fixedWidth = style.fixedWidth;
|
| 138 |
+
float fixedHeight = style.fixedHeight;
|
| 139 |
+
|
| 140 |
+
return new Rect(vector.x - fixedWidth / 2f, vector.y - fixedHeight / 2f, fixedWidth, fixedHeight);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
public static void DrawRect(Rect rect, Vector3 position, Quaternion rotation, Color color, float rectAlpha, float outlineAlpha)
|
| 144 |
+
{
|
| 145 |
+
if (Event.current.type != EventType.Repaint)
|
| 146 |
+
return;
|
| 147 |
+
|
| 148 |
+
Vector3[] corners = new Vector3[4];
|
| 149 |
+
for (int i = 0; i < 4; i++)
|
| 150 |
+
{
|
| 151 |
+
Vector3 point = GetLocalRectPoint(rect, i);
|
| 152 |
+
corners[i] = rotation * point + position;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
Vector3[] points = new Vector3[]
|
| 156 |
+
{
|
| 157 |
+
corners[0],
|
| 158 |
+
corners[1],
|
| 159 |
+
corners[2],
|
| 160 |
+
corners[3],
|
| 161 |
+
corners[0]
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
Color l_color = Handles.color;
|
| 165 |
+
Handles.color = color;
|
| 166 |
+
|
| 167 |
+
Vector2 offset = new Vector2(1f, 1f);
|
| 168 |
+
|
| 169 |
+
if (!Camera.current)
|
| 170 |
+
{
|
| 171 |
+
offset.y *= -1;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
Handles.DrawSolidRectangleWithOutline(points, new Color(1f, 1f, 1f, rectAlpha), new Color(1f, 1f, 1f, outlineAlpha));
|
| 175 |
+
|
| 176 |
+
Handles.color = l_color;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
private static Vector2 GetLocalRectPoint(Rect rect, int index)
|
| 180 |
+
{
|
| 181 |
+
switch (index)
|
| 182 |
+
{
|
| 183 |
+
case (0): return new Vector2(rect.xMin, rect.yMax);
|
| 184 |
+
case (1): return new Vector2(rect.xMax, rect.yMax);
|
| 185 |
+
case (2): return new Vector2(rect.xMax, rect.yMin);
|
| 186 |
+
case (3): return new Vector2(rect.xMin, rect.yMin);
|
| 187 |
+
}
|
| 188 |
+
return Vector3.zero;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
private static void SetDiscSectionPoints(Vector3[] dest, int count, Vector3 normal, Vector3 from, float angle)
|
| 192 |
+
{
|
| 193 |
+
from.Normalize();
|
| 194 |
+
Quaternion rotation = Quaternion.AngleAxis(angle / (float)(count - 1), normal);
|
| 195 |
+
Vector3 vector = from;
|
| 196 |
+
for (int i = 0; i < count; i++)
|
| 197 |
+
{
|
| 198 |
+
dest[i] = vector;
|
| 199 |
+
vector = rotation * vector;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
static Vector3[] s_array;
|
| 204 |
+
public static void DrawSolidArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius, int numSamples = 60)
|
| 205 |
+
{
|
| 206 |
+
if (Event.current.type != EventType.Repaint)
|
| 207 |
+
return;
|
| 208 |
+
|
| 209 |
+
numSamples = Mathf.Clamp(numSamples, 3, 60);
|
| 210 |
+
|
| 211 |
+
if (s_array == null)
|
| 212 |
+
s_array = new Vector3[60];
|
| 213 |
+
|
| 214 |
+
Color color = Handles.color;
|
| 215 |
+
SetDiscSectionPoints(s_array, numSamples, normal, from, angle);
|
| 216 |
+
InternalEditorBridge.ApplyWireMaterial();
|
| 217 |
+
GL.PushMatrix();
|
| 218 |
+
GL.MultMatrix(Handles.matrix);
|
| 219 |
+
GL.Begin(GL.TRIANGLES);
|
| 220 |
+
for (int i = 1; i < numSamples; i++)
|
| 221 |
+
{
|
| 222 |
+
GL.Color(color);
|
| 223 |
+
GL.Vertex(center);
|
| 224 |
+
GL.Vertex(center + s_array[i - 1] * radius);
|
| 225 |
+
GL.Vertex(center + s_array[i] * radius);
|
| 226 |
+
}
|
| 227 |
+
GL.End();
|
| 228 |
+
GL.PopMatrix();
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
public static void DrawSolidArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius, float outlineScale, int numSamples = 60)
|
| 232 |
+
{
|
| 233 |
+
if (Event.current.type != EventType.Repaint)
|
| 234 |
+
return;
|
| 235 |
+
|
| 236 |
+
numSamples = Mathf.Clamp(numSamples, 3, 60);
|
| 237 |
+
|
| 238 |
+
if(s_array == null)
|
| 239 |
+
s_array = new Vector3[60];
|
| 240 |
+
|
| 241 |
+
Color color = Handles.color;
|
| 242 |
+
SetDiscSectionPoints(s_array, numSamples, normal, from, angle);
|
| 243 |
+
InternalEditorBridge.ApplyWireMaterial();
|
| 244 |
+
GL.PushMatrix();
|
| 245 |
+
GL.MultMatrix(Handles.matrix);
|
| 246 |
+
GL.Begin(4);
|
| 247 |
+
for (int i = 1; i < numSamples; i++)
|
| 248 |
+
{
|
| 249 |
+
GL.Color(color);
|
| 250 |
+
GL.Vertex(center + s_array[i - 1] * radius * outlineScale);
|
| 251 |
+
GL.Vertex(center + s_array[i - 1] * radius);
|
| 252 |
+
GL.Vertex(center + s_array[i] * radius);
|
| 253 |
+
GL.Vertex(center + s_array[i - 1] * radius * outlineScale);
|
| 254 |
+
GL.Vertex(center + s_array[i] * radius);
|
| 255 |
+
GL.Vertex(center + s_array[i] * radius * outlineScale);
|
| 256 |
+
}
|
| 257 |
+
GL.End();
|
| 258 |
+
GL.PopMatrix();
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/DrawingUtility.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 9b3f77b5965944b8ba5c1beefa1eb533
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateGeometryTool.cs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEditor.U2D.Layout;
|
| 3 |
+
using UnityEngine;
|
| 4 |
+
|
| 5 |
+
namespace UnityEditor.U2D.Animation
|
| 6 |
+
{
|
| 7 |
+
internal class GenerateGeometryTool : MeshToolWrapper
|
| 8 |
+
{
|
| 9 |
+
private const float kWeightTolerance = 0.1f;
|
| 10 |
+
private SpriteMeshDataController m_SpriteMeshDataController = new SpriteMeshDataController();
|
| 11 |
+
private ITriangulator m_Triangulator;
|
| 12 |
+
private IOutlineGenerator m_OutlineGenerator;
|
| 13 |
+
private IWeightsGenerator m_WeightGenerator;
|
| 14 |
+
private GenerateGeometryPanel m_GenerateGeometryPanel;
|
| 15 |
+
|
| 16 |
+
internal override void OnCreate()
|
| 17 |
+
{
|
| 18 |
+
m_Triangulator = new Triangulator();
|
| 19 |
+
m_OutlineGenerator = new OutlineGenerator();
|
| 20 |
+
m_WeightGenerator = new BoundedBiharmonicWeightsGenerator();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public override void Initialize(LayoutOverlay layout)
|
| 24 |
+
{
|
| 25 |
+
base.Initialize(layout);
|
| 26 |
+
|
| 27 |
+
m_GenerateGeometryPanel = GenerateGeometryPanel.GenerateFromUXML();
|
| 28 |
+
m_GenerateGeometryPanel.skinningCache = skinningCache;
|
| 29 |
+
|
| 30 |
+
layout.rightOverlay.Add(m_GenerateGeometryPanel);
|
| 31 |
+
|
| 32 |
+
BindElements();
|
| 33 |
+
Hide();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
private void BindElements()
|
| 37 |
+
{
|
| 38 |
+
Debug.Assert(m_GenerateGeometryPanel != null);
|
| 39 |
+
|
| 40 |
+
m_GenerateGeometryPanel.onAutoGenerateGeometry += (float d, byte a, float s) =>
|
| 41 |
+
{
|
| 42 |
+
var selectedSprite = skinningCache.selectedSprite;
|
| 43 |
+
|
| 44 |
+
if (selectedSprite != null)
|
| 45 |
+
{
|
| 46 |
+
EditorUtility.DisplayProgressBar(TextContent.generatingGeometry, selectedSprite.name, 0f);
|
| 47 |
+
|
| 48 |
+
using (skinningCache.UndoScope(TextContent.generateGeometry))
|
| 49 |
+
{
|
| 50 |
+
GenerateGeometry(selectedSprite, d / 100f, a, s);
|
| 51 |
+
|
| 52 |
+
if (m_GenerateGeometryPanel.generateWeights)
|
| 53 |
+
{
|
| 54 |
+
EditorUtility.DisplayProgressBar(TextContent.generatingWeights, selectedSprite.name, 1f);
|
| 55 |
+
GenerateWeights(selectedSprite);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
skinningCache.vertexSelection.Clear();
|
| 59 |
+
skinningCache.events.meshChanged.Invoke(selectedSprite.GetMesh());
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
EditorUtility.ClearProgressBar();
|
| 63 |
+
}
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
m_GenerateGeometryPanel.onAutoGenerateGeometryAll += (float d, byte a, float s) =>
|
| 67 |
+
{
|
| 68 |
+
var sprites = skinningCache.GetSprites();
|
| 69 |
+
|
| 70 |
+
using (skinningCache.UndoScope(TextContent.generateGeometry))
|
| 71 |
+
{
|
| 72 |
+
for (var i = 0; i < sprites.Length; ++i)
|
| 73 |
+
{
|
| 74 |
+
var sprite = sprites[i];
|
| 75 |
+
|
| 76 |
+
if (!sprite.IsVisible())
|
| 77 |
+
continue;
|
| 78 |
+
|
| 79 |
+
EditorUtility.DisplayProgressBar(TextContent.generateGeometry, sprite.name, i * 2f / (sprites.Length * 2f));
|
| 80 |
+
|
| 81 |
+
GenerateGeometry(sprite, d / 100f, a, s);
|
| 82 |
+
|
| 83 |
+
if (m_GenerateGeometryPanel.generateWeights)
|
| 84 |
+
{
|
| 85 |
+
EditorUtility.DisplayProgressBar(TextContent.generatingWeights, sprite.name, (i * 2f + 1) / (sprites.Length * 2f));
|
| 86 |
+
GenerateWeights(sprite);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
foreach(var sprite in sprites)
|
| 91 |
+
skinningCache.events.meshChanged.Invoke(sprite.GetMesh());
|
| 92 |
+
|
| 93 |
+
EditorUtility.ClearProgressBar();
|
| 94 |
+
}
|
| 95 |
+
};
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
protected override void OnActivate()
|
| 99 |
+
{
|
| 100 |
+
base.OnActivate();
|
| 101 |
+
UpdateButton();
|
| 102 |
+
Show();
|
| 103 |
+
skinningCache.events.selectedSpriteChanged.AddListener(OnSelectedSpriteChanged);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
protected override void OnDeactivate()
|
| 107 |
+
{
|
| 108 |
+
base.OnDeactivate();
|
| 109 |
+
Hide();
|
| 110 |
+
skinningCache.events.selectedSpriteChanged.RemoveListener(OnSelectedSpriteChanged);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
private void Show()
|
| 114 |
+
{
|
| 115 |
+
m_GenerateGeometryPanel.SetHiddenFromLayout(false);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
private void Hide()
|
| 119 |
+
{
|
| 120 |
+
m_GenerateGeometryPanel.SetHiddenFromLayout(true);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
private void UpdateButton()
|
| 124 |
+
{
|
| 125 |
+
var selectedSprite = skinningCache.selectedSprite;
|
| 126 |
+
|
| 127 |
+
if (selectedSprite == null)
|
| 128 |
+
m_GenerateGeometryPanel.SetMode(GenerateGeometryPanel.GenerateMode.Multiple);
|
| 129 |
+
else
|
| 130 |
+
m_GenerateGeometryPanel.SetMode(GenerateGeometryPanel.GenerateMode.Single);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
private void OnSelectedSpriteChanged(SpriteCache sprite)
|
| 134 |
+
{
|
| 135 |
+
UpdateButton();
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
private void GenerateGeometry(SpriteCache sprite, float outlineDetail, byte alphaTolerance, float subdivide)
|
| 139 |
+
{
|
| 140 |
+
Debug.Assert(sprite != null);
|
| 141 |
+
|
| 142 |
+
var mesh = sprite.GetMesh();
|
| 143 |
+
|
| 144 |
+
Debug.Assert(mesh != null);
|
| 145 |
+
|
| 146 |
+
m_SpriteMeshDataController.spriteMeshData = mesh;
|
| 147 |
+
m_SpriteMeshDataController.OutlineFromAlpha(m_OutlineGenerator, mesh.textureDataProvider, outlineDetail, alphaTolerance);
|
| 148 |
+
m_SpriteMeshDataController.Triangulate(m_Triangulator);
|
| 149 |
+
|
| 150 |
+
if (subdivide > 0f)
|
| 151 |
+
{
|
| 152 |
+
var largestAreaFactor = Mathf.Lerp(0.5f, 0.05f, Math.Min(subdivide, 100f) / 100f);
|
| 153 |
+
m_SpriteMeshDataController.Subdivide(m_Triangulator, largestAreaFactor);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
foreach (var vertex in mesh.vertices)
|
| 157 |
+
vertex.position -= sprite.textureRect.position;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
private void GenerateWeights(SpriteCache sprite)
|
| 161 |
+
{
|
| 162 |
+
Debug.Assert(sprite != null);
|
| 163 |
+
|
| 164 |
+
var mesh = sprite.GetMesh();
|
| 165 |
+
|
| 166 |
+
Debug.Assert(mesh != null);
|
| 167 |
+
|
| 168 |
+
using (new DefaultPoseScope(skinningCache.GetEffectiveSkeleton(sprite)))
|
| 169 |
+
{
|
| 170 |
+
if (NeedsAssociateBones(sprite.GetCharacterPart()))
|
| 171 |
+
{
|
| 172 |
+
using (new AssociateBonesScope(sprite))
|
| 173 |
+
{
|
| 174 |
+
GenerateWeights(mesh);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
else
|
| 178 |
+
GenerateWeights(mesh);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
private bool NeedsAssociateBones(CharacterPartCache characterPart)
|
| 183 |
+
{
|
| 184 |
+
if (characterPart == null)
|
| 185 |
+
return false;
|
| 186 |
+
|
| 187 |
+
var skeleton = characterPart.skinningCache.character.skeleton;
|
| 188 |
+
|
| 189 |
+
return characterPart.BoneCount == 0 ||
|
| 190 |
+
(characterPart.BoneCount == 1 && characterPart.GetBone(0) == skeleton.GetBone(0));
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
private void GenerateWeights(MeshCache mesh)
|
| 194 |
+
{
|
| 195 |
+
Debug.Assert(mesh != null);
|
| 196 |
+
|
| 197 |
+
m_SpriteMeshDataController.spriteMeshData = mesh;
|
| 198 |
+
m_SpriteMeshDataController.CalculateWeights(m_WeightGenerator, null, kWeightTolerance);
|
| 199 |
+
m_SpriteMeshDataController.SortTrianglesByDepth();
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
protected override void OnGUI()
|
| 203 |
+
{
|
| 204 |
+
m_MeshPreviewBehaviour.showWeightMap = m_GenerateGeometryPanel.generateWeights;
|
| 205 |
+
m_MeshPreviewBehaviour.overlaySelected = m_GenerateGeometryPanel.generateWeights;
|
| 206 |
+
|
| 207 |
+
skeletonTool.skeletonStyle = SkeletonStyles.Default;
|
| 208 |
+
|
| 209 |
+
if (m_GenerateGeometryPanel.generateWeights)
|
| 210 |
+
skeletonTool.skeletonStyle = SkeletonStyles.WeightMap;
|
| 211 |
+
|
| 212 |
+
DoSkeletonGUI();
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateGeometryTool.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 237f0a0a8eeab0d46873db954d4abded
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateWeightsTool.cs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEditor.U2D.Layout;
|
| 3 |
+
using UnityEngine;
|
| 4 |
+
|
| 5 |
+
namespace UnityEditor.U2D.Animation
|
| 6 |
+
{
|
| 7 |
+
internal class GenerateWeightsTool : MeshToolWrapper
|
| 8 |
+
{
|
| 9 |
+
private const float kWeightTolerance = 0.01f;
|
| 10 |
+
private SpriteMeshDataController m_SpriteMeshDataController = new SpriteMeshDataController();
|
| 11 |
+
private IWeightsGenerator m_WeightGenerator;
|
| 12 |
+
private GenerateWeightsPanel m_GenerateWeightsPanel;
|
| 13 |
+
|
| 14 |
+
internal override void OnCreate()
|
| 15 |
+
{
|
| 16 |
+
m_WeightGenerator = new BoundedBiharmonicWeightsGenerator();
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public override void Initialize(LayoutOverlay layout)
|
| 20 |
+
{
|
| 21 |
+
base.Initialize(layout);
|
| 22 |
+
|
| 23 |
+
m_GenerateWeightsPanel = GenerateWeightsPanel.GenerateFromUXML();
|
| 24 |
+
|
| 25 |
+
layout.rightOverlay.Add(m_GenerateWeightsPanel);
|
| 26 |
+
|
| 27 |
+
BindElements();
|
| 28 |
+
m_GenerateWeightsPanel.SetHiddenFromLayout(true);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
private void BindElements()
|
| 32 |
+
{
|
| 33 |
+
Debug.Assert(m_GenerateWeightsPanel != null);
|
| 34 |
+
|
| 35 |
+
m_GenerateWeightsPanel.onGenerateWeights += () =>
|
| 36 |
+
{
|
| 37 |
+
HandleWeights(GenerateWeights, TextContent.generateWeights);
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
m_GenerateWeightsPanel.onNormalizeWeights += () =>
|
| 41 |
+
{
|
| 42 |
+
HandleWeights(NormalizeWeights, TextContent.normalizeWeights);
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
m_GenerateWeightsPanel.onClearWeights += () =>
|
| 46 |
+
{
|
| 47 |
+
HandleWeights(ClearWeights, TextContent.clearWeights);
|
| 48 |
+
};
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
protected override void OnActivate()
|
| 52 |
+
{
|
| 53 |
+
base.OnActivate();
|
| 54 |
+
m_GenerateWeightsPanel.SetHiddenFromLayout(false);
|
| 55 |
+
skinningCache.events.skinningModeChanged.AddListener(OnModeChanged);
|
| 56 |
+
skinningCache.events.selectedSpriteChanged.AddListener(OnSpriteSelectionChanged);
|
| 57 |
+
m_GenerateWeightsPanel.Update(skinningCache.mode == SkinningMode.Character);
|
| 58 |
+
OnSpriteSelectionChanged(skinningCache.selectedSprite);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
protected override void OnDeactivate()
|
| 62 |
+
{
|
| 63 |
+
base.OnDeactivate();
|
| 64 |
+
skinningCache.events.skinningModeChanged.RemoveListener(OnModeChanged);
|
| 65 |
+
skinningCache.events.selectedSpriteChanged.RemoveListener(OnSpriteSelectionChanged);
|
| 66 |
+
m_GenerateWeightsPanel.SetHiddenFromLayout(true);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
void OnModeChanged(SkinningMode mode)
|
| 70 |
+
{
|
| 71 |
+
m_GenerateWeightsPanel.Update(mode == SkinningMode.Character);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
void OnSpriteSelectionChanged(SpriteCache sprite)
|
| 75 |
+
{
|
| 76 |
+
m_GenerateWeightsPanel.generateButtonText = sprite != null ? TextContent.generate : TextContent.generateAll;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
private void HandleWeights(Action<SpriteCache> action, string undoName)
|
| 80 |
+
{
|
| 81 |
+
using (skinningCache.UndoScope(undoName))
|
| 82 |
+
{
|
| 83 |
+
var selectedSprite = skinningCache.selectedSprite;
|
| 84 |
+
if (selectedSprite != null)
|
| 85 |
+
HandleWeightsForSprite(selectedSprite, action);
|
| 86 |
+
else
|
| 87 |
+
{
|
| 88 |
+
var sprites = skinningCache.GetSprites();
|
| 89 |
+
|
| 90 |
+
foreach (var sprite in sprites)
|
| 91 |
+
{
|
| 92 |
+
if (sprite.IsVisible())
|
| 93 |
+
HandleWeightsForSprite(sprite, action);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
private void HandleWeightsForSprite(SpriteCache sprite, Action<SpriteCache> action)
|
| 100 |
+
{
|
| 101 |
+
Debug.Assert(sprite != null);
|
| 102 |
+
|
| 103 |
+
using (new DefaultPoseScope(skinningCache.GetEffectiveSkeleton(sprite)))
|
| 104 |
+
{
|
| 105 |
+
action(sprite);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
skinningCache.events.meshChanged.Invoke(sprite.GetMesh());
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
private void GenerateWeights(SpriteCache sprite)
|
| 112 |
+
{
|
| 113 |
+
using (m_GenerateWeightsPanel.associateBones ? new AssociateBonesScope(sprite) : null)
|
| 114 |
+
{
|
| 115 |
+
m_SpriteMeshDataController.spriteMeshData = sprite.GetMesh();
|
| 116 |
+
m_SpriteMeshDataController.CalculateWeights(m_WeightGenerator, skinningCache.vertexSelection, kWeightTolerance);
|
| 117 |
+
m_SpriteMeshDataController.SortTrianglesByDepth();
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
private void NormalizeWeights(SpriteCache sprite)
|
| 122 |
+
{
|
| 123 |
+
m_SpriteMeshDataController.spriteMeshData = sprite.GetMesh();
|
| 124 |
+
m_SpriteMeshDataController.NormalizeWeights(skinningCache.vertexSelection);
|
| 125 |
+
m_SpriteMeshDataController.SortTrianglesByDepth();
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
private void ClearWeights(SpriteCache sprite)
|
| 129 |
+
{
|
| 130 |
+
m_SpriteMeshDataController.spriteMeshData = sprite.GetMesh();
|
| 131 |
+
m_SpriteMeshDataController.ClearWeights(skinningCache.vertexSelection);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
protected override void OnGUI()
|
| 135 |
+
{
|
| 136 |
+
m_MeshPreviewBehaviour.showWeightMap = true;
|
| 137 |
+
m_MeshPreviewBehaviour.overlaySelected = true;
|
| 138 |
+
skeletonMode = SkeletonMode.EditPose;
|
| 139 |
+
meshMode = SpriteMeshViewMode.EditGeometry;
|
| 140 |
+
disableMeshEditor = true;
|
| 141 |
+
skeletonTool.skeletonStyle = SkeletonStyles.WeightMap;
|
| 142 |
+
|
| 143 |
+
DoSkeletonGUI();
|
| 144 |
+
DoMeshGUI();
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/GenerateWeightsTool.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 497003cbd9cf35349bb7a01db4d94b26
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/HorizontalToggleTools.cs
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.Animation
|
| 5 |
+
{
|
| 6 |
+
internal class HorizontalToggleTools
|
| 7 |
+
{
|
| 8 |
+
private static class Styles
|
| 9 |
+
{
|
| 10 |
+
public static GUIContent visibilityCollapseIcon = new GUIContent(IconUtility.LoadIconResource("Visibility_Tool", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.visibilityIconTooltip));
|
| 11 |
+
public static GUIContent visibilityIcon = new GUIContent(L10n.Tr(TextContent.visibilityIconText), IconUtility.LoadIconResource("Visibility_Tool", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.visibilityIconTooltip));
|
| 12 |
+
public static GUIContent characterCollapseIcon = new GUIContent(IconUtility.LoadIconResource("character_Mode", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.restorePose));
|
| 13 |
+
public static GUIContent characterIcon = new GUIContent(L10n.Tr(TextContent.characterIconText), IconUtility.LoadIconResource("character_Mode", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.restorePose));
|
| 14 |
+
public static GUIContent spriteSheetIcon = new GUIContent(L10n.Tr(TextContent.spriteSheetIconText), IconUtility.LoadIconResource("Sprite_Mode", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.spriteSheetIconTooltip));
|
| 15 |
+
public static GUIContent spriteSheetCollapseIcon = new GUIContent(IconUtility.LoadIconResource("Sprite_Mode", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.spriteSheetIconTooltip));
|
| 16 |
+
public static GUIContent copyIcon = new GUIContent(L10n.Tr(TextContent.copyText), IconUtility.LoadIconResource("Copy", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.copyTooltip));
|
| 17 |
+
public static GUIContent copyCollapseIcon = new GUIContent(IconUtility.LoadIconResource("Copy", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.copyTooltip));
|
| 18 |
+
public static GUIContent pasteIcon = new GUIContent(L10n.Tr(TextContent.pasteText), IconUtility.LoadIconResource("Paste", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.pasteTooltip));
|
| 19 |
+
public static GUIContent pasteCollapseIcon = new GUIContent(IconUtility.LoadIconResource("Paste", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath), L10n.Tr(TextContent.pasteTooltip));
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
private SkinningCache skinningCache { get; set; }
|
| 23 |
+
|
| 24 |
+
private CopyTool copyTool
|
| 25 |
+
{
|
| 26 |
+
get { return skinningCache.GetTool(Tools.CopyPaste) as CopyTool; }
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
private VisibilityTool visibilityTool
|
| 30 |
+
{
|
| 31 |
+
get { return skinningCache.GetTool(Tools.Visibility) as VisibilityTool; }
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
private SwitchModeTool switchmodeTool
|
| 35 |
+
{
|
| 36 |
+
get { return skinningCache.GetTool(Tools.SwitchMode) as SwitchModeTool; }
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
private GUIContent spriteSheetIcon
|
| 40 |
+
{
|
| 41 |
+
get { return collapseToolbar ? Styles.spriteSheetCollapseIcon : Styles.spriteSheetIcon; }
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
private GUIContent copyIcon
|
| 45 |
+
{
|
| 46 |
+
get { return collapseToolbar ? Styles.copyCollapseIcon : Styles.copyIcon; }
|
| 47 |
+
}
|
| 48 |
+
private GUIContent pasteIcon
|
| 49 |
+
{
|
| 50 |
+
get { return collapseToolbar ? Styles.pasteCollapseIcon : Styles.pasteIcon; }
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
internal Action<BaseTool> onActivateTool = (b) => {};
|
| 54 |
+
private BaseTool m_PreviousTool;
|
| 55 |
+
|
| 56 |
+
public bool collapseToolbar { get; set; }
|
| 57 |
+
|
| 58 |
+
internal HorizontalToggleTools(SkinningCache s)
|
| 59 |
+
{
|
| 60 |
+
skinningCache = s;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
internal void DoGUI(Rect drawArea, BaseTool currentTool, bool isDisabled)
|
| 64 |
+
{
|
| 65 |
+
using (new EditorGUI.DisabledScope(isDisabled))
|
| 66 |
+
{
|
| 67 |
+
GUILayout.BeginArea(drawArea);
|
| 68 |
+
EditorGUILayout.BeginHorizontal();
|
| 69 |
+
|
| 70 |
+
DoPreviewToggle();
|
| 71 |
+
DoModeToggle();
|
| 72 |
+
DoCopyToggle(currentTool);
|
| 73 |
+
GUILayout.FlexibleSpace();
|
| 74 |
+
DoVisibilityToggle(currentTool);
|
| 75 |
+
|
| 76 |
+
EditorGUILayout.EndHorizontal();
|
| 77 |
+
GUILayout.EndArea();
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
private void StorePreviousTool(BaseTool currentTool)
|
| 82 |
+
{
|
| 83 |
+
if(currentTool != copyTool && currentTool != visibilityTool)
|
| 84 |
+
m_PreviousTool = currentTool;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
private void DoModeToggle()
|
| 88 |
+
{
|
| 89 |
+
if (skinningCache.hasCharacter)
|
| 90 |
+
{
|
| 91 |
+
EditorGUI.BeginChangeCheck();
|
| 92 |
+
var isActive = GUILayout.Toggle(switchmodeTool.isActive , spriteSheetIcon, EditorStyles.toolbarButton);
|
| 93 |
+
if (EditorGUI.EndChangeCheck())
|
| 94 |
+
{
|
| 95 |
+
using (skinningCache.UndoScope(TextContent.setMode))
|
| 96 |
+
{
|
| 97 |
+
if (isActive)
|
| 98 |
+
switchmodeTool.Activate();
|
| 99 |
+
else
|
| 100 |
+
switchmodeTool.Deactivate();
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
private void DoCopyToggle(BaseTool currentTool)
|
| 107 |
+
{
|
| 108 |
+
if (GUILayout.Button(copyIcon, EditorStyles.toolbarButton))
|
| 109 |
+
{
|
| 110 |
+
copyTool.OnCopyActivated();
|
| 111 |
+
}
|
| 112 |
+
EditorGUI.BeginChangeCheck();
|
| 113 |
+
GUILayout.Toggle(copyTool.isActive, pasteIcon, EditorStyles.toolbarButton);
|
| 114 |
+
if (EditorGUI.EndChangeCheck())
|
| 115 |
+
TogglePasteTool(currentTool);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
internal void TogglePasteTool(BaseTool currentTool)
|
| 119 |
+
{
|
| 120 |
+
if (!copyTool.isActive)
|
| 121 |
+
{
|
| 122 |
+
onActivateTool(copyTool);
|
| 123 |
+
StorePreviousTool(currentTool);
|
| 124 |
+
}
|
| 125 |
+
else if (m_PreviousTool != null)
|
| 126 |
+
{
|
| 127 |
+
onActivateTool(m_PreviousTool);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
void DoVisibilityToggle(BaseTool currentTool)
|
| 132 |
+
{
|
| 133 |
+
EditorGUI.BeginChangeCheck();
|
| 134 |
+
GUILayout.Toggle(visibilityTool.isActive, visbilityIcon, EditorStyles.toolbarButton);
|
| 135 |
+
if (EditorGUI.EndChangeCheck())
|
| 136 |
+
ToggleVisibilityTool(currentTool);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
GUIContent visbilityIcon { get { return collapseToolbar ? Styles.visibilityCollapseIcon : Styles.visibilityIcon; } }
|
| 140 |
+
|
| 141 |
+
internal void ToggleVisibilityTool(BaseTool currentTool)
|
| 142 |
+
{
|
| 143 |
+
onActivateTool(visibilityTool);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
private void DoPreviewToggle()
|
| 147 |
+
{
|
| 148 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(skinningCache.selectedSprite);
|
| 149 |
+
|
| 150 |
+
EditorGUI.BeginDisabledGroup(skeleton == null || skeleton.isPosePreview == false);
|
| 151 |
+
EditorGUI.BeginChangeCheck();
|
| 152 |
+
GUILayout.Button(characterIcon, EditorStyles.toolbarButton);
|
| 153 |
+
if (EditorGUI.EndChangeCheck())
|
| 154 |
+
{
|
| 155 |
+
using (skinningCache.UndoScope("Restore Pose"))
|
| 156 |
+
{
|
| 157 |
+
skinningCache.RestoreBindPose();
|
| 158 |
+
skinningCache.events.restoreBindPose.Invoke();
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
EditorGUI.EndDisabledGroup();
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
GUIContent characterIcon { get { return collapseToolbar ? Styles.characterCollapseIcon : Styles.characterIcon; } }
|
| 165 |
+
}
|
| 166 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/HorizontalToggleTools.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 28c640dd2a903f0498148ed21c25a97f
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/IconUtility.cs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System.IO;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.Animation
|
| 5 |
+
{
|
| 6 |
+
internal static class IconUtility
|
| 7 |
+
{
|
| 8 |
+
static public readonly string k_LightIconResourcePath = "SkinningModule/Icons/Light";
|
| 9 |
+
static public readonly string k_DarkIconResourcePath = "SkinningModule/Icons/Dark";
|
| 10 |
+
static public readonly string k_SelectedResourceIconPath = "SkinningModule/Icons/Selected";
|
| 11 |
+
|
| 12 |
+
public static Texture2D LoadIconResource(string name, string personalPath, string proPath)
|
| 13 |
+
{
|
| 14 |
+
string iconPath = "";
|
| 15 |
+
|
| 16 |
+
if (EditorGUIUtility.isProSkin && !string.IsNullOrEmpty(proPath))
|
| 17 |
+
iconPath = Path.Combine(proPath, "d_" + name);
|
| 18 |
+
else
|
| 19 |
+
iconPath = Path.Combine(personalPath, name);
|
| 20 |
+
if (EditorGUIUtility.pixelsPerPoint > 1.0f)
|
| 21 |
+
{
|
| 22 |
+
var icon2x = ResourceLoader.Load<Texture2D>(iconPath + "@2x.png");
|
| 23 |
+
if (icon2x != null)
|
| 24 |
+
return icon2x;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
return ResourceLoader.Load<Texture2D>(iconPath+".png");
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MathUtility.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 5e4f2af0145cfe44797338834d0b013a
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MeshPreviewTool.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 9aa898c2e4f1cbc4ba5d122fc7b47317
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/MeshTool.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 9ee4e8d7932896548ab9dd0fa6efebc5
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleToolGroup.cs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using System.Collections.Generic;
|
| 3 |
+
using System.Linq;
|
| 4 |
+
using UnityEngine;
|
| 5 |
+
|
| 6 |
+
namespace UnityEditor.U2D.Animation
|
| 7 |
+
{
|
| 8 |
+
internal class ModuleToolGroup
|
| 9 |
+
{
|
| 10 |
+
class ToolGroupEntry
|
| 11 |
+
{
|
| 12 |
+
public BaseTool tool;
|
| 13 |
+
public Action activateCallback;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
class ToolGroup
|
| 17 |
+
{
|
| 18 |
+
public int groupId;
|
| 19 |
+
public List<ToolGroupEntry> tools = new List<ToolGroupEntry>();
|
| 20 |
+
public int previousToolIndex;
|
| 21 |
+
}
|
| 22 |
+
List<ToolGroup> m_ToolGroups = new List<ToolGroup>();
|
| 23 |
+
|
| 24 |
+
public void AddToolToGroup(int groupId, BaseTool tool, Action toolActivatedCallback)
|
| 25 |
+
{
|
| 26 |
+
List<ToolGroupEntry> tools = null;
|
| 27 |
+
for (int i = 0; i < m_ToolGroups.Count; ++i)
|
| 28 |
+
{
|
| 29 |
+
if (m_ToolGroups[i].groupId == groupId)
|
| 30 |
+
{
|
| 31 |
+
tools = m_ToolGroups[i].tools;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
var toolIndex = m_ToolGroups[i].tools.FindIndex(x => x.tool == tool);
|
| 35 |
+
if (toolIndex != -1)
|
| 36 |
+
{
|
| 37 |
+
Debug.LogError(string.Format("{0} already exist in group.", tool.name));
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (tools == null)
|
| 43 |
+
{
|
| 44 |
+
var toolGroup = new ToolGroup()
|
| 45 |
+
{
|
| 46 |
+
groupId = groupId
|
| 47 |
+
};
|
| 48 |
+
tools = toolGroup.tools;
|
| 49 |
+
m_ToolGroups.Add(toolGroup);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
tools.Add(new ToolGroupEntry()
|
| 53 |
+
{
|
| 54 |
+
tool = tool,
|
| 55 |
+
activateCallback = toolActivatedCallback
|
| 56 |
+
});
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public void ActivateTool(BaseTool tool)
|
| 60 |
+
{
|
| 61 |
+
var toolGroupIndex = -1;
|
| 62 |
+
var groupTool = m_ToolGroups.FirstOrDefault(x =>
|
| 63 |
+
{
|
| 64 |
+
toolGroupIndex = x.tools.FindIndex(y => y.tool == tool);
|
| 65 |
+
return toolGroupIndex >= 0;
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
if (groupTool != null && toolGroupIndex >= 0)
|
| 69 |
+
{
|
| 70 |
+
var previousTool = groupTool.previousToolIndex >= 0 ? groupTool.tools[groupTool.previousToolIndex] : null;
|
| 71 |
+
if (tool.isActive) // we want to deactivate the tool and switch to original
|
| 72 |
+
{
|
| 73 |
+
tool.Deactivate();
|
| 74 |
+
if (previousTool != null && previousTool.tool != tool && previousTool.tool != null)
|
| 75 |
+
{
|
| 76 |
+
previousTool.tool.Activate();
|
| 77 |
+
groupTool.previousToolIndex = toolGroupIndex;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
else
|
| 81 |
+
{
|
| 82 |
+
for (int i = 0; i < groupTool.tools.Count; ++i)
|
| 83 |
+
{
|
| 84 |
+
var gt = groupTool.tools[i];
|
| 85 |
+
if (gt.tool.isActive)
|
| 86 |
+
{
|
| 87 |
+
groupTool.previousToolIndex = i;
|
| 88 |
+
gt.tool.Deactivate();
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
tool.Activate();
|
| 92 |
+
if (groupTool.tools[toolGroupIndex].activateCallback != null)
|
| 93 |
+
groupTool.tools[toolGroupIndex].activateCallback();
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleToolGroup.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: ebefc406fa7f065458cfccf8e07be2f9
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/ModuleUtility.cs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using System;
|
| 3 |
+
using System.Collections.Generic;
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
namespace UnityEditor.U2D.Animation
|
| 7 |
+
{
|
| 8 |
+
internal static class ModuleUtility
|
| 9 |
+
{
|
| 10 |
+
public static Vector3 GUIToWorld(Vector3 guiPosition)
|
| 11 |
+
{
|
| 12 |
+
return GUIToWorld(guiPosition, Vector3.forward, Vector3.zero);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public static Vector3 GUIToWorld(Vector3 guiPosition, Vector3 planeNormal, Vector3 planePos)
|
| 16 |
+
{
|
| 17 |
+
Vector3 worldPos = Handles.inverseMatrix.MultiplyPoint(guiPosition);
|
| 18 |
+
|
| 19 |
+
if (Camera.current)
|
| 20 |
+
{
|
| 21 |
+
Ray ray = HandleUtility.GUIPointToWorldRay(guiPosition);
|
| 22 |
+
|
| 23 |
+
planeNormal = Handles.matrix.MultiplyVector(planeNormal);
|
| 24 |
+
|
| 25 |
+
planePos = Handles.matrix.MultiplyPoint(planePos);
|
| 26 |
+
|
| 27 |
+
Plane plane = new Plane(planeNormal, planePos);
|
| 28 |
+
|
| 29 |
+
float distance = 0f;
|
| 30 |
+
|
| 31 |
+
if (plane.Raycast(ray, out distance))
|
| 32 |
+
{
|
| 33 |
+
worldPos = Handles.inverseMatrix.MultiplyPoint(ray.GetPoint(distance));
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return worldPos;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public static GUIContent[] ToGUIContentArray(string[] names)
|
| 41 |
+
{
|
| 42 |
+
return Array.ConvertAll(names, n => new GUIContent(n));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public static Color CalculateNiceColor(int index, int numColors)
|
| 46 |
+
{
|
| 47 |
+
numColors = Mathf.Clamp(numColors, 1, int.MaxValue);
|
| 48 |
+
|
| 49 |
+
int loops = index / numColors;
|
| 50 |
+
index = index % 360;
|
| 51 |
+
|
| 52 |
+
int hueAngleStep = 360 / numColors;
|
| 53 |
+
float hueLoopOffset = hueAngleStep * 0.5f;
|
| 54 |
+
float hue = index * hueAngleStep + loops * hueLoopOffset;
|
| 55 |
+
|
| 56 |
+
return Color.HSVToRGB(Mathf.Repeat(hue, 360f) / 360f, 1f, 1f);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public static void UpdateLocalToWorldMatrices(List<SpriteBoneData> spriteBoneDataList, Matrix4x4 rootMatrix, ref Matrix4x4[] localToWorldMatrices)
|
| 60 |
+
{
|
| 61 |
+
if (localToWorldMatrices == null || localToWorldMatrices.Length != spriteBoneDataList.Count)
|
| 62 |
+
localToWorldMatrices = new Matrix4x4[spriteBoneDataList.Count];
|
| 63 |
+
|
| 64 |
+
bool[] calculatedMatrix = new bool[spriteBoneDataList.Count];
|
| 65 |
+
|
| 66 |
+
var processedBoneCount = 0;
|
| 67 |
+
while (processedBoneCount < spriteBoneDataList.Count)
|
| 68 |
+
{
|
| 69 |
+
int oldCount = processedBoneCount;
|
| 70 |
+
|
| 71 |
+
for (var i = 0; i < spriteBoneDataList.Count; ++i)
|
| 72 |
+
{
|
| 73 |
+
if (calculatedMatrix[i])
|
| 74 |
+
continue;
|
| 75 |
+
|
| 76 |
+
var sourceBone = spriteBoneDataList[i];
|
| 77 |
+
if (sourceBone.parentId != -1 && !calculatedMatrix[sourceBone.parentId])
|
| 78 |
+
continue;
|
| 79 |
+
|
| 80 |
+
var localToWorldMatrix = Matrix4x4.identity;
|
| 81 |
+
localToWorldMatrix.SetTRS(sourceBone.localPosition, sourceBone.localRotation, Vector3.one);
|
| 82 |
+
|
| 83 |
+
if (sourceBone.parentId == -1)
|
| 84 |
+
localToWorldMatrix = rootMatrix * localToWorldMatrix;
|
| 85 |
+
else if (calculatedMatrix[sourceBone.parentId])
|
| 86 |
+
localToWorldMatrix = localToWorldMatrices[sourceBone.parentId] * localToWorldMatrix;
|
| 87 |
+
|
| 88 |
+
localToWorldMatrices[i] = localToWorldMatrix;
|
| 89 |
+
calculatedMatrix[i] = true;
|
| 90 |
+
processedBoneCount++;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (oldCount == processedBoneCount)
|
| 94 |
+
throw new ArgumentException("Invalid hierarchy detected");
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
public static List<SpriteBoneData> CreateSpriteBoneData(UnityEngine.U2D.SpriteBone[] spriteBoneList, Matrix4x4 rootMatrix)
|
| 99 |
+
{
|
| 100 |
+
List<SpriteBoneData> spriteBoneDataList = new List<SpriteBoneData>(spriteBoneList.Length);
|
| 101 |
+
|
| 102 |
+
foreach (var spriteBone in spriteBoneList)
|
| 103 |
+
{
|
| 104 |
+
spriteBoneDataList.Add(new SpriteBoneData()
|
| 105 |
+
{
|
| 106 |
+
name = spriteBone.name,
|
| 107 |
+
parentId = spriteBone.parentId,
|
| 108 |
+
localPosition = spriteBone.position,
|
| 109 |
+
localRotation = spriteBone.rotation,
|
| 110 |
+
depth = spriteBone.position.z,
|
| 111 |
+
length = spriteBone.length
|
| 112 |
+
});
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
Matrix4x4[] localToWorldMatrices = null;
|
| 116 |
+
UpdateLocalToWorldMatrices(spriteBoneDataList, rootMatrix, ref localToWorldMatrices);
|
| 117 |
+
|
| 118 |
+
for (int i = 0; i < spriteBoneDataList.Count; ++i)
|
| 119 |
+
{
|
| 120 |
+
var spriteBoneData = spriteBoneDataList[i];
|
| 121 |
+
spriteBoneData.position = localToWorldMatrices[i].MultiplyPoint(Vector2.zero);
|
| 122 |
+
spriteBoneData.endPosition = localToWorldMatrices[i].MultiplyPoint(Vector2.right * spriteBoneData.length);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
return spriteBoneDataList;
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModule.cs
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using System;
|
| 3 |
+
using System.Linq;
|
| 4 |
+
using System.Collections.Generic;
|
| 5 |
+
using UnityEditor.U2D.Sprites;
|
| 6 |
+
|
| 7 |
+
namespace UnityEditor.U2D.Animation
|
| 8 |
+
{
|
| 9 |
+
[RequireSpriteDataProvider(typeof(ISpriteMeshDataProvider), typeof(ISpriteBoneDataProvider))]
|
| 10 |
+
internal partial class SkinningModule : SpriteEditorModuleBase
|
| 11 |
+
{
|
| 12 |
+
private static class Styles
|
| 13 |
+
{
|
| 14 |
+
public static string moduleName = L10n.Tr("Skinning Editor");
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
private SkinningCache m_SkinningCache;
|
| 18 |
+
private int m_PrevNearestControl = -1;
|
| 19 |
+
private SpriteOutlineRenderer m_SpriteOutlineRenderer;
|
| 20 |
+
private MeshPreviewTool m_MeshPreviewTool;
|
| 21 |
+
private SkinningMode m_PreviousSkinningMode;
|
| 22 |
+
private SpriteBoneInfluenceTool m_CharacterSpriteTool;
|
| 23 |
+
private HorizontalToggleTools m_HorizontalToggleTools;
|
| 24 |
+
private AnimationAnalytics m_Analytics;
|
| 25 |
+
private ModuleToolGroup m_ModuleToolGroup;
|
| 26 |
+
IMeshPreviewBehaviour m_MeshPreviewBehaviourOverride = null;
|
| 27 |
+
bool m_CollapseToolbar;
|
| 28 |
+
|
| 29 |
+
internal SkinningCache skinningCache
|
| 30 |
+
{
|
| 31 |
+
get { return m_SkinningCache; }
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
private BaseTool currentTool
|
| 35 |
+
{
|
| 36 |
+
get { return skinningCache.selectedTool; }
|
| 37 |
+
set { skinningCache.selectedTool = value; }
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public override string moduleName
|
| 41 |
+
{
|
| 42 |
+
get { return Styles.moduleName; }
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public override void OnModuleActivate()
|
| 46 |
+
{
|
| 47 |
+
m_SkinningCache = Cache.Create<SkinningCache>();
|
| 48 |
+
|
| 49 |
+
AddMainUI(spriteEditor.GetMainVisualContainer());
|
| 50 |
+
|
| 51 |
+
using (skinningCache.DisableUndoScope())
|
| 52 |
+
{
|
| 53 |
+
skinningCache.Create(spriteEditor, SkinningCachePersistentState.instance);
|
| 54 |
+
skinningCache.CreateToolCache(spriteEditor, m_LayoutOverlay);
|
| 55 |
+
m_CharacterSpriteTool = skinningCache.CreateTool<SpriteBoneInfluenceTool>();
|
| 56 |
+
m_CharacterSpriteTool.Initialize(m_LayoutOverlay);
|
| 57 |
+
m_MeshPreviewTool = skinningCache.CreateTool<MeshPreviewTool>();
|
| 58 |
+
SetupModuleToolGroup();
|
| 59 |
+
m_MeshPreviewTool.Activate();
|
| 60 |
+
|
| 61 |
+
m_SpriteOutlineRenderer = new SpriteOutlineRenderer(spriteEditor, skinningCache.events);
|
| 62 |
+
|
| 63 |
+
spriteEditor.enableMouseMoveEvent = true;
|
| 64 |
+
|
| 65 |
+
Undo.undoRedoPerformed += UndoRedoPerformed;
|
| 66 |
+
skinningCache.events.skeletonTopologyChanged.AddListener(SkeletonTopologyChanged);
|
| 67 |
+
skinningCache.events.skeletonPreviewPoseChanged.AddListener(SkeletonPreviewPoseChanged);
|
| 68 |
+
skinningCache.events.skeletonBindPoseChanged.AddListener(SkeletonBindPoseChanged);
|
| 69 |
+
skinningCache.events.characterPartChanged.AddListener(CharacterPartChanged);
|
| 70 |
+
skinningCache.events.skinningModeChanged.AddListener(OnViewModeChanged);
|
| 71 |
+
skinningCache.events.meshChanged.AddListener(OnMeshChanged);
|
| 72 |
+
skinningCache.events.boneNameChanged.AddListener(OnBoneNameChanged);
|
| 73 |
+
skinningCache.events.boneDepthChanged.AddListener(OnBoneDepthChanged);
|
| 74 |
+
skinningCache.events.spriteLibraryChanged.AddListener(OnSpriteLibraryChanged);
|
| 75 |
+
skinningCache.events.meshPreviewBehaviourChange.AddListener(OnMeshPreviewBehaviourChange);
|
| 76 |
+
|
| 77 |
+
skinningCache.RestoreFromPersistentState();
|
| 78 |
+
ActivateTool(skinningCache.selectedTool);
|
| 79 |
+
skinningCache.RestoreToolStateFromPersistentState();
|
| 80 |
+
|
| 81 |
+
// Set state for Switch Mode tool
|
| 82 |
+
m_PreviousSkinningMode = skinningCache.mode;
|
| 83 |
+
if (skinningCache.mode == SkinningMode.Character)
|
| 84 |
+
{
|
| 85 |
+
skinningCache.GetTool(Tools.SwitchMode).Deactivate();
|
| 86 |
+
}
|
| 87 |
+
else
|
| 88 |
+
{
|
| 89 |
+
skinningCache.GetTool(Tools.SwitchMode).Activate();
|
| 90 |
+
}
|
| 91 |
+
SetupSpriteEditor(true);
|
| 92 |
+
|
| 93 |
+
m_HorizontalToggleTools = new HorizontalToggleTools(skinningCache)
|
| 94 |
+
{
|
| 95 |
+
onActivateTool = (b) =>
|
| 96 |
+
{
|
| 97 |
+
using (skinningCache.UndoScope(TextContent.setTool))
|
| 98 |
+
{
|
| 99 |
+
ActivateTool(b);
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
var ai = spriteEditor.GetDataProvider<ISpriteEditorDataProvider>() as AssetImporter;
|
| 105 |
+
m_Analytics = new AnimationAnalytics(new UnityAnalyticsStorage(),
|
| 106 |
+
skinningCache.events,
|
| 107 |
+
new SkinningModuleAnalyticsModel(skinningCache),
|
| 108 |
+
ai == null ? -1 : ai.GetInstanceID());
|
| 109 |
+
|
| 110 |
+
UpdateCollapseToolbar();
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
public override void OnModuleDeactivate()
|
| 115 |
+
{
|
| 116 |
+
if (m_SpriteOutlineRenderer != null)
|
| 117 |
+
m_SpriteOutlineRenderer.Dispose();
|
| 118 |
+
|
| 119 |
+
spriteEditor.enableMouseMoveEvent = false;
|
| 120 |
+
|
| 121 |
+
Undo.undoRedoPerformed -= UndoRedoPerformed;
|
| 122 |
+
skinningCache.events.skeletonTopologyChanged.RemoveListener(SkeletonTopologyChanged);
|
| 123 |
+
skinningCache.events.skeletonPreviewPoseChanged.RemoveListener(SkeletonPreviewPoseChanged);
|
| 124 |
+
skinningCache.events.skeletonBindPoseChanged.RemoveListener(SkeletonBindPoseChanged);
|
| 125 |
+
skinningCache.events.characterPartChanged.RemoveListener(CharacterPartChanged);
|
| 126 |
+
skinningCache.events.skinningModeChanged.RemoveListener(OnViewModeChanged);
|
| 127 |
+
skinningCache.events.meshChanged.RemoveListener(OnMeshChanged);
|
| 128 |
+
skinningCache.events.boneNameChanged.RemoveListener(OnBoneNameChanged);
|
| 129 |
+
skinningCache.events.boneDepthChanged.RemoveListener(OnBoneDepthChanged);
|
| 130 |
+
skinningCache.events.spriteLibraryChanged.RemoveListener(OnSpriteLibraryChanged);
|
| 131 |
+
skinningCache.events.meshPreviewBehaviourChange.RemoveListener(OnMeshPreviewBehaviourChange);
|
| 132 |
+
|
| 133 |
+
RemoveMainUI(spriteEditor.GetMainVisualContainer());
|
| 134 |
+
RestoreSpriteEditor();
|
| 135 |
+
m_Analytics.Dispose();
|
| 136 |
+
m_Analytics = null;
|
| 137 |
+
|
| 138 |
+
Cache.Destroy(m_SkinningCache);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
private void UpdateCollapseToolbar()
|
| 142 |
+
{
|
| 143 |
+
m_CollapseToolbar = SkinningModuleSettings.compactToolBar;
|
| 144 |
+
m_WeightToolbar.CollapseToolBar(m_CollapseToolbar);
|
| 145 |
+
m_MeshToolbar.CollapseToolBar(m_CollapseToolbar);
|
| 146 |
+
m_BoneToolbar.CollapseToolBar(m_CollapseToolbar);
|
| 147 |
+
m_LayoutOverlay.verticalToolbar.Collapse(m_CollapseToolbar);
|
| 148 |
+
m_HorizontalToggleTools.collapseToolbar = m_CollapseToolbar;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
private void OnBoneNameChanged(BoneCache bone)
|
| 152 |
+
{
|
| 153 |
+
var character = skinningCache.character;
|
| 154 |
+
|
| 155 |
+
if (character != null && character.skeleton == bone.skeleton)
|
| 156 |
+
skinningCache.SyncSpriteSheetSkeletons();
|
| 157 |
+
DataModified();
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
private void OnBoneDepthChanged(BoneCache bone)
|
| 161 |
+
{
|
| 162 |
+
var sprites = skinningCache.GetSprites();
|
| 163 |
+
var controller = new SpriteMeshDataController();
|
| 164 |
+
|
| 165 |
+
foreach (var sprite in sprites)
|
| 166 |
+
{
|
| 167 |
+
var mesh = sprite.GetMesh();
|
| 168 |
+
|
| 169 |
+
if (mesh.ContainsBone(bone))
|
| 170 |
+
{
|
| 171 |
+
controller.spriteMeshData = mesh;
|
| 172 |
+
controller.SortTrianglesByDepth();
|
| 173 |
+
skinningCache.events.meshChanged.Invoke(mesh);
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
DataModified();
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
private void OnMeshChanged(MeshCache mesh)
|
| 181 |
+
{
|
| 182 |
+
DataModified();
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
private void DataModified()
|
| 186 |
+
{
|
| 187 |
+
spriteEditor.SetDataModified();
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
private void OnViewModeChanged(SkinningMode mode)
|
| 191 |
+
{
|
| 192 |
+
SetupSpriteEditor();
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
private void SetupSpriteEditor(bool setPreviewTexture = false)
|
| 196 |
+
{
|
| 197 |
+
var textureProvider = spriteEditor.GetDataProvider<ITextureDataProvider>();
|
| 198 |
+
if (textureProvider == null)
|
| 199 |
+
return;
|
| 200 |
+
|
| 201 |
+
var emptyTexture = new Texture2D(1, 1, TextureFormat.RGBAHalf, false, true);
|
| 202 |
+
emptyTexture.hideFlags = HideFlags.HideAndDontSave;
|
| 203 |
+
emptyTexture.SetPixel(1, 1, new Color(0, 0, 0, 0));
|
| 204 |
+
emptyTexture.Apply();
|
| 205 |
+
|
| 206 |
+
int width = 0, height = 0;
|
| 207 |
+
if (skinningCache.mode == SkinningMode.SpriteSheet)
|
| 208 |
+
{
|
| 209 |
+
textureProvider.GetTextureActualWidthAndHeight(out width, out height);
|
| 210 |
+
}
|
| 211 |
+
else
|
| 212 |
+
{
|
| 213 |
+
width = skinningCache.character.dimension.x;
|
| 214 |
+
height = skinningCache.character.dimension.y;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
if (m_PreviousSkinningMode != skinningCache.mode || setPreviewTexture)
|
| 218 |
+
{
|
| 219 |
+
spriteEditor.SetPreviewTexture(emptyTexture, width, height);
|
| 220 |
+
if (m_PreviousSkinningMode != skinningCache.mode)
|
| 221 |
+
{
|
| 222 |
+
m_PreviousSkinningMode = skinningCache.mode;
|
| 223 |
+
spriteEditor.ResetZoomAndScroll();
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
spriteEditor.spriteRects = new List<SpriteRect>();
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
private void RestoreSpriteEditor()
|
| 231 |
+
{
|
| 232 |
+
var textureProvider = spriteEditor.GetDataProvider<ITextureDataProvider>();
|
| 233 |
+
|
| 234 |
+
if (textureProvider != null)
|
| 235 |
+
{
|
| 236 |
+
int width, height;
|
| 237 |
+
textureProvider.GetTextureActualWidthAndHeight(out width, out height);
|
| 238 |
+
|
| 239 |
+
var texture = textureProvider.previewTexture;
|
| 240 |
+
spriteEditor.SetPreviewTexture(texture, width, height);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
var spriteRectProvider = spriteEditor.GetDataProvider<ISpriteEditorDataProvider>();
|
| 244 |
+
|
| 245 |
+
if (spriteRectProvider != null)
|
| 246 |
+
spriteEditor.spriteRects = new List<SpriteRect>(spriteRectProvider.GetSpriteRects());
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
public override bool CanBeActivated()
|
| 250 |
+
{
|
| 251 |
+
var dataProvider = spriteEditor.GetDataProvider<ISpriteEditorDataProvider>();
|
| 252 |
+
return dataProvider == null ? false : dataProvider.spriteImportMode != SpriteImportMode.None;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
public override void DoPostGUI()
|
| 256 |
+
{
|
| 257 |
+
if (!spriteEditor.windowDimension.Contains(Event.current.mousePosition))
|
| 258 |
+
HandleUtility.nearestControl = 0;
|
| 259 |
+
|
| 260 |
+
if (Event.current.type == EventType.Layout && m_PrevNearestControl != HandleUtility.nearestControl)
|
| 261 |
+
{
|
| 262 |
+
m_PrevNearestControl = HandleUtility.nearestControl;
|
| 263 |
+
spriteEditor.RequestRepaint();
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
skinningCache.EndUndoOperation();
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
public override void DoMainGUI()
|
| 270 |
+
{
|
| 271 |
+
Debug.Assert(currentTool != null);
|
| 272 |
+
|
| 273 |
+
DoViewGUI();
|
| 274 |
+
|
| 275 |
+
if (!spriteEditor.editingDisabled)
|
| 276 |
+
skinningCache.selectionTool.DoGUI();
|
| 277 |
+
|
| 278 |
+
m_MeshPreviewTool.previewBehaviourOverride = m_MeshPreviewBehaviourOverride != null ? m_MeshPreviewBehaviourOverride : currentTool.previewBehaviour;
|
| 279 |
+
m_MeshPreviewTool.DoGUI();
|
| 280 |
+
m_MeshPreviewTool.DrawOverlay();
|
| 281 |
+
|
| 282 |
+
m_SpriteOutlineRenderer.RenderSpriteOutline(spriteEditor, skinningCache.selectedSprite);
|
| 283 |
+
|
| 284 |
+
m_MeshPreviewTool.OverlayWireframe();
|
| 285 |
+
|
| 286 |
+
if (!spriteEditor.editingDisabled)
|
| 287 |
+
{
|
| 288 |
+
currentTool.DoGUI();
|
| 289 |
+
DoCopyPasteKeyboardEventHandling();
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
DrawRectGizmos();
|
| 293 |
+
|
| 294 |
+
if (SkinningModuleSettings.compactToolBar != m_CollapseToolbar)
|
| 295 |
+
UpdateCollapseToolbar();
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
public override void DoToolbarGUI(Rect drawArea)
|
| 299 |
+
{
|
| 300 |
+
m_HorizontalToggleTools.DoGUI(drawArea, currentTool, spriteEditor.editingDisabled);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
void DoCopyPasteKeyboardEventHandling()
|
| 304 |
+
{
|
| 305 |
+
var evt = Event.current;
|
| 306 |
+
if (evt.type == EventType.ValidateCommand)
|
| 307 |
+
{
|
| 308 |
+
if (evt.commandName == "Copy" || evt.commandName == "Paste")
|
| 309 |
+
evt.Use();
|
| 310 |
+
return;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
if (evt.type == EventType.ExecuteCommand)
|
| 314 |
+
{
|
| 315 |
+
var copyTool = skinningCache.GetTool(Tools.CopyPaste) as CopyTool;
|
| 316 |
+
if (copyTool != null && evt.commandName == "Copy")
|
| 317 |
+
{
|
| 318 |
+
copyTool.OnCopyActivated();
|
| 319 |
+
evt.Use();
|
| 320 |
+
}
|
| 321 |
+
else if (copyTool != null && evt.commandName == "Paste")
|
| 322 |
+
{
|
| 323 |
+
copyTool.OnPasteActivated(true, true, false, false);
|
| 324 |
+
evt.Use();
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
private void DrawRectGizmos()
|
| 330 |
+
{
|
| 331 |
+
if (Event.current.type == EventType.Repaint)
|
| 332 |
+
{
|
| 333 |
+
var selectedSprite = skinningCache.selectedSprite;
|
| 334 |
+
var sprites = skinningCache.GetSprites();
|
| 335 |
+
var unselectedRectColor = new Color(1f, 1f, 1f, 0.5f);
|
| 336 |
+
|
| 337 |
+
foreach (var sprite in sprites)
|
| 338 |
+
{
|
| 339 |
+
var skeleton = skinningCache.GetEffectiveSkeleton(sprite);
|
| 340 |
+
|
| 341 |
+
Debug.Assert(skeleton != null);
|
| 342 |
+
|
| 343 |
+
if (skeleton.isPosePreview)
|
| 344 |
+
continue;
|
| 345 |
+
|
| 346 |
+
var color = unselectedRectColor;
|
| 347 |
+
|
| 348 |
+
if (sprite == selectedSprite)
|
| 349 |
+
color = DrawingUtility.kSpriteBorderColor;
|
| 350 |
+
|
| 351 |
+
if (skinningCache.mode == SkinningMode.Character
|
| 352 |
+
&& sprite != selectedSprite)
|
| 353 |
+
continue;
|
| 354 |
+
|
| 355 |
+
var matrix = sprite.GetLocalToWorldMatrixFromMode();
|
| 356 |
+
var rect = new Rect(matrix.MultiplyPoint3x4(Vector3.zero), sprite.textureRect.size);
|
| 357 |
+
|
| 358 |
+
DrawingUtility.BeginLines(color);
|
| 359 |
+
DrawingUtility.DrawBox(rect);
|
| 360 |
+
DrawingUtility.EndLines();
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
private void UndoRedoPerformed()
|
| 366 |
+
{
|
| 367 |
+
using (new DisableUndoScope(skinningCache))
|
| 368 |
+
{
|
| 369 |
+
UpdateToggleState();
|
| 370 |
+
skinningCache.UndoRedoPerformed();
|
| 371 |
+
SetupSpriteEditor();
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
#region CharacterConsistency
|
| 376 |
+
//TODO: Bring this to a better place, maybe CharacterController
|
| 377 |
+
private void SkeletonPreviewPoseChanged(SkeletonCache skeleton)
|
| 378 |
+
{
|
| 379 |
+
var character = skinningCache.character;
|
| 380 |
+
|
| 381 |
+
if (character != null && character.skeleton == skeleton)
|
| 382 |
+
skinningCache.SyncSpriteSheetSkeletons();
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
private void SkeletonBindPoseChanged(SkeletonCache skeleton)
|
| 386 |
+
{
|
| 387 |
+
var character = skinningCache.character;
|
| 388 |
+
|
| 389 |
+
if (character != null && character.skeleton == skeleton)
|
| 390 |
+
skinningCache.SyncSpriteSheetSkeletons();
|
| 391 |
+
DataModified();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
private void SkeletonTopologyChanged(SkeletonCache skeleton)
|
| 395 |
+
{
|
| 396 |
+
var character = skinningCache.character;
|
| 397 |
+
|
| 398 |
+
if (character == null)
|
| 399 |
+
{
|
| 400 |
+
var sprite = FindSpriteFromSkeleton(skeleton);
|
| 401 |
+
|
| 402 |
+
Debug.Assert(sprite != null);
|
| 403 |
+
|
| 404 |
+
sprite.UpdateMesh(skeleton.bones);
|
| 405 |
+
|
| 406 |
+
DataModified();
|
| 407 |
+
}
|
| 408 |
+
else if (character.skeleton == skeleton)
|
| 409 |
+
{
|
| 410 |
+
skinningCache.CreateSpriteSheetSkeletons();
|
| 411 |
+
DataModified();
|
| 412 |
+
}
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
private void CharacterPartChanged(CharacterPartCache characterPart)
|
| 416 |
+
{
|
| 417 |
+
var character = skinningCache.character;
|
| 418 |
+
|
| 419 |
+
Debug.Assert(character != null);
|
| 420 |
+
|
| 421 |
+
using (new DefaultPoseScope(character.skeleton))
|
| 422 |
+
{
|
| 423 |
+
skinningCache.CreateSpriteSheetSkeleton(characterPart);
|
| 424 |
+
DataModified();
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
if (skinningCache.mode == SkinningMode.Character)
|
| 428 |
+
characterPart.SyncSpriteSheetSkeleton();
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
private SpriteCache FindSpriteFromSkeleton(SkeletonCache skeleton)
|
| 432 |
+
{
|
| 433 |
+
var sprites = skinningCache.GetSprites();
|
| 434 |
+
return sprites.FirstOrDefault(sprite => sprite.GetSkeleton() == skeleton);
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
#endregion
|
| 438 |
+
|
| 439 |
+
public override bool ApplyRevert(bool apply)
|
| 440 |
+
{
|
| 441 |
+
if (apply)
|
| 442 |
+
{
|
| 443 |
+
m_Analytics.FlushEvent();
|
| 444 |
+
skinningCache.applyingChanges = true;
|
| 445 |
+
skinningCache.RestoreBindPose();
|
| 446 |
+
ApplyBone();
|
| 447 |
+
ApplyMesh();
|
| 448 |
+
ApplyCharacter();
|
| 449 |
+
skinningCache.applyingChanges = false;
|
| 450 |
+
DoApplyAnalytics();
|
| 451 |
+
}
|
| 452 |
+
else
|
| 453 |
+
skinningCache.Revert();
|
| 454 |
+
return true;
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
private void DoApplyAnalytics()
|
| 458 |
+
{
|
| 459 |
+
var sprites = skinningCache.GetSprites();
|
| 460 |
+
var spriteBoneCount = sprites.Select(s => s.GetSkeleton().BoneCount).ToArray();
|
| 461 |
+
BoneCache[] bones = null;
|
| 462 |
+
|
| 463 |
+
if (skinningCache.hasCharacter)
|
| 464 |
+
bones = skinningCache.character.skeleton.bones;
|
| 465 |
+
else
|
| 466 |
+
bones = sprites.SelectMany(s => s.GetSkeleton().bones).ToArray();
|
| 467 |
+
|
| 468 |
+
m_Analytics.SendApplyEvent(sprites.Length, spriteBoneCount, bones);
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
private void ApplyBone()
|
| 472 |
+
{
|
| 473 |
+
var boneDataProvider = spriteEditor.GetDataProvider<ISpriteBoneDataProvider>();
|
| 474 |
+
if (boneDataProvider != null)
|
| 475 |
+
{
|
| 476 |
+
var sprites = skinningCache.GetSprites();
|
| 477 |
+
foreach (var sprite in sprites)
|
| 478 |
+
{
|
| 479 |
+
var bones = sprite.GetSkeleton().bones;
|
| 480 |
+
boneDataProvider.SetBones(new GUID(sprite.id), bones.ToSpriteBone(sprite.localToWorldMatrix).ToList());
|
| 481 |
+
}
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
private void ApplyMesh()
|
| 486 |
+
{
|
| 487 |
+
var meshDataProvider = spriteEditor.GetDataProvider<ISpriteMeshDataProvider>();
|
| 488 |
+
if (meshDataProvider != null)
|
| 489 |
+
{
|
| 490 |
+
var sprites = skinningCache.GetSprites();
|
| 491 |
+
foreach (var sprite in sprites)
|
| 492 |
+
{
|
| 493 |
+
var mesh = sprite.GetMesh();
|
| 494 |
+
var guid = new GUID(sprite.id);
|
| 495 |
+
meshDataProvider.SetVertices(guid, mesh.vertices.Select(x =>
|
| 496 |
+
new Vertex2DMetaData()
|
| 497 |
+
{
|
| 498 |
+
boneWeight = x.editableBoneWeight.ToBoneWeight(false),
|
| 499 |
+
position = x.position
|
| 500 |
+
}
|
| 501 |
+
).ToArray());
|
| 502 |
+
meshDataProvider.SetIndices(guid, mesh.indices.ToArray());
|
| 503 |
+
meshDataProvider.SetEdges(guid, mesh.edges.Select(x => new Vector2Int(x.index1, x.index2)).ToArray());
|
| 504 |
+
}
|
| 505 |
+
}
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
private void ApplyCharacter()
|
| 509 |
+
{
|
| 510 |
+
var characterDataProvider = spriteEditor.GetDataProvider<ICharacterDataProvider>();
|
| 511 |
+
var character = skinningCache.character;
|
| 512 |
+
if (characterDataProvider != null && character != null)
|
| 513 |
+
{
|
| 514 |
+
var data = new CharacterData();
|
| 515 |
+
var characterBones = character.skeleton.bones;
|
| 516 |
+
data.bones = characterBones.ToSpriteBone(Matrix4x4.identity);
|
| 517 |
+
|
| 518 |
+
var parts = character.parts;
|
| 519 |
+
data.parts = parts.Select(x =>
|
| 520 |
+
new CharacterPart()
|
| 521 |
+
{
|
| 522 |
+
spriteId = x.sprite.id,
|
| 523 |
+
spritePosition = new RectInt((int)x.position.x, (int)x.position.y, (int)x.sprite.textureRect.width, (int)x.sprite.textureRect.height),
|
| 524 |
+
bones = x.bones.Select(bone => Array.IndexOf(characterBones, bone)).ToArray()
|
| 525 |
+
}
|
| 526 |
+
).ToArray();
|
| 527 |
+
|
| 528 |
+
characterDataProvider.SetCharacterData(data);
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
var spriteLibDataProvider = spriteEditor.GetDataProvider<ISpriteLibDataProvider>();
|
| 532 |
+
if (spriteLibDataProvider != null)
|
| 533 |
+
{
|
| 534 |
+
spriteLibDataProvider.SetSpriteCategoryList(skinningCache.spriteCategoryList.ToSpriteLibrary());
|
| 535 |
+
}
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
void OnSpriteLibraryChanged()
|
| 539 |
+
{
|
| 540 |
+
DataModified();
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
void OnMeshPreviewBehaviourChange(IMeshPreviewBehaviour meshPreviewBehaviour)
|
| 545 |
+
{
|
| 546 |
+
m_MeshPreviewBehaviourOverride = meshPreviewBehaviour;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
private void SetupModuleToolGroup()
|
| 550 |
+
{
|
| 551 |
+
m_ModuleToolGroup = new ModuleToolGroup();
|
| 552 |
+
m_ModuleToolGroup.AddToolToGroup(0, skinningCache.GetTool(Tools.Visibility), null);
|
| 553 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.EditGeometry), () => currentTool = skinningCache.GetTool(Tools.EditGeometry));
|
| 554 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.CreateVertex), () => currentTool = skinningCache.GetTool(Tools.CreateVertex));
|
| 555 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.CreateEdge), () => currentTool = skinningCache.GetTool(Tools.CreateEdge));
|
| 556 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.SplitEdge), () => currentTool = skinningCache.GetTool(Tools.SplitEdge));
|
| 557 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.GenerateGeometry), () => currentTool = skinningCache.GetTool(Tools.GenerateGeometry));
|
| 558 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.EditPose), () => currentTool = skinningCache.GetTool(Tools.EditPose));
|
| 559 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.EditJoints), () => currentTool = skinningCache.GetTool(Tools.EditJoints));
|
| 560 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.CreateBone), () => currentTool = skinningCache.GetTool(Tools.CreateBone));
|
| 561 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.SplitBone), () => currentTool = skinningCache.GetTool(Tools.SplitBone));
|
| 562 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.WeightSlider), () => currentTool = skinningCache.GetTool(Tools.WeightSlider));
|
| 563 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.WeightBrush), () => currentTool = skinningCache.GetTool(Tools.WeightBrush));
|
| 564 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.GenerateWeights), () => currentTool = skinningCache.GetTool(Tools.GenerateWeights));
|
| 565 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.BoneInfluence), () => currentTool = skinningCache.GetTool(Tools.BoneInfluence));
|
| 566 |
+
m_ModuleToolGroup.AddToolToGroup(1, skinningCache.GetTool(Tools.CopyPaste), () => currentTool = skinningCache.GetTool(Tools.CopyPaste));
|
| 567 |
+
}
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModule.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 92be5a949cc9a014dbcb41d98e5aec03
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModuleView.cs
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEditor.U2D.Common;
|
| 3 |
+
using UnityEditor.U2D.Layout;
|
| 4 |
+
using UnityEngine;
|
| 5 |
+
using UnityEditor.ShortcutManagement;
|
| 6 |
+
using UnityEngine.UIElements;
|
| 7 |
+
|
| 8 |
+
namespace UnityEditor.U2D.Animation
|
| 9 |
+
{
|
| 10 |
+
internal partial class SkinningModule
|
| 11 |
+
{
|
| 12 |
+
private LayoutOverlay m_LayoutOverlay;
|
| 13 |
+
private BoneToolbar m_BoneToolbar;
|
| 14 |
+
private MeshToolbar m_MeshToolbar;
|
| 15 |
+
private WeightToolbar m_WeightToolbar;
|
| 16 |
+
|
| 17 |
+
private InternalEditorBridge.ShortcutContext m_ShortcutContext;
|
| 18 |
+
|
| 19 |
+
private static SkinningModule GetModuleFromContext(ShortcutArguments args)
|
| 20 |
+
{
|
| 21 |
+
var sc = args.context as InternalEditorBridge.ShortcutContext;
|
| 22 |
+
if (sc == null)
|
| 23 |
+
return null;
|
| 24 |
+
|
| 25 |
+
return sc.context as SkinningModule;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
[Shortcut("2D/Animation/Toggle Tool Text", typeof(InternalEditorBridge.ShortcutContext), KeyCode.BackQuote, ShortcutModifiers.Shift)]
|
| 29 |
+
private static void CollapseToolbar(ShortcutArguments args)
|
| 30 |
+
{
|
| 31 |
+
var sm = GetModuleFromContext(args);
|
| 32 |
+
if (sm != null)
|
| 33 |
+
{
|
| 34 |
+
SkinningModuleSettings.compactToolBar = !SkinningModuleSettings.compactToolBar;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
[Shortcut("2D/Animation/Restore Bind Pose", typeof(InternalEditorBridge.ShortcutContext), KeyCode.Alpha1, ShortcutModifiers.Shift)]
|
| 39 |
+
private static void DisablePoseModeKey(ShortcutArguments args)
|
| 40 |
+
{
|
| 41 |
+
var sm = GetModuleFromContext(args);
|
| 42 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 43 |
+
{
|
| 44 |
+
var effectiveSkeleton = sm.skinningCache.GetEffectiveSkeleton(sm.skinningCache.selectedSprite);
|
| 45 |
+
if (effectiveSkeleton != null && effectiveSkeleton.isPosePreview)
|
| 46 |
+
{
|
| 47 |
+
using (sm.skinningCache.UndoScope(TextContent.restorePose))
|
| 48 |
+
{
|
| 49 |
+
sm.skinningCache.RestoreBindPose();
|
| 50 |
+
sm.skinningCache.events.shortcut.Invoke("#1");
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
[Shortcut("2D/Animation/Toggle Character Mode", typeof(InternalEditorBridge.ShortcutContext), KeyCode.Alpha2, ShortcutModifiers.Shift)]
|
| 57 |
+
private static void ToggleCharacterModeKey(ShortcutArguments args)
|
| 58 |
+
{
|
| 59 |
+
var sm = GetModuleFromContext(args);
|
| 60 |
+
if (sm != null && !sm.spriteEditor.editingDisabled && sm.skinningCache.hasCharacter)
|
| 61 |
+
{
|
| 62 |
+
var tool = sm.skinningCache.GetTool(Tools.SwitchMode);
|
| 63 |
+
|
| 64 |
+
using (sm.skinningCache.UndoScope(TextContent.setMode))
|
| 65 |
+
{
|
| 66 |
+
if (tool.isActive)
|
| 67 |
+
tool.Deactivate();
|
| 68 |
+
else
|
| 69 |
+
tool.Activate();
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
sm.skinningCache.events.shortcut.Invoke("#2");
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
[Shortcut("2D/Animation/Preview Pose", typeof(InternalEditorBridge.ShortcutContext), KeyCode.Q, ShortcutModifiers.Shift)]
|
| 77 |
+
private static void EditPoseKey(ShortcutArguments args)
|
| 78 |
+
{
|
| 79 |
+
var sm = GetModuleFromContext(args);
|
| 80 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 81 |
+
{
|
| 82 |
+
sm.SetSkeletonTool(Tools.EditPose);
|
| 83 |
+
sm.skinningCache.events.shortcut.Invoke("#q");
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
[Shortcut("2D/Animation/Edit Bone", typeof(InternalEditorBridge.ShortcutContext), KeyCode.W, ShortcutModifiers.Shift)]
|
| 88 |
+
private static void EditJointsKey(ShortcutArguments args)
|
| 89 |
+
{
|
| 90 |
+
var sm = GetModuleFromContext(args);
|
| 91 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 92 |
+
{
|
| 93 |
+
sm.SetSkeletonTool(Tools.EditJoints);
|
| 94 |
+
sm.skinningCache.events.shortcut.Invoke("#w");
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
[Shortcut("2D/Animation/Create Bone", typeof(InternalEditorBridge.ShortcutContext), KeyCode.E, ShortcutModifiers.Shift)]
|
| 99 |
+
private static void CreateBoneKey(ShortcutArguments args)
|
| 100 |
+
{
|
| 101 |
+
var sm = GetModuleFromContext(args);
|
| 102 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 103 |
+
{
|
| 104 |
+
sm.SetSkeletonTool(Tools.CreateBone);
|
| 105 |
+
sm.skinningCache.events.shortcut.Invoke("#e");
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
[Shortcut("2D/Animation/Split Bone", typeof(InternalEditorBridge.ShortcutContext), KeyCode.R, ShortcutModifiers.Shift)]
|
| 110 |
+
private static void SplitBoneKey(ShortcutArguments args)
|
| 111 |
+
{
|
| 112 |
+
var sm = GetModuleFromContext(args);
|
| 113 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 114 |
+
{
|
| 115 |
+
sm.SetSkeletonTool(Tools.SplitBone);
|
| 116 |
+
sm.skinningCache.events.shortcut.Invoke("#r");
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
[Shortcut("2D/Animation/Auto Geometry", typeof(InternalEditorBridge.ShortcutContext), KeyCode.A, ShortcutModifiers.Shift)]
|
| 121 |
+
private static void GenerateGeometryKey(ShortcutArguments args)
|
| 122 |
+
{
|
| 123 |
+
var sm = GetModuleFromContext(args);
|
| 124 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 125 |
+
{
|
| 126 |
+
sm.SetMeshTool(Tools.GenerateGeometry);
|
| 127 |
+
sm.skinningCache.events.shortcut.Invoke("#a");
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
[Shortcut("2D/Animation/Edit Geometry", typeof(InternalEditorBridge.ShortcutContext), KeyCode.S, ShortcutModifiers.Shift)]
|
| 132 |
+
private static void MeshSelectionKey(ShortcutArguments args)
|
| 133 |
+
{
|
| 134 |
+
var sm = GetModuleFromContext(args);
|
| 135 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 136 |
+
{
|
| 137 |
+
sm.SetMeshTool(Tools.EditGeometry);
|
| 138 |
+
sm.skinningCache.events.shortcut.Invoke("#s");
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
[Shortcut("2D/Animation/Create Vertex", typeof(InternalEditorBridge.ShortcutContext), KeyCode.J, ShortcutModifiers.Shift)]
|
| 143 |
+
private static void CreateVertex(ShortcutArguments args)
|
| 144 |
+
{
|
| 145 |
+
var sm = GetModuleFromContext(args);
|
| 146 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 147 |
+
{
|
| 148 |
+
sm.SetMeshTool(Tools.CreateVertex);
|
| 149 |
+
sm.skinningCache.events.shortcut.Invoke("#d");
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
[Shortcut("2D/Animation/Create Edge", typeof(InternalEditorBridge.ShortcutContext), KeyCode.G, ShortcutModifiers.Shift)]
|
| 154 |
+
private static void CreateEdgeKey(ShortcutArguments args)
|
| 155 |
+
{
|
| 156 |
+
var sm = GetModuleFromContext(args);
|
| 157 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 158 |
+
{
|
| 159 |
+
sm.SetMeshTool(Tools.CreateEdge);
|
| 160 |
+
sm.skinningCache.events.shortcut.Invoke("#g");
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
[Shortcut("2D/Animation/Split Edge", typeof(InternalEditorBridge.ShortcutContext), KeyCode.H, ShortcutModifiers.Shift)]
|
| 165 |
+
private static void SplitEdge(ShortcutArguments args)
|
| 166 |
+
{
|
| 167 |
+
var sm = GetModuleFromContext(args);
|
| 168 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 169 |
+
{
|
| 170 |
+
sm.SetMeshTool(Tools.SplitEdge);
|
| 171 |
+
sm.skinningCache.events.shortcut.Invoke("#h");
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
[Shortcut("2D/Animation/Auto Weights", typeof(InternalEditorBridge.ShortcutContext), KeyCode.Z, ShortcutModifiers.Shift)]
|
| 176 |
+
private static void GenerateWeightsKey(ShortcutArguments args)
|
| 177 |
+
{
|
| 178 |
+
var sm = GetModuleFromContext(args);
|
| 179 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 180 |
+
{
|
| 181 |
+
sm.SetWeightTool(Tools.GenerateWeights);
|
| 182 |
+
sm.skinningCache.events.shortcut.Invoke("#z");
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
[Shortcut("2D/Animation/Weight Slider", typeof(InternalEditorBridge.ShortcutContext), KeyCode.X, ShortcutModifiers.Shift)]
|
| 187 |
+
private static void WeightSliderKey(ShortcutArguments args)
|
| 188 |
+
{
|
| 189 |
+
var sm = GetModuleFromContext(args);
|
| 190 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 191 |
+
{
|
| 192 |
+
sm.SetWeightTool(Tools.WeightSlider);
|
| 193 |
+
sm.skinningCache.events.shortcut.Invoke("#x");
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
[Shortcut("2D/Animation/Weight Brush", typeof(InternalEditorBridge.ShortcutContext), KeyCode.N, ShortcutModifiers.Shift)]
|
| 198 |
+
private static void WeightBrushKey(ShortcutArguments args)
|
| 199 |
+
{
|
| 200 |
+
var sm = GetModuleFromContext(args);
|
| 201 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 202 |
+
{
|
| 203 |
+
sm.SetWeightTool(Tools.WeightBrush);
|
| 204 |
+
sm.skinningCache.events.shortcut.Invoke("#c");
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
[Shortcut("2D/Animation/Bone Influence", typeof(InternalEditorBridge.ShortcutContext), KeyCode.V, ShortcutModifiers.Shift)]
|
| 209 |
+
private static void BoneInfluenceKey(ShortcutArguments args)
|
| 210 |
+
{
|
| 211 |
+
var sm = GetModuleFromContext(args);
|
| 212 |
+
if (sm != null && !sm.spriteEditor.editingDisabled && sm.skinningCache.mode == SkinningMode.Character)
|
| 213 |
+
{
|
| 214 |
+
sm.SetWeightTool(Tools.BoneInfluence);
|
| 215 |
+
sm.skinningCache.events.shortcut.Invoke("#v");
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
[Shortcut("2D/Animation/Paste Panel Weights", typeof(InternalEditorBridge.ShortcutContext), KeyCode.B, ShortcutModifiers.Shift)]
|
| 220 |
+
private static void PastePanelKey(ShortcutArguments args)
|
| 221 |
+
{
|
| 222 |
+
var sm = GetModuleFromContext(args);
|
| 223 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 224 |
+
{
|
| 225 |
+
sm.m_HorizontalToggleTools.TogglePasteTool(sm.currentTool);
|
| 226 |
+
sm.skinningCache.events.shortcut.Invoke("#b");
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
[Shortcut("2D/Animation/Visibility Panel", typeof(InternalEditorBridge.ShortcutContext), KeyCode.P, ShortcutModifiers.Shift)]
|
| 231 |
+
private static void VisibilityPanelKey(ShortcutArguments args)
|
| 232 |
+
{
|
| 233 |
+
var sm = GetModuleFromContext(args);
|
| 234 |
+
if (sm != null && !sm.spriteEditor.editingDisabled)
|
| 235 |
+
{
|
| 236 |
+
sm.m_HorizontalToggleTools.ToggleVisibilityTool(sm.currentTool);
|
| 237 |
+
sm.skinningCache.events.shortcut.Invoke("#p");
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
private void AddMainUI(VisualElement mainView)
|
| 242 |
+
{
|
| 243 |
+
var visualTree = ResourceLoader.Load<VisualTreeAsset>("LayoutOverlay/LayoutOverlay.uxml");
|
| 244 |
+
VisualElement clone = visualTree.CloneTree();
|
| 245 |
+
m_LayoutOverlay = clone.Q<LayoutOverlay>("LayoutOverlay");
|
| 246 |
+
|
| 247 |
+
mainView.Add(m_LayoutOverlay);
|
| 248 |
+
m_LayoutOverlay.hasScrollbar = true;
|
| 249 |
+
m_LayoutOverlay.StretchToParentSize();
|
| 250 |
+
|
| 251 |
+
CreateBoneToolbar();
|
| 252 |
+
CreateMeshToolbar();
|
| 253 |
+
CreateWeightToolbar();
|
| 254 |
+
|
| 255 |
+
m_ShortcutContext = new InternalEditorBridge.ShortcutContext()
|
| 256 |
+
{
|
| 257 |
+
isActive = isFocused,
|
| 258 |
+
context = this
|
| 259 |
+
};
|
| 260 |
+
InternalEditorBridge.RegisterShortcutContext(m_ShortcutContext);
|
| 261 |
+
InternalEditorBridge.AddEditorApplicationProjectLoadedCallback(OnProjectLoaded);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
private void OnProjectLoaded()
|
| 265 |
+
{
|
| 266 |
+
if (m_ShortcutContext != null)
|
| 267 |
+
InternalEditorBridge.RegisterShortcutContext(m_ShortcutContext);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
private void DoViewGUI()
|
| 271 |
+
{
|
| 272 |
+
if (spriteEditor.editingDisabled == m_BoneToolbar.enabledSelf)
|
| 273 |
+
{
|
| 274 |
+
m_BoneToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 275 |
+
m_MeshToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 276 |
+
m_WeightToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
if (spriteEditor.editingDisabled == m_LayoutOverlay.rightOverlay.enabledSelf)
|
| 280 |
+
{
|
| 281 |
+
m_LayoutOverlay.rightOverlay.SetEnabled(!spriteEditor.editingDisabled);
|
| 282 |
+
m_LayoutOverlay.rightOverlay.visible = !spriteEditor.editingDisabled;
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
private bool isFocused()
|
| 287 |
+
{
|
| 288 |
+
return spriteEditor != null && (EditorWindow.focusedWindow == spriteEditor as EditorWindow);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
private void CreateBoneToolbar()
|
| 292 |
+
{
|
| 293 |
+
m_BoneToolbar = BoneToolbar.GenerateFromUXML();
|
| 294 |
+
m_BoneToolbar.Setup(skinningCache);
|
| 295 |
+
m_LayoutOverlay.verticalToolbar.AddToContainer(m_BoneToolbar);
|
| 296 |
+
|
| 297 |
+
m_BoneToolbar.SetSkeletonTool += SetSkeletonTool;
|
| 298 |
+
m_BoneToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
private void CreateMeshToolbar()
|
| 302 |
+
{
|
| 303 |
+
m_MeshToolbar = MeshToolbar.GenerateFromUXML();
|
| 304 |
+
m_MeshToolbar.skinningCache = skinningCache;
|
| 305 |
+
m_LayoutOverlay.verticalToolbar.AddToContainer(m_MeshToolbar);
|
| 306 |
+
|
| 307 |
+
m_MeshToolbar.SetMeshTool += SetMeshTool;
|
| 308 |
+
m_MeshToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
private void CreateWeightToolbar()
|
| 312 |
+
{
|
| 313 |
+
m_WeightToolbar = WeightToolbar.GenerateFromUXML();
|
| 314 |
+
m_WeightToolbar.skinningCache = skinningCache;
|
| 315 |
+
m_LayoutOverlay.verticalToolbar.AddToContainer(m_WeightToolbar);
|
| 316 |
+
m_WeightToolbar.SetWeightTool += SetWeightTool;
|
| 317 |
+
m_WeightToolbar.SetEnabled(!spriteEditor.editingDisabled);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
private void SetSkeletonTool(Tools toolType)
|
| 321 |
+
{
|
| 322 |
+
var tool = skinningCache.GetTool(toolType) as SkeletonToolWrapper;
|
| 323 |
+
|
| 324 |
+
if (currentTool == tool)
|
| 325 |
+
return;
|
| 326 |
+
|
| 327 |
+
using (skinningCache.UndoScope(TextContent.setTool))
|
| 328 |
+
{
|
| 329 |
+
ActivateTool(tool);
|
| 330 |
+
|
| 331 |
+
if (tool.editBindPose)
|
| 332 |
+
skinningCache.RestoreBindPose();
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
private void SetMeshTool(Tools toolType)
|
| 337 |
+
{
|
| 338 |
+
var tool = skinningCache.GetTool(toolType);
|
| 339 |
+
|
| 340 |
+
if (currentTool == tool)
|
| 341 |
+
return;
|
| 342 |
+
|
| 343 |
+
using (skinningCache.UndoScope(TextContent.setTool))
|
| 344 |
+
{
|
| 345 |
+
ActivateTool(tool);
|
| 346 |
+
skinningCache.RestoreBindPose();
|
| 347 |
+
UnselectBones();
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
private void SetWeightTool(Tools toolType)
|
| 352 |
+
{
|
| 353 |
+
var tool = skinningCache.GetTool(toolType);
|
| 354 |
+
|
| 355 |
+
if (currentTool == tool)
|
| 356 |
+
return;
|
| 357 |
+
|
| 358 |
+
using (skinningCache.UndoScope(TextContent.setTool))
|
| 359 |
+
{
|
| 360 |
+
ActivateTool(tool);
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
private void ActivateTool(BaseTool tool)
|
| 365 |
+
{
|
| 366 |
+
m_ModuleToolGroup.ActivateTool(tool);
|
| 367 |
+
UpdateToggleState();
|
| 368 |
+
skinningCache.events.toolChanged.Invoke(tool);
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
private void UnselectBones()
|
| 372 |
+
{
|
| 373 |
+
skinningCache.skeletonSelection.Clear();
|
| 374 |
+
skinningCache.events.boneSelectionChanged.Invoke();
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
private void UpdateToggleState()
|
| 378 |
+
{
|
| 379 |
+
Debug.Assert(m_BoneToolbar != null);
|
| 380 |
+
Debug.Assert(m_MeshToolbar != null);
|
| 381 |
+
Debug.Assert(m_WeightToolbar != null);
|
| 382 |
+
|
| 383 |
+
m_BoneToolbar.UpdateToggleState();
|
| 384 |
+
m_MeshToolbar.UpdateToggleState();
|
| 385 |
+
m_WeightToolbar.UpdateToggleState();
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
private void RemoveMainUI(VisualElement mainView)
|
| 389 |
+
{
|
| 390 |
+
InternalEditorBridge.RemoveEditorApplicationProjectLoadedCallback(OnProjectLoaded);
|
| 391 |
+
InternalEditorBridge.UnregisterShortcutContext(m_ShortcutContext);
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningModuleView.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4ddf280179469e548a5aff8e5eec973c
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SkinningSerializer.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 6a526b93b1b26d040a197bb4ffe84ba1
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SpriteBoneInfluence.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: ae8222a77d2168b45b8a300c2ae1300b
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/SpriteMeshData.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 100c104341c6bfd4e824d8347fff1f87
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Editor/SkinningModule/TextContent.cs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
|
| 3 |
+
namespace UnityEditor.U2D.Animation
|
| 4 |
+
{
|
| 5 |
+
internal static class TextContent
|
| 6 |
+
{
|
| 7 |
+
// Undo
|
| 8 |
+
public static string setMode = "Set Mode";
|
| 9 |
+
public static string setTool = "Set Tool";
|
| 10 |
+
public static string pasteData = "Paste Data";
|
| 11 |
+
public static string generateGeometry = "Generate Geometry";
|
| 12 |
+
public static string generateWeights = "Generate Weights";
|
| 13 |
+
public static string normalizeWeights = "Normalize Weights";
|
| 14 |
+
public static string clearWeights = "Clear Weights";
|
| 15 |
+
public static string restorePose = "Restore Pose";
|
| 16 |
+
public static string selection = "Selection";
|
| 17 |
+
public static string clearSelection = "Clear Selection";
|
| 18 |
+
public static string editWeights = "Edit Weights";
|
| 19 |
+
public static string boneName = "Bone Name";
|
| 20 |
+
public static string boneDepth = "Bone Depth";
|
| 21 |
+
public static string rotateBone = "Rotate Bone";
|
| 22 |
+
public static string moveBone = "Move Bone";
|
| 23 |
+
public static string freeMoveBone = "Free Move Bone";
|
| 24 |
+
public static string moveJoint = "Move Joint";
|
| 25 |
+
public static string moveEndPoint = "Move End Point";
|
| 26 |
+
public static string boneLength = "Bone Length";
|
| 27 |
+
public static string createBone = "Create Bone";
|
| 28 |
+
public static string splitBone = "Split Bone";
|
| 29 |
+
public static string removeBone = "Remove Bone";
|
| 30 |
+
public static string moveVertices = "Move Vertices";
|
| 31 |
+
public static string createVertex = "Create Vertex";
|
| 32 |
+
public static string createEdge = "Create Edge";
|
| 33 |
+
public static string splitEdge = "Split Edge";
|
| 34 |
+
public static string removeEdge = "Remove Edge";
|
| 35 |
+
public static string removeVertices = "Remove Vertices";
|
| 36 |
+
public static string selectionChange = "Selection Change";
|
| 37 |
+
public static string boneVisibility = "Bone Visibility";
|
| 38 |
+
public static string setParentBone = "Set Parent Bone";
|
| 39 |
+
public static string visibilityChange = "VisibilityChange";
|
| 40 |
+
public static string boneSelection = "Bone Selection";
|
| 41 |
+
public static string expandBones = "Expand Bones";
|
| 42 |
+
public static string meshVisibility = "Mesh Visibility";
|
| 43 |
+
public static string meshOpacity = "Mesh Opacity";
|
| 44 |
+
public static string opacityChange = "Opacity Change";
|
| 45 |
+
|
| 46 |
+
// Tooltips
|
| 47 |
+
public static string visibilityIconTooltip = "Visibility tool";
|
| 48 |
+
public static string characterIconTooltip = "Restore bind pose";
|
| 49 |
+
public static string spriteSheetIconTooltip = "Switch between Sprite sheet and Character mode";
|
| 50 |
+
public static string copyTooltip = "Copy";
|
| 51 |
+
public static string pasteTooltip = "Paste";
|
| 52 |
+
public static string onTooltip = "On";
|
| 53 |
+
public static string offTooltip = "Off";
|
| 54 |
+
|
| 55 |
+
// Horizontal tool bar button txt
|
| 56 |
+
public static string visibilityIconText = "Visibility";
|
| 57 |
+
public static string characterIconText = "Reset Pose";
|
| 58 |
+
public static string spriteSheetIconText = "Sprite Sheet";
|
| 59 |
+
public static string copyText = "Copy";
|
| 60 |
+
public static string pasteText = "Paste";
|
| 61 |
+
|
| 62 |
+
// Settings
|
| 63 |
+
public static string selectedOutlineColor = "Selected Outline Color";
|
| 64 |
+
public static string spriteOutlineSize = "Sprite Outline Size";
|
| 65 |
+
public static string boneOutlineSize = "Bone Outline Size";
|
| 66 |
+
|
| 67 |
+
// Sprite Library
|
| 68 |
+
public static string convertGroupToCategory = "Convert Group to Category";
|
| 69 |
+
public static string newTrailingDots = "New...";
|
| 70 |
+
public static string removeEmptyCategory = "Remove Empty Category";
|
| 71 |
+
public static string convertLayerToCategory = "Convert Layer to Category";
|
| 72 |
+
public static string clearAllCategory = "Clear All Category";
|
| 73 |
+
public static string spriteCategoryChanged = "Sprite Category Changed";
|
| 74 |
+
public static string spriteCategoryIndexChanged = "Sprite Category Index Changed";
|
| 75 |
+
public static string category = "Category";
|
| 76 |
+
public static string label = "Label";
|
| 77 |
+
|
| 78 |
+
// Other
|
| 79 |
+
public static string generatingGeometry = "Generating Geometry";
|
| 80 |
+
public static string generatingWeights = "Generating Weights";
|
| 81 |
+
public static string vertexWeight = "Vertex Weight";
|
| 82 |
+
public static string vertexWeightToolTip = "Adjust bone weights for selected vertex";
|
| 83 |
+
public static string bone = "Bone";
|
| 84 |
+
public static string depth = "Depth";
|
| 85 |
+
public static string sprite = "Sprite";
|
| 86 |
+
public static string spriteVisibility = "SpriteVisibility";
|
| 87 |
+
public static string name = "Name";
|
| 88 |
+
public static string none = "None";
|
| 89 |
+
public static string size = "Size";
|
| 90 |
+
public static string visibilityTab = "Visibility Tab";
|
| 91 |
+
public static string addBoneInfluence = "Add Bone Influence";
|
| 92 |
+
public static string removeBoneInfluence = "Remove Bone Influence";
|
| 93 |
+
public static string reorderBoneInfluence = "Reorder Bone Influence";
|
| 94 |
+
public static string noSpriteSelected = "No sprite selected";
|
| 95 |
+
public static string weightSlider = "Weight Slider";
|
| 96 |
+
public static string weightBrush = "Weight Brush";
|
| 97 |
+
public static string generateAll = "Generate All";
|
| 98 |
+
public static string generate = "Generate";
|
| 99 |
+
public static string smoothMeshError = "Generated mesh could not be smoothed. Please try using different parameters";
|
| 100 |
+
public static string copyError1 = "Unable to convert copied data to Skinning Module paste data.";
|
| 101 |
+
public static string copyError2 = "There is no copied data to paste.";
|
| 102 |
+
public static string copyError3 = "Target has a different number of Sprites ({0}) compared to copied source ({1}) for Mesh copy.";
|
| 103 |
+
public static string mode = "Mode";
|
| 104 |
+
public static string modeTooltip = "Different operation mode for weight adjustment";
|
| 105 |
+
public static string boneToolTip = "The bone that is affecting";
|
| 106 |
+
}
|
| 107 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/CCDSolver2DEditor.cs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using UnityEngine.U2D.IK;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.IK
|
| 5 |
+
{
|
| 6 |
+
/// <summary>
|
| 7 |
+
/// Custom Inspector for CCDSolver2D.
|
| 8 |
+
/// </summary>
|
| 9 |
+
[CustomEditor(typeof(CCDSolver2D))]
|
| 10 |
+
[CanEditMultipleObjects]
|
| 11 |
+
public class CCDSolver2DEditor : Solver2DEditor
|
| 12 |
+
{
|
| 13 |
+
private static class Contents
|
| 14 |
+
{
|
| 15 |
+
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
| 16 |
+
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
| 17 |
+
public static readonly GUIContent chainLengthLabel = new GUIContent("Chain Length", "Number of Transforms handled by the IK");
|
| 18 |
+
public static readonly GUIContent iterationsLabel = new GUIContent("Iterations", "Number of iterations the IK solver is run per frame");
|
| 19 |
+
public static readonly GUIContent toleranceLabel = new GUIContent("Tolerance", "How close the target is to the goal to be considered as successful");
|
| 20 |
+
public static readonly GUIContent velocityLabel = new GUIContent("Velocity", "How fast the chain elements rotate to the effector per iteration");
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
private SerializedProperty m_TargetProperty;
|
| 24 |
+
private SerializedProperty m_EffectorProperty;
|
| 25 |
+
private SerializedProperty m_TransformCountProperty;
|
| 26 |
+
|
| 27 |
+
private SerializedProperty m_IterationsProperty;
|
| 28 |
+
private SerializedProperty m_ToleranceProperty;
|
| 29 |
+
private SerializedProperty m_VelocityProperty;
|
| 30 |
+
private CCDSolver2D m_Solver;
|
| 31 |
+
|
| 32 |
+
private void OnEnable()
|
| 33 |
+
{
|
| 34 |
+
m_Solver = target as CCDSolver2D;
|
| 35 |
+
var chainProperty = serializedObject.FindProperty("m_Chain");
|
| 36 |
+
m_TargetProperty = chainProperty.FindPropertyRelative("m_TargetTransform");
|
| 37 |
+
m_EffectorProperty = chainProperty.FindPropertyRelative("m_EffectorTransform");
|
| 38 |
+
m_TransformCountProperty = chainProperty.FindPropertyRelative("m_TransformCount");
|
| 39 |
+
m_IterationsProperty = serializedObject.FindProperty("m_Iterations");
|
| 40 |
+
m_ToleranceProperty = serializedObject.FindProperty("m_Tolerance");
|
| 41 |
+
m_VelocityProperty = serializedObject.FindProperty("m_Velocity");
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/// <summary>
|
| 45 |
+
/// Custom Inspector OnInspectorGUI override.
|
| 46 |
+
/// </summary>
|
| 47 |
+
public override void OnInspectorGUI()
|
| 48 |
+
{
|
| 49 |
+
IKChain2D chain = m_Solver.GetChain(0);
|
| 50 |
+
|
| 51 |
+
serializedObject.Update();
|
| 52 |
+
EditorGUILayout.PropertyField(m_EffectorProperty, Contents.effectorLabel);
|
| 53 |
+
EditorGUILayout.PropertyField(m_TargetProperty, Contents.targetLabel);
|
| 54 |
+
EditorGUILayout.IntSlider(m_TransformCountProperty, 0, IKUtility.GetMaxChainCount(chain), Contents.chainLengthLabel);
|
| 55 |
+
EditorGUILayout.PropertyField(m_IterationsProperty, Contents.iterationsLabel);
|
| 56 |
+
EditorGUILayout.PropertyField(m_ToleranceProperty, Contents.toleranceLabel);
|
| 57 |
+
EditorGUILayout.PropertyField(m_VelocityProperty, Contents.velocityLabel);
|
| 58 |
+
|
| 59 |
+
DrawCommonSolverInspector();
|
| 60 |
+
serializedObject.ApplyModifiedProperties();
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/CCDSolver2DEditor.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 089ed0d19d5c8124da97c7dc15838b97
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/FabrikSolver2DEditor.cs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using UnityEngine.U2D.IK;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.IK
|
| 5 |
+
{
|
| 6 |
+
/// <summary>
|
| 7 |
+
/// Custom Inspector for FabrikSolver2D.
|
| 8 |
+
/// </summary>
|
| 9 |
+
[CustomEditor(typeof(FabrikSolver2D))]
|
| 10 |
+
[CanEditMultipleObjects]
|
| 11 |
+
public class FabrikSolver2DEditor : Solver2DEditor
|
| 12 |
+
{
|
| 13 |
+
private static class Contents
|
| 14 |
+
{
|
| 15 |
+
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
| 16 |
+
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
| 17 |
+
public static readonly GUIContent chainLengthLabel = new GUIContent("Chain Length", "Number of Transforms handled by the IK");
|
| 18 |
+
public static readonly GUIContent iterationsLabel = new GUIContent("Iterations", "Number of iterations the IK solver is run per frame");
|
| 19 |
+
public static readonly GUIContent toleranceLabel = new GUIContent("Tolerance", "How close the target is to the goal to be considered as successful");
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
private SerializedProperty m_TargetProperty;
|
| 23 |
+
private SerializedProperty m_EffectorProperty;
|
| 24 |
+
private SerializedProperty m_TransformCountProperty;
|
| 25 |
+
private SerializedProperty m_IterationsProperty;
|
| 26 |
+
private SerializedProperty m_ToleranceProperty;
|
| 27 |
+
private FabrikSolver2D m_Solver;
|
| 28 |
+
|
| 29 |
+
private void OnEnable()
|
| 30 |
+
{
|
| 31 |
+
m_Solver = target as FabrikSolver2D;
|
| 32 |
+
var chainProperty = serializedObject.FindProperty("m_Chain");
|
| 33 |
+
m_TargetProperty = chainProperty.FindPropertyRelative("m_TargetTransform");
|
| 34 |
+
m_EffectorProperty = chainProperty.FindPropertyRelative("m_EffectorTransform");
|
| 35 |
+
m_TransformCountProperty = chainProperty.FindPropertyRelative("m_TransformCount");
|
| 36 |
+
m_IterationsProperty = serializedObject.FindProperty("m_Iterations");
|
| 37 |
+
m_ToleranceProperty = serializedObject.FindProperty("m_Tolerance");
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/// <summary>
|
| 41 |
+
/// Custom Inspector OnInspectorGUI override.
|
| 42 |
+
/// </summary>
|
| 43 |
+
public override void OnInspectorGUI()
|
| 44 |
+
{
|
| 45 |
+
IKChain2D chain = m_Solver.GetChain(0);
|
| 46 |
+
|
| 47 |
+
serializedObject.Update();
|
| 48 |
+
EditorGUILayout.PropertyField(m_EffectorProperty, Contents.effectorLabel);
|
| 49 |
+
EditorGUILayout.PropertyField(m_TargetProperty, Contents.targetLabel);
|
| 50 |
+
EditorGUILayout.IntSlider(m_TransformCountProperty, 0, IKUtility.GetMaxChainCount(chain), Contents.chainLengthLabel);
|
| 51 |
+
EditorGUILayout.PropertyField(m_IterationsProperty, Contents.iterationsLabel);
|
| 52 |
+
EditorGUILayout.PropertyField(m_ToleranceProperty, Contents.toleranceLabel);
|
| 53 |
+
|
| 54 |
+
DrawCommonSolverInspector();
|
| 55 |
+
|
| 56 |
+
serializedObject.ApplyModifiedProperties();
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/FabrikSolver2DEditor.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 1bbf7e9905b18064197948bb9710c04d
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/IKManager2DEditor.cs
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEditorInternal;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
using UnityEngine.U2D.IK;
|
| 4 |
+
using System;
|
| 5 |
+
using System.Collections.Generic;
|
| 6 |
+
using System.Reflection;
|
| 7 |
+
using System.Linq;
|
| 8 |
+
using UnityEditor.U2D.Animation;
|
| 9 |
+
|
| 10 |
+
namespace UnityEditor.U2D.IK
|
| 11 |
+
{
|
| 12 |
+
/// <summary>
|
| 13 |
+
/// Custom Inspector for IKManager2D.
|
| 14 |
+
/// </summary>
|
| 15 |
+
[CustomEditor(typeof(IKManager2D))]
|
| 16 |
+
[CanEditMultipleObjects]
|
| 17 |
+
class IKManager2DEditor : Editor
|
| 18 |
+
{
|
| 19 |
+
private class Contents
|
| 20 |
+
{
|
| 21 |
+
public static readonly GUIContent findAllSolversLabel = new GUIContent("Find Solvers", "Find all applicable solvers handled by this manager");
|
| 22 |
+
public static readonly GUIContent weightLabel = new GUIContent("Weight", "Blend between Forward and Inverse Kinematics");
|
| 23 |
+
public static readonly string listHeaderLabel = "IK Solvers";
|
| 24 |
+
public static readonly string createSolverString = "Create Solver";
|
| 25 |
+
public static readonly string restoreDefaultPoseString = "Restore Default Pose";
|
| 26 |
+
public static readonly GUIContent gizmoColorTooltip = new GUIContent("","Customizes the IK Chain's Gizmo color");
|
| 27 |
+
public static int showGizmoPropertyWidth = 20;
|
| 28 |
+
public static int solverPropertyWidth = 100;
|
| 29 |
+
public static int solverColorPropertyWidth = 40;
|
| 30 |
+
public static readonly GUIContent gizmoVisibilityToolTip = new GUIContent("",L10n.Tr("Show/Hide Gizmo"));
|
| 31 |
+
public readonly GUIStyle visibilityToggleStyle;
|
| 32 |
+
|
| 33 |
+
public Contents()
|
| 34 |
+
{
|
| 35 |
+
visibilityToggleStyle = new GUIStyle();
|
| 36 |
+
visibilityToggleStyle.fixedWidth = EditorGUIUtility.singleLineHeight;
|
| 37 |
+
visibilityToggleStyle.onNormal.background = IconUtility.LoadIconResource("Visibility_Tool", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath);
|
| 38 |
+
visibilityToggleStyle.normal.background = IconUtility.LoadIconResource("Visibility_Hidded", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
static Contents k_Contents;
|
| 43 |
+
private ReorderableList m_ReorderableList;
|
| 44 |
+
private Solver2D m_SelectedSolver;
|
| 45 |
+
private Editor m_SelectedSolverEditor;
|
| 46 |
+
|
| 47 |
+
SerializedProperty m_SolversProperty;
|
| 48 |
+
SerializedProperty m_SolverEditorDataProperty;
|
| 49 |
+
SerializedProperty m_WeightProperty;
|
| 50 |
+
List<Type> m_SolverTypes;
|
| 51 |
+
IKManager2D m_Manager;
|
| 52 |
+
|
| 53 |
+
private void OnEnable()
|
| 54 |
+
{
|
| 55 |
+
m_Manager = target as IKManager2D;
|
| 56 |
+
m_SolverTypes = GetDerivedTypes<Solver2D>();
|
| 57 |
+
m_SolversProperty = serializedObject.FindProperty("m_Solvers");
|
| 58 |
+
m_SolverEditorDataProperty = serializedObject.FindProperty("m_SolverEditorData");
|
| 59 |
+
m_WeightProperty = serializedObject.FindProperty("m_Weight");
|
| 60 |
+
SetupReordeableList();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
void SetupReordeableList()
|
| 64 |
+
{
|
| 65 |
+
m_ReorderableList = new ReorderableList(serializedObject, m_SolversProperty, true, true, true, true);
|
| 66 |
+
m_ReorderableList.drawHeaderCallback = (Rect rect) =>
|
| 67 |
+
{
|
| 68 |
+
GUI.Label(rect, Contents.listHeaderLabel);
|
| 69 |
+
};
|
| 70 |
+
m_ReorderableList.elementHeightCallback = (int index) =>
|
| 71 |
+
{
|
| 72 |
+
return EditorGUIUtility.singleLineHeight + 6;
|
| 73 |
+
};
|
| 74 |
+
m_ReorderableList.drawElementCallback = (Rect rect, int index, bool isactive, bool isfocused) =>
|
| 75 |
+
{
|
| 76 |
+
rect.y += 2f;
|
| 77 |
+
rect.height = EditorGUIUtility.singleLineHeight;
|
| 78 |
+
SerializedProperty element = m_SolversProperty.GetArrayElementAtIndex(index);
|
| 79 |
+
SerializedProperty elementData = m_SolverEditorDataProperty.GetArrayElementAtIndex(index);
|
| 80 |
+
var width = rect.width;
|
| 81 |
+
rect.width = width > Contents.showGizmoPropertyWidth ? Contents.showGizmoPropertyWidth : width;
|
| 82 |
+
var showGizmoProperty = elementData.FindPropertyRelative("showGizmo");
|
| 83 |
+
showGizmoProperty.boolValue = GUI.Toggle(rect, showGizmoProperty.boolValue, Contents.gizmoVisibilityToolTip, k_Contents.visibilityToggleStyle);
|
| 84 |
+
rect.x += rect.width;
|
| 85 |
+
width -= rect.width;
|
| 86 |
+
rect.width = width > Contents.solverPropertyWidth ? width - Contents.solverColorPropertyWidth : Contents.solverPropertyWidth;
|
| 87 |
+
EditorGUI.PropertyField(rect, element, GUIContent.none);
|
| 88 |
+
rect.x += rect.width;
|
| 89 |
+
width -= 100;
|
| 90 |
+
rect.width = width > Contents.solverColorPropertyWidth ? Contents.solverColorPropertyWidth : width;
|
| 91 |
+
EditorGUI.PropertyField(rect, elementData.FindPropertyRelative("color"), Contents.gizmoColorTooltip);
|
| 92 |
+
};
|
| 93 |
+
m_ReorderableList.onAddCallback = (ReorderableList list) =>
|
| 94 |
+
{
|
| 95 |
+
var menu = new GenericMenu();
|
| 96 |
+
|
| 97 |
+
foreach (Type type in m_SolverTypes)
|
| 98 |
+
{
|
| 99 |
+
Solver2DMenuAttribute attribute = Attribute.GetCustomAttribute(type, typeof(Solver2DMenuAttribute)) as Solver2DMenuAttribute;
|
| 100 |
+
|
| 101 |
+
if (attribute != null)
|
| 102 |
+
menu.AddItem(new GUIContent(attribute.menuPath), false, OnSelectMenu, type);
|
| 103 |
+
else
|
| 104 |
+
menu.AddItem(new GUIContent(type.Name), false, OnSelectMenu, type);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
menu.ShowAsContext();
|
| 108 |
+
};
|
| 109 |
+
m_ReorderableList.onRemoveCallback = (ReorderableList list) =>
|
| 110 |
+
{
|
| 111 |
+
Solver2D solver = m_Manager.solvers[list.index];
|
| 112 |
+
if (solver)
|
| 113 |
+
{
|
| 114 |
+
Undo.RegisterCompleteObjectUndo(m_Manager, Undo.GetCurrentGroupName());
|
| 115 |
+
|
| 116 |
+
m_Manager.RemoveSolver(solver);
|
| 117 |
+
|
| 118 |
+
GameObject solverGO = solver.gameObject;
|
| 119 |
+
|
| 120 |
+
if (solverGO.transform.childCount == 0)
|
| 121 |
+
Undo.DestroyObjectImmediate(solverGO);
|
| 122 |
+
else
|
| 123 |
+
Undo.DestroyObjectImmediate(solver);
|
| 124 |
+
|
| 125 |
+
EditorUtility.SetDirty(m_Manager);
|
| 126 |
+
}
|
| 127 |
+
else
|
| 128 |
+
{
|
| 129 |
+
ReorderableList.defaultBehaviours.DoRemoveButton(list);
|
| 130 |
+
}
|
| 131 |
+
};
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
private void OnSelectMenu(object param)
|
| 135 |
+
{
|
| 136 |
+
Type solverType = param as Type;
|
| 137 |
+
|
| 138 |
+
GameObject solverGO = new GameObject(GameObjectUtility.GetUniqueNameForSibling(m_Manager.transform, "New " + solverType.Name));
|
| 139 |
+
solverGO.transform.SetParent(m_Manager.transform);
|
| 140 |
+
solverGO.transform.localPosition = Vector3.zero;
|
| 141 |
+
solverGO.transform.rotation = Quaternion.identity;
|
| 142 |
+
solverGO.transform.localScale = Vector3.one;
|
| 143 |
+
|
| 144 |
+
Solver2D solver = solverGO.AddComponent(solverType) as Solver2D;
|
| 145 |
+
|
| 146 |
+
Undo.RegisterCreatedObjectUndo(solverGO, Contents.createSolverString);
|
| 147 |
+
Undo.RegisterCompleteObjectUndo(m_Manager, Contents.createSolverString);
|
| 148 |
+
m_Manager.AddSolver(solver);
|
| 149 |
+
EditorUtility.SetDirty(m_Manager);
|
| 150 |
+
|
| 151 |
+
Selection.activeGameObject = solverGO;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/// <summary>
|
| 155 |
+
/// Custom Inspector OnInspectorGUI override.
|
| 156 |
+
/// </summary>
|
| 157 |
+
public override void OnInspectorGUI()
|
| 158 |
+
{
|
| 159 |
+
if(k_Contents == null)
|
| 160 |
+
k_Contents = new Contents();
|
| 161 |
+
|
| 162 |
+
serializedObject.Update();
|
| 163 |
+
|
| 164 |
+
EditorGUILayout.Space();
|
| 165 |
+
|
| 166 |
+
m_ReorderableList.DoLayoutList();
|
| 167 |
+
|
| 168 |
+
EditorGUILayout.Space();
|
| 169 |
+
|
| 170 |
+
EditorGUILayout.PropertyField(m_WeightProperty, Contents.weightLabel);
|
| 171 |
+
|
| 172 |
+
EditorGUILayout.BeginHorizontal();
|
| 173 |
+
GUILayout.FlexibleSpace();
|
| 174 |
+
|
| 175 |
+
DoRestoreDefaultPoseButton();
|
| 176 |
+
|
| 177 |
+
GUILayout.FlexibleSpace();
|
| 178 |
+
EditorGUILayout.EndHorizontal();
|
| 179 |
+
|
| 180 |
+
serializedObject.ApplyModifiedProperties();
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
private void DoRestoreDefaultPoseButton()
|
| 184 |
+
{
|
| 185 |
+
if (GUILayout.Button(Contents.restoreDefaultPoseString, GUILayout.MaxWidth(150f)))
|
| 186 |
+
{
|
| 187 |
+
foreach (var l_target in targets)
|
| 188 |
+
{
|
| 189 |
+
var manager = l_target as IKManager2D;
|
| 190 |
+
|
| 191 |
+
IKEditorManager.instance.Record(manager, Contents.restoreDefaultPoseString);
|
| 192 |
+
|
| 193 |
+
foreach(var solver in manager.solvers)
|
| 194 |
+
{
|
| 195 |
+
for(int i = 0; i < solver.chainCount; ++i)
|
| 196 |
+
{
|
| 197 |
+
var chain = solver.GetChain(i);
|
| 198 |
+
chain.RestoreDefaultPose(solver.constrainRotation);
|
| 199 |
+
|
| 200 |
+
if(chain.target)
|
| 201 |
+
{
|
| 202 |
+
chain.target.position = chain.effector.position;
|
| 203 |
+
chain.target.rotation = chain.effector.rotation;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
IKEditorManager.instance.UpdateManagerImmediate(manager, true);
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
List<Type> GetDerivedTypes<T>() where T : class
|
| 214 |
+
{
|
| 215 |
+
List<Type> types = Assembly.GetAssembly(typeof(T)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))).ToList();
|
| 216 |
+
return types;
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/IKManager2DEditor.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 774c00e683b6094459a1ed557b35694b
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/LimbSolver2DEditor.cs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using UnityEngine.U2D.IK;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.IK
|
| 5 |
+
{
|
| 6 |
+
/// <summary>
|
| 7 |
+
/// Custom Inspector for LimbSolver2D.
|
| 8 |
+
/// </summary>
|
| 9 |
+
[CustomEditor(typeof(LimbSolver2D))]
|
| 10 |
+
[CanEditMultipleObjects]
|
| 11 |
+
public class LimbSolver2DEditor : Solver2DEditor
|
| 12 |
+
{
|
| 13 |
+
private static class Contents
|
| 14 |
+
{
|
| 15 |
+
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
| 16 |
+
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
| 17 |
+
public static readonly GUIContent flipLabel = new GUIContent("Flip", "Select between the two possible solutions of the solver");
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
private SerializedProperty m_ChainProperty;
|
| 21 |
+
private SerializedProperty m_FlipProperty;
|
| 22 |
+
|
| 23 |
+
private void OnEnable()
|
| 24 |
+
{
|
| 25 |
+
m_ChainProperty = serializedObject.FindProperty("m_Chain");
|
| 26 |
+
m_FlipProperty = serializedObject.FindProperty("m_Flip");
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/// <summary>
|
| 30 |
+
/// Custom Inspector OnInspectorGUI override.
|
| 31 |
+
/// </summary>
|
| 32 |
+
public override void OnInspectorGUI()
|
| 33 |
+
{
|
| 34 |
+
serializedObject.Update();
|
| 35 |
+
EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_EffectorTransform"), Contents.effectorLabel);
|
| 36 |
+
EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_TargetTransform"), Contents.targetLabel);
|
| 37 |
+
EditorGUILayout.PropertyField(m_FlipProperty, Contents.flipLabel);
|
| 38 |
+
|
| 39 |
+
DrawCommonSolverInspector();
|
| 40 |
+
|
| 41 |
+
serializedObject.ApplyModifiedProperties();
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/LimbSolver2DEditor.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 03bd69c1b56e1114794712e23f86f554
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/Solver2DEditor.cs
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using UnityEngine;
|
| 2 |
+
using UnityEngine.U2D.IK;
|
| 3 |
+
|
| 4 |
+
namespace UnityEditor.U2D.IK
|
| 5 |
+
{
|
| 6 |
+
/// <summary>
|
| 7 |
+
/// Custom Inspector for Solver2D.
|
| 8 |
+
/// </summary>
|
| 9 |
+
[CustomEditor(typeof(Solver2D))]
|
| 10 |
+
[CanEditMultipleObjects]
|
| 11 |
+
public class Solver2DEditor : Editor
|
| 12 |
+
{
|
| 13 |
+
private static class Contents
|
| 14 |
+
{
|
| 15 |
+
public static readonly GUIContent constrainRotationLabel = new GUIContent("Constrain Rotation", "Set Effector's rotation to Target");
|
| 16 |
+
public static readonly GUIContent solveFromDefaultPoseLabel = new GUIContent("Solve from Default Pose", "Restore transform's rotation to default value before solving the IK");
|
| 17 |
+
public static readonly GUIContent weightLabel = new GUIContent("Weight", "Blend between Forward and Inverse Kinematics");
|
| 18 |
+
public static readonly string restoreDefaultPoseString = "Restore Default Pose";
|
| 19 |
+
public static readonly string createTargetString = "Create Target";
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
private SerializedProperty m_ConstrainRotationProperty;
|
| 23 |
+
private SerializedProperty m_SolveFromDefaultPoseProperty;
|
| 24 |
+
private SerializedProperty m_WeightProperty;
|
| 25 |
+
private SerializedProperty m_SolverColorProperty;
|
| 26 |
+
|
| 27 |
+
private void SetupProperties()
|
| 28 |
+
{
|
| 29 |
+
if(m_ConstrainRotationProperty == null || m_SolveFromDefaultPoseProperty == null || m_WeightProperty == null)
|
| 30 |
+
{
|
| 31 |
+
m_ConstrainRotationProperty = serializedObject.FindProperty("m_ConstrainRotation");
|
| 32 |
+
m_SolveFromDefaultPoseProperty = serializedObject.FindProperty("m_SolveFromDefaultPose");
|
| 33 |
+
m_WeightProperty = serializedObject.FindProperty("m_Weight");
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/// <summary>
|
| 38 |
+
/// Custom Inspector GUI for Solver2D.
|
| 39 |
+
/// </summary>
|
| 40 |
+
protected void DrawCommonSolverInspector()
|
| 41 |
+
{
|
| 42 |
+
SetupProperties();
|
| 43 |
+
|
| 44 |
+
EditorGUILayout.PropertyField(m_ConstrainRotationProperty, Contents.constrainRotationLabel);
|
| 45 |
+
EditorGUILayout.PropertyField(m_SolveFromDefaultPoseProperty, Contents.solveFromDefaultPoseLabel);
|
| 46 |
+
EditorGUILayout.PropertyField(m_WeightProperty, Contents.weightLabel);
|
| 47 |
+
|
| 48 |
+
EditorGUILayout.Space();
|
| 49 |
+
|
| 50 |
+
EditorGUILayout.BeginHorizontal();
|
| 51 |
+
GUILayout.FlexibleSpace();
|
| 52 |
+
|
| 53 |
+
EditorGUI.BeginDisabledGroup(!EnableCreateTarget());
|
| 54 |
+
DoCreateTargetButton();
|
| 55 |
+
EditorGUI.EndDisabledGroup();
|
| 56 |
+
|
| 57 |
+
EditorGUI.BeginDisabledGroup(!EnableRestoreDefaultPose());
|
| 58 |
+
DoRestoreDefaultPoseButton();
|
| 59 |
+
EditorGUI.EndDisabledGroup();
|
| 60 |
+
|
| 61 |
+
GUILayout.FlexibleSpace();
|
| 62 |
+
EditorGUILayout.EndHorizontal();
|
| 63 |
+
|
| 64 |
+
EditorGUILayout.Space();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
private bool EnableRestoreDefaultPose()
|
| 68 |
+
{
|
| 69 |
+
foreach (var l_target in targets)
|
| 70 |
+
{
|
| 71 |
+
var solver = l_target as Solver2D;
|
| 72 |
+
|
| 73 |
+
if (!solver.isValid || IKEditorManager.instance.FindManager(solver) == null)
|
| 74 |
+
continue;
|
| 75 |
+
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
return false;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
private bool EnableCreateTarget()
|
| 83 |
+
{
|
| 84 |
+
foreach (var l_target in targets)
|
| 85 |
+
{
|
| 86 |
+
var solver = l_target as Solver2D;
|
| 87 |
+
|
| 88 |
+
if (!solver.isValid)
|
| 89 |
+
continue;
|
| 90 |
+
|
| 91 |
+
for(int i = 0; i < solver.chainCount; ++i)
|
| 92 |
+
{
|
| 93 |
+
var chain = solver.GetChain(i);
|
| 94 |
+
|
| 95 |
+
if(chain.target == null)
|
| 96 |
+
return true;
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
return false;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
private void DoRestoreDefaultPoseButton()
|
| 104 |
+
{
|
| 105 |
+
if (GUILayout.Button(Contents.restoreDefaultPoseString, GUILayout.MaxWidth(150f)))
|
| 106 |
+
{
|
| 107 |
+
foreach (var l_target in targets)
|
| 108 |
+
{
|
| 109 |
+
var solver = l_target as Solver2D;
|
| 110 |
+
|
| 111 |
+
if (!solver.isValid)
|
| 112 |
+
continue;
|
| 113 |
+
|
| 114 |
+
IKEditorManager.instance.Record(solver, Contents.restoreDefaultPoseString);
|
| 115 |
+
|
| 116 |
+
for(int i = 0; i < solver.chainCount; ++i)
|
| 117 |
+
{
|
| 118 |
+
var chain = solver.GetChain(i);
|
| 119 |
+
chain.RestoreDefaultPose(solver.constrainRotation);
|
| 120 |
+
|
| 121 |
+
if(chain.target)
|
| 122 |
+
{
|
| 123 |
+
chain.target.position = chain.effector.position;
|
| 124 |
+
chain.target.rotation = chain.effector.rotation;
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
IKEditorManager.instance.UpdateSolverImmediate(solver, true);
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
private void DoCreateTargetButton()
|
| 134 |
+
{
|
| 135 |
+
if (GUILayout.Button(Contents.createTargetString, GUILayout.MaxWidth(125f)))
|
| 136 |
+
{
|
| 137 |
+
foreach (var l_target in targets)
|
| 138 |
+
{
|
| 139 |
+
var solver = l_target as Solver2D;
|
| 140 |
+
|
| 141 |
+
if (!solver.isValid)
|
| 142 |
+
continue;
|
| 143 |
+
|
| 144 |
+
for(int i = 0; i < solver.chainCount; ++i)
|
| 145 |
+
{
|
| 146 |
+
var chain = solver.GetChain(i);
|
| 147 |
+
|
| 148 |
+
if(chain.target == null)
|
| 149 |
+
{
|
| 150 |
+
Undo.RegisterCompleteObjectUndo(solver, Contents.createTargetString);
|
| 151 |
+
|
| 152 |
+
chain.target = new GameObject(GameObjectUtility.GetUniqueNameForSibling(solver.transform, solver.name + "_Target")).transform;
|
| 153 |
+
chain.target.SetParent(solver.transform);
|
| 154 |
+
chain.target.position = chain.effector.position;
|
| 155 |
+
chain.target.rotation = chain.effector.rotation;
|
| 156 |
+
|
| 157 |
+
Undo.RegisterCreatedObjectUndo(chain.target.gameObject, Contents.createTargetString);
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Editor/Inspectors/Solver2DEditor.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4a4d0d0740dce7045a9925d5be120303
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/IKUtility.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: b5fde14964733764c8c198a418b2eaaf
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/LimbSolver2D.cs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System.Collections.Generic;
|
| 2 |
+
using UnityEngine.Scripting.APIUpdating;
|
| 3 |
+
|
| 4 |
+
namespace UnityEngine.U2D.IK
|
| 5 |
+
{
|
| 6 |
+
/// <summary>
|
| 7 |
+
/// Component for 2D Limb IK.
|
| 8 |
+
/// </summary>
|
| 9 |
+
[MovedFrom("UnityEngine.Experimental.U2D.IK")]
|
| 10 |
+
[Solver2DMenuAttribute("Limb")]
|
| 11 |
+
public class LimbSolver2D : Solver2D
|
| 12 |
+
{
|
| 13 |
+
[SerializeField]
|
| 14 |
+
private IKChain2D m_Chain = new IKChain2D();
|
| 15 |
+
|
| 16 |
+
[SerializeField]
|
| 17 |
+
private bool m_Flip;
|
| 18 |
+
private Vector3[] m_Positions = new Vector3[3];
|
| 19 |
+
private float[] m_Lengths = new float[2];
|
| 20 |
+
private float[] m_Angles = new float[2];
|
| 21 |
+
|
| 22 |
+
/// <summary>
|
| 23 |
+
/// Get Set for flip property.
|
| 24 |
+
/// </summary>
|
| 25 |
+
public bool flip
|
| 26 |
+
{
|
| 27 |
+
get { return m_Flip; }
|
| 28 |
+
set { m_Flip = value; }
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/// <summary>
|
| 32 |
+
/// Override base class DoInitialize.
|
| 33 |
+
/// </summary>
|
| 34 |
+
protected override void DoInitialize()
|
| 35 |
+
{
|
| 36 |
+
m_Chain.transformCount = m_Chain.effector == null || IKUtility.GetAncestorCount(m_Chain.effector) < 2 ? 0 : 3;
|
| 37 |
+
base.DoInitialize();
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/// <summary>
|
| 41 |
+
/// Override base class GetChainCount.
|
| 42 |
+
/// </summary>
|
| 43 |
+
/// <returns>Always returns 1.</returns>
|
| 44 |
+
protected override int GetChainCount()
|
| 45 |
+
{
|
| 46 |
+
return 1;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/// <summary>
|
| 50 |
+
/// Override base class GetChain.
|
| 51 |
+
/// </summary>
|
| 52 |
+
/// <param name="index">Index to query.</param>
|
| 53 |
+
/// <returns>Returns IKChain2D for the Solver.</returns>
|
| 54 |
+
public override IKChain2D GetChain(int index)
|
| 55 |
+
{
|
| 56 |
+
return m_Chain;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/// <summary>
|
| 60 |
+
/// Override base class DoPrepare.
|
| 61 |
+
/// </summary>
|
| 62 |
+
protected override void DoPrepare()
|
| 63 |
+
{
|
| 64 |
+
var lengths = m_Chain.lengths;
|
| 65 |
+
m_Positions[0] = m_Chain.transforms[0].position;
|
| 66 |
+
m_Positions[1] = m_Chain.transforms[1].position;
|
| 67 |
+
m_Positions[2] = m_Chain.transforms[2].position;
|
| 68 |
+
m_Lengths[0] = lengths[0];
|
| 69 |
+
m_Lengths[1] = lengths[1];
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/// <summary>
|
| 73 |
+
/// OVerride base class DoUpdateIK.
|
| 74 |
+
/// </summary>
|
| 75 |
+
/// <param name="effectorPositions">List of effector positions.</param>
|
| 76 |
+
protected override void DoUpdateIK(List<Vector3> effectorPositions)
|
| 77 |
+
{
|
| 78 |
+
Vector3 effectorPosition = effectorPositions[0];
|
| 79 |
+
Vector2 effectorLocalPosition2D = m_Chain.transforms[0].InverseTransformPoint(effectorPosition);
|
| 80 |
+
effectorPosition = m_Chain.transforms[0].TransformPoint(effectorLocalPosition2D);
|
| 81 |
+
|
| 82 |
+
if (effectorLocalPosition2D.sqrMagnitude > 0f && Limb.Solve(effectorPosition, m_Lengths, m_Positions, ref m_Angles))
|
| 83 |
+
{
|
| 84 |
+
float flipSign = flip ? -1f : 1f;
|
| 85 |
+
m_Chain.transforms[0].localRotation *= Quaternion.FromToRotation(Vector3.right, effectorLocalPosition2D) * Quaternion.FromToRotation(m_Chain.transforms[1].localPosition, Vector3.right);
|
| 86 |
+
m_Chain.transforms[0].localRotation *= Quaternion.AngleAxis(flipSign * m_Angles[0], Vector3.forward);
|
| 87 |
+
m_Chain.transforms[1].localRotation *= Quaternion.FromToRotation(Vector3.right, m_Chain.transforms[1].InverseTransformPoint(effectorPosition)) * Quaternion.FromToRotation(m_Chain.transforms[2].localPosition, Vector3.right);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/LimbSolver2D.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 30ae93fb156fc6d4c828c64571fc3edd
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2D.cs
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using System.Collections.Generic;
|
| 3 |
+
using UnityEngine.Scripting.APIUpdating;
|
| 4 |
+
using UnityEngine.Serialization;
|
| 5 |
+
|
| 6 |
+
namespace UnityEngine.U2D.IK
|
| 7 |
+
{
|
| 8 |
+
/// <summary>
|
| 9 |
+
/// Abstract class for implementing a 2D IK Solver.
|
| 10 |
+
/// </summary>
|
| 11 |
+
[MovedFrom("UnityEngine.Experimental.U2D.IK")]
|
| 12 |
+
public abstract class Solver2D : MonoBehaviour
|
| 13 |
+
{
|
| 14 |
+
[SerializeField]
|
| 15 |
+
private bool m_ConstrainRotation = true;
|
| 16 |
+
[FormerlySerializedAs("m_RestoreDefaultPose")]
|
| 17 |
+
[SerializeField]
|
| 18 |
+
private bool m_SolveFromDefaultPose = true;
|
| 19 |
+
[SerializeField][Range(0f, 1f)]
|
| 20 |
+
private float m_Weight = 1f;
|
| 21 |
+
|
| 22 |
+
private Plane m_Plane;
|
| 23 |
+
private List<Vector3> m_TargetPositions = new List<Vector3>();
|
| 24 |
+
|
| 25 |
+
/// <summary>
|
| 26 |
+
/// Returns the number of IKChain2D in the solver.
|
| 27 |
+
/// </summary>
|
| 28 |
+
public int chainCount
|
| 29 |
+
{
|
| 30 |
+
get { return GetChainCount(); }
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/// <summary>
|
| 34 |
+
/// Get Set for rotation constrain property.
|
| 35 |
+
/// </summary>
|
| 36 |
+
public bool constrainRotation
|
| 37 |
+
{
|
| 38 |
+
get { return m_ConstrainRotation; }
|
| 39 |
+
set { m_ConstrainRotation = value; }
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/// <summary>
|
| 43 |
+
/// Get Set for restoring default pose.
|
| 44 |
+
/// </summary>
|
| 45 |
+
public bool solveFromDefaultPose
|
| 46 |
+
{
|
| 47 |
+
get { return m_SolveFromDefaultPose; }
|
| 48 |
+
set { m_SolveFromDefaultPose = value; }
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/// <summary>
|
| 52 |
+
/// Returns true if the Solver2D is in a valid state.
|
| 53 |
+
/// </summary>
|
| 54 |
+
public bool isValid
|
| 55 |
+
{
|
| 56 |
+
get { return Validate(); }
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/// <summary>
|
| 60 |
+
/// Returns true if all chains in the Solver has a target.
|
| 61 |
+
/// </summary>
|
| 62 |
+
public bool allChainsHaveTargets
|
| 63 |
+
{
|
| 64 |
+
get { return HasTargets(); }
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/// <summary>
|
| 68 |
+
/// Get and Set Solver weights.
|
| 69 |
+
/// </summary>
|
| 70 |
+
public float weight
|
| 71 |
+
{
|
| 72 |
+
get { return m_Weight; }
|
| 73 |
+
set { m_Weight = Mathf.Clamp01(value); }
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
private void OnEnable() {}
|
| 77 |
+
|
| 78 |
+
/// <summary>
|
| 79 |
+
/// Validate and initialize the Solver.
|
| 80 |
+
/// </summary>
|
| 81 |
+
protected virtual void OnValidate()
|
| 82 |
+
{
|
| 83 |
+
m_Weight = Mathf.Clamp01(m_Weight);
|
| 84 |
+
|
| 85 |
+
if (!isValid)
|
| 86 |
+
Initialize();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
private bool Validate()
|
| 90 |
+
{
|
| 91 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 92 |
+
{
|
| 93 |
+
var chain = GetChain(i);
|
| 94 |
+
if (!chain.isValid)
|
| 95 |
+
return false;
|
| 96 |
+
}
|
| 97 |
+
return DoValidate();
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
private bool HasTargets()
|
| 101 |
+
{
|
| 102 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 103 |
+
{
|
| 104 |
+
var chain = GetChain(i);
|
| 105 |
+
if (chain.target == null)
|
| 106 |
+
return false;
|
| 107 |
+
}
|
| 108 |
+
return true;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/// <summary>
|
| 112 |
+
/// Initializes the solver.
|
| 113 |
+
/// </summary>
|
| 114 |
+
public void Initialize()
|
| 115 |
+
{
|
| 116 |
+
DoInitialize();
|
| 117 |
+
|
| 118 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 119 |
+
{
|
| 120 |
+
var chain = GetChain(i);
|
| 121 |
+
chain.Initialize();
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
private void Prepare()
|
| 126 |
+
{
|
| 127 |
+
var rootTransform = GetPlaneRootTransform();
|
| 128 |
+
if (rootTransform != null)
|
| 129 |
+
{
|
| 130 |
+
m_Plane.normal = rootTransform.forward;
|
| 131 |
+
m_Plane.distance = -Vector3.Dot(m_Plane.normal, rootTransform.position);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 135 |
+
{
|
| 136 |
+
var chain = GetChain(i);
|
| 137 |
+
var constrainTargetRotation = constrainRotation && chain.target != null;
|
| 138 |
+
|
| 139 |
+
if (m_SolveFromDefaultPose)
|
| 140 |
+
chain.RestoreDefaultPose(constrainTargetRotation);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
DoPrepare();
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
private void PrepareEffectorPositions()
|
| 147 |
+
{
|
| 148 |
+
m_TargetPositions.Clear();
|
| 149 |
+
|
| 150 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 151 |
+
{
|
| 152 |
+
var chain = GetChain(i);
|
| 153 |
+
|
| 154 |
+
if (chain.target)
|
| 155 |
+
m_TargetPositions.Add(chain.target.position);
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/// <summary>
|
| 160 |
+
/// Perfom Solver IK update.
|
| 161 |
+
/// </summary>
|
| 162 |
+
/// <param name="globalWeight">Weight for position solving.</param>
|
| 163 |
+
public void UpdateIK(float globalWeight)
|
| 164 |
+
{
|
| 165 |
+
if(allChainsHaveTargets)
|
| 166 |
+
{
|
| 167 |
+
PrepareEffectorPositions();
|
| 168 |
+
UpdateIK(m_TargetPositions, globalWeight);
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/// <summary>
|
| 173 |
+
/// Perform Solver IK update.
|
| 174 |
+
/// </summary>
|
| 175 |
+
/// <param name="positions">Positions of chain.</param>
|
| 176 |
+
/// <param name="globalWeight">Weight for position solving.</param>
|
| 177 |
+
public void UpdateIK(List<Vector3> positions, float globalWeight)
|
| 178 |
+
{
|
| 179 |
+
if(positions.Count != chainCount)
|
| 180 |
+
return;
|
| 181 |
+
|
| 182 |
+
float finalWeight = globalWeight * weight;
|
| 183 |
+
if (finalWeight == 0f)
|
| 184 |
+
return;
|
| 185 |
+
|
| 186 |
+
if (!isValid)
|
| 187 |
+
return;
|
| 188 |
+
|
| 189 |
+
Prepare();
|
| 190 |
+
|
| 191 |
+
if (finalWeight < 1f)
|
| 192 |
+
StoreLocalRotations();
|
| 193 |
+
|
| 194 |
+
DoUpdateIK(positions);
|
| 195 |
+
|
| 196 |
+
if (constrainRotation)
|
| 197 |
+
{
|
| 198 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 199 |
+
{
|
| 200 |
+
var chain = GetChain(i);
|
| 201 |
+
|
| 202 |
+
if (chain.target)
|
| 203 |
+
chain.effector.rotation = chain.target.rotation;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
if (finalWeight < 1f)
|
| 208 |
+
BlendFkToIk(finalWeight);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
private void StoreLocalRotations()
|
| 212 |
+
{
|
| 213 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 214 |
+
{
|
| 215 |
+
var chain = GetChain(i);
|
| 216 |
+
chain.StoreLocalRotations();
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
private void BlendFkToIk(float finalWeight)
|
| 221 |
+
{
|
| 222 |
+
for (int i = 0; i < GetChainCount(); ++i)
|
| 223 |
+
{
|
| 224 |
+
var chain = GetChain(i);
|
| 225 |
+
var constrainTargetRotation = constrainRotation && chain.target != null;
|
| 226 |
+
chain.BlendFkToIk(finalWeight, constrainTargetRotation);
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/// <summary>
|
| 231 |
+
/// Override to return the IKChain2D at the given index.
|
| 232 |
+
/// </summary>
|
| 233 |
+
/// <param name="index">Index for IKChain2D.</param>
|
| 234 |
+
/// <returns></returns>
|
| 235 |
+
public abstract IKChain2D GetChain(int index);
|
| 236 |
+
|
| 237 |
+
/// <summary>
|
| 238 |
+
/// OVerride to return the number of chains in the Solver
|
| 239 |
+
/// </summary>
|
| 240 |
+
/// <returns>Integer represents IKChain2D count.</returns>
|
| 241 |
+
protected abstract int GetChainCount();
|
| 242 |
+
|
| 243 |
+
/// <summary>
|
| 244 |
+
/// Override to perform Solver IK update
|
| 245 |
+
/// </summary>
|
| 246 |
+
/// <param name="effectorPositions">Position of the effectors.</param>
|
| 247 |
+
protected abstract void DoUpdateIK(List<Vector3> effectorPositions);
|
| 248 |
+
|
| 249 |
+
/// <summary>
|
| 250 |
+
/// Override to perform custom validation.
|
| 251 |
+
/// </summary>
|
| 252 |
+
/// <returns>Returns true if the Solver is in a valid state. False otherwise.</returns>
|
| 253 |
+
protected virtual bool DoValidate() { return true; }
|
| 254 |
+
|
| 255 |
+
/// <summary>
|
| 256 |
+
/// Override to perform initialize the solver
|
| 257 |
+
/// </summary>
|
| 258 |
+
protected virtual void DoInitialize() {}
|
| 259 |
+
|
| 260 |
+
/// <summary>
|
| 261 |
+
/// Override to prepare the solver for update
|
| 262 |
+
/// </summary>
|
| 263 |
+
protected virtual void DoPrepare() {}
|
| 264 |
+
|
| 265 |
+
/// <summary>
|
| 266 |
+
/// Override to return the root Unity Transform of the Solver. The default implementation returns the root
|
| 267 |
+
/// transform of the first chain.
|
| 268 |
+
/// </summary>
|
| 269 |
+
/// <returns>Unity Transform that represents the root.</returns>
|
| 270 |
+
protected virtual Transform GetPlaneRootTransform()
|
| 271 |
+
{
|
| 272 |
+
if (chainCount > 0)
|
| 273 |
+
return GetChain(0).rootTransform;
|
| 274 |
+
return null;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/// <summary>
|
| 278 |
+
/// Convert a world position coordinate to the solver's plane space
|
| 279 |
+
/// </summary>
|
| 280 |
+
/// <param name="worldPosition">Vector3 representing world position</param>
|
| 281 |
+
/// <returns>Converted position in solver's plane</returns>
|
| 282 |
+
protected Vector3 GetPointOnSolverPlane(Vector3 worldPosition)
|
| 283 |
+
{
|
| 284 |
+
return GetPlaneRootTransform().InverseTransformPoint(m_Plane.ClosestPointOnPlane(worldPosition));
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/// <summary>
|
| 288 |
+
/// Convert a position from solver's plane to world coordinate
|
| 289 |
+
/// </summary>
|
| 290 |
+
/// <param name="planePoint">Vector3 representing a position in the Solver's plane.</param>
|
| 291 |
+
/// <returns>Converted position to world coordinate.</returns>
|
| 292 |
+
protected Vector3 GetWorldPositionFromSolverPlanePoint(Vector2 planePoint)
|
| 293 |
+
{
|
| 294 |
+
return GetPlaneRootTransform().TransformPoint(planePoint);
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2D.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: fd469cc9c7a046649b08db54fa8e1cca
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/IK/Runtime/Solver2DMenuAttribute.cs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using UnityEngine;
|
| 3 |
+
using UnityEngine.Scripting.APIUpdating;
|
| 4 |
+
|
| 5 |
+
namespace UnityEngine.U2D.IK
|
| 6 |
+
{
|
| 7 |
+
/// <summary>
|
| 8 |
+
/// Attribute to add a menu item in IKManager2D to create the Solver.
|
| 9 |
+
/// </summary>
|
| 10 |
+
[MovedFrom("UnityEngine.Experimental.U2D.IK")]
|
| 11 |
+
[AttributeUsage(AttributeTargets.Class)]
|
| 12 |
+
public sealed class Solver2DMenuAttribute : Attribute
|
| 13 |
+
{
|
| 14 |
+
string m_MenuPath;
|
| 15 |
+
|
| 16 |
+
/// <summary>
|
| 17 |
+
/// Menu path.
|
| 18 |
+
/// </summary>
|
| 19 |
+
public string menuPath
|
| 20 |
+
{
|
| 21 |
+
get { return m_MenuPath; }
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/// <summary>
|
| 25 |
+
/// Constructor
|
| 26 |
+
/// </summary>
|
| 27 |
+
/// <param name="_menuPath">Menu item path.</param>
|
| 28 |
+
public Solver2DMenuAttribute(string _menuPath)
|
| 29 |
+
{
|
| 30 |
+
m_MenuPath = _menuPath;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|