diff --git a/IronToad_UnityProject/Assets/BansheeGz.meta b/IronToad_UnityProject/Assets/BansheeGz.meta new file mode 100644 index 0000000..32380ef --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4c2a3a5b1b8384d5c8af8ee8bae092aa +folderAsset: yes +timeCreated: 1484953020 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve.meta new file mode 100644 index 0000000..a842f22 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 57191a445dbf4436eb022e58a93c378b +folderAsset: yes +timeCreated: 1484953020 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples.meta new file mode 100644 index 0000000..0d210bb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3f6e9929ec3d4d143b1fbea21cc0d3ff +folderAsset: yes +timeCreated: 1458400496 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations.meta new file mode 100644 index 0000000..e411cd6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 758f9f59418c8c54da21525f0f062516 +folderAsset: yes +timeCreated: 1476657327 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller new file mode 100644 index 0000000..896944e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller.meta new file mode 100644 index 0000000..41e5f35 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimatedObjectsForPoints.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: db3da87b26ed5d0448acc48198ffa770 +timeCreated: 1477969440 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim new file mode 100644 index 0000000..2771716 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim.meta new file mode 100644 index 0000000..a1071e9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGAnimationTest.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: be87f1a6c5eefe34b9aa201349f0c3d0 +timeCreated: 1476658635 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller new file mode 100644 index 0000000..1956833 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller.meta new file mode 100644 index 0000000..c9f5f89 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGComponentTest.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87d06f2350ef4e94daec3edf4dd97b72 +timeCreated: 1476658635 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller new file mode 100644 index 0000000..709c6c3 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller.meta new file mode 100644 index 0000000..90e2a90 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingAdaptiveMath.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a4a9c0fd6deb9f8418329c54a11468e6 +timeCreated: 1476936696 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller new file mode 100644 index 0000000..cbc59e2 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller.meta new file mode 100644 index 0000000..02bcf56 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGCurveSnappingBaseMath.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 516ff215bfef74c4ebe1b3b634c7f489 +timeCreated: 1476936686 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller new file mode 100644 index 0000000..a8032dc Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller.meta new file mode 100644 index 0000000..aab67eb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGLeafs.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 76ad43ce2f816254090bb04929bb9e55 +timeCreated: 1476838167 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller new file mode 100644 index 0000000..5ae545a Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller.meta new file mode 100644 index 0000000..bbb5b64 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoomin.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb3c033f1dfe7964dac7eeddac8b1a56 +timeCreated: 1476944185 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim new file mode 100644 index 0000000..5320eec Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim.meta new file mode 100644 index 0000000..052154a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoominAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ad2186b334267245a953ff31e7ce1fd +timeCreated: 1476944185 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller new file mode 100644 index 0000000..e47f0e3 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller.meta new file mode 100644 index 0000000..06b3265 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoon.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38aa8bab7803d794ca7285b4bf017945 +timeCreated: 1476807795 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim new file mode 100644 index 0000000..f3fc0be Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim.meta new file mode 100644 index 0000000..1cb0ae9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f91122ae46f42fb4e88dd5ecad9a7403 +timeCreated: 1476807795 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim new file mode 100644 index 0000000..c7696ef Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim.meta new file mode 100644 index 0000000..90f03c9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGMoonIdleAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c65020880747fa241bf235f7e6e29b16 +timeCreated: 1476808692 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim new file mode 100644 index 0000000..d429c87 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim.meta new file mode 100644 index 0000000..31c4f07 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointTransformsAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca93d1b2992418548b16f01ac657af1f +timeCreated: 1477969440 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim new file mode 100644 index 0000000..20a8efb Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim.meta new file mode 100644 index 0000000..aea7aa4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGPointsModeSphereAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ab8b640f7d94674c926ecbd6452e733 +timeCreated: 1477839802 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim new file mode 100644 index 0000000..a16f89a Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim.meta new file mode 100644 index 0000000..67391cf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap1Animation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55f60c7466992b3468cf6475c8f54eb5 +timeCreated: 1476936686 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim new file mode 100644 index 0000000..89328a2 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim.meta new file mode 100644 index 0000000..dd87064 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnap2Animation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f14f007c89370af44b7e39032619b8dc +timeCreated: 1476936696 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller new file mode 100644 index 0000000..9812e4a Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller.meta new file mode 100644 index 0000000..01b5907 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkin.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdf0f3c49bb0a35409c240dadbe57fe0 +timeCreated: 1476949544 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim new file mode 100644 index 0000000..da1b6e4 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim.meta new file mode 100644 index 0000000..f7a2729 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSnufkinAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 051cca5984a41bb418d953714382b62e +timeCreated: 1476949544 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller new file mode 100644 index 0000000..db8a52e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller.meta new file mode 100644 index 0000000..819c43c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSphere.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c13ca1ff3eda6e94ca464be8b351d23e +timeCreated: 1477839802 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller new file mode 100644 index 0000000..bb57cb4 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller.meta new file mode 100644 index 0000000..4b4b56e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectile.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4381832d97e48b343ab2c1cc3d0d1cf9 +timeCreated: 1476924217 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim new file mode 100644 index 0000000..cf431f2 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim.meta new file mode 100644 index 0000000..00a8807 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGStarProjectileAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b161154b027eb8347bef0a765e6bb3dd +timeCreated: 1476924217 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller new file mode 100644 index 0000000..acf4a97 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller.meta new file mode 100644 index 0000000..ca8aa25 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSun.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ab0bd3e92df901142ae5b83904aadf63 +timeCreated: 1476800669 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim new file mode 100644 index 0000000..36c7b33 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim.meta new file mode 100644 index 0000000..5a8352b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGSunAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4cb7c4a1ee9b590498e6866202fe23ca +timeCreated: 1476800669 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim new file mode 100644 index 0000000..64a3400 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim.meta new file mode 100644 index 0000000..c502a16 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Animations/BGTreeAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dab27e7b63564f4419261a691368b852 +timeCreated: 1476838167 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity new file mode 100644 index 0000000..83a0f48 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity.meta new file mode 100644 index 0000000..d509900 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8800f51ec9c6b754a8df17b14a2c6ff3 +timeCreated: 1458400524 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity new file mode 100644 index 0000000..66c6cd9 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity.meta new file mode 100644 index 0000000..fa21037 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveDemo2.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9c119faa3d242b45ba786dfe2e3f8a8 +timeCreated: 1476650409 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity new file mode 100644 index 0000000..42a82be Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity.meta new file mode 100644 index 0000000..36545f5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveMainMenu.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f610a1fed574e58438e8d9d13506a00d +timeCreated: 1477522827 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity new file mode 100644 index 0000000..a27afde Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity.meta new file mode 100644 index 0000000..e802144 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCcChangeCursorLinear.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 033171da8db1994499ead13b8ec05dc0 +timeCreated: 1477542088 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity new file mode 100644 index 0000000..02c9992 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity.meta new file mode 100644 index 0000000..df7e1c3 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestClosestPoint.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce52d115c270eef42bc0891ccdb4d2e8 +timeCreated: 1476651640 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity new file mode 100644 index 0000000..b8965a5 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity.meta new file mode 100644 index 0000000..358202d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestComponents.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfc6f54abf0c59a44a0e227bba8eee52 +timeCreated: 1476650452 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity new file mode 100644 index 0000000..6d24a0e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity.meta new file mode 100644 index 0000000..34c7b27 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestCustomFields.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf8a28d06b5552f418492e2816f17f9a +timeCreated: 1477391785 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity new file mode 100644 index 0000000..a27c54d Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity.meta new file mode 100644 index 0000000..a7d2539 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestMath.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a340a876dfa92848aa868ed979eff31 +timeCreated: 1476651353 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity new file mode 100644 index 0000000..6ee0b2e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity.meta new file mode 100644 index 0000000..dba9355 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPerformance.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f95d49a695ede441b1dc953ab80ccea +timeCreated: 1476651781 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity new file mode 100644 index 0000000..670ff08 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity.meta new file mode 100644 index 0000000..18b34df --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsMode.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 73541577b3f697c44a11313a118a5cdf +timeCreated: 1477839477 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity new file mode 100644 index 0000000..59d7424 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity.meta new file mode 100644 index 0000000..1daa5b2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestPointsTransforms.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f9c252eb9b86c045abec185eeaf56cb +timeCreated: 1477962967 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity new file mode 100644 index 0000000..6edb574 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity.meta new file mode 100644 index 0000000..3c5c3ba --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntime.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2cc6fac9de9cc1c4198b9a986f2ced0e +timeCreated: 1476651544 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity new file mode 100644 index 0000000..a25a2c5 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity.meta new file mode 100644 index 0000000..9d296bf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestRuntimeCustomFields.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 069231f22cd3fdd4e80459175f290597 +timeCreated: 1480534258 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity new file mode 100644 index 0000000..fb50bb7 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity.meta new file mode 100644 index 0000000..d124b75 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/BGCurveTestSnapping.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e960b8306460399409434b1280f8c9b0 +timeCreated: 1476935558 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials.meta new file mode 100644 index 0000000..1dc76f6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dcbc0c43653154e41bc9880c9294d8b8 +folderAsset: yes +timeCreated: 1458645295 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png new file mode 100644 index 0000000..1ec06e9 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png.meta new file mode 100644 index 0000000..211c6f6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoard.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 3a4eefcafddd73142a4ceaefb345a49a +timeCreated: 1472808092 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat new file mode 100644 index 0000000..47e56e4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat @@ -0,0 +1,138 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: BGTestCheckerBoardMaterial + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 5 + m_CustomRenderQueue: -1 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 2800000, guid: 3a4eefcafddd73142a4ceaefb345a49a, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: _SrcBlend + second: 1 + data: + first: + name: _DstBlend + second: 0 + data: + first: + name: _Cutoff + second: 0.5 + data: + first: + name: _Parallax + second: 0.02 + data: + first: + name: _ZWrite + second: 1 + data: + first: + name: _Glossiness + second: 0.5 + data: + first: + name: _BumpScale + second: 1 + data: + first: + name: _OcclusionStrength + second: 1 + data: + first: + name: _DetailNormalMapScale + second: 1 + data: + first: + name: _UVSec + second: 0 + data: + first: + name: _Mode + second: 0 + data: + first: + name: _Metallic + second: 0 + m_Colors: + data: + first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat.meta new file mode 100644 index 0000000..a0c627f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestCheckerBoardMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f4894a38511664429af761d6a5d8e39 +timeCreated: 1476477684 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png new file mode 100644 index 0000000..ac6d3fc Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png.meta new file mode 100644 index 0000000..c6d8a1d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestGrass.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 1a1345ea99d095547b416fae47e2d9f1 +timeCreated: 1476824191 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat new file mode 100644 index 0000000..d25a84d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat @@ -0,0 +1,146 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: BGTestLineRenderer + m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 5 + m_CustomRenderQueue: 3000 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 0, y: 0.6278035} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: _SrcBlend + second: 1 + data: + first: + name: _DstBlend + second: 0 + data: + first: + name: _Cutoff + second: 0.5 + data: + first: + name: _Parallax + second: 0.02 + data: + first: + name: _ZWrite + second: 1 + data: + first: + name: _Glossiness + second: 0.5 + data: + first: + name: _BumpScale + second: 1 + data: + first: + name: _OcclusionStrength + second: 1 + data: + first: + name: _DetailNormalMapScale + second: 1 + data: + first: + name: _UVSec + second: 0 + data: + first: + name: _Mode + second: 0 + data: + first: + name: _Metallic + second: 0 + data: + first: + name: _InvFade + second: 1 + m_Colors: + data: + first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} + data: + first: + name: _TintColor + second: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0.5019608} diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat.meta new file mode 100644 index 0000000..f586724 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRenderer.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e1d1eae4a23f8294cb3213b2bccfba73 +timeCreated: 1458645316 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat new file mode 100644 index 0000000..a8d90bb Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat.meta new file mode 100644 index 0000000..eadccbd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ae3eb8adc3950cb4899d2a8dc3564602 +timeCreated: 1473155545 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat new file mode 100644 index 0000000..4540361 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat.meta new file mode 100644 index 0000000..9d52cb7 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestMoonMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0eee3b445c49c204badd4329bcefe33f +timeCreated: 1476798409 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat new file mode 100644 index 0000000..21996d1 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat.meta new file mode 100644 index 0000000..23cc949 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestSunMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30754a36b3e17624e9fb692f43141a77 +timeCreated: 1476671354 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat new file mode 100644 index 0000000..1b00d09 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat @@ -0,0 +1,147 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: BGTestTrailRenderer + m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _ALPHABLEND_ON + m_LightmapFlags: 5 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: _SrcBlend + second: 5 + data: + first: + name: _DstBlend + second: 10 + data: + first: + name: _Cutoff + second: 0.5 + data: + first: + name: _Parallax + second: 0.02 + data: + first: + name: _ZWrite + second: 0 + data: + first: + name: _Glossiness + second: 0.5 + data: + first: + name: _BumpScale + second: 1 + data: + first: + name: _OcclusionStrength + second: 1 + data: + first: + name: _DetailNormalMapScale + second: 1 + data: + first: + name: _UVSec + second: 0 + data: + first: + name: _Mode + second: 2 + data: + first: + name: _Metallic + second: 0 + data: + first: + name: _InvFade + second: 0.68 + m_Colors: + data: + first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} + data: + first: + name: _TintColor + second: {r: 1, g: 1, b: 1, a: 0.309} diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat.meta new file mode 100644 index 0000000..294ad4e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrailRenderer.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d35e47db85705e4685d4124921a2aee +timeCreated: 1472455730 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat new file mode 100644 index 0000000..4a92d7b Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat.meta new file mode 100644 index 0000000..c14939e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeLeafsMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f399b603419be14ba9bffcf786e93cd +timeCreated: 1476837719 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat new file mode 100644 index 0000000..99a5e26 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat.meta new file mode 100644 index 0000000..b409f3d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTreeTrunkMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f8b792cce88f944e987ce9c635c0b6e +timeCreated: 1476824693 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat new file mode 100644 index 0000000..f7ea09c Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat.meta new file mode 100644 index 0000000..ab8049d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8996621c7d91d01498be54470d647f3a +timeCreated: 1476825659 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png new file mode 100644 index 0000000..61f3c01 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png.meta new file mode 100644 index 0000000..d084214 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestTrunk.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 3bde5aacfe0a5e94684f114f910c4f69 +timeCreated: 1476825649 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts.meta new file mode 100644 index 0000000..2dbe228 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e6304e86eef112241a61fbb81e7bbcb1 +folderAsset: yes +timeCreated: 1458540160 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs new file mode 100644 index 0000000..837b338 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace BansheeGz.BGSpline.Example +{ + //camera movements + public class BGTestCamera : MonoBehaviour + { + private const int Speed = 100; + + private GUIStyle style; + + // Update is called once per frame + private void Update() + { + if (Input.GetKey(KeyCode.A)) transform.RotateAround(Vector3.zero, Vector3.up, Speed*Time.deltaTime); + else if (Input.GetKey(KeyCode.D)) transform.RotateAround(Vector3.zero, Vector3.up, -Speed*Time.deltaTime); + } + + private void OnGUI() + { + if (style == null) style = new GUIStyle(GUI.skin.label) {fontSize = 24}; + + GUILayout.BeginHorizontal(); + + GUILayout.Label("Use A and D to rotate camera", style); + + if (BGTestMainMenu.Inited && GUILayout.Button("To Main Menu")) SceneManager.LoadScene("BGCurveMainMenu"); + + GUILayout.EndHorizontal(); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs.meta new file mode 100644 index 0000000..8a18216 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCamera.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b39cc109801a26b4289d4bd8b6fc6b01 +timeCreated: 1471249888 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs new file mode 100644 index 0000000..bee5bc1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs @@ -0,0 +1,489 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + //testing BGCcCursorChangeLinear (this test is automated) + /* + * Abbreviations for GameObjects names + * F- Forward (speed positive) + * B- Backward (speed negative) + * Cycle- Cycle mode + * PP- PingPong mode + * Closed- closed curve + * Open- Not closed curve + * D0- delay at point 0 + * DL- delay at last point + * DA- delay at all points + * SF- speed field is present + * */ + + public class BGTestCcChangeCursorLinear : MonoBehaviour + { + private readonly List sequences = new List(10); + + // Use this for initialization + void Start() + { + var changeCursors = GetComponentsInChildren(true); + + // for this to work we need to rename curves +// Array.Sort(changeCursors, (o1, o2) => string.Compare(o1.gameObject.name, o2.gameObject.name)); + + for (var i = 0; i < changeCursors.Length; i++) Register(changeCursors[i]); + } + + private void Register(BGCcCursorChangeLinear curve) + { + sequences.Add(new Sequence(curve)); + } + + // Update is called once per frame + void Update() + { + foreach (var sequence in sequences) + if (sequence.Curve.gameObject.activeInHierarchy) + { + sequence.Check(); + } + } + + + // no luck here. There shoould be some way to pass curve's number and get rid of this? + /* + public void PointReached(int point, int curve) + { + Process(curve, point); + } + */ + + //Nigthmare start (idea.. we need to switch to non persistent events for this test, which send reference to a curve) + public void PointReached0(int point) + { + Process(0, point); + } + + public void PointReached1(int point) + { + Process(1, point); + } + + public void PointReached2(int point) + { + Process(2, point); + } + + public void PointReached3(int point) + { + Process(3, point); + } + + public void PointReached4(int point) + { + Process(4, point); + } + + public void PointReached5(int point) + { + Process(5, point); + } + + public void PointReached6(int point) + { + Process(6, point); + } + + public void PointReached7(int point) + { + Process(7, point); + } + + public void PointReached8(int point) + { + Process(8, point); + } + + public void PointReached9(int point) + { + Process(9, point); + } + + public void PointReached10(int point) + { + Process(10, point); + } + + public void PointReached11(int point) + { + Process(11, point); + } + + public void PointReached12(int point) + { + Process(12, point); + } + + public void PointReached13(int point) + { + Process(13, point); + } + + public void PointReached14(int point) + { + Process(14, point); + } + + public void PointReached15(int point) + { + Process(15, point); + } + + public void PointReached16(int point) + { + Process(16, point); + } + + public void PointReached17(int point) + { + Process(17, point); + } + + public void PointReached18(int point) + { + Process(18, point); + } + + public void PointReached19(int point) + { + Process(19, point); + } + + public void PointReached20(int point) + { + Process(20, point); + } + + public void PointReached21(int point) + { + Process(21, point); + } + + public void PointReached22(int point) + { + Process(22, point); + } + + public void PointReached23(int point) + { + Process(23, point); + } + + public void PointReached24(int point) + { + Process(24, point); + } + + public void PointReached25(int point) + { + Process(25, point); + } + + public void PointReached26(int point) + { + Process(26, point); + } + + public void PointReached27(int point) + { + Process(27, point); + } + + public void PointReached28(int point) + { + Process(28, point); + } + + public void PointReached29(int point) + { + Process(29, point); + } + + public void PointReached30(int point) + { + Process(30, point); + } + + public void PointReached31(int point) + { + Process(31, point); + } + + public void PointReached32(int point) + { + Process(32, point); + } + + + private void Process(int curve, int pointIndex) + { + var sequence = sequences[curve]; + if (!sequence.Curve.gameObject.activeSelf) return; + +// print("Reached {" + pointIndex + "} for curve =" + curve); + + sequence.Reached(pointIndex); + } + + private sealed class Sequence + { + //precision does not matter too much idea.. lower the value, something wrong here + public const float Epsilon = 0.1f; + + private readonly List expectedPoints = new List(); + private BGCcCursorChangeLinear changeCursor; + + private int pointCursor; + private bool valid = true; + private float lastPoint; + + private float started; + + public BGCurve Curve; + + + private float Elapsed + { + get { return Time.time - started; } + } + + public Sequence(BGCcCursorChangeLinear changeCursor) + { + this.changeCursor = changeCursor; + var cursor = changeCursor.Cursor; + var curve = changeCursor.Curve; + Curve = curve; + started = Time.time; + + + if (!Curve.gameObject.activeInHierarchy) return; + + ThrowIf("Stop overflow control is not supported", changeCursor.OverflowControl == BGCcCursorChangeLinear.OverflowControlEnum.Stop); + + + var pointsCount = curve.PointsCount; + ThrowIf("Curve should have at least 2 points.", pointsCount < 2); + + var math = changeCursor.Cursor.Math.Math; + + var sectionIndex = cursor.CalculateSectionIndex(); + var speed = changeCursor.CurrentSpeed; + var speedPositive = speed > 0; + + if (speedPositive) + { + //=================================== Positive speed + //first point + if (curve.Closed && sectionIndex == pointsCount - 1) + { + expectedPoints.Add(new ExpectedPoint(0, math.GetDistance() - cursor.Distance, speed, 0)); + } + else if (!curve.Closed && sectionIndex == pointsCount - 2) + { + expectedPoints.Add(new ExpectedPoint(pointsCount - 1, math.GetDistance() - cursor.Distance, speed, 0)); + } + else + { + expectedPoints.Add(new ExpectedPoint(sectionIndex + 1, math[sectionIndex + 1].DistanceFromStartToOrigin - cursor.Distance, speed, 0)); + } + + //go towards end + for (var i = sectionIndex + 2; i < pointsCount; i++) + { + expectedPoints.Add(new ExpectedPoint(i, math[i - 1].Distance, changeCursor.GetSpeedAtPoint(i - 1), changeCursor.GetDelayAtPoint(i - 1))); + } + + //add last point + if (curve.Closed && sectionIndex != pointsCount) + { + expectedPoints.Add(new ExpectedPoint(0, math[pointsCount - 1].Distance, changeCursor.GetSpeedAtPoint(pointsCount - 1), changeCursor.GetDelayAtPoint(pointsCount - 1))); + } + + + if (changeCursor.OverflowControl == BGCcCursorChangeLinear.OverflowControlEnum.PingPong) + { + if (curve.Closed) + expectedPoints.Add(new ExpectedPoint(pointsCount - 1, math[pointsCount - 1].Distance, + changeCursor.GetSpeedAtPoint(pointsCount - 1), changeCursor.GetDelayAtPoint(0))); + + //go all the way down + for (var i = pointsCount - 2; i >= 0; i--) + { + expectedPoints.Add(new ExpectedPoint(i, math[i].Distance, changeCursor.GetSpeedAtPoint(i), changeCursor.GetDelayAtPoint(i + 1))); + } + } + else + { + if (!curve.Closed) + { + expectedPoints.Add(new ExpectedPoint(0, math[pointsCount - 2].Distance, 0, changeCursor.GetDelayAtPoint(pointsCount - 1))); + } + } + + //go up to initial position + for (var i = 1; i <= sectionIndex; i++) + { + expectedPoints.Add(new ExpectedPoint(i, math[i - 1].Distance, changeCursor.GetSpeedAtPoint(i - 1), changeCursor.GetDelayAtPoint(i - 1))); + } + + //last point + expectedPoints.Add(new ExpectedPoint(-1, cursor.Distance - math[sectionIndex].DistanceFromStartToOrigin, speed, changeCursor.GetDelayAtPoint(sectionIndex))); + } + else + { + //=================================== Negative speed + //first point + expectedPoints.Add(new ExpectedPoint(sectionIndex, cursor.Distance - math[sectionIndex].DistanceFromStartToOrigin, speed, 0)); + + //go towards start + for (var i = sectionIndex - 1; i >= 0; i--) + { + expectedPoints.Add(new ExpectedPoint(i, math[i].Distance, changeCursor.GetSpeedAtPoint(i), changeCursor.GetDelayAtPoint(i + 1))); + } + + if (changeCursor.OverflowControl == BGCcCursorChangeLinear.OverflowControlEnum.PingPong) + { + for (var i = 1; i < pointsCount; i++) + { + expectedPoints.Add(new ExpectedPoint(i, math[i - 1].Distance, changeCursor.GetSpeedAtPoint(i - 1), changeCursor.GetDelayAtPoint(i - 1))); + } + + if (curve.Closed) + { + expectedPoints.Add(new ExpectedPoint(0, math[pointsCount - 1].Distance, changeCursor.GetSpeedAtPoint(pointsCount - 1), changeCursor.GetDelayAtPoint(pointsCount - 1))); + expectedPoints.Add(new ExpectedPoint(pointsCount - 1, math[pointsCount - 1].Distance, + changeCursor.GetSpeedAtPoint(pointsCount - 1), changeCursor.GetDelayAtPoint(0))); + } + } + else + { + if (curve.Closed) + { + expectedPoints.Add(new ExpectedPoint(pointsCount - 1, math[pointsCount - 1].Distance, + changeCursor.GetSpeedAtPoint(pointsCount - 1), changeCursor.GetDelayAtPoint(0))); + } + else + { + expectedPoints.Add(new ExpectedPoint(pointsCount - 1, 0, 0, changeCursor.GetDelayAtPoint(0))); + } + } + + + //go from end to initial section + for (var i = pointsCount - 2; i > sectionIndex; i--) + { + expectedPoints.Add(new ExpectedPoint(i, math[i].Distance, changeCursor.GetSpeedAtPoint(i), changeCursor.GetDelayAtPoint(i + 1))); + } + + //last point + expectedPoints.Add(new ExpectedPoint(-1, math[sectionIndex].DistanceFromEndToOrigin - cursor.Distance, changeCursor.GetSpeedAtPoint(sectionIndex), + changeCursor.GetDelayAtPoint(sectionIndex + 1))); + } + } + + private void ThrowIf(string message, bool condition) + { + if (condition) throw GetException(message); + } + + private UnityException GetException(string message) + { + return new UnityException(message + ". Curve=" + changeCursor.Curve.gameObject.name); + } + + public void Check() + { + if (!valid) return; + + var toCheck = expectedPoints[pointCursor]; + + if (toCheck.PointIndex == -1) + { + if (toCheck.ExpectedDelay < Elapsed) + { + MoveNext(); + } + } + else if (toCheck.ExpectedDelay < Elapsed - Epsilon) + { + valid = false; + Debug.LogException(GetException("Missing event: expected " + toCheck + " event did not occur")); + return; + } + } + + public void Reached(int point) + { + if (!valid) return; + + var toCompare = expectedPoints[pointCursor]; + if (toCompare.PointIndex >= 0 && toCompare.PointIndex != point) + { + valid = false; + Debug.LogException(GetException("Points indexes mismatch: expected " + toCompare.PointIndex + ", actual=" + point)); + return; + } + + var expectedDelay = toCompare.ExpectedDelay; + var actualDelay = Elapsed; + if (Math.Abs(expectedDelay - actualDelay) > Epsilon) + { + valid = false; + Debug.LogException(GetException("Timing mismatch at point {" + toCompare.PointIndex + "}: expected " + expectedDelay + ", actual=" + actualDelay)); + return; + } + + MoveNext(); + } + + private void MoveNext() + { + started = Time.time; + pointCursor = pointCursor == expectedPoints.Count - 1 ? 0 : pointCursor + 1; + } + } + + private sealed class ExpectedPoint + { + public readonly float Distance; + public readonly int PointIndex; + public readonly float Speed; + public readonly float Delay; + + public ExpectedPoint(int pointIndex, float distance, float speed, float delay) + { + Speed = speed; + Distance = distance; + PointIndex = pointIndex; + Delay = delay; + } + + public double ExpectedDelay + { + get + { + var speed = Math.Abs(Speed); + var delay = Mathf.Clamp(Delay, 0, float.MaxValue); + return delay + (speed < Sequence.Epsilon ? Sequence.Epsilon : Distance/speed); + } + } + + public override string ToString() + { + return "Point " + PointIndex + " after " + ExpectedDelay + " delay."; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs.meta new file mode 100644 index 0000000..15e7260 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCcChangeCursorLinear.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9ae216fc3e845094f987bb267515c24f +timeCreated: 1477542371 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs new file mode 100644 index 0000000..1699a5c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs @@ -0,0 +1,32 @@ +using UnityEngine; + +namespace BansheeGz.BGSpline.Example +{ + // rotate and scale an object + public class BGTestCurveChange : MonoBehaviour + { + private const float RotationSpeed = 40; + private const float ScaleUpperLimit = 1.25f; + private const float ScaleLowerLimit = .5f; + + private Vector3 scaleSpeed = Vector3.one*.1f; + + // Update is called once per frame + private void Update() + { + //rotate + transform.RotateAround(transform.position, Vector3.up, RotationSpeed*Time.deltaTime); + + //scale + var localScale = transform.localScale; + var upperLimit = localScale.x > ScaleUpperLimit; + var lowerLimit = localScale.x < ScaleLowerLimit; + if (upperLimit || lowerLimit) + { + scaleSpeed = -scaleSpeed; + localScale = upperLimit ? new Vector3(ScaleUpperLimit, ScaleUpperLimit, ScaleUpperLimit) : new Vector3(ScaleLowerLimit, ScaleLowerLimit, ScaleLowerLimit); + } + transform.localScale = localScale + scaleSpeed*Time.deltaTime; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs.meta new file mode 100644 index 0000000..e93daf2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveChange.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 878d4ca641b7844418bd302124244337 +timeCreated: 1474194271 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs new file mode 100644 index 0000000..92fbfdc --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs @@ -0,0 +1,321 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using Random = UnityEngine.Random; + +namespace BansheeGz.BGSpline.Example +{ + //check math's CalcPositionByClosestPoint method. (this test can be automated with CheckResults set to true) + public class BGTestCurveClosestPoint : MonoBehaviour + { + [Tooltip("Line renderer material")] public Material LineRendererMaterial; + + [Tooltip("Object to use for point's indication")] public GameObject PointIndicator; + + [Range(1, 100)] [Tooltip("How much points to use with search")] public int NumberOfPointsToSeek = 10; + + [Range(2, 100)] [Tooltip("How much points to add to the curve")] public int NumberOfCurvePoints = 100; + + [Range(1, 30)] [Tooltip("How much sections to use for splitting each curve's segment")] public int NumberOfSplits = 30; + + [Range(1, 5)] [Tooltip("Transition period")] public int Period = 4; + + [Tooltip("Use slow check method to validate results")] public bool CheckResults = false; + + + private BGCurve curve; + private BGCcMath math; + + //this is an area, defined by camera frustum (so we could see curve and points) + private static Vector3 min = new Vector3(-10, 0, -2); + private static Vector3 max = new Vector3(10, 10, 2); + + + //indicator objects + private GameObject[] objects; + + //curve's points positions + private Vector3[] oldCurvePointPos; + private Vector3[] newCurvePointPos; + + //point's positions + private Vector3[] oldPointPos; + private Vector3[] newPointPos; + + //for transitions + private float startTime = -100000; + + private int ErrorPointIndex = -1; + private GUIStyle style; + + private bool HasError + { + get { return ErrorPointIndex >= 0; } + } + + // Use this for initialization + private void Start() + { + //init components + curve = gameObject.AddComponent(); + curve.Closed = true; + math = gameObject.AddComponent(); + gameObject.AddComponent(); + var lineRenderer = gameObject.GetComponent(); + lineRenderer.sharedMaterial = LineRendererMaterial; + var color = new Color(.2f, .2f, .2f, 1f); +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.startWidth = lineRenderer.endWidth = .03f; + lineRenderer.startColor = lineRenderer.endColor = color; +#else + lineRenderer.SetWidth(.03f, .03f); + lineRenderer.SetColors(color, color); +#endif + math.SectionParts = NumberOfSplits; + + //create curve's points + for (var i = 0; i < NumberOfCurvePoints; i++) + { + var controlRandom = Random.Range(0, 3); + var controlType = BGCurvePoint.ControlTypeEnum.Absent; + switch (controlRandom) + { + case 1: + controlType = BGCurvePoint.ControlTypeEnum.BezierIndependant; + break; + case 2: + controlType = BGCurvePoint.ControlTypeEnum.BezierSymmetrical; + break; + } + curve.AddPoint(new BGCurvePoint(curve, + Vector3.zero, + controlType, + RandomVector()*.3f, + RandomVector()*.3f)); + } + + //init arrays + oldPointPos = new Vector3[NumberOfPointsToSeek]; + newPointPos = new Vector3[NumberOfPointsToSeek]; + oldCurvePointPos = new Vector3[NumberOfCurvePoints]; + newCurvePointPos = new Vector3[NumberOfCurvePoints]; + + InitArray(newCurvePointPos, oldCurvePointPos); + InitArray(newPointPos, oldPointPos); + + //create objects + objects = new GameObject[NumberOfPointsToSeek]; + for (var i = 0; i < NumberOfPointsToSeek; i++) + { + var clone = Instantiate(PointIndicator); + clone.transform.parent = transform; + objects[i] = clone; + } + PointIndicator.SetActive(false); + + //init cycle + InitCycle(); + } + + private void OnGUI() + { + if (style == null) style = new GUIStyle(GUI.skin.label) {fontSize = 20}; + GUI.Label(new Rect(0, 30, 600, 30), "Turn on Gizmos to see Debug lines", style); + } + + + private void InitCycle() + { + InitArray(oldCurvePointPos, newCurvePointPos); + InitArray(oldPointPos, newPointPos); + } + + // Update is called once per frame + private void Update() + { + if (HasError) + { + //use it for debugging + Process(ErrorPointIndex, true); + } + else + { + Calculate(null, null); + + + var elapsed = Time.time - startTime; + if (elapsed > Period) + { + startTime = Time.time; + InitCycle(); + elapsed = 0; + } + + //lerp + var ratio = elapsed/Period; + for (var i = 0; i < NumberOfCurvePoints; i++) + { + curve[i].PositionLocal = Vector3.Lerp(oldCurvePointPos[i], newCurvePointPos[i], ratio); + } + for (var i = 0; i < NumberOfPointsToSeek; i++) + { + objects[i].transform.localPosition = Vector3.Lerp(oldPointPos[i], newPointPos[i], ratio); + } + } + } + + + private void Calculate(object sender, EventArgs e) + { + for (var i = 0; i < NumberOfPointsToSeek; i++) + { + Process(i); + if (HasError) break; + } + } + + private void Process(int i, bool suppressWarning = false) + { + var point = objects[i].transform.position; + float distanceUsingMath; + var posUsingMath = math.CalcPositionByClosestPoint(point, out distanceUsingMath); + + Debug.DrawLine(point, posUsingMath, Color.yellow); + + if (!CheckResults) return; + + float distanceUsingCheckMethod; + var posUsingCheckMethod = CalcPositionByClosestPoint(math, point, out distanceUsingCheckMethod); + Debug.DrawLine(point, posUsingCheckMethod, Color.blue); + + var distanceCheck = Math.Abs(distanceUsingMath - distanceUsingCheckMethod) > .01f; + var pointCheck = Vector3.Magnitude(posUsingMath - posUsingCheckMethod) > 0.001f; + if ((distanceCheck || pointCheck) && Mathf.Abs((point - posUsingMath).magnitude - (point - posUsingCheckMethod).magnitude) > BGCurve.Epsilon) + { + ErrorPointIndex = i; + if (!suppressWarning) + { + Debug.Log("Error detected. Simulation stopped, but erroneous iteration's still running. Use debugger to debug the issue."); + Debug.Log("!!! Discrepancy detected while calculating pos by closest point: 1) [Using math] pos=" + posUsingMath + ", distance=" + distanceUsingMath + + " 2) [Using check method] pos=" + posUsingCheckMethod + ", distance=" + distanceUsingCheckMethod); + + + if (pointCheck) + { + Debug.Log("Reason: Result points varies more than " + BGCurve.Epsilon + ". Difference=" + Vector3.Magnitude(posUsingMath - posUsingCheckMethod)); + } + if (distanceCheck) + { + Debug.Log("Reason: Distances varies more than 1cm. Difference=" + Math.Abs(distanceUsingMath - distanceUsingCheckMethod)); + } + + var mathPos = math.CalcByDistance(BGCurveBaseMath.Field.Position, distanceUsingMath); + var checkMethodPos = math.CalcByDistance(BGCurveBaseMath.Field.Position, distanceUsingCheckMethod); + Debug.Log("Distance check: 1) [Using math] check=" + (Vector3.SqrMagnitude(mathPos - posUsingMath) < BGCurve.Epsilon ? "passed" : "failed") + + " 2) [Using check method] check=" + (Vector3.SqrMagnitude(checkMethodPos - posUsingCheckMethod) < BGCurve.Epsilon ? "passed" : "failed")); + + + var actualDistUsingMath = Vector3.Distance(point, posUsingMath); + var actualDistanceUsingCheckMethod = Vector3.Distance(point, posUsingCheckMethod); + Debug.Log("Actual distance: 1) [Using math] Dist=" + actualDistUsingMath + + " 2) [Using check method] Dist=" + actualDistanceUsingCheckMethod + + + (Math.Abs(actualDistUsingMath - actualDistanceUsingCheckMethod) > BGCurve.Epsilon + ? (". And the winner is " + (actualDistUsingMath < actualDistanceUsingCheckMethod ? "math" : "check method")) + : "")); + } + } + } + + //Bruteforce method for checking results only. Do not use it. + private static Vector3 CalcPositionByClosestPoint(BGCcMath math, Vector3 targetPoint, out float distance) + { + var sections = math.Math.SectionInfos; + var sectionsCount = sections.Count; + var result = sections[0][0].Position; + var minDistance = Vector3.SqrMagnitude(sections[0][0].Position - targetPoint); + distance = 0; + for (var i = 0; i < sectionsCount; i++) + { + var currentSection = sections[i]; + + + var points = currentSection.Points; + var pointsCount = points.Count; + for (var j = 1; j < pointsCount; j++) + { + var point = points[j]; + float ratio; + + var closestPoint = CalcClosestPointToLine(points[j - 1].Position, point.Position, targetPoint, out ratio); + + var sqrMagnitude = Vector3.SqrMagnitude(targetPoint - closestPoint); + if (!(minDistance > sqrMagnitude)) continue; + + + minDistance = sqrMagnitude; + result = closestPoint; + + if (ratio == 1) + { + var sectionIndex = i; + var pointIndex = j; + if (j == pointsCount - 1 && i < sectionsCount - 1) + { + sectionIndex = i + 1; + pointIndex = 0; + } + distance = sections[sectionIndex].DistanceFromStartToOrigin + sections[sectionIndex][pointIndex].DistanceToSectionStart; + } + else + { + distance = sections[i].DistanceFromStartToOrigin + Mathf.Lerp(currentSection[j - 1].DistanceToSectionStart, point.DistanceToSectionStart, ratio); + } + } + } + return result; + } + + + private static Vector3 RandomVector() + { + return new Vector3(Random.Range(min.x, max.x), Random.Range(min.y, max.y), Random.Range(min.z, max.z)); + } + + private static void InitArray(Vector3[] oldArray, Vector3[] newArray) + { + for (var i = 0; i < oldArray.Length; i++) + { + oldArray[i] = newArray[i]; + newArray[i] = RandomVector(); + } + } + + private static Vector3 CalcClosestPointToLine(Vector3 a, Vector3 b, Vector3 p, out float ratio) + { + var ap = p - a; + var ab = b - a; + var sqrtMagnitude = ab.sqrMagnitude; + if (Math.Abs(sqrtMagnitude) < BGCurve.Epsilon) + { + ratio = 1; + return b; + } + + var distance = Vector3.Dot(ap, ab)/sqrtMagnitude; + if (distance < 0) + { + ratio = 0; + return a; + } + if (distance > 1) + { + ratio = 1; + return b; + } + ratio = distance; + return a + ab*distance; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs.meta new file mode 100644 index 0000000..9639075 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveClosestPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e541fe02faf348f4a82165f3484dbb8c +timeCreated: 1474039391 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs new file mode 100644 index 0000000..d7381c1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs @@ -0,0 +1,77 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + // This is old obsolete example class, left for compatibility only. + // DO NOT USE IT AS AN EXAMPLE PLEASE + // Use Cc components (BGCurveBaseMath -> BGCcMath, LineRenderer -> BGCcVisualizationLineRenderer) + [RequireComponent(typeof (BGCurve))] + [RequireComponent(typeof (LineRenderer))] + public class BGTestCurveDynamic : MonoBehaviour + { + private const int TimeToMoveUp = 3; + + public GameObject ObjectToMove; + + private BGCurve curve; + private BGCurveBaseMath curveBaseMath; + + private float started; + private float ratio; + private LineRenderer lineRenderer; + + + // Use this for initialization + private void Start() + { + curve = GetComponent(); +// curve.TraceChanges = true; + + lineRenderer = GetComponent(); + +// curveBaseMath = new BGCurveBaseMath(curve, true); + curveBaseMath = new BGCurveBaseMath(curve); + started = Time.time; + + ResetLineRenderer(); + curve.Changed += (sender, args) => ResetLineRenderer(); + } + + private void ResetLineRenderer() + { + const int points = 50; + + var positions = new Vector3[points]; + for (var i = 0; i < points; i++) + { + positions[i] = curveBaseMath.CalcPositionByDistanceRatio(((float) i/(points - 1))); + } + +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = points; +#else + lineRenderer.SetVertexCount(points); +#endif + + lineRenderer.SetPositions(positions); + } + + // Update is called once per frame + private void Update() + { + transform.RotateAround(Vector3.zero, Vector3.up, 40*Time.deltaTime); + + ratio = (Time.time - started)/TimeToMoveUp; + if (ratio >= 1) + { + started = Time.time; + ratio = 0; + } + else + { + ObjectToMove.transform.position = curveBaseMath.CalcPositionByDistanceRatio(ratio); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs.meta new file mode 100644 index 0000000..6ca7b9a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveDynamic.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 14e1aa9c8356b444eb28ff9fadb1e98e +timeCreated: 1473297298 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs new file mode 100644 index 0000000..4b0314a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs @@ -0,0 +1,324 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using BansheeGz.BGSpline.Curve; +using Random = UnityEngine.Random; + +namespace BansheeGz.BGSpline.Example +{ + // math visual testing (for internal use) + public class BGTestCurveMath : MonoBehaviour + { + [Tooltip("Material to use with LineRenderer")] public Material LineRendererMaterial; + + [Tooltip("Object to move along a curve")] public MeshRenderer ObjectToMove; + + private const float Period = 3; + private const int ObjectsCount = 4; + private const float ObjectsSpeed = .3f; + + private TestCurves testCurves; + + private GUIStyle style; + + // Use this for initialization + private void Start() + { + testCurves = new TestCurves(GetComponent(), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent), ObjectToMove, LineRendererMaterial); + + //Base, OptimizeStraightLines + testCurves.Add(new CurveData(testCurves, "BGBaseStraightLines", "Base, OptimizeStraightLines = true", transform.position + new Vector3(-4, 1), + new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) {OptimizeStraightLines = true}, CurveData.MathTypeEnum.Base)); + + //Base, UsePointPositionsToCalcTangents + testCurves.Add(new CurveData(testCurves, "BGBasePos2Tangents", "Base, UsePointPositionsToCalcTangents = true", transform.position + new Vector3(-4, 4), + new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) {UsePointPositionsToCalcTangents = true}, CurveData.MathTypeEnum.Base)); + + //Adaptive + testCurves.Add(new CurveData(testCurves, "BGAdaptive", "Adaptive", transform.position + new Vector3(4, 4), + new BGCurveAdaptiveMath.ConfigAdaptive(BGCurveBaseMath.Fields.PositionAndTangent) /* { Tolerance = .2f }*/, CurveData.MathTypeEnum.Adaptive)); + + //Formula + testCurves.Add(new CurveData(testCurves, "BGFormula", "Formula", transform.position + new Vector3(4, 1), + new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent), CurveData.MathTypeEnum.Formula)); + } + + + // Update is called once per frame + private void Update() + { + testCurves.Update(); + if (Input.GetKeyDown(KeyCode.LeftArrow)) testCurves.MoveLeft(); + if (Input.GetKeyDown(KeyCode.RightArrow)) testCurves.MoveRight(); + } + + private void OnGUI() + { + if (style == null) style = new GUIStyle(GUI.skin.label) {fontSize = 18}; + GUI.Label(new Rect(0, 24, 800, 30), "Left Arrow - move left, Right Arrow - move right", style); + GUI.Label(new Rect(0, 48, 800, 30), "Comparing with: " + testCurves.CurrentToString(), style); + } + + + //==================================== abstract curve's data + private abstract class CurveDataAbstract + { + private readonly List objectsToMove = new List(); + private readonly Material objectToMoveMaterial; + private readonly LineRenderer lineRenderer; + public readonly Material LineRendererMaterial; + protected readonly GameObject GameObject; + + protected BGCurveBaseMath Math; + + private BGCurve curve; + + public BGCurve Curve + { + get { return curve; } + protected set + { + curve = value; + curve.Changed += (sender, args) => UpdateLineRenderer(); + } + } + + + protected CurveDataAbstract(GameObject gameObject, Material lineRendererMaterial, Color color) + { + GameObject = gameObject; + LineRendererMaterial = lineRendererMaterial; + + //change material + objectToMoveMaterial = Instantiate(lineRendererMaterial); + objectToMoveMaterial.SetColor("_TintColor", color); + + + //add lineRenderer + lineRenderer = gameObject.AddComponent(); + lineRenderer.material = lineRendererMaterial; +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.startWidth = lineRenderer.endWidth = 0.05f; + lineRenderer.startColor = lineRenderer.endColor = color; +#else + lineRenderer.SetWidth(0.05f, 0.05f); + lineRenderer.SetColors(color, color); +#endif + + } + + //=================== line renderer + private void UpdateLineRenderer() + { + const int count = 100; + var positions = new Vector3[100]; + const float countMinusOne = count - 1; + for (var i = 0; i < 100; i++) + { + var distanceRatio = i/countMinusOne; + positions[i] = Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, distanceRatio); + } +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = count; +#else + lineRenderer.SetVertexCount(count); +#endif + lineRenderer.SetPositions(positions); + } + + //=================== objects + protected void AddObjects(int count, MeshRenderer pattern, Transform parent) + { + for (var i = 0; i < count; i++) + { + var clone = Instantiate(pattern.gameObject); + clone.transform.parent = parent; + AddObject(clone); + } + } + + protected void AddObject(GameObject obj) + { + obj.GetComponent().sharedMaterial = objectToMoveMaterial; + objectsToMove.Add(obj.gameObject); + } + + protected void UpdateObjects(List distanceRatios) + { + for (var i = 0; i < objectsToMove.Count; i++) + { + var position = Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, distanceRatios[i]); + var tangent = Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Tangent, distanceRatios[i]); + + objectsToMove[i].transform.position = position; + objectsToMove[i].transform.LookAt(position + tangent); + } + } + + public abstract void Update(); + } + + //==================================== Reference Curve + private sealed class TestCurves : CurveDataAbstract + { + public readonly List DistanceRatios = new List(); + public readonly MeshRenderer ObjectToMove; + private readonly List curves = new List(); + + private float startTime = -Period*2; + private Quaternion fromRotation; + private Quaternion toRotation; + private int currentCurveIndex = -1; + + + public TestCurves(BGCurve curve, BGCurveBaseMath.Config config, MeshRenderer objectToMove, Material lineRendererMaterial) + : base(curve.gameObject, lineRendererMaterial, Color.green) + { + Curve = curve; + Math = new BGCurveBaseMath(curve, config); + ObjectToMove = objectToMove; + + AddObject(objectToMove.gameObject); + AddObjects(ObjectsCount - 1, objectToMove, curve.transform); + + const float offset = 1/(float) ObjectsCount; + for (var i = 0; i < ObjectsCount; i++) DistanceRatios.Add(i*offset); + } + + public void MoveRight() + { + currentCurveIndex++; + if (currentCurveIndex == curves.Count) currentCurveIndex = 0; + } + + public void MoveLeft() + { + currentCurveIndex--; + if (currentCurveIndex < 0) currentCurveIndex = curves.Count - 1; + } + + public override void Update() + { + if (Time.time - startTime > Period) + { + startTime = Time.time; + + fromRotation = Curve.transform.rotation; + toRotation = Quaternion.Euler(Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f)); + } + + var ratio = (Time.time - startTime)/Period; + Curve.transform.rotation = Quaternion.Lerp(fromRotation, toRotation, ratio); + for (var i = 0; i < DistanceRatios.Count; i++) + { + DistanceRatios[i] += ObjectsSpeed*Time.deltaTime; + if (DistanceRatios[i] > 1) DistanceRatios[i] = 0; + } + UpdateObjects(DistanceRatios); + + foreach (var data in curves) data.Update(); + } + + public bool IsCurrent(CurveData curve) + { + return currentCurveIndex >= 0 && currentCurveIndex < curves.Count && curves[currentCurveIndex] == curve; + } + + public void Add(CurveData curveData) + { + curves.Add(curveData); + } + + public string CurrentToString() + { + return currentCurveIndex < 0 ? "None" : curves[currentCurveIndex].Description; + } + } + + //==================================== Some Curve + private sealed class CurveData : CurveDataAbstract + { + public enum MathTypeEnum + { + Base, + Formula, + Adaptive + } + + private readonly Vector3 origin; + private readonly TestCurves testCurves; + private readonly Vector3 originalScale = new Vector3(.7f, .7f, .7f); + + private readonly string description; + + public string Description + { + get { return description; } + } + + public CurveData(TestCurves testCurves, string name, string description, Vector3 position, BGCurveBaseMath.Config config, MathTypeEnum mathType) + : base(new GameObject(name), testCurves.LineRendererMaterial, Color.magenta) + { + this.testCurves = testCurves; + this.description = description; + + //game object + GameObject.transform.position = position; + origin = position; + + //curve + Curve = GameObject.AddComponent(); + Curve.Closed = testCurves.Curve.Closed; + + //add points + for (var i = 0; i < testCurves.Curve.PointsCount; i++) + { + var point = testCurves.Curve[i]; + var clonePoint = new BGCurvePoint(Curve, point.PositionLocal, point.ControlType, point.ControlFirstLocal, point.ControlSecondLocal); + Curve.AddPoint(clonePoint); + } + + //init math after points are added + switch (mathType) + { + case MathTypeEnum.Base: + Math = new BGCurveBaseMath(Curve, config); + break; + case MathTypeEnum.Formula: +#pragma warning disable 0618 + Math = new BGCurveFormulaMath(Curve, config); +#pragma warning restore 0618 + + break; + case MathTypeEnum.Adaptive: + Math = new BGCurveAdaptiveMath(Curve, (BGCurveAdaptiveMath.ConfigAdaptive) config); + break; + default: + throw new ArgumentOutOfRangeException("mathType", mathType, null); + } + + AddObjects(ObjectsCount, testCurves.ObjectToMove, GameObject.transform); + + //scale down + GameObject.transform.localScale = originalScale; + } + + public override void Update() + { + var curveTransform = Curve.gameObject.transform; + + var referenceTransform = testCurves.Curve.transform; + + curveTransform.rotation = referenceTransform.rotation; + + var moveTime = 10*Time.deltaTime; + + var current = testCurves.IsCurrent(this); + curveTransform.position = Vector3.MoveTowards(curveTransform.position, current ? referenceTransform.position : origin, moveTime); + curveTransform.localScale = Vector3.MoveTowards(curveTransform.localScale, current ? referenceTransform.transform.localScale : originalScale, moveTime/4); + + UpdateObjects(testCurves.DistanceRatios); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs.meta new file mode 100644 index 0000000..45eeaa0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f583c3c12fc27e84e93751f76bb81bc5 +timeCreated: 1471388845 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs new file mode 100644 index 0000000..638651c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs @@ -0,0 +1,120 @@ +using BansheeGz.BGSpline.Components; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + // test class for example only (adding moving deleting points at runtime) + [RequireComponent(typeof (BGCcMath))] + public class BGTestCurveRuntime : MonoBehaviour + { + // the height between 2 points + private const float OneTierHeight = 2; + //number of points to add (so total is 9). Should be even. + private const int PointsCountToAdd = 8; + //point's move time + private const float PointMoveTime = 1.5f; + //spread for control points + private const int MaximumControlSpread = 4; + + + public GameObject ObjectToMove; + + private BGCurve curve; + + private BGCcMath math; + + // section spawn start time + private float started; + + // current point's pointer (index) + private int counter; + // position for new point. The point will be moved slowly towards it. + private Vector3 nextPosition; + // position for new point's 1st control + private Vector3 nextControl1; + // position for previous point's 2nd control. + private Vector3 nextControl2; + + // Use this for initialization + private void Start() + { + curve = GetComponent(); + math = GetComponent(); + Reset(); + } + + //new cycle + private void Reset() + { + //delete all points (use curve.Delete to remove a single point) + curve.Clear(); + + //add very first point + curve.AddPoint(new BGCurvePoint(curve, Vector3.zero) {ControlType = BGCurvePoint.ControlTypeEnum.BezierIndependant}); + + started = Time.time; + counter = 0; + } + + // Update is called once per frame + private void Update() + { + var elapsed = Time.time - started; + + if (elapsed >= PointMoveTime || curve.PointsCount < 2) + { + if (counter == PointsCountToAdd) + { + //=========================================== Reset (end of cycle) + Reset(); + } + else + { + //=========================================== New point spawning + //spawn new point at the same position as the last one + var position = curve[curve.PointsCount - 1].PositionLocal; + curve.AddPoint(new BGCurvePoint(curve, position) + { + ControlType = BGCurvePoint.ControlTypeEnum.BezierIndependant, + //unfortunately by default ControlFirstLocal and ControlSecondLocal are not equal to Vector3.zero. That was a mistake. + ControlFirstLocal = Vector3.zero, + ControlSecondLocal = Vector3.zero + }); + + // are we going up or down + var up = counter < (PointsCountToAdd >> 1); + + //assign next positions to drag a point (and controls) to + nextPosition = position + new Vector3(0, up ? OneTierHeight : -OneTierHeight, 0); + var controlPosition = new Vector3( + Random.Range(-MaximumControlSpread, MaximumControlSpread), + (up ? OneTierHeight : -OneTierHeight)*.5f, + Random.Range(-MaximumControlSpread, MaximumControlSpread)); + nextControl1 = Vector3.Lerp(position - nextPosition, controlPosition, .8f); + nextControl2 = Vector3.Lerp(nextPosition - position, controlPosition, .8f); + started = Time.time; + + counter++; + if (curve.PointsCount > 2) curve.Delete(0); + } + } + else + { + var ratio = elapsed/PointMoveTime; + //=========================================== Moving a current point (and adjacent controls) slowly to their future positions + // changing curve's attributes, like point's positions or controls fires curve.Changed event (in curve's LateUpdate) + // math object uses this event to recalculate it's cached data (and it's relatively expensive operation). + // we also use this event to call UpdateLineRenderer to update UI. + var lastPoint = curve[curve.PointsCount - 1]; + lastPoint.PositionLocal = Vector3.Lerp(lastPoint.PositionLocal, nextPosition, ratio); + lastPoint.ControlFirstLocal = Vector3.Lerp(lastPoint.PositionLocal, nextControl1, ratio); + lastPoint.ControlFirstLocal = Vector3.Lerp(lastPoint.PositionLocal, nextControl2, ratio); + + // move particles. we can use math's cached data directly, if we want to + var section = math.Math[0]; + ObjectToMove.transform.position = math.Math.CalcByDistance(BGCurveBaseMath.Field.Position, section.DistanceFromStartToOrigin + section.Distance*ratio); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs.meta new file mode 100644 index 0000000..8c4dbc9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntime.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4b89742ecd879a046849644e458dc278 +timeCreated: 1471249888 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs new file mode 100644 index 0000000..0032cba --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs @@ -0,0 +1,65 @@ +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using UnityEngine; + +namespace BansheeGz.BGSpline.Example +{ + // Testing creating custom fields from scratch at runtime + public class BGTestCurveRuntimeCustomFields : MonoBehaviour + { + private const string SpeedFieldName = "speed"; + private const string DelayFieldName = "delay"; + private const float Width = .02f; + + + public Transform ObjectToMove; + public Material LineRendererMaterial; + + // Use this for initialization + void Start() + { + //move object + var translateObject = gameObject.AddComponent(); + translateObject.ObjectToManipulate = ObjectToMove; + + //move cursor + var changeCursor = gameObject.AddComponent(); + + //add line renderer + gameObject.AddComponent(); + var lineRenderer = gameObject.GetComponent(); + lineRenderer.sharedMaterial = LineRendererMaterial; +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.startWidth = lineRenderer.endWidth = Width; +#else + lineRenderer.SetWidth(Width, Width); +#endif + + //set up curve + var curve = changeCursor.Curve; + curve.Closed = true; + curve.Mode2D = BGCurve.Mode2DEnum.XY; + curve.PointsMode = BGCurve.PointsModeEnum.GameObjectsTransform; + + //add points + curve.AddPoint(new BGCurvePoint(curve, new Vector2(-5, 0))); + curve.AddPoint(new BGCurvePoint(curve, new Vector2(0, 5), BGCurvePoint.ControlTypeEnum.BezierSymmetrical, new Vector2(-5, 0), new Vector2(5, 0))); + curve.AddPoint(new BGCurvePoint(curve, new Vector2(5, 0))); + + //setup custom fields + //---speed + changeCursor.SpeedField = NewFloatField(changeCursor, SpeedFieldName, 5, 10, 15); + //---delay + changeCursor.DelayField = NewFloatField(changeCursor, DelayFieldName, 3, 1, 2); + } + + //Add field with values + private static BGCurvePointField NewFloatField(BGCcCursorChangeLinear changeCursor, string fieldName, params float[] values) + { + var curve = changeCursor.Curve; + var field = curve.AddField(fieldName, BGCurvePointField.TypeEnum.Float); + for (var i = 0; i < values.Length; i++) curve[i].SetFloat(fieldName, values[i]); + return field; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs.meta new file mode 100644 index 0000000..8bdee64 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveRuntimeCustomFields.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 69984b3a12156f746b3c5b5c83d103c6 +timeCreated: 1480534479 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs new file mode 100644 index 0000000..55f13fe --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs @@ -0,0 +1,416 @@ +using UnityEngine; +using System.Collections.Generic; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + //for 1.1 version Demo scene + public class BGTestCurveShowcase : MonoBehaviour + { + [Header("Light")] public Light Light; + + [Header("Logo parts")] public BGCcCursorObjectTranslate B; + public BGCcCursorObjectTranslate G; + public BGCcMath Curve; + + [Header("Projectiles")] public GameObject ProjectileFolder; + public TrailRenderer Projectile1; + public TrailRenderer Projectile2; + public BGCcCursor ProjectileCurve1; + + [Header("Particles")] public ParticleSystem BParticles; + public ParticleSystem GParticles; + public ParticleSystem CurveParticles1; + public ParticleSystem CurveParticles2; + + //============== dynamic + [Header("Dynamic")] public GameObject DynamicCurve; + public Light Light1; + public Light Light2; + public Light Light3; + + //============== some useless stuff + private readonly List effects = new List(); + + + //============== misc + private const float ScaleMin = 0.85f; + private const float ScaleMax = 1.15f; + private static readonly Vector3 FromScale = new Vector3(ScaleMin, ScaleMin, ScaleMin); + private static readonly Vector3 ToScale = new Vector3(ScaleMax, ScaleMax, ScaleMax); + private const float ScalePeriodMin = 1; + private const float ScalePeriodMax = 2; + + + //============== Unity callbacks + // Use this for initialization + private void Start() + { + //comment the effect to disable it + // scale the whole thing + effects.Add(new EffectScale(gameObject, ScalePeriodMin, ScalePeriodMax, FromScale, ToScale)); + + // scale parts + effects.Add(new EffectScale(B.gameObject, ScalePeriodMin, ScalePeriodMax, FromScale, ToScale)); + effects.Add(new EffectScale(G.gameObject, ScalePeriodMin, ScalePeriodMax, FromScale, ToScale)); + effects.Add(new EffectScale(Curve.gameObject, ScalePeriodMin, ScalePeriodMax, FromScale, ToScale)); + + //rotate letters + effects.Add(new EffectRotate(EffectRotate.CycleType.Random, B.gameObject, 1f, Vector3.zero, new Vector3(0, 360, 0), 2, 3)); + effects.Add(new EffectRotate(EffectRotate.CycleType.Random, G.gameObject, 1.6f, Vector3.zero, new Vector3(0, 360, 0), 4, 6)); + + //particles + // particles movements are done with Cc components + + //change tiling (on shared material) + effects.Add(new EffectChangeTiling(2, B.GetComponent().sharedMaterial, 0, 0, .2f, 1)); + + //rotate light + effects.Add(new EffectRotate(EffectRotate.CycleType.Swing, Light.gameObject, 3f, new Vector3(70, -90, 0), new Vector3(110, -90, 0))); + + //projectiles + effects.Add(new EffectRotate(EffectRotate.CycleType.FirstToLast, ProjectileFolder, 10, Vector3.zero, new Vector3(360, 0, 0))); + effects.Add(new EffectMoveAndRotateAlongCurve(ProjectileCurve1, Projectile1.gameObject, 3, 5, .1f)); + effects.Add(new EffectMoveAndRotateAlongCurve(ProjectileCurve1, Projectile2.gameObject, 3, 5, .1f, Mathf.PI)); + + //dynamic + effects.Add(new EffectDynamicCurve(DynamicCurve, 4, Light1, Light2, Light3)); + } + + // Update is called once per frame + private void Update() + { + foreach (var effect in effects) effect.Update(); + } + + + //========================================== Abstract Phase + private abstract class Phase + { + private readonly float periodMin; + private readonly float periodMax; + + internal float period = -10000; + internal float startTime; + + protected Phase(float periodMin, float periodMax) + { + this.periodMin = periodMin; + this.periodMax = periodMax; + } + + protected internal virtual void PhaseStart() + { + startTime = Time.time; + period = Random.Range(periodMin, periodMax); + } + + public abstract void Update(); + } + + private sealed class PhaseDelay : Phase + { + public PhaseDelay(float periodMin, float periodMax) : base(periodMin, periodMax) + { + } + + public override void Update() + { + } + } + + //========================================== Abstract Effect (compound phase) + private abstract class Effect : Phase + { + private readonly List phases = new List(); + + private int currentPhaseIndex; + + protected Effect(float periodMin, float periodMax) : base(periodMin, periodMax) + { + phases.Add(this); + } + + protected void AddPhase(Phase phase) + { + phases.Add(phase); + } + + protected void AddPhase(Phase phase, int index) + { + phases.Insert(index, phase); + } + + public override void Update() + { + var phase = phases[currentPhaseIndex]; + + var newPhase = false; + if (Time.time - phase.startTime > phase.period) + { + //next phase + newPhase = true; + currentPhaseIndex++; + if (currentPhaseIndex == phases.Count) currentPhaseIndex = 0; + + phase = phases[currentPhaseIndex]; + phase.PhaseStart(); + } + + if (phase is Effect) + { + var effect = (Effect) phase; + + if (newPhase) effect.Start(); + + effect.Update((Time.time - phase.startTime)/phase.period); + } + } + + protected float CheckReverse(float ratio, bool reverse) + { + return reverse ? (1 - ratio) : ratio; + } + + protected abstract void Update(float ratio); + + protected virtual void Start() + { + } + + //remap ratio value to new range (for example, if count=2, .25 and 0.75 will become 0.5) + protected static float Scale(float ratio, float count) + { + var smallPeriod = 1f/count; + return (ratio - Mathf.FloorToInt(ratio/smallPeriod)*smallPeriod)/smallPeriod; + } + } + + + //========================================== Change Scale + private sealed class EffectScale : Effect + { + private readonly GameObject target; + + private Vector3 min; + private Vector3 max; + private Vector3 oldScale; + private Vector3 newScale; + + public EffectScale(GameObject target, float periodMin, float periodMax, Vector3 min, Vector3 max) + : base(periodMin, periodMax) + { + this.target = target; + newScale = target.transform.localScale; + this.min = min; + this.max = max; + } + + protected override void Update(float ratio) + { + target.transform.localScale = Vector3.Lerp(oldScale, newScale, ratio); + } + + protected override void Start() + { + oldScale = newScale; + newScale = new Vector3(Random.Range(min.x, max.x), Random.Range(min.y, max.y), Random.Range(min.z, max.z)); + } + } + + //========================================== Change Rotate + private sealed class EffectRotate : Effect + { + internal enum CycleType + { + FirstToLast, + Swing, + Random + } + + private readonly GameObject target; + private readonly Vector3 min; + private readonly Vector3 max; + private readonly CycleType cycleType; + + private bool reverse; + + //full 360 on y + public EffectRotate(CycleType cycleType, GameObject target, float period, Vector3 min, Vector3 max, float delayMin, float delayMax) + : this(cycleType, target, period, min, max) + { + AddPhase(new PhaseDelay(delayMin, delayMax), 0); + } + + public EffectRotate(CycleType cycleType, GameObject target, float period, Vector3 min, Vector3 max) + : base(period, period) + { + this.target = target; + this.cycleType = cycleType; + this.min = min; + this.max = max; + } + + protected override void Update(float ratio) + { + target.transform.eulerAngles = Vector3.Lerp(min, max, CheckReverse(ratio, reverse)); + } + + protected override void Start() + { + switch (cycleType) + { + case CycleType.FirstToLast: + reverse = false; + break; + case CycleType.Swing: + reverse = !reverse; + break; + default: + reverse = Random.Range(0, 2) == 0; + break; + } + } + } + + //========================================== Change tiling + private sealed class EffectChangeTiling : Effect + { + private readonly float tileXMin; + private readonly float tileXMax; + private readonly float tileYMin; + private readonly float tileYMax; + private readonly Material material; + + private bool reverse; + + public EffectChangeTiling(float period, Material material, float tileXMin, float tileXMax, float tileYMin, float tileYMax) + : base(period, period) + { + this.material = material; + this.tileXMin = tileXMin; + this.tileXMax = tileXMax; + this.tileYMin = tileYMin; + this.tileYMax = tileYMax; + } + + protected override void Update(float ratio) + { + ratio = CheckReverse(ratio, reverse); + material.mainTextureScale = new Vector2(Mathf.Lerp(tileXMin, tileXMax, ratio), Mathf.Lerp(tileYMin, tileYMax, ratio)); + } + + protected override void Start() + { + reverse = !reverse; + } + } + + + //============================================================================================================== + // Working with BGCurve + //============================================================================================================== + //========================================== Move object along and rotate around tangent + private sealed class EffectMoveAndRotateAlongCurve : Effect + { + private readonly GameObject target; + private readonly BGCcCursor cursor; + private readonly float rotateCount; + private readonly float rotationDistance; + private readonly float initialRotationRadians; + + public EffectMoveAndRotateAlongCurve(BGCcCursor cursor, GameObject target, float period, int rotateCount, float rotationDistance, float initialRotationRadians = 0) + : base(period, period) + { + this.target = target; + this.cursor = cursor; + this.rotateCount = rotateCount; + this.rotationDistance = rotationDistance; + this.initialRotationRadians = initialRotationRadians; + } + + protected override void Update(float ratio) + { + var position = cursor.CalculatePosition(); + //Tangent should be included in Math calculation + var tangent = cursor.CalculateTangent(); + + var angle = initialRotationRadians + Mathf.Lerp(0, Mathf.PI*2, Scale(ratio, rotateCount)); + var pos = position + Quaternion.LookRotation(tangent)*(new Vector3(Mathf.Sin(angle), Mathf.Cos(angle))*rotationDistance); + + target.transform.position = pos; + } + } + + //========================================== creating BGCurve at runtime + private sealed class EffectDynamicCurve : Effect + { + private const int PointsCount = 3; + private const float SpanX = 8; + private const float SpanZ = 4; + + private readonly BGCcMath math; + private readonly Light[] lights; + private readonly float[] fromDistanceRatios; + private readonly float[] toDistanceRatios; + + public EffectDynamicCurve(GameObject target, float period, params Light[] lights) + : base(period, period) + { + target.AddComponent(); + math = target.AddComponent(); + math.Curve.Closed = true; + this.lights = lights; + fromDistanceRatios = new float[lights.Length]; + toDistanceRatios = new float[lights.Length]; + } + + protected override void Update(float ratio) + { + for (var i = 0; i < lights.Length; i++) + { + var light = lights[i]; + + //move + light.gameObject.transform.position = math.Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, Mathf.Lerp(fromDistanceRatios[i], toDistanceRatios[i], ratio)); + + if (ratio < .1) + { + //lights on + light.intensity = Mathf.Lerp(0, 3, ratio*10); + } + else if (ratio > .9) + { + //lights off + light.intensity = Mathf.Lerp(3, 0, (ratio - .9f)*10); + } + } + } + + protected override void Start() + { + var curve = math.Curve; + curve.Clear(); + for (var i = 0; i < PointsCount; i++) AddPoint(curve); + + for (var i = 0; i < fromDistanceRatios.Length; i++) + { + fromDistanceRatios[i] = Random.Range(0f, 1); + toDistanceRatios[i] = Random.Range(0f, 1); + } + } + + private void AddPoint(BGCurve curve) + { + var control = RandomVector(); + curve.AddPoint(new BGCurvePoint(curve, RandomVector(), BGCurvePoint.ControlTypeEnum.BezierSymmetrical, control, -control)); + } + + private Vector3 RandomVector() + { + return new Vector3(Random.Range(-SpanX, SpanX), 0, Random.Range(-SpanZ, SpanZ)); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs.meta new file mode 100644 index 0000000..61f53e9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveShowcase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7958ebe98960fcd45a797f75226031f5 +timeCreated: 1472366315 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs new file mode 100644 index 0000000..ee7d9d8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + // This is old obsolete example class, left for compatibility only. + // DO NOT USE IT AS AN EXAMPLE PLEASE + // Use Cc components (BGCurveBaseMath -> BGCcMath, LineRenderer -> BGCcVisualizationLineRenderer) + [RequireComponent(typeof (BGCurve))] + [RequireComponent(typeof (LineRenderer))] + public class BGTestCurveStatic : MonoBehaviour + { + private const int TimeToMoveUp = 3; + + public GameObject ObjectToMove; + + private BGCurve curve; + private BGCurveBaseMath curveBaseMath; + + private float started; + private float ratio; + private LineRenderer lineRenderer; + + + // Use this for initialization + private void Start() + { + curve = GetComponent(); + lineRenderer = GetComponent(); + +// curveBaseMath = new BGCurveBaseMath(curve, false, 30); + curveBaseMath = new BGCurveBaseMath(curve); + started = Time.time; + + ResetLineRenderer(); + } + + private void ResetLineRenderer() + { + const int points = 100; + + var positions = new Vector3[points]; + for (var i = 0; i < 100; i++) + { + positions[i] = curveBaseMath.CalcPositionByDistanceRatio(((float) i/(points - 1))); + } +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = points; +#else + lineRenderer.SetVertexCount(points); +#endif + lineRenderer.SetPositions(positions); + } + + // Update is called once per frame + private void Update() + { + ratio = (Time.time - started)/TimeToMoveUp; + if (ratio >= 1) + { + started = Time.time; + ratio = 0; + } + else + { + ObjectToMove.transform.position = curveBaseMath.CalcPositionByDistanceRatio(ratio); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs.meta new file mode 100644 index 0000000..0b1adb5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestCurveStatic.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e58e9b269669674fb2020bb632d196f +timeCreated: 1473297298 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs new file mode 100644 index 0000000..74cae35 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs @@ -0,0 +1,96 @@ +using UnityEngine; +using System.Collections; + +namespace BansheeGz.BGSpline.Example +{ + //for 1.2 version demo scene + public class BGTestDirector : MonoBehaviour + { + private static readonly Color NightColor = Color.black; + private static readonly Color DayColor = new Color32(176, 224, 240, 255); + + //Day + public Light SunLight; + public Light DirectionalLight; + public ParticleSystem SunParticles; + + //Night + public Animator MoonAnimator; + public Light MoonLight; + public ParticleSystem StarsParticles; + + //Stars + public GameObject Stars; + + //callback for sun, reaching particular point + public void Sun(int point) + { + switch (point) + { + case 0: + StartCoroutine(ChangeBackColor(NightColor, DayColor)); + StartCoroutine(ChangeDirectLightIntensity(0, .8f)); + SunParticles.Play(); + break; + case 1: + SunLight.intensity = 1; + Stars.transform.localPosition += new Vector3(0, -20); + break; + case 3: + Stars.transform.localPosition -= new Vector3(0, -20); + SunLight.intensity = 0; + SunParticles.Stop(); + break; + } + } + + //callback for moon, reaching particular point + public void Moon(int point) + { + switch (point) + { + case 0: + StartCoroutine(ChangeBackColor(DayColor, NightColor)); + StartCoroutine(ChangeDirectLightIntensity(.8f, 0)); + StarsParticles.Play(); + break; + case 1: + MoonAnimator.SetBool("play", true); + MoonLight.intensity = 1; + break; + case 2: + StarsParticles.Stop(); + break; + case 3: + MoonAnimator.SetBool("play", false); + MoonLight.intensity = 0; + break; + } + } + + + private IEnumerator ChangeBackColor(Color from, Color to) + { + var started = Time.time; + const float changeTime = 1; + + while (Time.time - started < changeTime) + { + Camera.main.backgroundColor = Color.Lerp(from, to, (Time.time - started)/changeTime); + yield return null; + } + } + + private IEnumerator ChangeDirectLightIntensity(float from, float to) + { + var started = Time.time; + const float changeTime = 1; + + while (Time.time - started < changeTime) + { + DirectionalLight.intensity = Mathf.Lerp(from, to, (Time.time - started)/changeTime); + yield return null; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs.meta new file mode 100644 index 0000000..eb74c8b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestDirector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dbe40e6961ee5c74cb358876bec697f9 +timeCreated: 1476809059 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs new file mode 100644 index 0000000..fc9610f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace BansheeGz.BGSpline.Example +{ + //for main menu scene + public class BGTestMainMenu : MonoBehaviour + { + //to let know that scenes are loaded via menu + public static bool Inited; + + // Use this for initialization + void Start() + { + Inited = true; + } + + //for loading scenes + public void LoadScene(string scene) + { + SceneManager.LoadScene(scene); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs.meta new file mode 100644 index 0000000..0ed9afd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestMainMenu.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1bfad38550106584c93e18ad90e98703 +timeCreated: 1477523840 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs new file mode 100644 index 0000000..7025c50 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs @@ -0,0 +1,166 @@ +using UnityEngine; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Example +{ + //for testing performance + //DO NOT USE Unity Handles (for curve's points) with this test class! + [RequireComponent(typeof (BGCcMath))] + public class BGTestPerformance : MonoBehaviour + { + public enum ControlTypeForNewPoints + { + Random, + Absent, + Bezier + } + + //speed range for objects + private const float SpeedRange = 5f; + //transition period for points + private const int Period = 10; + + //===========================Public + [Tooltip("Object's prefab")] public GameObject ObjectToMove; + [Tooltip("Limits for points positions and transitions")] public Bounds Bounds = new Bounds(Vector3.zero, Vector3.one); + [Tooltip("Number of points to spawn")] [Range(2, 2000)] public int PointsCount = 100; + [Tooltip("Number of objects to spawn")] [Range(1, 500)] public int ObjectsCount = 100; + [Tooltip("Control Type")] public ControlTypeForNewPoints ControlType; + + //===========================Private + + private float startTime = -1000; + private BGCurve curve; + private BGCurveBaseMath math; + + //points + private Vector3[] oldPos; + private Vector3[] newPos; + + //objs + private GameObject[] objects; + private float[] speed; + private float[] distances; + + private float oldDistance; + + //Unity callback + private void Start() + { + curve = GetComponent(); + var ccMath = GetComponent(); + math = ccMath.Math; + curve = ccMath.Curve; + + //init arrays + oldPos = new Vector3[PointsCount]; + newPos = new Vector3[PointsCount]; + speed = new float[ObjectsCount]; + distances = new float[ObjectsCount]; + objects = new GameObject[ObjectsCount]; + + + //--------------------------- init from points + for (var i = 0; i < PointsCount; i++) + { + var controlTypeEnum = BGCurvePoint.ControlTypeEnum.BezierIndependant; + switch (ControlType) + { + case ControlTypeForNewPoints.Absent: + controlTypeEnum = BGCurvePoint.ControlTypeEnum.Absent; + break; + case ControlTypeForNewPoints.Random: + controlTypeEnum = (BGCurvePoint.ControlTypeEnum) Random.Range(0, 3); + break; + } + curve.AddPoint(new BGCurvePoint(curve, RandomVector(), controlTypeEnum, RandomVector(), RandomVector())); + } + + //Recalculate manually after points were added (normally you would not do it) + math.Recalculate(); + + //---------------------------- init objects + if (ObjectToMove != null) + { + var totalDistance = oldDistance = math.GetDistance(); + for (var i = 0; i < ObjectsCount; i++) + { + var obj = Instantiate(ObjectToMove, Vector3.zero, Quaternion.identity) as GameObject; + obj.transform.parent = transform; + objects[i] = obj; + distances[i] = Random.Range(0, totalDistance); + } + ObjectToMove.SetActive(false); + //--------------------------- init speed + for (var i = 0; i < ObjectsCount; i++) + { + speed[i] = Random.Range(0, 2) == 0 ? Random.Range(-SpeedRange, -SpeedRange*0.3f) : Random.Range(SpeedRange*0.3f, SpeedRange); + } + } + } + + //Unity callback + private void Update() + { + //reset transitions + if (Time.time - startTime > Period) + { + startTime = Time.time; + for (var i = 0; i < PointsCount; i++) + { + oldPos[i] = newPos[i]; + newPos[i] = RandomVector(); + } + } + + //move points + var ratio = (Time.time - startTime)/Period; + var points = curve.Points; + for (var i = 0; i < PointsCount; i++) points[i].PositionLocal = Vector3.Lerp(oldPos[i], newPos[i], ratio); + + //move objects + var totalDistance = math.GetDistance(); + if (ObjectToMove != null) + { + var remapRatio = totalDistance/oldDistance; + for (var i = 0; i < ObjectsCount; i++) + { + var distance = distances[i]; + + //since curve's length changed-remap + distance = distance*remapRatio; + + distance = distance + speed[i]*Time.deltaTime; + if (distance < 0) + { + speed[i] = -speed[i]; + distance = 0; + } + else if (distance > totalDistance) + { + speed[i] = -speed[i]; + distance = totalDistance; + } + distances[i] = distance; + + objects[i].transform.position = math.CalcByDistance(BGCurveBaseMath.Field.Position, distance); + } + } + oldDistance = totalDistance; + } + + //misc utility methods + private Vector3 RandomVector() + { + return new Vector3(Range(0), Range(1), Range(2)); + } + + private float Range(int index) + { + return Random.Range(Bounds.min[index], Bounds.max[index]); + } + } +} + + diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs.meta new file mode 100644 index 0000000..475c152 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Scripts/BGTestPerformance.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6fd365c04f9bb4241803aced3a970a79 +timeCreated: 1473296685 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain.meta new file mode 100644 index 0000000..4c47095 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d8330cb9504691b4795df7a28fd10477 +folderAsset: yes +timeCreated: 1476659936 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset new file mode 100644 index 0000000..9fe26ea Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset.meta new file mode 100644 index 0000000..d25782c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestDemoTerrain.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 737d7a849d554e141aa574ee80ee3fce +timeCreated: 1476659987 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset new file mode 100644 index 0000000..76d7970 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset.meta new file mode 100644 index 0000000..758fa36 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Terrain/BGTestSnappingTerrain.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 763f4ae12b87e6b4b980c9d761465159 +timeCreated: 1476935958 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons.meta new file mode 100644 index 0000000..cbaea5a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dea56a8d07951be4e84ca5f838b758db +folderAsset: yes +timeCreated: 1458400512 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png new file mode 100644 index 0000000..95e8bc1 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png.meta new file mode 100644 index 0000000..1c5f3c6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGAdd123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 03ce3b24581c7414eaca31c2b196ecc6 +timeCreated: 1458521116 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png new file mode 100644 index 0000000..2ea0724 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png.meta new file mode 100644 index 0000000..3f59db8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWhite123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ded8bd90f16890a408091013c9b03b43 +timeCreated: 1472605753 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png new file mode 100644 index 0000000..5142b78 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png.meta new file mode 100644 index 0000000..45fc7d5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGBoxWithBorder123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: e14f8a9efcef446448911c88a64bf86a +timeCreated: 1472058752 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png new file mode 100644 index 0000000..b8f845c Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png.meta new file mode 100644 index 0000000..d9441ad --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcEditName123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: e087ffb98e49ae34eb43f2f4d66da109 +timeCreated: 1473063659 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png new file mode 100644 index 0000000..1e2fd87 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png.meta new file mode 100644 index 0000000..93bbe89 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCcNoImage123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: a414723b197ce2f4a9fd841e965f138e +timeCreated: 1472488893 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png new file mode 100644 index 0000000..0d41968 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png.meta new file mode 100644 index 0000000..869a6f8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapseAll123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: db1c9655fc10b724eb307b7e321ac31c +timeCreated: 1472909534 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png new file mode 100644 index 0000000..77ece6d Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png.meta new file mode 100644 index 0000000..44686ff --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCollapsed123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: d576ae51c051b294d978d836848416bf +timeCreated: 1472909534 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png new file mode 100644 index 0000000..deb194c Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png.meta new file mode 100644 index 0000000..4670524 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGComponents123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ace41ad38c804f34a961b1f7624cb0bb +timeCreated: 1471761007 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png new file mode 100644 index 0000000..077f420 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png.meta new file mode 100644 index 0000000..2dbf1ce --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlAbsent123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ed1ce6f1c6c55454c8302d8c78840174 +timeCreated: 1472300443 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png new file mode 100644 index 0000000..56f6f8b Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png.meta new file mode 100644 index 0000000..0d7f106 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierIndependent123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 7a229d4c49ec7a04e9772d939231a8ad +timeCreated: 1472300443 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png new file mode 100644 index 0000000..a7614b6 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png.meta new file mode 100644 index 0000000..abcc4f4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGControlBezierSymmetrical123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 41860c26ee4a2c444afde8d31ba5f57f +timeCreated: 1472300443 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png new file mode 100644 index 0000000..d036a25 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png.meta new file mode 100644 index 0000000..2dee12e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGConvertAll123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: bb7f32b6d453d8f4f99301a76ba8fe6d +timeCreated: 1458530462 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png new file mode 100644 index 0000000..2e0d9ec Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png.meta new file mode 100644 index 0000000..d9371b6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCopy123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ee35c284a32612c429d5fa9be3a4a535 +timeCreated: 1477995243 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png new file mode 100644 index 0000000..f70d7e5 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png.meta new file mode 100644 index 0000000..24dba01 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveComponents123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: a5b7666fd68eee74ea8390d47cb34a42 +timeCreated: 1472489767 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png new file mode 100644 index 0000000..8633937 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png.meta new file mode 100644 index 0000000..3a57bba --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGCurveLogo123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 5a06bd789ce83514da6205207ff54c0d +timeCreated: 1458414750 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png new file mode 100644 index 0000000..940047a Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png.meta new file mode 100644 index 0000000..1a0e02d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDeSelectAll123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 119252f46a08a6c40a4cad087e0cec60 +timeCreated: 1458533499 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png new file mode 100644 index 0000000..28ce032 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png.meta new file mode 100644 index 0000000..4546b64 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGDelete123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: fcc2685fe63bfea449c91455d49e65a5 +timeCreated: 1458400542 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png new file mode 100644 index 0000000..53df01c Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png.meta new file mode 100644 index 0000000..feb5dc0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpandAll123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 2f28d70650a3865498f01cfa3de75a10 +timeCreated: 1472909534 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png new file mode 100644 index 0000000..aefc7c0 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png.meta new file mode 100644 index 0000000..57eac92 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGExpanded123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: dc96184b02b25ad45a6a23eb39b83b91 +timeCreated: 1472909534 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png new file mode 100644 index 0000000..46e1467 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png.meta new file mode 100644 index 0000000..186002c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGFields123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 0c858be9b0c10534cad42984dc3d2b77 +timeCreated: 1471761007 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png new file mode 100644 index 0000000..5b478d2 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png.meta new file mode 100644 index 0000000..3dcfd24 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOff123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 983231345b8a72746867a924b0375d51 +timeCreated: 1476159626 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png new file mode 100644 index 0000000..0ac2224 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png.meta new file mode 100644 index 0000000..26b400a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHandlesOn123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: b6b3c686fb07aa0448eb20914ba73271 +timeCreated: 1476159626 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png new file mode 100644 index 0000000..4637694 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png.meta new file mode 100644 index 0000000..dcae7fd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHelp123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 974c3f86d59ae4c4aaeb18abc1b04b7f +timeCreated: 1472530071 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png new file mode 100644 index 0000000..97355cf Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png.meta new file mode 100644 index 0000000..c44a9cb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 94ab056a92cf75c47ab8adcde965871f +timeCreated: 1472629649 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png new file mode 100644 index 0000000..80522d4 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png.meta new file mode 100644 index 0000000..c560bb1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyErrorSelectedIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 1621a394d1618b047a3fd6ddb5ee1a65 +timeCreated: 1472629649 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png new file mode 100644 index 0000000..7b0ec9e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png.meta new file mode 100644 index 0000000..f01c15f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: b2b36280c75a2ba44921866c2c6d7fdb +timeCreated: 1472627466 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png new file mode 100644 index 0000000..79f7281 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png.meta new file mode 100644 index 0000000..3930e7a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchySelectedIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: dceb510e1662d644a909812caca5b951 +timeCreated: 1472628860 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png new file mode 100644 index 0000000..ba81295 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png.meta new file mode 100644 index 0000000..a7e4474 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 8f4d290373499e94f94187cdc78c6f46 +timeCreated: 1472720551 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png new file mode 100644 index 0000000..4a78ce7 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png.meta new file mode 100644 index 0000000..8c04724 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGHierarchyWarningSelectedIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: f3a7ac617df5b574ba63b171b3ae8114 +timeCreated: 1472720551 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png new file mode 100644 index 0000000..c4a3a14 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png.meta new file mode 100644 index 0000000..edb81bf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOff123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 45a92439e841a594ab7df00f55b18d91 +timeCreated: 1472306768 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png new file mode 100644 index 0000000..e4350e5 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png.meta new file mode 100644 index 0000000..de223f9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGLockOn123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 535564b74ec2c1b4d9df8f6f5430a3f5 +timeCreated: 1472306768 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png new file mode 100644 index 0000000..bbd733f Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png.meta new file mode 100644 index 0000000..d3bb70a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMenuItemBackground123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 48df368591a03fa4583ab62aa8facd31 +timeCreated: 1472736046 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png new file mode 100644 index 0000000..7dfa15c Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png.meta new file mode 100644 index 0000000..f7d25b4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveDown123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: e3e4ceb5bbc46d24aa7c095e2d01d0a6 +timeCreated: 1458523994 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png new file mode 100644 index 0000000..1623d76 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png.meta new file mode 100644 index 0000000..36c8d3b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGMoveUp123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 16d471e6b1100174e99104967a4a5371 +timeCreated: 1458523994 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png new file mode 100644 index 0000000..256802e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png.meta new file mode 100644 index 0000000..4502fa6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOff123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: b1aef48490f4ed0428d5c198de902252 +timeCreated: 1472713091 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png new file mode 100644 index 0000000..4ed7e01 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png.meta new file mode 100644 index 0000000..27e9e1e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGOn123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ce573ece89da18f498539bf492e4fc89 +timeCreated: 1472713091 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png new file mode 100644 index 0000000..e61bbe1 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png.meta new file mode 100644 index 0000000..0c975ad --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPaste123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 5654b1bf9b5758d4292b8b5fae9480b4 +timeCreated: 1477995243 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png new file mode 100644 index 0000000..4dbf389 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png.meta new file mode 100644 index 0000000..480b409 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointControlBS123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 72e35837ef2d6e144b6d6dc21a5a836f +timeCreated: 1472299645 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png new file mode 100644 index 0000000..9009de3 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png.meta new file mode 100644 index 0000000..500cbaa --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointDelete123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 285c5dc0cef41774b99e38ea9a1dd9ab +timeCreated: 1472300690 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png new file mode 100644 index 0000000..d99a061 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png.meta new file mode 100644 index 0000000..dd87626 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertAfter123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: ddd4a46b3f2129546a7bd2c9ee33481a +timeCreated: 1472739488 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png new file mode 100644 index 0000000..9aec75d Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png.meta new file mode 100644 index 0000000..5cc4c66 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointInsertBefore123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 6c4383b335fb4f84d8b4891eb8162aa5 +timeCreated: 1472739488 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png new file mode 100644 index 0000000..cf1b00d Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png.meta new file mode 100644 index 0000000..b187ffb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPointSelected123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: c2df81ec1d6e7a7429f8b01c6503d2f6 +timeCreated: 1472281979 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png new file mode 100644 index 0000000..ea35677 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png.meta new file mode 100644 index 0000000..6a08073 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGPoints123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: bfc1eb453ec737f46b11184eaf5ed806 +timeCreated: 1458400542 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png new file mode 100644 index 0000000..9fa64ba Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png.meta new file mode 100644 index 0000000..9b5f002 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectAll123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: dede35dbc7af6e7489d42029b6b694f4 +timeCreated: 1458533499 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png new file mode 100644 index 0000000..f96afb3 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png.meta new file mode 100644 index 0000000..5904b7e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionAdd123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: cf5fc4a27a2691e4e8a4f7945b3328c8 +timeCreated: 1472746448 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png new file mode 100644 index 0000000..208da0e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png.meta new file mode 100644 index 0000000..5a53e9a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSelectionRemove123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 433f6e35670079941910fc178f9bce4c +timeCreated: 1472746448 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png new file mode 100644 index 0000000..56aa4ac Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png.meta new file mode 100644 index 0000000..45b70f8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettings123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 4d7dfc35a926ca14d9ddd3f3d6986d61 +timeCreated: 1458400542 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png new file mode 100644 index 0000000..0684743 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png.meta new file mode 100644 index 0000000..439c2d2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGSettingsIcon123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 94e25c1cd35aa4649ba3d4357982aeff +timeCreated: 1472983008 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png new file mode 100644 index 0000000..d55413b Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png.meta new file mode 100644 index 0000000..c8b68e2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableCell123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 59bb3d50c693c0b41b9ad2688737d022 +timeCreated: 1471855053 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png new file mode 100644 index 0000000..4d78502 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png.meta new file mode 100644 index 0000000..14d350a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableHeader123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 688c50e97be6de94c97dfebffc0232ef +timeCreated: 1471855053 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png new file mode 100644 index 0000000..7053893 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png.meta new file mode 100644 index 0000000..5fe0800 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTableTitle123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: d5ac72114a58e9a4a96233d3b26b7d50 +timeCreated: 1471859604 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png new file mode 100644 index 0000000..59f79b9 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png.meta new file mode 100644 index 0000000..aa0bb49 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickNo123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 095ffc4f31a16bf4a931b1fe2f14b0f2 +timeCreated: 1458400542 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png new file mode 100644 index 0000000..2d378de Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png.meta new file mode 100644 index 0000000..a77ca54 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/BGTickYes123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: c5b649d34ba7fee4d80a14ac192a1cd5 +timeCreated: 1458400542 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components.meta new file mode 100644 index 0000000..26f5e43 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c93d1ca76bb7c1e4191b3fafb5e2c7e3 +folderAsset: yes +timeCreated: 1472488316 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png new file mode 100644 index 0000000..44a9c9e Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png.meta new file mode 100644 index 0000000..613af6b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 2e8bc914727b8974e9302c4788246b6e +timeCreated: 1472492039 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png new file mode 100644 index 0000000..db30383 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png.meta new file mode 100644 index 0000000..dd528f4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 271b8ad5a36deae43b56d79270be2caf +timeCreated: 1472942522 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png new file mode 100644 index 0000000..a50e361 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png.meta new file mode 100644 index 0000000..6637c50 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 5e55633039becc942bb8a380d8cf6d77 +timeCreated: 1472942522 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png new file mode 100644 index 0000000..59d6c94 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png.meta new file mode 100644 index 0000000..fefed03 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: d2786fd700db6304d82b0eb6badf912a +timeCreated: 1476113367 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png new file mode 100644 index 0000000..933a1b9 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png.meta new file mode 100644 index 0000000..c77decb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: db2c2a331f01c584c8d02062fedaeac6 +timeCreated: 1472942522 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png new file mode 100644 index 0000000..a8848ac Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png.meta new file mode 100644 index 0000000..f7e976e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 913b0df64e0187e4e844d7fba6bd1e5f +timeCreated: 1472488522 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png new file mode 100644 index 0000000..a445dea Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png.meta new file mode 100644 index 0000000..966c3a1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 0def80e3c2695d345b205d3d2752e5b9 +timeCreated: 1474946153 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png new file mode 100644 index 0000000..cbafa42 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png.meta new file mode 100644 index 0000000..386f775 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: f95ffc49338c9e241a8b77d87ccb1317 +timeCreated: 1476469956 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png new file mode 100644 index 0000000..6ac1205 Binary files /dev/null and b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png differ diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png.meta new file mode 100644 index 0000000..58c70aa --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 7b4f1912d4b7c8841b28c9b596a7ace9 +timeCreated: 1473076361 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts.meta new file mode 100644 index 0000000..c82250c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0843b6513bb58f147abafe88acbdf49b +folderAsset: yes +timeCreated: 1458400502 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc.meta new file mode 100644 index 0000000..6f1b0e8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a25bc0e736a11d546bd0490d3cc13f88 +folderAsset: yes +timeCreated: 1471596338 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs new file mode 100644 index 0000000..0184bc6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs @@ -0,0 +1,102 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Identify the position on the curve by the distance from the start. + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcCursor")] + [ + CcDescriptor( + Description = "Identify location on the curve by distance.", + Name = "Cursor", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursor123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcCursor")] + public class BGCcCursor : BGCcWithMath + { + //=============================================================================================== + // Fields + //=============================================================================================== + + [SerializeField] [Tooltip("Distance from start of the curve.")] private float distance; + + /// Distance from the start + public float Distance + { + get { return distance; } + set + { + distance = Math.ClampDistance(value); + FireChangedParams(); + } + } + + /// Normalized distance from the start [Range(0,1)] + public float DistanceRatio + { + get { return Mathf.Clamp01(distance/Math.GetDistance()); } + set + { + distance = Math.GetDistance()*Mathf.Clamp01(value); + FireChangedParams(); + } + } + + public override bool SupportHandles + { + get { return true; } + } + + public override bool SupportHandlesSettings + { + get { return true; } + } + +#if UNITY_EDITOR + [Range(.5f, 1.5f)] [SerializeField] private float handlesScale = 1; + [SerializeField] private Color handlesColor = Color.white; + + public float HandlesScale + { + get { return handlesScale; } + set { handlesScale = value; } + } + + public Color HandlesColor + { + get { return handlesColor; } + set { handlesColor = value; } + } +#endif + + //=============================================================================================== + // Public functions + //=============================================================================================== + /// Calculates tangent by current distance + public Vector3 CalculateTangent() + { + return Math.CalcByDistance(BGCurveBaseMath.Field.Tangent, distance); + } + + /// Calculates position by current distance + public Vector3 CalculatePosition() + { + return Math.CalcByDistance(BGCurveBaseMath.Field.Position, distance); + } + + /// Calculates section's index by current distance + public int CalculateSectionIndex() + { + return Math.CalcSectionIndexByDistance(distance); + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + public override void Start() + { + //clamp + Distance = distance; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs.meta new file mode 100644 index 0000000..f82c3f3 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 924df4c68ad59e943b47b75f2323f73a +timeCreated: 1471831265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs new file mode 100644 index 0000000..cc8712a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs @@ -0,0 +1,551 @@ +using System; +using UnityEngine; +using UnityEngine.Events; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Change cursor position linearly + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcCursorChangeLinear")] + [ + CcDescriptor( + Description = "Change cursor position linearly", + Name = "Cursor Change Linear", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorChangeLinear123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcCursorChangeLinear")] + + //idea.. refactor it.. the whole class looks like a nightmare + public class BGCcCursorChangeLinear : BGCcWithCursor + { + //=============================================================================================== + // Static & Enums + //=============================================================================================== + /// Speed, that is so small, that it can be ignored + public const float SpeedThreshold = 0.00001f; + + /// What to do, then cursor reaches first or last points + public enum OverflowControlEnum + { + /// Cycle in the same direction. For example, if it reaches the end point, start from the first point again + Cycle = 0, + + /// Change speed to -speed, and go in opposite direction + PingPong = 1, + + /// Stop + Stop = 2, + } + + //=============================================================================================== + // Events (Not persistent) + //=============================================================================================== + /// point was reached + public event EventHandler PointReached; + + //=============================================================================================== + // Fields (persistent) + //=============================================================================================== + + + [SerializeField] [Tooltip("Constant movement speed along the curve (Speed * Time.deltaTime)." + + "You can override this value for each point with speedField")] private float speed = 5; + + [SerializeField] [Tooltip("How to change speed, then curve's end reached.")] private OverflowControlEnum overflowControl; + + [SerializeField] [Tooltip("If curve's length changed, " + + "cursor position be adjusted with curve's length to ensure visually constant speed along the curve. ")] private bool adjustByTotalLength; + + [SerializeField] [Tooltip("Field to store the speed between each point. It should be a float field.")] private BGCurvePointField speedField; + + + [SerializeField] [Tooltip("Delay at each point. You can override this value for each point with delayField")] private float delay; + + [SerializeField] [Tooltip("Field to store the delays at points. It should be a float field.")] private BGCurvePointField delayField; + + [SerializeField] [Tooltip("Event is fired, then point is reached")] private PointReachedEvent pointReachedEvent = new PointReachedEvent(); + + + /// What to do, then cursor reaches first or last points + public OverflowControlEnum OverflowControl + { + get { return overflowControl; } + set + { + if (ParamChanged(ref overflowControl, value)) Stopped = false; + } + } + + /// Speed. It can be overriden for each point by SpeedField. The result speed is calculated as Speed * Time.deltaTime + public float Speed + { + get { return speed; } + set { ParamChanged(ref speed, value); } + } + + /// Should we adjust cursor position by the total length of the curve + public bool AdjustByTotalLength + { + get { return adjustByTotalLength; } + set { ParamChanged(ref adjustByTotalLength, value); } + } + + /// Custom field to get speed value. It should be a float field. If it's null, "Speed" property is used. The result speed is calculated as Speed * Time.deltaTime + public BGCurvePointField SpeedField + { + get { return speedField; } + set { ParamChanged(ref speedField, value); } + } + + /// Delay at each point. It can be overriden for each point by DelayField. + public float Delay + { + get { return delay; } + set { ParamChanged(ref delay, value); } + } + + /// Custom field to get delay value. It should be a float field. If it's null, "Delay" property is used. + public BGCurvePointField DelayField + { + get { return delayField; } + set { ParamChanged(ref delayField, value); } + } + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + //curve's length at last calculation (only if adjustByTotalLength=true) + private float oldLength; + //is speed is reversed (if speed field is present) + private bool speedReversed; + //current section index (it's calculated only if it's required) + private int currentSectionIndex; + //delay started time + private float delayStarted = -1; + //if speed was positive while delay occured + private bool speedWasPositiveWhileDelayed; + //this is a part of overall nightmare, this class is. + private bool skipZeroPoint; + + + /// If it's stopped or moving + public bool Stopped { get; set; } + + /// If speed field is present and actual speed is reversed at the moment. It can be the case if PingPong is used. + public bool SpeedReversed + { + get { return speedReversed; } + } + + /// Speed at current cursor position + public float CurrentSpeed + { + get + { + if (Curve.PointsCount < 2) return 0; + + //no field + if (speedField == null) return speed; + + //by field + var speedAtPoint = Curve[Cursor.CalculateSectionIndex()].GetFloat(speedField.FieldName); + return speedReversed ? -speedAtPoint : speedAtPoint; + } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + public override void Start() + { + oldLength = Cursor.Math.GetDistance(); + if (Application.isPlaying && Curve.PointsCount > 1 && (delay > 0 || delayField != null || pointReachedEvent.GetPersistentEventCount() > 0 || PointReached != null)) + currentSectionIndex = Cursor.Math.Math.CalcSectionIndexByDistance(Cursor.Distance); + } + + // Update is called once per frame + private void Update() + { + if (Stopped || (speedField == null && Mathf.Abs(speed) < SpeedThreshold)) return; + + var pointsCount = Curve.PointsCount; + if (pointsCount < 2) return; + + var cursor = Cursor; + var math = cursor.Math.Math; + var isPlaying = Application.isPlaying; + + //===================================================== cursor is delayed at point + if (isPlaying && delayStarted >= 0 && !CheckIfDelayIsOver(math, cursor)) return; + + //we are delayed so no need to process movement- return + if (delayStarted >= 0) return; + + + //===================================================== cursor is moving + //calculate adjustment if needed + var distance = cursor.Distance; + var newLength = 0f; + if (adjustByTotalLength) + { + newLength = math.GetDistance(); + if (Math.Abs(newLength) > BGCurve.Epsilon && Math.Abs(oldLength) > BGCurve.Epsilon && Math.Abs(newLength - oldLength) > BGCurve.Epsilon) distance = distance*newLength/oldLength; + } + + //-------------------------------- Check for new Delay + var newSectionIndex = -1; + + //check for new delays (and fire events) + var firingEvents = pointReachedEvent.GetPersistentEventCount() > 0 || PointReached != null; + var checkDelay = isPlaying && (delay > 0 || delayField != null); + if ((checkDelay || firingEvents) && CheckForNewDelay(math, distance, ref newSectionIndex, checkDelay, firingEvents)) return; + + //-------------------------------- calculate speed + var currentSpeed = speed; + if (speedField != null) + { + //we need to retrieve speed from a field value + if (newSectionIndex == -1) newSectionIndex = math.CalcSectionIndexByDistance(distance); + currentSpeed = Curve[newSectionIndex].GetFloat(speedField.FieldName); + if (speedReversed) currentSpeed = -currentSpeed; + } + + //-------------------------------- change distance + var newDistance = distance + currentSpeed*Time.deltaTime; + + + //-------------------------------- Check Overflows + if (newDistance < 0 || newDistance > math.GetDistance()) Overflow(math, ref newDistance, currentSpeed >= 0, checkDelay, firingEvents); + + //assign new value + cursor.Distance = newDistance; + oldLength = newLength; + } + + //=============================================================================================== + // Public functions + //=============================================================================================== + /// Delay at specified point + public float GetDelayAtPoint(int point) + { + return delayField == null ? delay : Curve[point].GetFloat(delayField.FieldName); + } + + /// Speed at specified point + public float GetSpeedAtPoint(int point) + { + return speedField == null ? speed : Curve[point].GetFloat(speedField.FieldName); + } + + //=============================================================================================== + // Private functions + //=============================================================================================== + //if delay required at given point + private bool IsDelayRequired(int pointIndex) + { + var hasDelayField = delayField != null; + return (!hasDelayField && delay > 0) || (hasDelayField && Curve[pointIndex].GetFloat(delayField.FieldName) > BGCurve.Epsilon); + } + + //start delay at current point + private void StartDelay(bool speedIsPositive) + { + delayStarted = Time.time; + speedWasPositiveWhileDelayed = speedIsPositive; + } + + //checks if cursor passed a point (current section is changed) and if new delay occured. Also fires events if needed + private bool CheckForNewDelay(BGCurveBaseMath math, float distance, ref int newSectionIndex, bool checkDelay, bool firingEvents) + { + if (currentSectionIndex == 0 && skipZeroPoint) return false; + if (!math.Curve.Closed && currentSectionIndex == math.Curve.PointsCount - 1) return false; + + newSectionIndex = math.CalcSectionIndexByDistance(distance); + if (currentSectionIndex != newSectionIndex) + { + //section is changed (there could be several points between) + + //if speed was positive or negative? + bool speedPositive; + if (speedField == null) speedPositive = speed > 0; + else + { + speedPositive = Curve[currentSectionIndex].GetFloat(speedField.FieldName) > 0; + if (speedReversed) speedPositive = !speedPositive; + } + + if (CheckDelayAtSectionChanged(newSectionIndex, checkDelay, firingEvents, speedPositive)) return true; + } + //no delay + delayStarted = -1; + + return false; + } + + //section is changed- check if delay required + private bool CheckDelayAtSectionChanged(int newSectionIndex, bool checkDelay, bool firingEvents, bool speedPositive) + { + var cursor = Cursor; + var math = cursor.Math.Math; + + var lastPointIndex = Curve.PointsCount - 1; + + //now we need to iterate all passed points + if (speedPositive) + { + //check for infinite loop (just in case) + if (newSectionIndex > currentSectionIndex) + { + for (var i = currentSectionIndex + 1; i <= newSectionIndex; i++) + { + if (firingEvents) FirePointReachedEvent(i); + + if (checkDelay && CheckDelayAtPoint(math, cursor, i, speedPositive)) return true; + } + } + } + else + { + //if speed is negative, the processing is slightly different + + if (currentSectionIndex == 0 && !Curve.Closed) currentSectionIndex = lastPointIndex; + + //check for infinite loop (just in case) + if (newSectionIndex < currentSectionIndex) + { + for (var i = currentSectionIndex; i > newSectionIndex; i--) + { + if (firingEvents) FirePointReachedEvent(i); + + if (checkDelay && CheckDelayAtPoint(math, cursor, i, speedPositive)) return true; + } + } + } + + currentSectionIndex = newSectionIndex; + return false; + } + + //points was passed and we check if delay is required at this point + private bool CheckDelayAtPoint(BGCurveBaseMath math, BGCcCursor cursor, int pointIndex, bool speedPositive) + { + if (IsDelayRequired(pointIndex)) + { + //we gotta delay at this point + currentSectionIndex = pointIndex; + //move cursor straight to the point + cursor.Distance = Curve.PointsCount - 1 == pointIndex && !Curve.Closed ? math.GetDistance() : math[pointIndex].DistanceFromStartToOrigin; + + // !!!!!!! start delay + StartDelay(speedPositive); + //we does not need to process movement (it will be ignored at any rate, cause we stick to the particular point) + return true; + } + return false; + } + + // overflow occurred + private void Overflow(BGCurveBaseMath math, ref float newDistance, bool currentSpeedPositive, bool checkDelay, bool firingEvents) + { + var lessThanZero = newDistance < 0; + var totalDistance = math.GetDistance(); + var lastPointIndex = Curve.PointsCount - 1; + + //we need to check delays. (all points up to boundary point) + if (checkDelay || firingEvents) + { + if (currentSpeedPositive) + { + //process all passed points +// var lastPointIndexToCheck = Curve.Closed ? lastPointIndex : lastPointIndex - 1; + var lastPointIndexToCheck = lastPointIndex; + if (currentSectionIndex != lastPointIndexToCheck) if (CheckDelayAtSectionChanged(lastPointIndexToCheck, checkDelay, firingEvents, true)) return; + } + else + { + if (currentSectionIndex > 0) + { + if (CheckDelayAtSectionChanged(0, checkDelay, firingEvents, false)) return; + } + + //this needs to be refactored + if (!skipZeroPoint) + { + if (checkDelay && CheckDelayAtPoint(math, Cursor, 0, false)) + { + if (firingEvents) FirePointReachedEvent(0); + skipZeroPoint = true; + return; + } + } + } + } + + + //overflow + switch (overflowControl) + { + case OverflowControlEnum.Stop: + newDistance = lessThanZero ? 0 : totalDistance; + Stopped = true; + break; + + case OverflowControlEnum.Cycle: + newDistance = lessThanZero ? totalDistance + newDistance : newDistance - totalDistance; + break; + + case OverflowControlEnum.PingPong: + if (speedField == null) speed = -speed; + speedReversed = !speedReversed; + currentSpeedPositive = !currentSpeedPositive; + newDistance = lessThanZero ? -newDistance : totalDistance*2 - newDistance; + break; + } + + if (newDistance < 0) newDistance = 0; + else if (newDistance > totalDistance) newDistance = totalDistance; + + + //ok, we need to check delays.. once again. (single boundary point) + if (checkDelay || firingEvents) + { + if (Curve.Closed) + { + if (skipZeroPoint) + { + skipZeroPoint = false; + } + else + { + if (firingEvents) FirePointReachedEvent(0); + + currentSectionIndex = currentSpeedPositive ? 0 : lastPointIndex; + + if (checkDelay && CheckDelayAtPoint(math, Cursor, 0, currentSpeedPositive)) return; + } + } + else + { + if (lessThanZero) + { + //original speed was negative + if (skipZeroPoint) + { + skipZeroPoint = false; + } + else + { + currentSectionIndex = 0; + if (firingEvents) FirePointReachedEvent(0); + if (checkDelay && CheckDelayAtPoint(math, Cursor, 0, currentSpeedPositive)) return; + } + } + else + { + //original speed was positive + if (!Curve.Closed) + { + if (currentSpeedPositive) + { + //last->first + currentSectionIndex = 0; + if (firingEvents) FirePointReachedEvent(0); + if (checkDelay && CheckDelayAtPoint(math, Cursor, 0, currentSpeedPositive)) return; + } + else + { + //last->last (pingpong) + currentSectionIndex = lastPointIndex - 1; + } + } + } + } + } + } + + //check if delay is over + private bool CheckIfDelayIsOver(BGCurveBaseMath math, BGCcCursor cursor) + { + var pointsCountMinusOne = Curve.PointsCount - 1; + + if (adjustByTotalLength) oldLength = math.GetDistance(); + + //curve is not closed and delayed at last point + var delayAtLastPoint = !Curve.Closed && currentSectionIndex == pointsCountMinusOne; + + //curve may be changing, so we need to adjust a position anyway + cursor.Distance = delayAtLastPoint ? math.GetDistance() : math[currentSectionIndex].DistanceFromStartToOrigin; + var delayValue = GetDelayAtPoint(currentSectionIndex); + + // we are still delayed + if (!(Time.time - delayStarted > delayValue)) return false; + + + // delay is over, start moving + delayStarted = -1; + if (speedWasPositiveWhileDelayed) + { + // if (delayAtLastPoint) cursor.Distance = 0; + // else cursor.Distance += BGCurve.Epsilon; + cursor.Distance += BGCurve.Epsilon; + } + else + { + if (currentSectionIndex > 0) + { + currentSectionIndex--; + cursor.Distance -= BGCurve.Epsilon; + } + else + { + if (!skipZeroPoint) + { + currentSectionIndex = pointsCountMinusOne; + cursor.Distance = math.GetDistance() - BGCurve.Epsilon; + } + } + } + return true; + } + + //fire "point is reached" event + private void FirePointReachedEvent(int pointIndex) + { + if (PointReached != null) PointReached(this, PointReachedArgs.GetInstance(pointIndex)); + + //probably we could skip pointPassed.GetPersistentEventCount() check + if (pointReachedEvent.GetPersistentEventCount() > 0) pointReachedEvent.Invoke(pointIndex); + } + + //=============================================================================================== + // Unity Persistent event + //=============================================================================================== + /// Fired when cursor reaches a point + [Serializable] + public class PointReachedEvent : UnityEvent + { + } + + //=============================================================================================== + // C# not persistent event + //=============================================================================================== + /// Fired when cursor reaches a point + public class PointReachedArgs : EventArgs + { + private static readonly PointReachedArgs Instance = new PointReachedArgs(); + + //point's index + public int PointIndex { get; private set; } + + private PointReachedArgs() + { + } + + public static PointReachedArgs GetInstance(int index) + { + Instance.PointIndex = index; + return Instance; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs.meta new file mode 100644 index 0000000..adabe67 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorChangeLinear.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 535a3a5d00075854a98f71fdd486b248 +timeCreated: 1472620386 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs new file mode 100644 index 0000000..95d60f7 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs @@ -0,0 +1,387 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// + /// Rotates an object. + /// if no rotation field is defined, object rotation is based on the curve's tangent at current Cursor position. + /// If rotation field is used, 2 rotation values, taken from boundary points, are lerped by current Cursor position. + /// + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcCursorObjectRotate")] + [ + CcDescriptor( + Description = "Align the object's rotation with curve's tangent or 'rotation' field values at the point, the Cursor provides.", + Name = "Rotate Object By Cursor", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectRotate123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcRotateObject")] + [ExecuteInEditMode] + public class BGCcCursorObjectRotate : BGCcWithCursorObject + { + //=============================================================================================== + // Enums + //=============================================================================================== + /// Rotation interpolation between current rotation and target rotation + public enum RotationInterpolationEnum + { + None = 0, + Lerp = 1, + Slerp = 2, + } + + /// Up direction for target rotation. It's used only if rotationField is not assigned. + public enum RotationUpEnum + { + WorldUp = 0, + WorldCustom = 1, + + LocalUp = 2, + LocalCustom = 3, + + TargetParentUp = 4, + TargetParentUpCustom = 5, + } + + //=============================================================================================== + // Events + //=============================================================================================== + + /// object was rotated + public event EventHandler ChangedObjectRotation; + + + //=============================================================================================== + // Fields (persistent) + //=============================================================================================== + + //============================================= Common + [SerializeField] [Tooltip("Rotation interpolation mode.")] private RotationInterpolationEnum rotationInterpolation; + + [SerializeField] [Tooltip("Rotation Lerp rotationSpeed. (Quaternion.Lerp(from,to, lerpSpeed * Time.deltaTime)) ")] private float lerpSpeed = 5; + + [SerializeField] [Tooltip("Rotation Slerp rotationSpeed. (Quaternion.Slerp(from,to, slerpSpeed * Time.deltaTime)) ")] private float slerpSpeed = 5; + + [SerializeField] [Tooltip("Angle to add to final result.")] private Vector3 offsetAngle; + + //============================================= Tangent rotation + [SerializeField] [Tooltip("Up mode for tangent Quaternion.LookRotation. It's used only if rotationField is not assigned." + + "\r\n1) WorldUp - use Vector.up in world coordinates" + + "\r\n2) WorldCustom - use custom Vector in world coordinates" + + "\r\n3) LocalUp - use Vector.up in local coordinates " + + "\r\n4) LocalCustom - use custom Vector in local coordinates" + + "\r\n5) TargetParentUp - use Vector.up in target object parent's local coordinates" + + "\r\n6) TargetParentUpCustom- use custom Vector in target object parent's local coordinates" + )] private RotationUpEnum upMode = RotationUpEnum.WorldUp; + + [SerializeField] [Tooltip("Custom Up vector for tangent Quaternion.LookRotation. It's used only if rotationField is not assigned.")] private Vector3 upCustom = Vector3.up; + + //============================================= By field rotation + [SerializeField] [Tooltip("Field to store the rotation between each point. It should be a Quaternion field.")] private BGCurvePointField rotationField; + + [SerializeField] [Tooltip("Additional 360 degree revolutions around tangent. It's used only if rotationField is assigned. " + + "It can be overriden with 'int' revolutionsAroundTangentField field.")] private int revolutionsAroundTangent; + + [SerializeField] [Tooltip("Field to store additional 360 degree revolutions around tangent for each point. It's used only if rotationField is assigned. " + + "It should be an int field.")] private BGCurvePointField revolutionsAroundTangentField; + + [SerializeField] [Tooltip("By default revolutions around tangent is counter-clockwise. Set it to true to reverse direction. It's used only if rotationField is assigned." + + "It can be overriden with bool field")] private bool revolutionsClockwise; + + [SerializeField] [Tooltip("Field to store direction for revolutions around tangent. It should be an bool field. It's used only if rotationField is assigned.")] private BGCurvePointField + revolutionsClockwiseField; + + + /// Rotation interpolation between current rotation and target rotation + public RotationInterpolationEnum RotationInterpolation + { + get { return rotationInterpolation; } + set { ParamChanged(ref rotationInterpolation, value); } + } + + /// Rotation speed for Lerp rotation interpolation + public float LerpSpeed + { + get { return lerpSpeed; } + set { ParamChanged(ref lerpSpeed, value); } + } + + /// Rotation speed for Slerp rotation interpolation + public float SlerpSpeed + { + get { return slerpSpeed; } + set { ParamChanged(ref slerpSpeed, value); } + } + + /// Custom Up Vector(direction) for target rotaion + public Vector3 UpCustom + { + get { return upCustom; } + set { ParamChanged(ref upCustom, value); } + } + + /// Up mode for tangent rotation. It's used only if rotationField is not assigned. + public RotationUpEnum UpMode + { + get { return upMode; } + set { ParamChanged(ref upMode, value); } + } + + /// Rotation field to get rotation values from. It should be a Quaternion field + public BGCurvePointField RotationField + { + get { return rotationField; } + set { ParamChanged(ref rotationField, value); } + } + + /// Field for a number of full turnovers around tangent. It's used only if rotationField is assigned. It should be an int field + public BGCurvePointField RevolutionsAroundTangentField + { + get { return revolutionsAroundTangentField; } + set { ParamChanged(ref revolutionsAroundTangentField, value); } + } + + /// Number of full turnovers around tangent for each section.It's used only if rotationField is assigned. It can be overriden with RevolutionsAroundTangentField + public int RevolutionsAroundTangent + { + get { return revolutionsAroundTangent; } + set { ParamChanged(ref revolutionsAroundTangent, value); } + } + + /// Field for identifying if RevolutionsAroundTangent should be clockwise or counter clockwise.It's used only if rotationField is assigned. It should be an bool field + public BGCurvePointField RevolutionsClockwiseField + { + get { return revolutionsClockwiseField; } + set { ParamChanged(ref revolutionsClockwiseField, value); } + } + + /// Should RevolutionsAroundTangent be clockwise or counter clockwise. It's used only if rotationField is assigned. It can be overriden by RevolutionsClockwiseField + public bool RevolutionsClockwise + { + get { return revolutionsClockwise; } + set { ParamChanged(ref revolutionsClockwise, value); } + } + + /// offset to apply to final rotation + public Vector3 OffsetAngle + { + get { return offsetAngle; } + set { ParamChanged(ref offsetAngle, value); } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get + { + return ChoseMessage(base.Error, + () => + { + if (!Cursor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent)) + { + if (rotationField == null) return "Math should calculate tangents if rotation field is null."; + + if (RevolutionsAroundTangent != 0 || RevolutionsAroundTangentField != null) return "Math should calculate tangents if revolutions are used."; + } + + return null; + }); + } + } + + public override string Warning + { + get + { + return rotationField == null && (upMode == RotationUpEnum.TargetParentUp || upMode == RotationUpEnum.TargetParentUpCustom) + && ObjectToManipulate != null && ObjectToManipulate.parent == null + ? "Up Mode is set to " + upMode + ", however object's parent is null" + : null; + } + } + + public override bool SupportHandles + { + get { return true; } + } + + public override bool SupportHandlesSettings + { + get { return true; } + } + +#if UNITY_EDITOR + [Range(.5f, 1.5f)] [SerializeField] private float handlesScale = 1; + [SerializeField] private Color handlesColor = Color.white; + + public float HandlesScale + { + get { return handlesScale; } + set { handlesScale = value; } + } + + public Color HandlesColor + { + get { return handlesColor; } + set { handlesColor = value; } + } +#endif + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + //latest successfull rotation that was used + private Quaternion rotation = Quaternion.identity; + + /// latest successfull rotation that was used + public Quaternion Rotation + { + get { return rotation; } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + // Update is called once per frame + private void Update() + { + if (Curve.PointsCount == 0) return; + + var targetTransform = ObjectToManipulate; + if (targetTransform == null) return; + + if (!TryToCalculateRotation(ref rotation)) return; + + targetTransform.rotation = rotation; + + if (ChangedObjectRotation != null) ChangedObjectRotation(this, null); + } + + //=============================================================================================== + // Public Functions + //=============================================================================================== + /// Try to calculate target rotation at current Cursor positon + /// true if result was actually calculated and changed, false if calculation is failed + public bool TryToCalculateRotation(ref Quaternion result) + { + var pointsCount = Curve.PointsCount; + if (pointsCount == 0) return false; + + var cursor = Cursor; + var math = cursor.Math; + + if (rotationField == null) + { + // =============================================== By tangent + if (math == null || !math.IsCalculated(BGCurveBaseMath.Field.Tangent)) return false; + + if (pointsCount == 1) result = Quaternion.identity; + else + { + var tangent = cursor.CalculateTangent(); + if (Vector3.SqrMagnitude(tangent) < 0.01) return false; + + // up vector + Vector3 upwards; + switch (upMode) + { + case RotationUpEnum.WorldUp: + upwards = Vector3.up; + break; + case RotationUpEnum.WorldCustom: + upwards = upCustom; + break; + case RotationUpEnum.LocalUp: + upwards = transform.InverseTransformDirection(Vector3.up); + break; + case RotationUpEnum.LocalCustom: + upwards = transform.InverseTransformDirection(upCustom); + break; + default: + //TargetParentUp or TargetParentUpCustom + var targetTransform = ObjectToManipulate; + if (targetTransform.parent != null) + { + upwards = targetTransform.parent.InverseTransformDirection(upMode == RotationUpEnum.TargetParentUp ? Vector3.up : upCustom); + } + else + { + upwards = upMode == RotationUpEnum.TargetParentUp ? Vector3.up : upCustom; + } + break; + } + result = Quaternion.LookRotation(tangent, upwards); + } + } + else + { + // =============================================== By field + if (pointsCount == 1) result = Curve[0].GetQuaternion(rotationField.FieldName); + else + { + if (revolutionsAroundTangentField == null && revolutionsAroundTangent == 0) result = LerpQuaternion(rotationField.FieldName); //no compications + else + { + // there is possible revolutions involved- we need to check field if it exists + + //we need currentSection only if field is present + var currentSection = revolutionsAroundTangentField != null || revolutionsClockwiseField != null ? cursor.CalculateSectionIndex() : -1; + //rotaion without revolutoins + result = LerpQuaternion(rotationField.FieldName, currentSection); + + //do we have revolutions? + var additionalRevolutions = Mathf.Clamp( + revolutionsAroundTangentField != null + ? Curve[currentSection].GetInt(revolutionsAroundTangentField.FieldName) + : revolutionsAroundTangent + , 0, int.MaxValue); + + if (additionalRevolutions > 0 && math.IsCalculated(BGCurveBaseMath.Field.Tangent)) + { + //additional rotation around tangent is needed + var tangent = cursor.CalculateTangent(); + + if (Vector3.SqrMagnitude(tangent) > 0.01) + { + // targetAngle- target angle at t=1 + var targetAngle = 360*additionalRevolutions; + + //change if Clockwise + if (revolutionsClockwiseField != null ? Curve[currentSection].GetBool(revolutionsClockwiseField.FieldName) : revolutionsClockwise) targetAngle = -targetAngle; + + //calculate t ratio for lerping. 0- at start (from point), 1= at the end (to point) + int indexFrom, indexTo; + var t = GetT(out indexFrom, out indexTo, currentSection); + var angle = Mathf.Lerp(0, targetAngle, t); + + //sum up rotaitons + result = result*Quaternion.AngleAxis(angle, tangent); + } + } + } + } + } + + + // sum up rotations + result *= Quaternion.Euler(offsetAngle); + + // interpolation (rotation speed) + switch (rotationInterpolation) + { + case RotationInterpolationEnum.Lerp: + result = Quaternion.Lerp(ObjectToManipulate.rotation, rotation, lerpSpeed*Time.deltaTime); + break; + case RotationInterpolationEnum.Slerp: + result = Quaternion.Slerp(ObjectToManipulate.rotation, rotation, slerpSpeed*Time.deltaTime); + break; + } + + //success + return true; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs.meta new file mode 100644 index 0000000..8223ffa --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectRotate.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 23f6c63f13e40be449a87a9114fb11ff +timeCreated: 1471833132 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs new file mode 100644 index 0000000..6ab75a6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs @@ -0,0 +1,74 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Scale an object according to the cursor's position. Scale values are taken from a curve's Vector3 field + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcCursorObjectScale")] + [ + CcDescriptor( + Description = "Scale the object, according to cursor position. Scale values are taken from curve's field values.", + Name = "Scale Object By Cursor", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectScale123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcScaleObject")] + [ExecuteInEditMode] + public class BGCcCursorObjectScale : BGCcWithCursorObject + { + //=============================================================================================== + // Events + //=============================================================================================== + /// object was scaled + public event EventHandler ObjectScaled; + + //=============================================================================================== + // Fields(Persistent) + //=============================================================================================== + + [SerializeField] [Tooltip("Field to store the scale value at points. It should be a Vector3 field.")] private BGCurvePointField scaleField; + + public BGCurvePointField ScaleField + { + get { return scaleField; } + set { ParamChanged(ref scaleField, value); } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get { return ChoseMessage(base.Error, () => scaleField == null ? "Scale field is not defined." : null); } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + + // Update is called once per frame + private void Update() + { + if (ObjectToManipulate == null || scaleField == null) return; + + var pointsCount = Curve.PointsCount; + + switch (pointsCount) + { + case 0: + return; + case 1: + ObjectToManipulate.localScale = Curve[0].GetVector3(scaleField.FieldName); + break; + default: + var result = LerpVector(scaleField.FieldName); + if (float.IsNaN(result.x) || float.IsNaN(result.y) || float.IsNaN(result.z)) return; + + ObjectToManipulate.localScale = result; + + if (ObjectScaled != null) ObjectScaled(this, null); + break; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs.meta new file mode 100644 index 0000000..458366f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectScale.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f7dfbbb5e66f759498113fb337587365 +timeCreated: 1476113428 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs new file mode 100644 index 0000000..0398864 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs @@ -0,0 +1,54 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Components +{ + /// Moves an object to cursor's position + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcCursorObjectTranslate")] + [ + CcDescriptor( + Description = "Translate an object to the position, the cursor provides.", + Name = "Translate Object By Cursor", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcCursorObjectTranslate123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcTranslateObject")] + [ExecuteInEditMode] + public class BGCcCursorObjectTranslate : BGCcWithCursorObject + { + //=============================================================================================== + // Events + //=============================================================================================== + /// object was moved + public event EventHandler ObjectTranslated; + + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + // Update is called once per frame + private void Update() + { + var transformToMove = ObjectToManipulate; + + if (transformToMove == null) return; + + var pointsCount = Curve.PointsCount; + + switch (pointsCount) + { + case 0: + return; + case 1: + transformToMove.position = Curve[0].PositionWorld; + break; + default: + + transformToMove.position = Cursor.CalculatePosition(); + + if (ObjectTranslated != null) ObjectTranslated(this, null); + + break; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs.meta new file mode 100644 index 0000000..b4e0a89 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcCursorObjectTranslate.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9d916ef28168e544d9dc5bb790f67ba0 +timeCreated: 1471733597 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs new file mode 100644 index 0000000..e4f71fd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs @@ -0,0 +1,696 @@ +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.Events; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Math solver for the curve. + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcMath")] + [DisallowMultipleComponent] + [ + CcDescriptor( + Description = "Math solver for the curve (position, tangent, total distance, position by closest point). With this component you can use math functions.", + Name = "Math", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcMath123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcMath")] + public class BGCcMath : BGCc, BGCurveMathI + { + //=============================================================================================== + // Static + //=============================================================================================== + // maximum parts for Base math sectionParts parameter + private const int PartsMax = 100; + //reusable empty vertices array + private static readonly Vector3[] EmptyVertices = new Vector3[0]; + + //=============================================================================================== + // Enums + //=============================================================================================== + /// Type of approximation + public enum MathTypeEnum + { + /// Every spline's section will be split to even parts + Base, + + /// Every spline's section will be split to uneven parts, based on the spline's curvature + Adaptive + } + + /// How math should be updated + public enum UpdateModeEnum + { + /// Always update math then spline is changed + Always = 0, + + /// Update math only if Axis Aligned Bounding Box for the spline is visible + AabbVisible = 1, + + /// Update math only if some renderer is visible + RendererVisible = 2, + } + + //=============================================================================================== + // Events (Not persistent) + //=============================================================================================== + + /// if underlying math is recalculated + public event EventHandler ChangedMath; + + + //=============================================================================================== + // Fields (Persistent) + //=============================================================================================== + + //=========================================================== Fields to calculate + [SerializeField] [Tooltip("Which fields you want to use.")] private BGCurveBaseMath.Fields fields = BGCurveBaseMath.Fields.Position; + + + //=========================================================== Math type + [SerializeField] [Tooltip("Math type to use.\r\n" + + "Base - uses uniformely split sections;\r\n " + + "Adaptive - uses non-uniformely split sections, based on the curvature. Expiremental.")] private MathTypeEnum mathType; + + + //=========================================================== Base + + [SerializeField] [Tooltip("The number of equal parts for each section, used by Base math.")] [Range(1, PartsMax)] private int sectionParts = 30; + + [SerializeField] [Tooltip("Use only 2 points for straight lines. Tangents may be calculated slightly different. Used by Base math.")] private bool optimizeStraightLines; + + //=========================================================== Adaptive + [SerializeField] [Tooltip("Tolerance, used by Adaptive Math. The bigger the tolerance- the lesser splits. " + + "Note: The final tolerance used by Math is based on this value but different.")] [Range(BGCurveAdaptiveMath.MinTolerance, BGCurveAdaptiveMath.MaxTolerance)] private + float tolerance = .2f; + + //=========================================================== Common + [SerializeField] [Tooltip("Points position will be used for tangent calculation. This can gain some performance")] private bool usePositionToCalculateTangents; + + + //=========================================================== Update modes + [SerializeField] [Tooltip("Updating math takes some resources. You can fine-tune in which cases math is updated." + + "\r\n1) Always- always update" + + "\r\n2) AabbVisible- update only if AABB (Axis Aligned Bounding Box) around points and controls is visible" + + "\r\n3) RendererVisible- update only if some renderer is visible" + )] private UpdateModeEnum updateMode; + + [SerializeField] [Tooltip("Renderer to check for updating math. Math will be updated only if renderer is visible")] private Renderer rendererForUpdateCheck; + + //=========================================================== Persistent Event + [SerializeField] [Tooltip("Event is fired, then math is recalculated")] private MathChangedEvent mathChangedEvent = new MathChangedEvent(); + + + //--------------------------------------------------------------------------------------------- + + + /// Underlying math type + public MathTypeEnum MathType + { + get { return mathType; } + set { ParamChanged(ref mathType, value); } + } + + //=========================================================== Base + /// How many parts to use for splitting every spline's section for Base Math + public int SectionParts + { + get { return Mathf.Clamp(sectionParts, 1, PartsMax); } + set { ParamChanged(ref sectionParts, Mathf.Clamp(value, 1, PartsMax)); } + } + + /// Should we use 2 points for straight lines or should we split it to sectionParts. Used by Base math. + public bool OptimizeStraightLines + { + get { return optimizeStraightLines; } + set { ParamChanged(ref optimizeStraightLines, value); } + } + + //=========================================================== Adaptive + /// Tolerance parameter for Adaptive math. Note, the final value math uses is based on it but differs + public float Tolerance + { + get { return tolerance; } + set { ParamChanged(ref tolerance, value); } + } + + + //=========================================================== Common + /// Which fields to calculate + public BGCurveBaseMath.Fields Fields + { + get { return fields; } + set { ParamChanged(ref fields, value); } + } + + + public bool UsePositionToCalculateTangents + { + get { return usePositionToCalculateTangents; } + set { ParamChanged(ref usePositionToCalculateTangents, value); } + } + + + public UpdateModeEnum UpdateMode + { + get { return updateMode; } + set { ParamChanged(ref updateMode, value); } + } + + public Renderer RendererForUpdateCheck + { + get { return rendererForUpdateCheck; } + set { ParamChanged(ref rendererForUpdateCheck, value); } + } + + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get + { + return updateMode == UpdateModeEnum.RendererVisible && RendererForUpdateCheck == null + ? "Update mode is set to " + updateMode + ", however the RendererForUpdateCheck is null" + : null; + } + } + + public override string Warning + { + get + { + if (Curve.SnapType == BGCurve.SnapTypeEnum.Curve && Fields == BGCurveBaseMath.Fields.PositionAndTangent && !UsePositionToCalculateTangents) + return "Your curve's snap mode is Curve, and you are calculating tangents. However you use formula for tangents, instead of points positions." + + "This may result in wrong tangents. Set UsePositionToCalculateTangents to true."; + return null; + } + } + + public override string Info + { + get { return Math == null ? null : "Math uses " + Math.PointsCount + " points"; } + } + + public override bool SupportHandles + { + get { return true; } + } + + public override bool SupportHandlesSettings + { + get { return true; } + } + +#if UNITY_EDITOR + [Range(.5f, 1.5f)] [Tooltip("Spheres scale")] [SerializeField] private float spheresScale = 1; + [SerializeField] [Tooltip("Spheres color")] private Color spheresColor = Color.white; + [Range(2, 100)] [Tooltip("Maximum number of spheres. This parameter only affects how much points are shown in the Editor")] [SerializeField] private int spheresCount = 100; + + public float SpheresScale + { + get { return spheresScale; } + set { spheresScale = value; } + } + + public Color SpheresColor + { + get { return spheresColor; } + set { spheresColor = value; } + } + + public int SpheresCount + { + get { return spheresCount; } + set { spheresCount = value; } + } +#endif + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + // underlying math solver. + private BGCurveBaseMath math; + + // visibility checking Component. It uses standard Unity callbacks method to trace attached renderer visibility (AabbVisible and RendererVisible modes) + private VisibilityCheck visibilityCheck; + + // Mesh filter for generated mesh with 2 points for visibility check (AabbVisible mode) + private MeshFilter meshFilter; + // Reusable array for 2 points for visibility check (AabbVisible mode) + private readonly Vector3[] vertices = new Vector3[2]; + + /// Underlying math solver. You should not cache it, unless you are sure, mathType can not be changed at runtime. + public BGCurveBaseMath Math + { + get + { + if (math == null) InitMath(null, null); + return math; + } + } + + //is new math object is required? + private bool NewMathRequired + { + get + { + return math == null + || (mathType == MathTypeEnum.Base && math.GetType() != typeof(BGCurveBaseMath)) + || (mathType == MathTypeEnum.Adaptive && math.GetType() != typeof(BGCurveAdaptiveMath)); + } + } + + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + public override void Start() + { + Curve.Changed += SendEventsIfMathIsNotCreated; + } + + public override void OnDestroy() + { + if (math != null) + { + math.Changed -= MathWasChanged; + math.ChangeRequested -= MathOnChangeRequested; + math.Dispose(); + } + ChangedParams -= InitMath; + } + + //=============================================================================================== + // Public Functions + //=============================================================================================== + + /// By default math is created only if it's required. Call this method to ensure math is created + public void EnsureMathIsCreated() + { +#pragma warning disable 0168 + //ensure math exists + var temp = Math; +#pragma warning restore 0168 + } + + /// Recalculate internal caches. this is a costly operation + /// Ignore all checks and force recalculation at any rate + public void Recalculate(bool force = false) + { + Math.Recalculate(force); + } + + + //================================ Misc + /// Is given field is calculated? + public bool IsCalculated(BGCurveBaseMath.Field field) + { + var math = Math; + return math != null && math.IsCalculated(field); + } + + /// Clamp distance to valid range + public float ClampDistance(float distance) + { + var math = Math; + return distance < 0 ? 0 : (distance > math.GetDistance() ? math.GetDistance() : distance); + } + + + //================================ Total Distance + //see interface for comments + public float GetDistance() + { + return Math.GetDistance(); + } + + + //================================ Calc by ratio + //see interface for comments + public Vector3 CalcByDistanceRatio(BGCurveBaseMath.Field field, float ratio, bool useLocal = false) + { + return Math.CalcByDistanceRatio(field, ratio, useLocal); + } + + //see interface for comments + public Vector3 CalcByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false) + { + return Math.CalcByDistanceRatio(distanceRatio, out tangent, useLocal); + } + + //see interface for comments + public Vector3 CalcPositionByDistanceRatio(float ratio, bool useLocal = false) + { + return Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, ratio, useLocal); + } + + //see interface for comments + public Vector3 CalcTangentByDistanceRatio(float ratio, bool useLocal = false) + { + return Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Tangent, ratio, useLocal); + } + + //see interface for comments + public Vector3 CalcPositionAndTangentByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false) + { + return Math.CalcPositionAndTangentByDistanceRatio(distanceRatio, out tangent, useLocal); + } + + //================================ Calc by distance + //see interface for comments + public Vector3 CalcByDistance(BGCurveBaseMath.Field field, float distance, bool useLocal = false) + { + return Math.CalcByDistance(field, distance, useLocal); + } + + //see interface for comments + public Vector3 CalcByDistance(float distance, out Vector3 tangent, bool useLocal = false) + { + return Math.CalcByDistance(distance, out tangent, useLocal); + } + + //see interface for comments + public Vector3 CalcPositionByDistance(float distance, bool useLocal = false) + { + return Math.CalcByDistance(BGCurveBaseMath.Field.Position, distance, useLocal); + } + + //see interface for comments + public Vector3 CalcTangentByDistance(float distance, bool useLocal = false) + { + return Math.CalcByDistance(BGCurveBaseMath.Field.Tangent, distance, useLocal); + } + + //see interface for comments + public Vector3 CalcPositionAndTangentByDistance(float distance, out Vector3 tangent, bool useLocal = false) + { + return Math.CalcPositionAndTangentByDistance(distance, out tangent, useLocal); + } + + /// Access calculated section's data by index + public BGCurveBaseMath.SectionInfo this[int i] + { + get { return Math[i]; } + } + + + //================================ Calc by closest point + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, out Vector3 tangent, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + return Math.CalcPositionByClosestPoint(point, out distance, out tangent, skipSectionsOptimization, skipPointsOptimization); + } + + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + return Math.CalcPositionByClosestPoint(point, out distance, skipSectionsOptimization, skipPointsOptimization); + } + + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + return Math.CalcPositionByClosestPoint(point, skipSectionsOptimization, skipPointsOptimization); + } + + //================================ Calc section index + //see interface for comments + public int CalcSectionIndexByDistance(float distance) + { + return Math.CalcSectionIndexByDistance(distance); + } + + //see interface for comments + public int CalcSectionIndexByDistanceRatio(float distanceRatio) + { + return Math.CalcSectionIndexByDistanceRatio(distanceRatio); + } + + + //=============================================================================================== + // Private Functions + //=============================================================================================== + //we do not have to create a math implementation until it's needed, but we have to trace spline's changes and fire events + private void SendEventsIfMathIsNotCreated(object sender, BGCurveChangedArgs e) + { + //no more need to trace changes, since math is tracing it by itself + if (math != null) Curve.Changed -= SendEventsIfMathIsNotCreated; + //implementation is not created yet, but we need to fire events to indicate math 'would be' changed if it is created + else MathWasChanged(sender, e); + } + + //init math with current params + private void InitMath(object sender, EventArgs e) + { + //new config + var config = mathType == MathTypeEnum.Adaptive + ? new BGCurveAdaptiveMath.ConfigAdaptive(fields) {Tolerance = tolerance} + : new BGCurveBaseMath.Config(fields) {Parts = sectionParts}; + + config.UsePointPositionsToCalcTangents = usePositionToCalculateTangents; + config.OptimizeStraightLines = optimizeStraightLines; + config.Fields = fields; + + if (updateMode != UpdateModeEnum.Always && Application.isPlaying) + { + switch (updateMode) + { + case UpdateModeEnum.AabbVisible: + InitAabbVisibleBefore(config); + break; + case UpdateModeEnum.RendererVisible: + InitRendererVisible(config); + break; + } + } + + if (NewMathRequired) + { + //we need to create new math object + + var mathWasNull = math == null; + + if (mathWasNull) ChangedParams += InitMath; + else + { + math.ChangeRequested -= MathOnChangeRequested; + math.Changed -= MathWasChanged; + math.Dispose(); + } + + switch (MathType) + { + case MathTypeEnum.Base: + math = new BGCurveBaseMath(Curve, config); + break; + default: + // case MathTypeEnum.Adaptive: + math = new BGCurveAdaptiveMath(Curve, (BGCurveAdaptiveMath.ConfigAdaptive) config); + break; + } + + + math.Changed += MathWasChanged; + + if (!mathWasNull) MathWasChanged(this, null); + } + else + { + //we can reuse existing math object + + math.ChangeRequested -= MathOnChangeRequested; + //reinit math with new params (it will be recalculated as result) + math.Init(config); + } + + //init AABB + if (updateMode == UpdateModeEnum.AabbVisible) InitAabbVisibleAfter(); + } + + //before math was created (or inited) + private void InitAabbVisibleBefore(BGCurveBaseMath.Config config) + { + if (!Application.isPlaying) return; + + if (meshFilter != null) Destroy(meshFilter.gameObject); + + var aabbGameObject = new GameObject("AabbBox"); + aabbGameObject.transform.parent = transform; + var renderer = aabbGameObject.AddComponent(); + meshFilter = aabbGameObject.AddComponent(); + meshFilter.mesh = new Mesh(); + InitVisibilityCheck(config, renderer); + + MathOnChangeRequested(this, null); + } + + //after math was created (or inited) + private void InitAabbVisibleAfter() + { + if (!Application.isPlaying) return; + + math.ChangeRequested += MathOnChangeRequested; + } + + //math received change request (but not changed yet). This callback is called only if updateMode=UpdateModeEnum.AabbVisible + private void MathOnChangeRequested(object sender, EventArgs eventArgs) + { + if (!Application.isPlaying) return; + + // if visibilityCheck is not inited or the mesh is already visible, we dont need to recalculate the mesh + if (visibilityCheck == null || visibilityCheck.Visible) return; + + // here we should construct a mesh with 2 points (min to max), so Unity calls its OnBecameVisible OnBecameInvisible callbacks + // I'm not sure how fast it is, but it (probably) should be faster than calculating it manually without this mesh + var points = Curve.Points; + var mesh = meshFilter.sharedMesh; + + switch (points.Length) + { + case 0: + mesh.vertices = EmptyVertices; + break; + case 1: + vertices[0] = points[0].PositionWorld; + vertices[1] = vertices[0]; + mesh.vertices = vertices; + break; + default: + var matrix = transform.localToWorldMatrix; + var firstPoint = points[0].PositionWorld; + var pointsCount = points.Length; + var lastPointIndex = pointsCount - 1; + var closed = Curve.Closed; + + var min = firstPoint; + var max = firstPoint; + for (var i = 0; i < pointsCount; i++) + { + var point = points[i]; + var posLocal = point.PositionLocal; + var posWorld = matrix.MultiplyPoint(posLocal); + + //copy/pasted for the sake of performance + if (min.x > posWorld.x) min.x = posWorld.x; + if (min.y > posWorld.y) min.y = posWorld.y; + if (min.z > posWorld.z) min.z = posWorld.z; + + if (max.x < posWorld.x) max.x = posWorld.x; + if (max.y < posWorld.y) max.y = posWorld.y; + if (max.z < posWorld.z) max.z = posWorld.z; + + if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + { + if (closed || i != 0) + { + var controlWorld = matrix.MultiplyPoint(point.ControlFirstLocal + posLocal); + + //copy/pasted for the sake of performance + if (min.x > controlWorld.x) min.x = controlWorld.x; + if (min.y > controlWorld.y) min.y = controlWorld.y; + if (min.z > controlWorld.z) min.z = controlWorld.z; + + if (max.x < controlWorld.x) max.x = controlWorld.x; + if (max.y < controlWorld.y) max.y = controlWorld.y; + if (max.z < controlWorld.z) max.z = controlWorld.z; + } + if (closed || i != lastPointIndex) + { + var controlWorld = matrix.MultiplyPoint(point.ControlSecondLocal + posLocal); + + //copy/pasted for the sake of performance + if (min.x > controlWorld.x) min.x = controlWorld.x; + if (min.y > controlWorld.y) min.y = controlWorld.y; + if (min.z > controlWorld.z) min.z = controlWorld.z; + + if (max.x < controlWorld.x) max.x = controlWorld.x; + if (max.y < controlWorld.y) max.y = controlWorld.y; + if (max.z < controlWorld.z) max.z = controlWorld.z; + } + } + } + + vertices[0] = min; + vertices[1] = max; + + mesh.vertices = vertices; + break; + } + } + + + //setup renderer visible option for update mode + private void InitRendererVisible(BGCurveBaseMath.Config config) + { + InitVisibilityCheck(config, RendererForUpdateCheck); + } + + //attach visibility check component to target GameObject (the one, the renderer is attached to) + private void InitVisibilityCheck(BGCurveBaseMath.Config config, Renderer renderer) + { + if (visibilityCheck != null) + { + visibilityCheck.BecameVisible -= BecameVisible; + Destroy(visibilityCheck); + } + + if (renderer == null) return; + + visibilityCheck = renderer.gameObject.AddComponent(); + + visibilityCheck.BecameVisible += BecameVisible; + + config.ShouldUpdate = () => visibilityCheck.Visible; + } + + //became visible callback for use with VisibilityCheck Component + private void BecameVisible(object sender, EventArgs e) + { + math.Configuration.FireUpdate(); + } + + //math was changed callback + private void MathWasChanged(object sender, EventArgs e) + { + if (ChangedMath != null) ChangedMath(this, null); + + if (mathChangedEvent.GetPersistentEventCount() > 0) mathChangedEvent.Invoke(); + } + + //=============================================================================================== + // Private classes + //=============================================================================================== + //it's used for visibility checks + private sealed class VisibilityCheck : MonoBehaviour + { + //Fired when became visible + public event EventHandler BecameVisible; + + /// Is currently visible + public bool Visible { get; private set; } + + //================================== Unity Callbacks + private void OnBecameVisible() + { + Visible = true; + if (BecameVisible != null) BecameVisible(this, null); + } + + private void OnBecameInvisible() + { + Visible = false; + } + } + + //=============================================================================================== + // Unity Persistent Event + //=============================================================================================== + [Serializable] + public class MathChangedEvent : UnityEvent + { + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs.meta new file mode 100644 index 0000000..a94ab97 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b6d20671ad38ded4fa2362df353b9a31 +timeCreated: 1471598370 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs new file mode 100644 index 0000000..afeb610 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs @@ -0,0 +1,567 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// + /// Splits the curve to single line. This class does not change anything except providing point's positions. + /// Subclasses, like BGCcVisualizationLineRenderer or BGCcTriangulate2D uses this data for their own purposes. + /// + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcSplitterPolyline")] + [ + CcDescriptor( + Description = "Calculates points positions for polyline along the curve. It does not change or modify anything. Use Positions field to access points.", + Name = "Splitter Polyline", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcSplitterPolyline123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcSplitterPolyline")] + public class BGCcSplitterPolyline : BGCcWithMath + { + //=============================================================================================== + // Events + //=============================================================================================== + /// ui updated + public event EventHandler ChangedPositions; + + + //=============================================================================================== + // Enums + //=============================================================================================== + /// Split mode + public enum SplitModeEnum + { + /// Math precalculated data is reused + UseMathData = 0, + + /// Use specified number of parts for whole spline + PartsTotal = 1, + + /// Use specified number of parts for each spline's section + PartsPerSection = 2 + } + + //=============================================================================================== + // Fields (Persistent) + //=============================================================================================== + [SerializeField] [Tooltip("How to split the curve. " + + "TotalSections -total sections for whole curve;\r\n " + + "PartSections - each part (between 2 points) will use the same amount of splits;\r\n" + + "UseMathData -use data, precalculated by Math component. " + + "Note, you can tweak some params at Math as well.")] private SplitModeEnum splitMode = SplitModeEnum.UseMathData; + + [SerializeField] [Range(1, 1000)] [Tooltip("Total number of parts to split a curve to. " + + "The actual number of parts can be less than partsTotal due to optimization, but never more.")] private int partsTotal = 30; + + + [SerializeField] [Range(1, 150)] [Tooltip("Every section of the curve will be split on even parts. " + + "The actual number of parts can be less than partsPerSection due to optimization, but never more.")] private int partsPerSection = 30; + + [SerializeField] [Tooltip("Split straight lines. Straight lines are optimized by default and are not split.")] private bool doNotOptimizeStraightLines; + + [SerializeField] [Tooltip("By default positions in world coordinates. Set this parameter to true to use local coordinates. " + + "Local coordinates are calculated slower.")] protected bool useLocal; + + + /// Split mode + public SplitModeEnum SplitMode + { + get { return splitMode; } + set { ParamChanged(ref splitMode, value); } + } + + /// Number of parts for PartsTotal splitMode + public int PartsTotal + { + get { return Mathf.Clamp(partsTotal, 1, 1000); } + //idea.. we may skip updateui if splitmode is not PartsTotal + set { ParamChanged(ref partsTotal, Mathf.Clamp(value, 1, 1000)); } + } + + /// Number of parts for PartsPerSection splitMode + public int PartsPerSection + { + get { return Mathf.Clamp(partsPerSection, 1, 150); } + //idea.. we may skip updateui if splitmode is not PartsPerSection + set { ParamChanged(ref partsPerSection, Mathf.Clamp(value, 1, 150)); } + } + + + /// skip straight lines optimization. Used by Base Math + public bool DoNotOptimizeStraightLines + { + get { return doNotOptimizeStraightLines; } + set { ParamChanged(ref doNotOptimizeStraightLines, value); } + } + + /// Use local coordinates instead of world for positions + public virtual bool UseLocal + { + get { return useLocal; } + set { ParamChanged(ref useLocal, value); } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Warning + { + get + { + var math = Math; + var warning = ""; + + if (math == null) return warning; + + //check math precision + switch (SplitMode) + { + case SplitModeEnum.PartsTotal: + + var curvedSectionsCount = math.Math.SectionsCount - (DoNotOptimizeStraightLines ? 0 : CountStraightLines(Math.Math, null)); + var partsForCurved = curvedSectionsCount == 0 ? 0 : PartsTotal/curvedSectionsCount; + + if (partsForCurved > math.SectionParts) + warning = "Math use less parts per section (" + math.SectionParts + "). You now use " + partsForCurved + + " parts for curved section. You need to increase Math's 'SectionParts' field accordingly to increase polyline precision."; + break; + case SplitModeEnum.PartsPerSection: + + if (PartsPerSection > math.SectionParts) + warning = "Math use less parts per section (" + math.SectionParts + "). You need to increase Math's 'SectionParts' field accordingly to increase polyline precision."; + + break; + } + return warning; + } + } + + public override string Info + { + get { return "Polyline has " + PointsCount + " points"; } + } + + + public override bool SupportHandles + { + get { return true; } + } + + public override bool SupportHandlesSettings + { + get { return true; } + } + +#if UNITY_EDITOR + [Range(.5f, 1.5f)] [Tooltip("Spheres scale")] [SerializeField] private float spheresScale = 1; + [SerializeField] [Tooltip("Spheres color")] private Color spheresColor = Color.white; + [Range(2, 100)] [Tooltip("Maximum number of spheres. This parameter only affects how much points are shown in the Editor")] [SerializeField] private int spheresCount = 100; + + public float SpheresScale + { + get { return spheresScale; } + set { spheresScale = value; } + } + + public Color SpheresColor + { + get { return spheresColor; } + set { spheresColor = value; } + } + + public int SpheresCount + { + get { return spheresCount; } + set { spheresCount = value; } + } +#endif + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + + //do not remove readonly. Reusable positions list, storing last calculated positions + protected readonly List positions = new List(); + //if current data valid? + private bool dataValid; + //reusable array, storing if section is straight. + private bool[] straightBits; + + + //different providers for different modes + private PositionsProvider positionsProvider; + + + /// latest points count. It's not getting updated until it's queried + public int PointsCount + { + get + { + if (!dataValid) UpdateData(); + return positions == null ? 0 : positions.Count; + } + } + + /// latest points positions used. It's not getting updated until it's queried + public List Positions + { + get + { + if (!dataValid) UpdateData(); + return positions; + } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + public override void Start() + { + AddListeners(); + } + + public override void OnDestroy() + { + RemoveListeners(); + } + + //=============================================================================================== + // Public methods + //=============================================================================================== + /// init all listeners for math and it's own params + public void AddListeners() + { + //monitor underlying math changes + Math.ChangedMath -= UpdateRequested; + Math.ChangedMath += UpdateRequested; + + //monitor own params + ChangedParams -= UpdateRequested; + ChangedParams += UpdateRequested; + } + + /// mark data as invalid + public void InvalidateData() + { + dataValid = false; + if (ChangedPositions != null) ChangedPositions(this, null); + } + + /// remove attached listeners + public void RemoveListeners() + { + try + { + Math.ChangedMath -= UpdateRequested; + ChangedParams -= UpdateRequested; + } + catch (MissingReferenceException) + { + } + } + + + //=============================================================================================== + // Private methods + //=============================================================================================== + //refresh data + private void UpdateData() + { + dataValid = true; + + + Transform myTransform; + try + { + myTransform = transform; + } + catch (MissingReferenceException) + { + RemoveListeners(); + return; + } + + + var noData = true; + + //have no idea how to cope with UndoRedo + try + { + noData = Math == null || Math.Math == null || Math.Math.SectionsCount == 0; + } + catch (MissingReferenceException) + { + } + + positions.Clear(); + if (noData) return; + + var baseMath = Math.Math; + var sectionsCount = baseMath.SectionsCount; + + //count number of straight lines + var straightLinesCount = 0; + if (!doNotOptimizeStraightLines) + { + //resize only if length < sectionsCount to reduce GC + if (straightBits == null || straightBits.Length < sectionsCount) Array.Resize(ref straightBits, sectionsCount); + straightLinesCount = CountStraightLines(baseMath, straightBits); + } + + //recalculate points + InitProvider(ref positionsProvider, this).Build(positions, straightLinesCount, straightBits); + + + if (!UseLocal) return; + + //slow convertion (world->local) + var matrix = myTransform.worldToLocalMatrix; + var count = positions.Count; + for (var i = 0; i < count; i++) positions[i] = matrix.MultiplyPoint(positions[i]); + } + + + //curve was updated + protected virtual void UpdateRequested(object sender, EventArgs e) + { + InvalidateData(); + } + + //init required provider. Each mode has it's own provider + private static PositionsProvider InitProvider(ref PositionsProvider positionsProvider, BGCcSplitterPolyline cc) + { + //assign positions provider if needed + var mode = cc.splitMode; + var providerObsolete = positionsProvider == null || !positionsProvider.Comply(mode); + switch (mode) + { + case SplitModeEnum.PartsTotal: + if (providerObsolete) positionsProvider = new PositionsProviderTotalParts(); + ((PositionsProviderTotalParts) positionsProvider).Init(cc.Math, cc.PartsTotal); + break; + case SplitModeEnum.PartsPerSection: + if (providerObsolete) positionsProvider = new PositionsProviderPartsPerSection(); + ((PositionsProviderPartsPerSection) positionsProvider).Init(cc.Math, cc.PartsPerSection); + break; + default: + // case SplitModeEnum.UseMathData: + if (providerObsolete) positionsProvider = new PositionsProviderMath(); + ((PositionsProviderMath) positionsProvider).Init(cc.Math); + break; + } + return positionsProvider; + } + + //count the number of straight lines + public static int CountStraightLines(BGCurveBaseMath math, bool[] straight) + { + var curve = math.Curve; + var points = curve.Points; + if (points.Length == 0) return 0; + + var sections = math.SectionInfos; + var sectionsCount = sections.Count; + var fillArray = straight != null; + + var straightLinesCount = 0; + var previousControlAbsent = points[0].ControlType == BGCurvePoint.ControlTypeEnum.Absent; + for (var i = 0; i < sectionsCount; i++) + { + var nextPoint = curve.Closed && i == sectionsCount - 1 ? points[0] : points[i + 1]; + var nextControlAbsent = nextPoint.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + + if (previousControlAbsent && nextControlAbsent) + { + if (fillArray) straight[i] = true; + straightLinesCount++; + } + else if (fillArray) straight[i] = false; + + previousControlAbsent = nextControlAbsent; + } + return straightLinesCount; + } + + + //=============================================================================================== + // Helper classes + //=============================================================================================== + + //============================================= Abstract provider + /// Abstract provider + public abstract class PositionsProvider + { + //used math + protected BGCcMath Math; + + protected virtual void InitInner(BGCcMath math) + { + Math = math; + } + + /// if this provider can build points for the given mode + public abstract bool Comply(SplitModeEnum splitMode); + + /// calculate points fro polyline + public virtual void Build(List positions, int straightLinesCount, bool[] straightBits) + { + var math = Math.Math; + + var sections = math.SectionInfos; + var sectionsCount = sections.Count; + + + //first point always present + positions.Add(math[0][0].Position); + + //fill in points + if (straightLinesCount == 0) for (var i = 0; i < sectionsCount; i++) FillInSplitSection(sections[i], positions); + else + { + for (var i = 0; i < sectionsCount; i++) + { + var section = sections[i]; + + if (straightBits[i]) positions.Add(section[section.PointsCount - 1].Position); + else FillInSplitSection(section, positions); + } + } + } + + // add points for a section by a given number of points + protected static void FillIn(BGCurveBaseMath.SectionInfo section, List result, int parts) + { + var onePartDistance = section.Distance/parts; + for (var j = 1; j <= parts; j++) + { + Vector3 tangent; + Vector3 pos; + section.CalcByDistance(onePartDistance*j, out pos, out tangent, true, false); + result.Add(pos); + } + } + + // add points for a split section + protected abstract void FillInSplitSection(BGCurveBaseMath.SectionInfo section, List result); + } + + //============================================= Provider for total parts mode + /// Provider for total parts mode + public sealed class PositionsProviderTotalParts : PositionsProvider + { + private int parts; + private int reminderForCurved; + private int partsPerSectionFloor; + + + public void Init(BGCcMath math, int parts) + { + InitInner(math); + + this.parts = parts; + } + + public override bool Comply(SplitModeEnum splitMode) + { + return splitMode == SplitModeEnum.PartsTotal; + } + + public override void Build(List positions, int straightLinesCount, bool[] straightBits) + { + var curve = Math.Curve; + var sections = Math.Math.SectionInfos; + var sectionsCount = sections.Count; + + //at least one section is curved (maxParts>=sectionsCount, so floatParts >=1) + var floatParts = (parts - straightLinesCount)/(float) (sectionsCount - straightLinesCount); + + reminderForCurved = (int) ((parts - straightLinesCount)%(float) (sectionsCount - straightLinesCount)); + partsPerSectionFloor = Mathf.FloorToInt(floatParts); + + + if (parts < sectionsCount) + { + if (parts == 1) + { + //only one part per whole curve (one->last) + positions.Add(sections[0][0].Position); + positions.Add(curve.Closed ? Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, .5f) : sections[sectionsCount - 1][sections[sectionsCount - 1].PointsCount - 1].Position); + } + else if (parts == 2 && curve.Closed) + { + positions.Add(sections[0][0].Position); + positions.Add(Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, .3333f)); + positions.Add(Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, .6667f)); + } + else for (var i = 0; i <= parts; i++) positions.Add(Math.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, i/(float) parts)); + } + else base.Build(positions, straightLinesCount, straightBits); + } + + // add points for a split section + protected override void FillInSplitSection(BGCurveBaseMath.SectionInfo section, List result) + { + //curved + var partsForSection = partsPerSectionFloor; + if (reminderForCurved > 0) + { + partsForSection++; + reminderForCurved--; + } + + FillIn(section, result, partsForSection); + } + } + + //============================================= Provider for parts per section mode + + /// Provider for parts per section mode + public sealed class PositionsProviderPartsPerSection : PositionsProvider + { + private int parts; + + public void Init(BGCcMath math, int partsPerSection) + { + InitInner(math); + parts = partsPerSection; + } + + public override bool Comply(SplitModeEnum splitMode) + { + return splitMode == SplitModeEnum.PartsPerSection; + } + + // add points for a split section + protected override void FillInSplitSection(BGCurveBaseMath.SectionInfo section, List result) + { + FillIn(section, result, parts); + } + } + + //============================================= Provider for useMath mode + + /// Provider for useMath mode + public sealed class PositionsProviderMath : PositionsProvider + { + public void Init(BGCcMath ccMath) + { + InitInner(ccMath); + } + + public override bool Comply(SplitModeEnum splitMode) + { + return splitMode == SplitModeEnum.UseMathData; + } + + // add points for a split section + protected override void FillInSplitSection(BGCurveBaseMath.SectionInfo section, List result) + { + var sectionPoints = section.Points; + var count = sectionPoints.Count; + + for (var j = 1; j < count; j++) result.Add(sectionPoints[j].Position); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs.meta new file mode 100644 index 0000000..b8d137e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcSplitterPolyline.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 62cd433e62a5ee04c956c0f388f66df1 +timeCreated: 1474931604 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs new file mode 100644 index 0000000..cd7e82c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs @@ -0,0 +1,404 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Triangulate 2D spline. Currently only simple polygons are supported + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcTriangulate2D")] + [DisallowMultipleComponent] + [ + CcDescriptor( + Description = "Triangulate 2D spline. Currently only simple polygons are supported.", + Name = "Triangulate 2D", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcTriangulate2D123.png") + ] + [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcTriangulate2D")] + [ExecuteInEditMode] + public class BGCcTriangulate2D : BGCcSplitterPolyline + { + //=============================================================================================== + // Static + //=============================================================================================== + //min scale for UV + private const float MinUvScale = 0.000001f; + //max scale for UV + private const float MaxUvScale = 1000000; + + //temp List to avoid GC (it's used by traingulation algorithm) + private static readonly List V = new List(); + + //=============================================================================================== + // Fields (Persistent) + //=============================================================================================== + + [SerializeField] [Tooltip("UV scale")] private Vector2 scaleUV = new Vector2(1, 1); + [SerializeField] [Tooltip("UV offset")] private Vector2 offsetUV = new Vector2(0, 0); + [SerializeField] [Tooltip("Flip triangles")] private bool flip; + [SerializeField] [Tooltip("Double sided")] private bool doubleSided; + [SerializeField] [Tooltip("UV scale for back side")] private Vector2 scaleBackUV = new Vector2(1, 1); + [SerializeField] [Tooltip("UV offset for back side")] private Vector2 offsetBackUV = new Vector2(0, 0); + [SerializeField] [Tooltip("Update mesh every frame, even if curve's not changed. This can be useful, if UVs are animated.")] private bool updateEveryFrame; + + + //the number of frame, last triangulation was build + private int updateAtFrame; + + //keeps track about running Coroutine for every frame update + private bool everyFrameUpdateIsRunning; + + /// Scale all UV values + public Vector2 ScaleUv + { + get { return scaleUV; } + set + { + if (Mathf.Abs(scaleUV.x - value.x) < BGCurve.Epsilon && Mathf.Abs(scaleUV.y - value.y) < BGCurve.Epsilon) return; + ParamChanged(ref scaleUV, value); + } + } + + /// Should faces be flipped + public bool Flip + { + get { return flip; } + set + { + if (flip == value) return; + ParamChanged(ref flip, value); + } + } + + /// Generate triangles for backside + public bool DoubleSided + { + get { return doubleSided; } + set { ParamChanged(ref doubleSided, value); } + } + + /// Should triangulation occur every frame even if curve is not changed + public bool UpdateEveryFrame + { + get { return updateEveryFrame; } + set + { + if (updateEveryFrame == value) return; + updateEveryFrame = value; + ParamChanged(ref updateEveryFrame, value); + + if (updateEveryFrame && !everyFrameUpdateIsRunning && gameObject.activeSelf && Application.isPlaying) StartCoroutine(UiUpdater()); + } + } + + // override parent UseLocal to be always true. I doubt, there is any way to use world's coordinates for meshes (like local for LineRenderer) + public override bool UseLocal + { + get { return true; } + set { } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + + public override string Error + { + get { return !Curve.Mode2DOn ? "Curve should be in 2D mode" : null; } + } + + public override string Info + { + get { return "Mesh uses " + vertices.Count + " vertices and " + (triangles.Count / 3) + " triangles."; } + } + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + + [NonSerialized] private MeshFilter meshFilter; + [NonSerialized] private readonly List vertices = new List(); + [NonSerialized] private readonly List points = new List(); + [NonSerialized] private readonly List uvs = new List(); + [NonSerialized] private readonly List triangles = new List(); + + + + public MeshFilter MeshFilter + { + get + { + //do not replace with ?? + if (meshFilter == null) meshFilter = GetComponent(); + return meshFilter; + } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + + public override void Start() + { + base.Start(); + if (MeshFilter.sharedMesh == null) UpdateUI(); + + if (updateEveryFrame && gameObject.activeSelf && Application.isPlaying) StartCoroutine(UiUpdater()); + } + + void OnEnable() + { + if (updateEveryFrame && !everyFrameUpdateIsRunning && Application.isPlaying) StartCoroutine(UiUpdater()); + } + + void OnDisable() + { + if (updateEveryFrame && everyFrameUpdateIsRunning && Application.isPlaying) everyFrameUpdateIsRunning = false; + } + + //=============================================================================================== + // Public Functions + //=============================================================================================== + public void UpdateUI() + { + updateAtFrame = Time.frameCount; + + if (!Curve.Mode2DOn) return; + + var mode2D = Curve.Mode2D; + + var positions = Positions; + + var positionsCount = positions.Count; + //I dont know why, but triangulator works wrong in case first pos= last pos + if (Curve.Closed) positionsCount--; + + MeshFilter meshFilter; + try + { + meshFilter = MeshFilter; + } + catch (MissingReferenceException) + { + RemoveListeners(); + return; + } + var mesh = meshFilter.sharedMesh; + if (mesh == null) + { + mesh = new Mesh(); + meshFilter.mesh = mesh; + } + + vertices.Clear(); + triangles.Clear(); + uvs.Clear(); + if (positionsCount > 2) + { + //we need to triangulate + points.Clear(); + var minMax = new Vector4(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue); + for (var i = 0; i < positionsCount; i++) + { + var pos = positions[i]; + + Vector3 vert; + Vector2 point; + switch (mode2D) + { + case BGCurve.Mode2DEnum.XY: + vert = new Vector3(pos.x, pos.y); + point = new Vector2(pos.x, pos.y); + break; + case BGCurve.Mode2DEnum.XZ: + vert = new Vector3(pos.x, 0, pos.z); + point = new Vector2(pos.x, pos.z); + break; + default: + // case BGCurve.Mode2DEnum.YZ: + vert = new Vector3(0, pos.y, pos.z); + point = new Vector2(pos.y, pos.z); + break; + } + vertices.Add(vert); + points.Add(point); + + //min + if (point.x < minMax.x) minMax.x = point.x; + if (point.y < minMax.y) minMax.y = point.y; + //max + if (point.x > minMax.z) minMax.z = point.x; + if (point.y > minMax.w) minMax.w = point.y; + } + + //tris + Triangulate(points, triangles); + if (!flip) triangles.Reverse(); + + //uvs + var width = minMax.z - minMax.x; + var height = minMax.w - minMax.y; + var pointsCount = points.Count; + var scaleX = Mathf.Clamp(scaleUV.x, MinUvScale, MaxUvScale); + var scaleY = Mathf.Clamp(scaleUV.y, MinUvScale, MaxUvScale); + for (var i = 0; i < pointsCount; i++) + { + var point = points[i]; + uvs.Add(new Vector2(offsetUV.x + ((point.x - minMax.x) / width) * scaleX, offsetUV.y + ((point.y - minMax.y) / height) * scaleY)); + } + + // doubleSided + if (doubleSided) + { + //add points, we can not reuse the same points, cause we need unique UVs + var verticesCount = vertices.Count; + for (var i = 0; i < verticesCount; i++) vertices.Add(vertices[i]); + + //add triangles + var trianglesCount = triangles.Count; + for (var i = trianglesCount - 1; i >= 0; i--) triangles.Add(triangles[i] + verticesCount); + + //uvs + scaleX = Mathf.Clamp(scaleBackUV.x, MinUvScale, MaxUvScale); + scaleY = Mathf.Clamp(scaleBackUV.y, MinUvScale, MaxUvScale); + for (var i = 0; i < pointsCount; i++) + { + var point = points[i]; + uvs.Add(new Vector2(offsetBackUV.x + ((point.x - minMax.x) / width) * scaleX, offsetBackUV.y + ((point.y - minMax.y) / height) * scaleY)); + } + } + } + + mesh.Clear(); + mesh.SetVertices(vertices); + mesh.SetTriangles(triangles, 0); + mesh.SetUVs(0, uvs); + mesh.RecalculateNormals(); + } + + //=============================================================================================== + // Private Functions + //=============================================================================================== + // curve's changed + protected override void UpdateRequested(object sender, EventArgs e) + { + base.UpdateRequested(sender, e); + UpdateUI(); + } + + private IEnumerator UiUpdater() + { + everyFrameUpdateIsRunning = true; + while (updateEveryFrame) + { + if (updateAtFrame != Time.frameCount) UpdateUI(); + yield return null; + } + + everyFrameUpdateIsRunning = false; + } + + + //==================================== This code from http://wiki.unity3d.com/index.php?title=Triangulator + // Triangulate simple polygon. I have no idea how good this algorithm is and what it's actually doing + private static void Triangulate(List points, List tris) + { + tris.Clear(); + + int n = points.Count; + if (n < 3) return; + + V.Clear(); + + if (Area(points) > 0) for (int v = 0; v < n; v++) V.Add(v); + else for (int v = 0; v < n; v++) V.Add((n - 1) - v); + + int nv = n; + int count = 2*nv; + for (int m = 0, v = nv - 1; nv > 2;) + { + if ((count--) <= 0) return; + + int u = v; + if (nv <= u) u = 0; + + v = u + 1; + + if (nv <= v) v = 0; + int w = v + 1; + if (nv <= w) w = 0; + + if (Snip(points, u, v, w, nv, V)) + { + int a, b, c, s, t; + a = V[u]; + b = V[v]; + c = V[w]; + tris.Add(a); + tris.Add(b); + tris.Add(c); + m++; + for (s = v, t = v + 1; t < nv; s++, t++) V[s] = V[t]; + nv--; + count = 2*nv; + } + } + } + + private static float Area(List points) + { + int n = points.Count; + float A = 0.0f; + for (int p = n - 1, q = 0; q < n; p = q++) + { + Vector2 pval = points[p]; + Vector2 qval = points[q]; + A += pval.x*qval.y - qval.x*pval.y; + } + return (A*0.5f); + } + + private static bool Snip(List points, int u, int v, int w, int n, List V) + { + int p; + Vector2 A = points[V[u]]; + Vector2 B = points[V[v]]; + Vector2 C = points[V[w]]; + if (Mathf.Epsilon > (((B.x - A.x)*(C.y - A.y)) - ((B.y - A.y)*(C.x - A.x)))) return false; + for (p = 0; p < n; p++) + { + if ((p == u) || (p == v) || (p == w)) continue; + Vector2 P = points[V[p]]; + if (InsideTriangle(A, B, C, P)) return false; + } + return true; + } + + private static bool InsideTriangle(Vector2 A, Vector2 B, Vector2 C, Vector2 P) + { + float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; + float cCROSSap, bCROSScp, aCROSSbp; + + ax = C.x - B.x; + ay = C.y - B.y; + bx = A.x - C.x; + by = A.y - C.y; + cx = B.x - A.x; + cy = B.y - A.y; + apx = P.x - A.x; + apy = P.y - A.y; + bpx = P.x - B.x; + bpy = P.y - B.y; + cpx = P.x - C.x; + cpy = P.y - C.y; + + aCROSSbp = ax*bpy - ay*bpx; + cCROSSap = cx*apy - cy*apx; + bCROSScp = bx*cpy - by*cpx; + + return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs.meta new file mode 100644 index 0000000..869f0cc --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcTriangulate2D.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 60c959525d457be479e941b787ed7a5d +timeCreated: 1476469986 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs new file mode 100644 index 0000000..b469c3f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs @@ -0,0 +1,200 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Components +{ + /// + /// Visualize curve in Play mode with standard LineRenderer Component. + /// This component updates LineRenderer vertex count & positions only + /// + [HelpURL("http://www.bansheegz.com/BGCurve/Cc/BGCcVisualizationLineRenderer")] + [RequireComponent(typeof(LineRenderer))] + [DisallowMultipleComponent] + [ + CcDescriptor( + Description = "Visualize curve with standard LineRenderer Unity component.", + Name = "Cc Line Renderer", + Image = "Assets/BansheeGz/BGCurve/Icons/Components/BGCcVisualizationLineRenderer123.png") + ] + [AddComponentMenu("BansheeGz/BGCurve/Components/BGCcLineRenderer")] + public class BGCcVisualizationLineRenderer : BGCcSplitterPolyline + { + //=============================================================================================== + // Events + //=============================================================================================== + /// ui updated + public event EventHandler ChangedVisualization; + + //=============================================================================================== + // Fields (Persistent) + //=============================================================================================== + [SerializeField] [Tooltip("Update LineRenderer at Start method.")] private bool updateAtStart; + + /// If LineRenderer should be updated then Start is called + public bool UpdateAtStart + { + get { return updateAtStart; } + set { updateAtStart = value; } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get { return ChoseMessage(base.Error, () => (LineRenderer == null) ? "LineRenderer is null" : null); } + } + + public override string Warning + { + get + { + var warning = base.Warning; + + var lineRenderer = LineRenderer; + if (lineRenderer == null) return warning; + + if (!lineRenderer.useWorldSpace) + warning += "\r\nLineRenderer uses local space (LineRenderer.useWorldSpace=false)! " + + "This is not optimal, especially if you plan to update a curve at runtime. Try to set LineRenderer.useWorldSpace to true"; + + return warning.Length == 0 ? null : warning; + } + } + + public override string Info + { + get { return lineRenderer != null ? "LineRenderer uses " + PointsCount + " points" : "LineRenderer is null"; } + } + + public override bool SupportHandles + { + get { return false; } + } + + + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + //linerenderer cached + private LineRenderer lineRenderer; + + /// Get Unity's LineRenderer component + public LineRenderer LineRenderer + { + get + { + //do not replace with ?? + if (lineRenderer == null) lineRenderer = GetComponent(); + return lineRenderer; + } + } + + //=============================================================================================== + // Unity Callbacks + //=============================================================================================== + // Use this for initialization + public override void Start() + { + base.Start(); + + if (updateAtStart) UpdateUI(); + else Math.EnsureMathIsCreated(); + } + + //=============================================================================================== + // Public functions + //=============================================================================================== + //see parent for comments + public override void AddedInEditor() + { + UpdateUI(); + } + + /// Update underlying Unity's LineRenderer component + public void UpdateUI() + { + try + { + //have no idea how to cope with UndoRedo + if (Math == null) return; + } + catch (MissingReferenceException) + { + return; + } + var math = Math.Math; + + if (math == null) return; + + LineRenderer lineRenderer; + try + { + //have no idea how to cope with UndoRedo + lineRenderer = LineRenderer; + } + catch (MissingReferenceException) + { + return; + } + + if (lineRenderer == null) return; + + var curve = Curve; + + if (curve == null) return; + + + if (math.SectionsCount == 0) + { + //not enough points +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = 0; +#else + lineRenderer.SetVertexCount(0); +#endif + + if (positions != null && positions.Count > 0 && ChangedVisualization != null) ChangedVisualization(this, null); + positions.Clear(); + } + else + { + //============== ok + useLocal = !lineRenderer.useWorldSpace; + var newPositions = Positions; + + //update LineRenderer + var count = newPositions.Count; + if (count > 0) + { +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = count; +#else + lineRenderer.SetVertexCount(count); +#endif + //the only way to get rid of GC is to use slow one-by-one setter unfortunately + for (var i = 0; i < count; i++) lineRenderer.SetPosition(i, newPositions[i]); + } + else + { +#if UNITY_5_5 || UNITY_5_6 + lineRenderer.numPositions = 0; +#else + lineRenderer.SetVertexCount(0); +#endif + } + if (ChangedVisualization != null) ChangedVisualization(this, null); + } + } + + //=============================================================================================== + // Private functions + //=============================================================================================== + //math/curve is changed + protected override void UpdateRequested(object sender, EventArgs e) + { + base.UpdateRequested(sender, e); + UpdateUI(); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs.meta new file mode 100644 index 0000000..32699a3 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcVisualizationLineRenderer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8a69af748a081a14dbc7aa333bece5af +timeCreated: 1471596363 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs new file mode 100644 index 0000000..da2d667 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs @@ -0,0 +1,97 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// CC + cursor + [RequireComponent(typeof (BGCcCursor))] + public abstract class BGCcWithCursor : BGCc + { + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + //cursor Cc component + private BGCcCursor cursor; + + public BGCcCursor Cursor + { + get + { + //do not replace with ?? + if (cursor == null) cursor = GetParent(); + return cursor; + } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + + public override string Error + { + get { return Cursor == null ? "Cursor is null" : null; } + } + + + //=============================================================================================== + // Public methods + //=============================================================================================== + /// Lerp 2 Quaternion field values by current cursor position (optionally currentSection is provided to reduce required calculation) + public Quaternion LerpQuaternion(string fieldName, int currentSection = -1) + { + int indexFrom, indexTo; + var t = GetT(out indexFrom, out indexTo, currentSection); + + //get values + var from = Curve[indexFrom].GetQuaternion(fieldName); + var to = Curve[indexTo].GetQuaternion(fieldName); + + //not sure how to handle zero cases + if (from.x == 0 && from.y == 0 && from.z == 0 && from.w == 0) from = Quaternion.identity; + if (to.x == 0 && to.y == 0 && to.z == 0 && to.w == 0) to = Quaternion.identity; + + //lerp + var result = Quaternion.Lerp(@from, to, t); + return float.IsNaN(result.x) || float.IsNaN(result.y) || float.IsNaN(result.z) || float.IsNaN(result.w) ? Quaternion.identity : result; + } + + /// Lerp 2 Vector3 field values by current cursor position (optionally currentSection is provided to reduce required calculation) + public Vector3 LerpVector(string name, int currentSection = -1) + { + int indexFrom, indexTo; + var t = GetT(out indexFrom, out indexTo, currentSection); + + //get values + var from = Curve[indexFrom].GetVector3(name); + var to = Curve[indexTo].GetVector3(name); + + //lerp + return Vector3.Lerp(@from, to, t); + } + + /// get T value for interpolation (optionally currentSection is provided to reduce required calculation) + public float GetT(out int indexFrom, out int indexTo, int currentSection = -1) + { + var math = Cursor.Math.Math; + var distance = Cursor.Distance; + + GetFromToIndexes(out indexFrom, out indexTo, currentSection); + + //get t value + var section = math[indexFrom]; + var t = (distance - section.DistanceFromStartToOrigin)/section.Distance; + + return t; + } + + //=============================================================================================== + // Private methods + //=============================================================================================== + // get points indexes by cursor position (optionally currentSection is provided to reduce required calculation) + protected void GetFromToIndexes(out int indexFrom, out int indexTo, int currentSection = -1) + { + indexFrom = currentSection < 0 ? Cursor.CalculateSectionIndex() : currentSection; + indexTo = indexFrom == Curve.PointsCount - 1 ? 0 : indexFrom + 1; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs.meta new file mode 100644 index 0000000..e5a2a3d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b76de9a8934b6214a8672a403d2252ca +timeCreated: 1472620770 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs new file mode 100644 index 0000000..60ae08f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace BansheeGz.BGSpline.Components +{ + /// CC + cursor + object to manipulate + public abstract class BGCcWithCursorObject : BGCcWithCursor + { + //=============================================================================================== + // Static + //=============================================================================================== + //error message to use (probably can be inlined without any effect) + private const string ErrorObjectNotSet = "Object To Manipulate is not set."; + + //=============================================================================================== + // Fields (Persistent) + //=============================================================================================== + [SerializeField] [Tooltip("Object to manipulate.\r\n")] private Transform objectToManipulate; + + public Transform ObjectToManipulate + { + get { return objectToManipulate; } + set { ParamChanged(ref objectToManipulate, value); } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get { return objectToManipulate == null ? ErrorObjectNotSet : null; } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs.meta new file mode 100644 index 0000000..d639fd8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithCursorObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 12c8a5c3f07ca5c45b3361e5f8482f54 +timeCreated: 1471738385 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs new file mode 100644 index 0000000..147a7bc --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Components +{ + /// Cc + math + [RequireComponent(typeof (BGCcMath))] + public abstract class BGCcWithMath : BGCc + { + //=============================================================================================== + // Fields (Not persistent) + //=============================================================================================== + private BGCcMath math; + + public BGCcMath Math + { + get + { + //do not replace with ?? + if (math == null) math = GetComponent(); + return math; + } + } + + //=============================================================================================== + // Editor stuff + //=============================================================================================== + public override string Error + { + get { return Math == null ? "Math is null" : null; } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs.meta new file mode 100644 index 0000000..2cf7a5b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Cc/BGCcWithMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ea6e5d4a7e5fc4949b54bdf635d14073 +timeCreated: 1471733928 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve.meta new file mode 100644 index 0000000..479f49b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d243b7f5d60cbc64185d2dbbfaa3021b +folderAsset: yes +timeCreated: 1458400564 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs new file mode 100644 index 0000000..bdac355 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs @@ -0,0 +1,287 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// Abstract superclass for components. + /// + /// Current Requirements: + /// 1) editor should be extended from BGCcEditor + /// 2) Should have a descriptor. + /// 3) Only one RequireComponent of type BGCc (parent). Parent is another Cc component, this component is totally depends on and can not operate without it. + /// + /// Cc stands for "Curve's component" + /// + [RequireComponent(typeof (BGCurve))] + public abstract class BGCc : MonoBehaviour + { + /// if component's parameters changed + public event EventHandler ChangedParams; + + /// Any information Cc wants to provide (for editor) + public virtual string Info + { + get { return null; } + } + + /// Warning (for editor) + public virtual string Warning + { + get { return null; } + } + + /// Error if something is wrong (for editor) + public virtual string Error + { + get { return null; } + } + + +#if UNITY_EDITOR + // ============================================== !!! This is editor only field +#pragma warning disable 0414 + //should CC's handles be shown in SceneView + [SerializeField] private bool showHandles = true; +#pragma warning restore 0414 +#endif + + /// Does this Cc supports handles in SceneView? + public virtual bool SupportHandles + { + get { return false; } + } + + /// Does this Cc supports some adjustable settings for handles in SceneView? + public virtual bool SupportHandlesSettings + { + get { return false; } + } + + //=============================================== Curve + private BGCurve curve; + + public BGCurve Curve + { + get + { + //do not replace with ?? + if (curve == null) curve = GetComponent(); + return curve; + } + } + + + //=============================================== Parent + //parent is another Cc component, this component is totally depends on and can not operate without it + [SerializeField] private BGCc parent; + + public void SetParent(BGCc parent) + { + this.parent = parent; + } + + public T GetParent() where T : BGCc + { + return (T) GetParent(typeof (T)); + } + + public BGCc GetParent(Type type) + { + if (parent != null) return parent; + parent = (BGCc) GetComponent(type); + return parent; + } + + + //=============================================== Name + //you can name your Cc + [SerializeField] private string ccName; + + public string CcName + { + get { return string.IsNullOrEmpty(ccName) ? "" + GetInstanceID() : ccName; } + set { ccName = value; } + } + + //=============================================== Transaction + //transaction is for events grouping only + private int transactionLevel; + + //=============================================== Descriptor + //descriptor is used to add icon, name and description to Cc + private CcDescriptor descriptor; + + + public CcDescriptor Descriptor + { + get + { + //do not replace with ?? + if (descriptor == null) descriptor = GetDescriptor(GetType()); + return descriptor; + } + } + + // www page, containing help info + public virtual string HelpURL + { + get + { + var helpUrl = GetHelpUrl(GetType()); + return helpUrl == null ? null : helpUrl.URL; + } + } + + //=================================================== Unity Methods + public virtual void Start() + { + } + + public virtual void OnDestroy() + { + } + + //=================================================== Methods + //in case any param changed + protected bool ParamChanged(ref T oldValue, T newValue) + { + var oldValueNull = oldValue == null; + var newValueNull = newValue == null; + if (oldValueNull && newValueNull) return false; + + if (oldValueNull == newValueNull && oldValue.Equals(newValue)) return false; + + oldValue = newValue; + FireChangedParams(); + return true; + } + + + /// if component has an error + public bool HasError() + { + return !string.IsNullOrEmpty(Error); + } + + /// if component has a warning + public bool HasWarning() + { + return !string.IsNullOrEmpty(Warning); + } + + //utility method for chosing error message + protected string ChoseMessage(string baseError, Func childError) + { + return !string.IsNullOrEmpty(baseError) ? baseError : childError(); + } + + /// if any parameter changed + public void FireChangedParams() + { + if (ChangedParams != null && transactionLevel == 0) ChangedParams(this, null); + } + + /// component was added via editor menu + public virtual void AddedInEditor() + { + } + + /// get parent Cc class + public Type GetParentClass() + { + return GetParentClass(GetType()); + } + + /// get parent Cc class + public static Type GetParentClass(Type ccType) + { + //gather required + var requiredList = BGReflectionAdapter.GetCustomAttributes(ccType, typeof (RequireComponent), true); + if (requiredList.Length == 0) return null; + + var result = new List(); + foreach (var item in requiredList) + { + var requiredComponent = (RequireComponent) item; + CheckRequired(requiredComponent.m_Type0, result); + CheckRequired(requiredComponent.m_Type1, result); + CheckRequired(requiredComponent.m_Type2, result); + } + + if (result.Count == 0) return null; + if (result.Count > 1) throw new CcException(ccType + " has more than one parent (extended from BGCc class), calculated by RequireComponent attribute"); + return result[0]; + } + + //add class if it's not abstract and a child of BGCc + private static void CheckRequired(Type type, List result) + { + if (type == null || BGReflectionAdapter.IsAbstract(type) || !BGReflectionAdapter.IsClass(type) || !BGReflectionAdapter.IsSubclassOf(type,typeof (BGCc)))return; + + result.Add(type); + } + + /// Check standard Unity's DisallowMultipleComponent attribute + public static bool IsSingle(Type ccType) + { + return BGReflectionAdapter.GetCustomAttributes(ccType, typeof(DisallowMultipleComponent), true).Length > 0; + } + + /// This is used to group events. Use it to change several params and fire one single event + public void Transaction(Action action) + { + transactionLevel++; + try + { + action(); + } + finally + { + transactionLevel--; + if (transactionLevel == 0) + { + if (ChangedParams != null) ChangedParams(this, null); + } + } + } + + //======================== descriptor for Editor + /// this descriptor is used by editor + [AttributeUsage(AttributeTargets.Class)] + public class CcDescriptor : Attribute + { + /// Component's name + public string Name { get; set; } + /// Component's desciption + public string Description { get; set; } + /// Component's icon + public string Image { get; set; } + } + /// Retrieves the descriptor from "type" + public static CcDescriptor GetDescriptor(Type type) + { + var propertyInfos = BGReflectionAdapter.GetCustomAttributes(type, typeof(CcDescriptor), false); + if (propertyInfos.Length > 0) return (CcDescriptor) propertyInfos[0]; + return null; + } + + // get Unity's HelpURLAttribute attrubute + private static HelpURLAttribute GetHelpUrl(Type type) + { + var propertyInfos = BGReflectionAdapter.GetCustomAttributes(type,typeof (HelpURLAttribute), false); + if (propertyInfos.Length > 0) return (HelpURLAttribute) propertyInfos[0]; + return null; + } + + //======================== Exception + /// Exception if something is wrong with Cc related stuff + public class CcException :Exception + { + public CcException(string message) : base(message) + { + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs.meta new file mode 100644 index 0000000..e2ff3d6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ea9b7560ce13a143be3db48f8a69684 +timeCreated: 1471605336 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs new file mode 100644 index 0000000..5cf3bba --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs @@ -0,0 +1,2063 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace BansheeGz.BGSpline.Curve +{ + /// Basic class for spline's points data + [HelpURL("http://www.bansheegz.com/BGCurve/")] + [ExecuteInEditMode] + [DisallowMultipleComponent] + [Serializable] + [AddComponentMenu("BansheeGz/BGCurve/BGCurve")] + public class BGCurve : MonoBehaviour + { + #region static + + //=============================================================================================== + // Static + //=============================================================================================== + + //Package version + public const float Version = 1.22f; + //Epsilon value (very small value, that can be ignored). Assuming 1=1 meter (Unity's recommendation), it equals to (1*10^-5)=10 micrometers + public const float Epsilon = 0.00001f; + + //min snapping distance + public const float MinSnapDistance = 0.1f; + //max snapping distance + public const float MaxSnapDistance = 100; + + //Some private methods names (editor may invoke private methods and fields to properly handle Undo/Redo operations and points mode conversion) + public const string MethodAddPoint = "AddPoint"; + public const string MethodDeletePoint = "Delete"; + public const string MethodSetPointsNames = "SetPointsNames"; + public const string MethodAddField = "AddField"; + public const string MethodDeleteField = "DeleteField"; + public const string MethodConvertPoints = "ConvertPoints"; + + + //Event names (these events are fired at any rate) + public const string EventClosed = "closed is changed"; + public const string EventSnapType = "snapType is changed"; + public const string EventSnapAxis = "snapAxis is changed"; + public const string EventSnapDistance = "snapDistance is changed"; + public const string EventSnapTrigger = "snapTriggerInteraction is changed"; + public const string EventSnapBackfaces = "snapToBackFaces is changed"; + public const string EventSnapLayerMask = "snapLayerMask is changed"; + public const string EventAddField = "add a field"; + public const string EventDeleteField = "delete a field"; + public const string EventFieldName = "field name is changed"; + public const string Event2D = "2d mode is changed"; + public const string EventForceUpdate = "force update is changed"; + + public const string EventPointsMode = "points mode is changed"; + public const string EventClearAllPoints = "clear all points"; + public const string EventAddPoint = "add a point"; + public const string EventAddPoints = "add points"; + public const string EventDeletePoints = "delete points"; + public const string EventSwapPoints = "swap points"; + public const string EventReversePoints = "reverse points"; + + + //Event names (these events are fired only if events args are enabled). this is done for performance sake + public const string EventTransaction = "changes in transaction"; + public const string EventTransform = "transform is changed"; + public const string EventForcedUpdate = "forced update"; + public const string EventPointPosition = "point position is changed"; + public const string EventPointTransform = "point transform is changed"; + public const string EventPointControl = "point control is changed"; + public const string EventPointControlType = "point control type is changed"; + public const string EventPointField = "point field value is changed"; + + //static reusable array for snapping double sided + private static readonly RaycastHit[] raycastHitArray = new RaycastHit[50]; + //static reusable array for deleting points + private static readonly BGCurvePointI[] pointArray = new BGCurvePointI[1]; + //static reusable list for storing Unity objects + private static readonly List pointsList = new List(); + //static reusable list for storing points index + private static readonly List pointsIndexesList = new List(); + + #endregion + + #region enums + + //=============================================================================================== + // Enums + //=============================================================================================== + + /// 2D mode for a curve. If mode is on, only 2 points and controls coordinates matter, the third one is always 0 + public enum Mode2DEnum + { + Off, + XY, + XZ, + YZ + } + + /// + /// Snap mode for a curve. If mode is on, every curve's point (and every approximation point, if mode=Curve) will be snapped to the closest collider if any. + /// With 'Curve' mode, Base Math gives better result, than Adaptive Math, cause it splits the curve into equal parts. + /// Note, 'Curve' mode will add a huge overhead if you are changing the curve at runtime, cause for every approximation point 2 raycasts will be cast + /// + public enum SnapTypeEnum + { + /// No snapping + Off, + + /// Only curve's points are snapped + Points, + + /// Both curve's points and approximation points are snapped + Curve + } + + /// Snapping axis. For terrain use Y + public enum SnapAxisEnum + { + X, + Y, + Z + } + + /// Then events are fired + public enum EventModeEnum + { + /// events are fired once per frame in Update + Update, + + /// events are fired once per frame in LateUpdate. Use it if you are using animations + LateUpdate, + + /// events are suppressed + NoEvents + } + + /// Force Changed event firing + public enum ForceChangedEventModeEnum + { + /// Changed event is fired only if some change is detected + Off, + + /// Forced Changed event is fired only in Editor + EditorOnly, + + /// Forced Changed event is fired in Editor and every frame at Runtime + EditorAndRuntime + } + + /// How points are stored + public enum PointsModeEnum + { + /// Points are stored right inside curve's components. + Inlined, + + /// Points are stored as separate components(MonoBehaviours) attached to curve's GameObject. + Components, + + /// Points are stored as separate components(MonoBehaviours) attached to their own GameObjects. Unity's transform is not used. + GameObjectsNoTransform, + + /// + /// Points are stored as separate components(MonoBehaviours) attached to their own GameObjects. Unity's transform position is used as point position. + /// Rotation and Scale affects controls positions. + /// + GameObjectsTransform + } + + #endregion + + #region Fields & Events & Props & Delegates + + //=============================================================================================== + // Fields + //=============================================================================================== + + +#if UNITY_EDITOR + // ============================================== !!! This is editor ONLY field +#pragma warning disable 0414 + [SerializeField] private BGCurveSettings settings = new BGCurveSettings(); +#pragma warning restore 0414 +#endif + + // ======================================= Delegates + + /// Iteration method callback, used by ForEach method for iterating over each point + public delegate void IterationCallback(BGCurvePointI point, int index, int count); + + // ======================================= Events + + /// Any curve's change. By default events are fired once per frame in Update, set ImmediateChangeEvents to fire event as soon as any change + public event EventHandler Changed; + + /// Before any change. + public event EventHandler BeforeChange; + + // ======================================= Fields (persistent) + + // 2D mode + [Tooltip("2d Mode for a curve. In 2d mode, only 2 coordinates matter, the third will always be 0 (including controls). " + + "Handles in Editor will also be switched to 2d mode")] [SerializeField] private Mode2DEnum mode2D = Mode2DEnum.Off; + + //if curve is closed (e.g. if last and first point are connected) + [Tooltip("If curve is closed")] [SerializeField] private bool closed; + + + //points inlined + [SerializeField] private BGCurvePoint[] points = new BGCurvePoint[0]; + + //points components + [SerializeField] private BGCurvePointComponent[] pointsComponents = new BGCurvePointComponent[0]; + + //points as separate game objects + [SerializeField] private BGCurvePointGO[] pointsGameObjects = new BGCurvePointGO[0]; + + //custom fields + [SerializeField] private BGCurvePointField[] fields = new BGCurvePointField[0]; + + //snapping mode + [Tooltip("Snap type. A collider should exists for points to snap to." + + "\r\n 1) Off - snaping is off" + + "\r\n 2) Points - only curve's points will be snapped." + + "\r\n 3) Curve - both curve's points and split points will be snapped. " + + "With 'Curve' mode Base Math type gives better results, than Adaptive Math, cause snapping occurs after approximation." + + "Also, 'Curve' mode can add a huge overhead if you are changing curve's points at runtime.")] [SerializeField] private SnapTypeEnum snapType = SnapTypeEnum.Off; + + //snapping axis + [Tooltip("Axis for snapping points")] [SerializeField] private SnapAxisEnum snapAxis = SnapAxisEnum.Y; + + //snapping distance + [Tooltip("Snapping distance.")] [SerializeField] [Range(MinSnapDistance, MaxSnapDistance)] private float snapDistance = 10; + + //snapping layer mask + [Tooltip("Layer mask for snapping")] [SerializeField] private LayerMask snapLayerMask = -1; + + //should snapping take triggers into account + [Tooltip("Should snapping takes triggers into account")] [SerializeField] private QueryTriggerInteraction snapTriggerInteraction = QueryTriggerInteraction.UseGlobal; + + //should snapping take triggers into account + [Tooltip("Should snapping takes backfaces of colliders into account")] [SerializeField] private bool snapToBackFaces; + + //events mode + [Tooltip("Event mode for runtime")] [SerializeField] private EventModeEnum eventMode = EventModeEnum.Update; + + //points mode + [Tooltip("Points mode, how points are stored. " + + "\r\n 1) Inline - points stored inlined with the curve's component." + + "\r\n 2) Component - points are stored as MonoBehaviour scripts attached to the curve's GameObject." + + "\r\n 3) GameObject - points are stored as MonoBehaviour scripts attached to separate GameObject for each point.")] [SerializeField] private PointsModeEnum pointsMode = + PointsModeEnum.Inlined; + + //force firing Update event + [Tooltip("Force firing of Changed event. This can be useful if you use Unity's Animation. Do not use it unless you really need it.")] [SerializeField] private ForceChangedEventModeEnum + forceChangedEventMode; + + + // ======================================= Props + /// Curve's points + public BGCurvePointI[] Points + { + get + { + switch (pointsMode) + { + case PointsModeEnum.Inlined: + return points; + case PointsModeEnum.Components: + return pointsComponents; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + return pointsGameObjects; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + } + + /// Number of curve's points + public int PointsCount + { + get + { + switch (pointsMode) + { + case PointsModeEnum.Inlined: + return points.Length; + case PointsModeEnum.Components: + return pointsComponents.Length; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + return pointsGameObjects.Length; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + } + + /// Curve's custom fields + public BGCurvePointField[] Fields + { + get { return fields; } + } + + /// Number of curve's custom fields + public int FieldsCount + { + get { return fields.Length; } + } + + /// If curve is closed, e.g. last and first points are connected + public bool Closed + { + get { return closed; } + set + { + if (value == closed) return; + FireBeforeChange(EventClosed); + closed = value; + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventClosed)); + } + } + + /// How points are stored + public PointsModeEnum PointsMode + { + get { return pointsMode; } + set + { + if (pointsMode == value) return; + ConvertPoints(value); + } + } + + + /// In 2d mode only 2 coordinates matter, the 3rd one will always be 0 (including control) + public Mode2DEnum Mode2D + { + get { return mode2D; } + set + { + if (mode2D == value) return; + + Apply2D(value); + } + } + + /// Is 2D mode On? + public bool Mode2DOn + { + get { return mode2D != Mode2DEnum.Off; } + } + + /// Snapping mode + public SnapTypeEnum SnapType + { + get { return snapType; } + set + { + if (snapType == value) return; + FireBeforeChange(EventSnapType); + snapType = value; + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapType)); + } + } + + /// Snapping axis. For terrain use Y + public SnapAxisEnum SnapAxis + { + get { return snapAxis; } + set + { + if (snapAxis == value) return; + FireBeforeChange(EventSnapAxis); + snapAxis = value; + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapAxis)); + } + } + + /// Snapping distance + public float SnapDistance + { + get { return snapDistance; } + set + { + if (Math.Abs(snapDistance - value) < Epsilon) return; + + FireBeforeChange(EventSnapDistance); + snapDistance = Mathf.Clamp(value, MinSnapDistance, MaxSnapDistance); + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapDistance)); + } + } + + /// Should snapping take triggers into account + public QueryTriggerInteraction SnapTriggerInteraction + { + get { return snapTriggerInteraction; } + set + { + if (snapTriggerInteraction == value) return; + + FireBeforeChange(EventSnapTrigger); + snapTriggerInteraction = value; + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapTrigger)); + } + } + + /// Should snapping take colliders backfaces into account + public bool SnapToBackFaces + { + get { return snapToBackFaces; } + set + { + if (snapToBackFaces == value) return; + + FireBeforeChange(EventSnapBackfaces); + snapToBackFaces = value; + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapBackfaces)); + } + } + + /// Snapping layer mask + public LayerMask SnapLayerMask + { + get { return snapLayerMask; } + set + { + if (snapLayerMask == value) return; + + FireBeforeChange(EventSnapLayerMask); + snapLayerMask = value; + if (snapType != SnapTypeEnum.Off) ApplySnapping(); + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Snap, EventSnapLayerMask)); + } + } + + /// Force firing of Changed event. This can be useful if you use Unity's Animation. Do not use it unless you really need it. + public ForceChangedEventModeEnum ForceChangedEventMode + { + get { return forceChangedEventMode; } + set + { + if (forceChangedEventMode == value) return; + + FireBeforeChange(EventForceUpdate); + forceChangedEventMode = value; + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Curve, EventForceUpdate)); + } + } + + //------------------------------ these fields are not persistent + //for batch operation (to avoid event firing for every operation) + private int transactionLevel; + + //list of events grouped by transaction (this is used only if UseEventsArgs is set to true) + private List changeList; + + //store custom fields structure for values. see FieldsTree comments for more info + private FieldsTree fieldsTree; + + //changed flag is reset every frame. + private bool changed; + + //fire Changed event as soon as change is made. By default they are grouped within a frame (for performance sake) + private bool immediateChangeEvents; + + //stores event mode for reset after SupressEvent is set to false. + private EventModeEnum eventModeOld = EventModeEnum.Update; + + //keeps last used eventType to use in FireFinalEvent. (if UseEventsArgs is false, we dont keep events list, fired during one single frame, and use only the last one) + private BGCurveChangedArgs.ChangeTypeEnum lastEventType; + + //keeps last event message to use in FireFinalEvent. (if UseEventsArgs is false, we dont keep events list, fired during one single frame, and use only the last one) + private string lastEventMessage; + + //list of points with Transforms attached () + private List pointsWithTransforms; + + + [Obsolete("It is not used anymore and should be removed")] + public bool TraceChanges + { + get { return Changed != null; } + set { } + } + + /// Disable events firing temporarily + public bool SupressEvents + { + get { return eventMode == EventModeEnum.NoEvents; } + set + { + if (value && eventMode != EventModeEnum.NoEvents) eventModeOld = eventMode; + eventMode = value ? EventModeEnum.NoEvents : eventModeOld; + } + } + + /// Use events args (no need for them if you do not use them). + public bool UseEventsArgs { get; set; } + + /// How events are fired + public EventModeEnum EventMode + { + get { return eventMode; } + set { eventMode = value; } + } + + /// Should events be fired immediately after the change. This mode is used by Editors and not recommended for runtime. + public bool ImmediateChangeEvents + { + get { return immediateChangeEvents; } + set { immediateChangeEvents = value; } + } + + //the list of events accumulated during transaction. (this is used only if UseEventsArgs is set to true) + private List ChangeList + { + get { return changeList ?? (changeList = new List()); } + } + + #endregion + + #region Public Functions + + //=============================================================================================== + // Public functions + //=============================================================================================== + // only required ones- no math. to use math use BGCurveBaseMath or BGCurveAdaptiveMath or your own class with provided classes as an example + + // ======================================= Points construction + /// Create a point, world coordinate are used + public BGCurvePoint CreatePointFromWorldPosition(Vector3 worldPos, BGCurvePoint.ControlTypeEnum controlType) + { + return new BGCurvePoint(this, worldPos, controlType, true); + } + + /// Create a point, world coordinate are used + public BGCurvePoint CreatePointFromWorldPosition(Vector3 worldPos, BGCurvePoint.ControlTypeEnum controlType, + Vector3 control1WorldPos, Vector3 control2WorldPos) + { + return new BGCurvePoint(this, worldPos, controlType, control1WorldPos, control2WorldPos, true); + } + + /// Create a point, local coordinate are used + public BGCurvePoint CreatePointFromLocalPosition(Vector3 localPos, BGCurvePoint.ControlTypeEnum controlType) + { + return new BGCurvePoint(this, localPos, controlType); + } + + /// Create a point, local coordinate are used + public BGCurvePoint CreatePointFromLocalPosition(Vector3 localPos, BGCurvePoint.ControlTypeEnum controlType, + Vector3 control1LocalPos, Vector3 control2LocalPos) + { + return new BGCurvePoint(this, localPos, controlType, control1LocalPos, control2LocalPos); + } + + + // ======================================= Points handling + /// Remove all points + public void Clear() + { + var pointsCount = PointsCount; + if (pointsCount == 0) return; + + FireBeforeChange(EventClearAllPoints); + + switch (pointsMode) + { + case PointsModeEnum.Inlined: + points = new BGCurvePoint[0]; + break; + case PointsModeEnum.Components: + if (pointsCount > 0) for (var i = pointsCount - 1; i >= 0; i--) DestroyIt(pointsComponents[i]); + pointsComponents = new BGCurvePointComponent[0]; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + if (pointsCount > 0) for (var i = pointsCount - 1; i >= 0; i--) DestroyIt(pointsGameObjects[i].gameObject); + pointsGameObjects = new BGCurvePointGO[0]; + break; + } + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventClearAllPoints)); + } + + /// Returns a point's index + public int IndexOf(BGCurvePointI point) + { + return IndexOf(Points, point); + } + + + /// Add a point to the end + public BGCurvePointI AddPoint(BGCurvePoint point) + { + return AddPoint(point, PointsCount, null); + } + + /// Add a point at specified index + public BGCurvePointI AddPoint(BGCurvePoint point, int index) + { + return AddPoint(point, index, null); + } + + /// Add several points. + public void AddPoints(BGCurvePoint[] points) + { + AddPoints(points, PointsCount, false); + } + + /// Add several points at specified index. + public void AddPoints(BGCurvePoint[] points, int index) + { + AddPoints(points, index, false); + } + + /// Removes a point + public void Delete(BGCurvePointI point) + { + Delete(IndexOf(point), null); + } + + /// Removes a point at specified index + public void Delete(int index) + { + Delete(index, null); + } + + /// Removes several points + public void Delete(BGCurvePointI[] points) + { + Delete(points, null); + } + + /// Swaps 2 points + public void Swap(int index1, int index2) + { + if (index1 < 0 || index1 >= PointsCount || index2 < 0 || index2 >= PointsCount) throw new UnityException("Unable to remove a point. Invalid indexes: " + index1 + ", " + index2); + + FireBeforeChange(EventSwapPoints); + + var points = Points; + + var point1 = points[index1]; + var point2 = points[index2]; + + var hasTransform = point1.PointTransform != null || point2.PointTransform != null; + + points[index2] = point1; + points[index1] = point2; + + if (IsGoMode(pointsMode)) SetPointsNames(); + + if (hasTransform) CachePointsWithTransforms(); + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventSwapPoints)); + } + + /// Reverse points order, keeping curve intact + public void Reverse() + { + var pointsCount = PointsCount; + + if (pointsCount < 2) return; + FireBeforeChange(EventReversePoints); + + var points = Points; + var hasFields = FieldsCount > 0; + var pointsMode = PointsMode; + + var mid = pointsCount >> 1; + var countMinusOne = pointsCount - 1; + for (var i = 0; i < mid; i++) + { + var point1 = points[i]; + var point2 = points[countMinusOne - i]; + + var position = point2.PositionLocal; + var controlType = point2.ControlType; + var control1 = point2.ControlFirstLocal; + var control2 = point2.ControlSecondLocal; + var fields2 = hasFields ? GetFieldsValues(point2, pointsMode) : null; + + point2.PositionLocal = point1.PositionLocal; + point2.ControlType = point1.ControlType; + point2.ControlFirstLocal = point1.ControlSecondLocal; + point2.ControlSecondLocal = point1.ControlFirstLocal; + if (hasFields) SetFieldsValues(point2, pointsMode, GetFieldsValues(point1, pointsMode)); + + point1.PositionLocal = position; + point1.ControlType = controlType; + point1.ControlFirstLocal = control2; + point1.ControlSecondLocal = control1; + if (hasFields) SetFieldsValues(point1, pointsMode, fields2); + } + + if (pointsCount%2 != 0) + { + //point at the center- we need to swap controls + var point = points[mid]; + var control = point.ControlFirstLocal; + point.ControlFirstLocal = point.ControlSecondLocal; + point.ControlSecondLocal = control; + } + + if (IsGoMode(pointsMode)) SetPointsNames(); + + CachePointsWithTransforms(); + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventReversePoints)); + } + + /// Access a point by index + public BGCurvePointI this[int i] + { + get + { + switch (pointsMode) + { + case PointsModeEnum.Inlined: + return points[i]; + case PointsModeEnum.Components: + return pointsComponents[i]; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + return pointsGameObjects[i]; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + set + { + switch (pointsMode) + { + case PointsModeEnum.Inlined: + points[i] = (BGCurvePoint) value; + break; + case PointsModeEnum.Components: + pointsComponents[i] = (BGCurvePointComponent) value; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + pointsGameObjects[i] = (BGCurvePointGO) value; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + } + + // ============================================== Custom Fields + /// Add a custom field + public BGCurvePointField AddField(string name, BGCurvePointField.TypeEnum type) + { + return AddField(name, type, null); + } + + + /// Delete a custom field + public void DeleteField(BGCurvePointField field) + { + DeleteField(field, null); + } + + /// Get number of field + public int IndexOf(BGCurvePointField field) + { + return IndexOf(fields, field); + } + + /// is curve has a field with provided name + public bool HasField(string name) + { + if (FieldsCount == 0) return false; + foreach (var field in fields) if (String.Equals(name, field.FieldName)) return true; + return false; + } + + /// + /// get the index of field's value within array of values + /// this method is meant to be private, but we can not keep it private cause of performance + /// + public int IndexOfFieldValue(string name) + { + if (fieldsTree == null || !fieldsTree.Comply(fields)) PrivateUpdateFieldsValuesIndexes(); + return fieldsTree.GetIndex(name); + } + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + // updates indexes for custom fields values. See FieldsTree for details. + public void PrivateUpdateFieldsValuesIndexes() + { + fieldsTree = fieldsTree ?? new FieldsTree(); + fieldsTree.Update(fields); + } + + // ============================================== 2D mode. + /// apply 2D mode to all points + public void Apply2D(Mode2DEnum value) + { + FireBeforeChange(Event2D); + mode2D = value; + + if (mode2D != Mode2DEnum.Off && PointsCount > 0) + { + Transaction(() => + { + var points = Points; + var count = points.Length; + for (var i = 0; i < count; i++) Apply2D(points[i]); + }); + } + else FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, Event2D)); + } + + /// change point's coordinate to comply to 2d mode + public virtual void Apply2D(BGCurvePointI point) + { + point.PositionLocal = point.PositionLocal; + point.ControlFirstLocal = point.ControlFirstLocal; + point.ControlSecondLocal = point.ControlSecondLocal; + } + + /// change vector coordinates to comply to 2d mode + public virtual Vector3 Apply2D(Vector3 point) + { + switch (mode2D) + { + case Mode2DEnum.XY: + return new Vector3(point.x, point.y, 0); + case Mode2DEnum.XZ: + return new Vector3(point.x, 0, point.z); + case Mode2DEnum.YZ: + return new Vector3(0, point.y, point.z); + } + return point; + } + + // ============================================== Snapping. + /// apply snapping to all points + public void ApplySnapping() + { + if (snapType == SnapTypeEnum.Off) return; + + var points = Points; + var length = points.Length; + for (var i = 0; i < length; i++) ApplySnapping(points[i]); + } + + /// apply snapping to one single point + public void ApplySnapping(BGCurvePointI point) + { + if (snapType == SnapTypeEnum.Off) return; + var pos = point.PositionWorld; + + if (ApplySnapping(ref pos)) point.PositionWorld = pos; + } + + /// apply snapping to one position and returns true if position was changed + public bool ApplySnapping(ref Vector3 pos) + { + if (snapType == SnapTypeEnum.Off) return false; + + //assign direction + Vector3 direction; + switch (snapAxis) + { + case SnapAxisEnum.Y: + direction = Vector3.up; + break; + case SnapAxisEnum.X: + direction = Vector3.right; + break; + default: + // case SnapAxisEnum.Z: + direction = Vector3.forward; + break; + } + + //cast front side + var resultPos = new Vector3(); + float minDistance = -1; + for (var k = 0; k < 2; k++) + { + var ray = new Ray(pos, k == 0 ? direction : -direction); + + RaycastHit hit; + if (!Physics.Raycast(ray, out hit, snapDistance, snapLayerMask, snapTriggerInteraction)) continue; + + if (!(minDistance < 0) && !(minDistance > hit.distance)) continue; + + minDistance = hit.distance; + resultPos = hit.point; + } + + //cast back side + if (snapToBackFaces) + { + for (var j = 0; j < 2; j++) + { + var count = Physics.RaycastNonAlloc(j == 0 + ? new Ray(new Vector3(pos.x + direction.x*snapDistance, pos.y + direction.y*snapDistance, pos.z + direction.z*snapDistance), -direction) + : new Ray(new Vector3(pos.x - direction.x*snapDistance, pos.y - direction.y*snapDistance, pos.z - direction.z*snapDistance), direction), + raycastHitArray, snapDistance, snapLayerMask, snapTriggerInteraction); + if (count == 0) continue; + + //iterate all unsorted results + for (var i = 0; i < count; i++) + { + var raycastHit = raycastHitArray[i]; + var distanceToCheck = snapDistance - raycastHit.distance; + if (!(minDistance < 0) && !(minDistance > distanceToCheck)) continue; + + minDistance = distanceToCheck; + resultPos = raycastHit.point; + } + } + } + + if (minDistance < 0) return false; + + //assign new pos + pos = resultPos; + + return true; + } + + + // ============================================== batch handling (to avoid event firing for every operation). + /// + /// Executes a batch operation. + /// During batch operation events firing will be suppressed, and event will be fired only after Transaction. + /// it is for event handling only . + /// + public void Transaction(Action action) + { + FireBeforeChange(EventTransaction); + transactionLevel++; + if (UseEventsArgs && transactionLevel == 1) ChangeList.Clear(); + try + { + action(); + } + finally + { + transactionLevel--; + if (transactionLevel == 0) + { + FireChange(UseEventsArgs + ? BGCurveChangedArgs.GetInstance(this, ChangeList.ToArray(), EventTransaction) + : null); + if (UseEventsArgs) ChangeList.Clear(); + } + } + } + + /// Current transaction level. + public int TransactionLevel + { + get { return transactionLevel; } + } + + // search for index within array + protected internal static int IndexOf(T[] array, T item) + { + return Array.IndexOf(array, item); + } + + + // ============================================== event handling + /// Fires BeforeChange event if not within transaction and events are not suppressed. + public void FireBeforeChange(string operation) + { + if (eventMode == EventModeEnum.NoEvents || transactionLevel > 0 || BeforeChange == null) return; + + BeforeChange(this, UseEventsArgs ? BGCurveChangedArgs.BeforeChange.GetInstance(operation) : null); + } + + /// Fires Changed event (if some conditions are met) + public void FireChange(BGCurveChangedArgs change, bool ignoreEventsGrouping = false, object sender = null) + { + if (eventMode == EventModeEnum.NoEvents || Changed == null) return; + + if (transactionLevel > 0 || (!immediateChangeEvents && !ignoreEventsGrouping)) + { + changed = true; + if (change != null) + { + lastEventType = change.ChangeType; + lastEventMessage = change.Message; + } + if (UseEventsArgs && !ChangeList.Contains(change)) ChangeList.Add((BGCurveChangedArgs) change.Clone()); + return; + } + + Changed(sender ?? this, change); + } + + // ============================================== Unity callbacks + public void Start() + { + CachePointsWithTransforms(); + } + + // Unity's Update callback + protected virtual void Update() + { + // is transform.hasChanged is true by default? + if (Time.frameCount == 1) transform.hasChanged = false; + if (eventMode != EventModeEnum.Update || Changed == null) return; + FireFinalEvent(); + } + + // Unity's LateUpdate callback + protected virtual void LateUpdate() + { + if (eventMode != EventModeEnum.LateUpdate || Changed == null) return; + FireFinalEvent(); + } + + // ============================================== Utility methods + /// world position to local position + public Vector3 ToLocal(Vector3 worldPoint) + { + return transform.InverseTransformPoint(worldPoint); + } + + /// local position to world position + public Vector3 ToWorld(Vector3 localPoint) + { + return transform.TransformPoint(localPoint); + } + + /// direction from world to local + public Vector3 ToLocalDirection(Vector3 direction) + { + return transform.InverseTransformDirection(direction); + } + + /// direction from local to world + public Vector3 ToWorldDirection(Vector3 direction) + { + return transform.TransformDirection(direction); + } + + /// execute Action for each point. Params are Point,index,length. + public void ForEach(IterationCallback iterationCallback) + { + //do not replace PointsCount with local var, cause it can be changed while iteration + for (var i = 0; i < PointsCount; i++) iterationCallback(Points[i], i, PointsCount); + } + + //update points GameObjects names and sort + private void SetPointsNames() + { + try + { + if (gameObject == null) return; + } + catch (MissingReferenceException) + { + return; + } + + var name = gameObject.name; + var length = pointsGameObjects.Length; + for (var i = 0; i < length; i++) + { + var go = pointsGameObjects[i].gameObject; + + //set name + go.name = name + "[" + i + "]"; + + //move to bottom + go.transform.SetSiblingIndex(go.transform.parent.childCount - 1); + } + } + + // copy arrays and add a new element + public static T[] Insert(T[] oldArray, int index, T[] newElements) + { + var newArray = new T[oldArray.Length + newElements.Length]; + + //copy before index + if (index > 0) Array.Copy(oldArray, newArray, index); + + //copy after index + if (index < oldArray.Length) Array.Copy(oldArray, index, newArray, index + newElements.Length, oldArray.Length - index); + + //copy new elements + Array.Copy(newElements, 0, newArray, index, newElements.Length); + + return newArray; + } + + // copy arrays and add a new element + public static T[] Insert(T[] oldArray, int index, T newElement) + { + var newArray = new T[oldArray.Length + 1]; + + //copy before index + if (index > 0) Array.Copy(oldArray, newArray, index); + + //copy after index + if (index < oldArray.Length) Array.Copy(oldArray, index, newArray, index + 1, oldArray.Length - index); + + newArray[index] = newElement; + + return newArray; + } + + // copy arrays and removes an element + public static T[] Remove(T[] oldArray, int index) + { + var newArray = new T[oldArray.Length - 1]; + if (index > 0) Array.Copy(oldArray, newArray, index); + + if (index < oldArray.Length - 1) Array.Copy(oldArray, index + 1, newArray, index, oldArray.Length - 1 - index); + + return newArray; + } + + /// standard c# toString override + public override string ToString() + { + return "BGCurve [id=" + GetInstanceID() + "], points=" + PointsCount; + } + + /// if this mode uses separate GameObjects for points + public static bool IsGoMode(PointsModeEnum pointsMode) + { + return pointsMode == PointsModeEnum.GameObjectsNoTransform || pointsMode == PointsModeEnum.GameObjectsTransform; + } + + // ============================================== Point's transforms + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + //if a transform was added to a point + public void PrivateTransformForPointAdded(int index) + { + if (index < 0 || PointsCount >= index) return; + if (pointsWithTransforms == null) pointsWithTransforms = new List(); + + if (pointsWithTransforms.IndexOf(index) == -1) pointsWithTransforms.Add(index); + } + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + //if a transform was removed from a point + public void PrivateTransformForPointRemoved(int index) + { + if (pointsWithTransforms == null || pointsWithTransforms.IndexOf(index) == -1) return; + + pointsWithTransforms.Remove(index); + } + + #endregion + + #region Private Functions + + //=============================================================================================== + // Private functions + //=============================================================================================== + + // ============================================== Points + //add a point. this method is not meant to be public, Editor uses it via reflection + private BGCurvePointI AddPoint(BGCurvePoint point, int index, Func provider = null) + { + if (index < 0 || index > PointsCount) throw new UnityException("Unable to add a point. Invalid index: " + index); + + FireBeforeChange(EventAddPoint); + + BGCurvePointI result; + + //insert a point + switch (pointsMode) + { + case PointsModeEnum.Inlined: + points = Insert(points, index, point); + result = point; + break; + + case PointsModeEnum.Components: + var pointComponent = (BGCurvePointComponent) Convert(point, PointsModeEnum.Inlined, pointsMode, provider); + pointsComponents = Insert(pointsComponents, index, pointComponent); + result = pointComponent; + break; + + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + var pointGameObject = (BGCurvePointGO) Convert(point, PointsModeEnum.Inlined, pointsMode, provider); + pointsGameObjects = Insert(pointsGameObjects, index, pointGameObject); + + SetPointsNames(); + + result = pointGameObject; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + + //fields + if (FieldsCount > 0) + { + var fieldValues = GetFieldsValues(result, pointsMode); + foreach (var field in fields) BGCurvePoint.PrivateFieldAdded(field, fieldValues); + } + + //point transforms + if ((point.PointTransform != null) || (pointsWithTransforms != null && pointsWithTransforms.Count > 0)) CachePointsWithTransforms(); + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Point, EventAddPoint)); + + return result; + } + + //retrieve fields values from point + private BGCurvePoint.FieldsValues GetFieldsValues(BGCurvePointI point, PointsModeEnum pointsMode) + { + BGCurvePoint.FieldsValues fieldValues; + switch (pointsMode) + { + case PointsModeEnum.Inlined: + fieldValues = ((BGCurvePoint) point).PrivateValuesForFields; + break; + case PointsModeEnum.Components: + fieldValues = ((BGCurvePointComponent) point).Point.PrivateValuesForFields; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + fieldValues = ((BGCurvePointGO) point).PrivateValuesForFields; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + return fieldValues; + } + + //set fields values for point + private void SetFieldsValues(BGCurvePointI point, PointsModeEnum pointsMode, BGCurvePoint.FieldsValues fieldsValues) + { + switch (pointsMode) + { + case PointsModeEnum.Inlined: + ((BGCurvePoint) point).PrivateValuesForFields = fieldsValues; + break; + case PointsModeEnum.Components: + ((BGCurvePointComponent) point).Point.PrivateValuesForFields = fieldsValues; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + ((BGCurvePointGO) point).PrivateValuesForFields = fieldsValues; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + + // add several points. this method is not meant to be public, Editor uses it via reflection + private void AddPoints(BGCurvePoint[] points, int index, bool skipFieldsProcessing = false, Func provider = null) + { + if (points == null) return; + + var pointsLength = points.Length; + + if (pointsLength == 0) return; + + if (index < 0 || index > PointsCount) throw new UnityException("Unable to add points. Invalid index: " + index); + + + FireBeforeChange(EventAddPoints); + + BGCurvePointI[] addedPoints; + var hasPointTransform = pointsWithTransforms != null && pointsWithTransforms.Count > 0; + + //add points + switch (pointsMode) + { + case PointsModeEnum.Inlined: + + this.points = Insert(this.points, index, points); + if (!hasPointTransform) + { + for (var i = 0; i < pointsLength; i++) + { + if (points[i].PointTransform == null) continue; + hasPointTransform = true; + break; + } + } + addedPoints = points; + break; + case PointsModeEnum.Components: + + var toAdd = new BGCurvePointComponent[pointsLength]; + for (var i = 0; i < pointsLength; i++) + { + var point = points[i]; + hasPointTransform = hasPointTransform || point.PointTransform != null; + toAdd[i] = (BGCurvePointComponent) Convert(point, PointsModeEnum.Inlined, pointsMode, provider); + } + pointsComponents = Insert(pointsComponents, index, toAdd); + + addedPoints = points; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + + var pointsToAdd = new BGCurvePointGO[pointsLength]; + for (var i = 0; i < pointsLength; i++) + { + var point = points[i]; + hasPointTransform = hasPointTransform || point.PointTransform != null; + pointsToAdd[i] = (BGCurvePointGO) Convert(point, PointsModeEnum.Inlined, pointsMode, provider); + } + pointsGameObjects = Insert(pointsGameObjects, index, pointsToAdd); + + SetPointsNames(); + + addedPoints = pointsToAdd; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + + + //process fields + if (!skipFieldsProcessing && FieldsCount > 0) AddFields(pointsMode, addedPoints); + + //point transforms + if (hasPointTransform) CachePointsWithTransforms(); + + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventAddPoints)); + } + + // removes a point. this method is not meant to be public, Editor uses it via reflection + private void Delete(int index, Action destroyer) + { + if (index < 0 || index >= PointsCount) throw new UnityException("Unable to remove a point. Invalid index: " + index); + + switch (pointsMode) + { + case PointsModeEnum.Inlined: + pointArray[0] = points[index]; + break; + case PointsModeEnum.Components: + pointArray[0] = pointsComponents[index]; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + pointArray[0] = pointsGameObjects[index]; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + Delete(pointArray, destroyer); + } + + // removes points. this method is not meant to be public, Editor uses it via reflection + private void Delete(BGCurvePointI[] pointsToDelete, Action destroyer) + { + if (pointsToDelete == null || pointsToDelete.Length == 0 || PointsCount == 0) return; + + pointsList.Clear(); + pointsIndexesList.Clear(); + + var oldPoints = Points; + + //find point indexes + var length = pointsToDelete.Length; + for (var i = 0; i < length; i++) + { + var index = Array.IndexOf(oldPoints, pointsToDelete[i]); + if (index >= 0) pointsIndexesList.Add(index); + } + + //no luck + if (pointsIndexesList.Count == 0) return; + + //at this point we know for sure we have to delete at least one point + FireBeforeChange(EventDeletePoints); + + //assign new array + var newLength = oldPoints.Length - pointsIndexesList.Count; + BGCurvePointI[] newPoints; + switch (pointsMode) + { + case PointsModeEnum.Inlined: + points = new BGCurvePoint[newLength]; + newPoints = points; + break; + case PointsModeEnum.Components: + pointsComponents = new BGCurvePointComponent[newLength]; + newPoints = pointsComponents; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + pointsGameObjects = new BGCurvePointGO[newLength]; + newPoints = pointsGameObjects; + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + + //sort indexes to delete + pointsIndexesList.Sort(); + + //fill new array + var cursor = 0; + var count = pointsIndexesList.Count; + for (var i = 0; i < count; i++) + { + var indexToRemove = pointsIndexesList[i]; + + if (indexToRemove > cursor) Array.Copy(oldPoints, cursor, newPoints, cursor - i, indexToRemove - cursor); + + cursor = indexToRemove + 1; + + switch (pointsMode) + { + case PointsModeEnum.Components: + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + pointsList.Add(oldPoints[indexToRemove]); + break; + } + } + if (cursor < oldPoints.Length) Array.Copy(oldPoints, cursor, newPoints, cursor - count, oldPoints.Length - cursor); + + + //sort and set new names for GO points + switch (pointsMode) + { + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + SetPointsNames(); + break; + } + + //destroy + if (pointsList.Count > 0) + { + var pointsCount = pointsList.Count; + for (var i = 0; i < pointsCount; i++) + { + var toDelete = pointsList[i]; + + if (destroyer != null) destroyer(toDelete); + else + { + switch (pointsMode) + { + case PointsModeEnum.Components: + DestroyIt((Object) toDelete); + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + DestroyIt(((BGCurvePointGO) toDelete).gameObject); + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + } + } + } + + CachePointsWithTransforms(); + + pointsList.Clear(); + pointsIndexesList.Clear(); + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventDeletePoints)); + } + + // ============================================== Point conversion + //convert between points store options, attached to GameObject. it's also accessed via reflection by Editor + // !! NOTE: do not change the order of different actions- it affects Undo/Redo operations + private void ConvertPoints(PointsModeEnum pointsMode, Func provider = null, Action destroyer = null) + { + var oldMode = PointsMode; + if (oldMode == pointsMode) return; + + FireBeforeChange(EventPointsMode); + + switch (oldMode) + { + case PointsModeEnum.Inlined: + + if (points.Length > 0) + { + //------------------------------------------------------- from inlined + + switch (pointsMode) + { + case PointsModeEnum.Components: + { + // to components + var toAdd = new BGCurvePointComponent[points.Length]; + for (var i = 0; i < points.Length; i++) toAdd[i] = (BGCurvePointComponent) Convert(points[i], oldMode, pointsMode, provider); + + this.pointsMode = pointsMode; + pointsComponents = Insert(pointsComponents, 0, toAdd); + + //no need to process fields, cause the same point is reused + } + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + { + // to gameobjects + var toAdd = new BGCurvePointGO[points.Length]; + + for (var i = 0; i < points.Length; i++) toAdd[i] = (BGCurvePointGO) Convert(points[i], oldMode, pointsMode, provider); + + this.pointsMode = pointsMode; + pointsGameObjects = Insert(pointsGameObjects, 0, toAdd); + + SetPointsNames(); + + //fields + if (FieldsCount > 0) AddFields(pointsMode, toAdd); + } + break; + } + points = new BGCurvePoint[0]; + } + break; + case PointsModeEnum.Components: + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + + var hasAnyPoint = oldMode == PointsModeEnum.Components && pointsComponents.Length > 0 || (IsGoMode(oldMode) && pointsGameObjects.Length > 0); + + if (hasAnyPoint) + { + //------------------------------------------------------- from components OR from GO + BGCurvePointI[] toRemove = null; + if (oldMode == PointsModeEnum.Components) + { + //------------------------------------------------------- from components + switch (pointsMode) + { + case PointsModeEnum.Inlined: + var pointsToAdd = new BGCurvePoint[pointsComponents.Length]; + + for (var i = 0; i < pointsComponents.Length; i++) pointsToAdd[i] = (BGCurvePoint) Convert(pointsComponents[i], oldMode, pointsMode, provider); + + points = Insert(points, 0, pointsToAdd); + + //no need to process fields, cause the same point is reused + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + var toAdd = new BGCurvePointGO[pointsComponents.Length]; + + for (var i = 0; i < pointsComponents.Length; i++) toAdd[i] = (BGCurvePointGO) Convert(pointsComponents[i], oldMode, pointsMode, provider); + + pointsGameObjects = Insert(pointsGameObjects, 0, toAdd); + + SetPointsNames(); + + //fields + if (FieldsCount > 0) AddFields(pointsMode, toAdd); + + break; + } + + toRemove = pointsComponents; + pointsComponents = new BGCurvePointComponent[0]; + } + else + { + //------------------------------------------------------- from GO + + switch (pointsMode) + { + case PointsModeEnum.Inlined: + + var pointsToAdd = new BGCurvePoint[pointsGameObjects.Length]; + + for (var i = 0; i < pointsGameObjects.Length; i++) pointsToAdd[i] = (BGCurvePoint) Convert(pointsGameObjects[i], oldMode, pointsMode, provider); + + points = Insert(points, 0, pointsToAdd); + + toRemove = pointsGameObjects; + break; + + case PointsModeEnum.Components: + + var toAdd = new BGCurvePointComponent[pointsGameObjects.Length]; + + for (var i = 0; i < pointsGameObjects.Length; i++) toAdd[i] = (BGCurvePointComponent) Convert(pointsGameObjects[i], oldMode, pointsMode, provider); + + pointsComponents = Insert(pointsComponents, 0, toAdd); + + toRemove = pointsGameObjects; + break; + + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + + for (var i = 0; i < pointsGameObjects.Length; i++) Convert(pointsGameObjects[i], oldMode, pointsMode, provider); + break; + } + + if (toRemove != null) pointsGameObjects = new BGCurvePointGO[0]; + } + + //------------------------------------------------------- from components OR from GO + //do not remove (it's here for undo/redo) + this.pointsMode = pointsMode; + if (toRemove != null) + { + //here we need to destroy Unity's persistent objects we dont use anymore (it should be the last action) + var useComponents = oldMode == PointsModeEnum.Components; + for (var i = 0; i < toRemove.Length; i++) + { + var pointComponent = toRemove[i]; + + if (destroyer != null) destroyer(pointComponent); + else DestroyIt(useComponents ? (Object) pointComponent : ((BGCurvePointGO) pointComponent).gameObject); + } + } + } + + break; + default: + throw new ArgumentOutOfRangeException("pointsMode"); + } + + this.pointsMode = pointsMode; + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Points, EventPointsMode)); + } + + //convert point's mode + private static BGCurvePointI Convert(BGCurvePointI point, PointsModeEnum from, PointsModeEnum to, Func provider) + { + BGCurvePointI result; + switch (from) + { + case PointsModeEnum.Inlined: + //------------------------------------------ From inline + switch (to) + { + case PointsModeEnum.Components: + + //---------- To components + + result = provider == null ? point.Curve.gameObject.AddComponent() : (BGCurvePointComponent) provider(); + ((BGCurvePointComponent) result).PrivateInit((BGCurvePoint) point); + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + + //---------- To GO + result = ConvertInlineToGo((BGCurvePoint) point, to, provider); + break; + default: + throw new ArgumentOutOfRangeException("to", to, null); + } + break; + case PointsModeEnum.Components: + //------------------------------------------ From Component + switch (to) + { + case PointsModeEnum.Inlined: + + //---------- To inline + + result = ((BGCurvePointComponent) point).Point; + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + + //---------- To GO + result = ConvertInlineToGo(((BGCurvePointComponent) point).Point, to, provider); + break; + default: + throw new ArgumentOutOfRangeException("to", to, null); + } + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + //------------------------------------------ From GO + + switch (to) + { + case PointsModeEnum.Inlined: + + //---------- To inline + + result = ConvertGoToInline((BGCurvePointGO) point, from); + break; + + case PointsModeEnum.Components: + + //---------- To Component + + result = provider != null ? (BGCurvePointComponent) provider() : point.Curve.gameObject.AddComponent(); + ((BGCurvePointComponent) result).PrivateInit(ConvertGoToInline((BGCurvePointGO) point, from)); + break; + case PointsModeEnum.GameObjectsNoTransform: + case PointsModeEnum.GameObjectsTransform: + ((BGCurvePointGO) point).PrivateInit(null, to); + result = point; + break; + default: + throw new ArgumentOutOfRangeException("to", to, null); + } + break; + default: + throw new ArgumentOutOfRangeException("from", @from, null); + } + + //point references + var pointTransform = point.PointTransform; + if (pointTransform != null) + { + BGCurveReferenceToPoint reference = null; + + if (from != PointsModeEnum.Inlined) reference = BGCurveReferenceToPoint.GetReferenceToPoint(point); + + if (to != PointsModeEnum.Inlined) + { + //not inlined + if (reference == null) reference = pointTransform.gameObject.AddComponent(); + reference.Point = result; + } + else + { + //inlined + if (reference != null) DestroyIt(reference); + } + } + + return result; + } + + //convert point from Inline to GameObject + private static BGCurvePointGO ConvertInlineToGo(BGCurvePoint point, PointsModeEnum to, Func provider) + { + BGCurvePointGO pointGO; + if (provider != null) pointGO = (BGCurvePointGO) provider(); + else + { + var gameObjectForPoint = new GameObject(); + var pointTransform = gameObjectForPoint.transform; + pointTransform.parent = point.Curve.transform; + pointTransform.localRotation = Quaternion.identity; + pointTransform.localPosition = Vector3.zero; + pointTransform.localScale = Vector3.one; + pointGO = gameObjectForPoint.AddComponent(); + } + + pointGO.PrivateInit(point, to); + + //transfer fields + pointGO.PrivateValuesForFields = point.PrivateValuesForFields; + + return pointGO; + } + + //convert point from GameObject to Inline + private static BGCurvePoint ConvertGoToInline(BGCurvePointGO pointGO, PointsModeEnum @from) + { + BGCurvePoint result; + switch (@from) + { + case PointsModeEnum.GameObjectsNoTransform: + result = new BGCurvePoint(pointGO.Curve, pointGO.PointTransform, pointGO.PositionLocal, pointGO.ControlType, pointGO.ControlFirstLocal, pointGO.ControlSecondLocal); + break; + case PointsModeEnum.GameObjectsTransform: + var transform = pointGO.PointTransform != null ? pointGO.PointTransform : pointGO.Curve.transform; + var control1 = transform.InverseTransformVector(pointGO.ControlFirstLocalTransformed); + var control2 = transform.InverseTransformVector(pointGO.ControlSecondLocalTransformed); + result = new BGCurvePoint(pointGO.Curve, pointGO.PointTransform, pointGO.PositionLocal, pointGO.ControlType, control1, control2); + break; + default: + throw new ArgumentOutOfRangeException("PointsModeEnum"); + } + + + //transfer fields + if (pointGO.Curve.FieldsCount > 0) result.PrivateValuesForFields = pointGO.PrivateValuesForFields; + + return result; + } + + + // ============================================== Events + //fires a "final" event. By default events are grouped within single frame and one single event is fired at Update or LateUpdate + private void FireFinalEvent() + { + var transformChanged = transform.hasChanged; + + var forceUpdateEveryFrame = forceChangedEventMode == ForceChangedEventModeEnum.EditorAndRuntime; + + if (!transformChanged && immediateChangeEvents && !forceUpdateEveryFrame) return; + + //check additionally for point's changes + if (pointsMode == PointsModeEnum.GameObjectsTransform) + { + var points = (BGCurvePointGO[]) Points; + var length = points.Length; + for (var i = 0; i < length; i++) + { + var point = points[i]; + var pointTransform = point.gameObject.transform; + if (!pointTransform.hasChanged) continue; + + pointTransform.hasChanged = false; + changed = true; + lastEventType = BGCurveChangedArgs.ChangeTypeEnum.Points; + lastEventMessage = EventPointPosition; + } + } + + //check points transforms + if (pointsWithTransforms != null) + { + var pointsWithTransformsCount = pointsWithTransforms.Count; + if (pointsWithTransformsCount > 0) + { + var points = Points; + var pointCount = points.Length; + for (var i = 0; i < pointsWithTransformsCount; i++) + { + var index = pointsWithTransforms[i]; + if (index >= pointCount) continue; + + var point = points[index]; + var pointTransform = point.PointTransform; + if (pointTransform == null || !pointTransform.hasChanged) continue; + + pointTransform.hasChanged = false; + changed = true; + lastEventType = BGCurveChangedArgs.ChangeTypeEnum.Points; + lastEventMessage = EventPointPosition; + } + } + } + + if (!transformChanged && !changed && !forceUpdateEveryFrame) return; + + if (changed) FireChange(UseEventsArgs ? BGCurveChangedArgs.GetInstance(this, lastEventType, lastEventMessage) : null, true); + else if (transformChanged) FireChange(UseEventsArgs ? BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.CurveTransform, EventTransform) : null, true); + else FireChange(UseEventsArgs ? BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Curve, EventForcedUpdate) : null, true); + + transform.hasChanged = changed = false; + } + + + // ============================================== Fields + + //add fields to provided points + private void AddFields(PointsModeEnum pointsMode, BGCurvePointI[] addedPoints) + { + foreach (var point in addedPoints) + { + var fieldsValues = GetFieldsValues(point, pointsMode); + foreach (var field in fields) BGCurvePoint.PrivateFieldAdded(field, fieldsValues); + } + } + + //add a custom field. this method is not meant to be public, Editor uses it via reflection + private BGCurvePointField AddField(string name, BGCurvePointField.TypeEnum type, Func provider = null) + { + //check if name is ok + BGCurvePointField.CheckName(this, name, true); + + FireBeforeChange(EventAddField); + + //at this point the change is certainly will occur + //add a field + var field = provider == null ? gameObject.AddComponent() : provider(); + field.hideFlags = HideFlags.HideInInspector; + field.Init(this, name, type); + + fields = Insert(fields, fields.Length, field); + + PrivateUpdateFieldsValuesIndexes(); + + if (PointsCount > 0) + { + //update all points + var points = Points; + foreach (var point in points) BGCurvePoint.PrivateFieldAdded(field, GetFieldsValues(point, pointsMode)); + } + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Fields, EventAddField)); + + return field; + } + + // delete a custom field. this method is not meant to be public, Editor uses it via reflection + private void DeleteField(BGCurvePointField field, Action destroyer = null) + { + //find field index + var deletedIndex = IndexOf(fields, field); + if (deletedIndex < 0 || deletedIndex >= fields.Length) throw new UnityException("Unable to remove a fields. Invalid index: " + deletedIndex); + + //get the index for field's value + var indexOfField = IndexOfFieldValue(field.FieldName); + + FireBeforeChange(EventDeleteField); + + //at this point the change is certainly will occur + //remove field from list + fields = Remove(fields, deletedIndex); + + //update fields values indexes. See FieldsTree commments for more details + PrivateUpdateFieldsValuesIndexes(); + + if (PointsCount > 0) + { + //update all points + var points = Points; + foreach (var point in points) BGCurvePoint.PrivateFieldDeleted(field, indexOfField, GetFieldsValues(point, pointsMode)); + } + + //destroy field component + if (destroyer == null) DestroyIt(field); + else destroyer(field); + + + FireChange(BGCurveChangedArgs.GetInstance(this, BGCurveChangedArgs.ChangeTypeEnum.Fields, EventDeleteField)); + } + + // ============================================== Point's transforms + //find points with Transforms attached + private void CachePointsWithTransforms() + { + if (pointsWithTransforms != null) pointsWithTransforms.Clear(); + var points = Points; + var count = points.Length; + for (var i = 0; i < count; i++) + { + if (points[i].PointTransform != null) + { + if (pointsWithTransforms == null) pointsWithTransforms = new List(); + pointsWithTransforms.Add(i); + } + } + } + + // ============================================== Utils + //destroy Unity object + public static void DestroyIt(Object obj) + { + if (Application.isEditor) DestroyImmediate(obj); + else Destroy(obj); + } + + #endregion + + #region Private Classes + + //=============================================================================================== + // Private classes + //=============================================================================================== + + // stores info about how fields values should be stored. + // fields values are stored in arrays, so we need to keep track of index within this array for each field + private sealed class FieldsTree + { + private readonly Dictionary fieldName2Index = new Dictionary(); + + /// if current index is up-to-date? + public bool Comply(BGCurvePointField[] fields) + { + return fields == null ? fieldName2Index.Count == 0 : fieldName2Index.Count == fields.Length; + } + + /// get index by field's name + public int GetIndex(string name) + { + int index; + if (fieldName2Index.TryGetValue(name, out index)) return index; + throw new UnityException("Can not find a index of field " + name); + } + + /// update whole index + public void Update(BGCurvePointField[] fields) + { + fieldName2Index.Clear(); + int boolIndex = 0, + intIndex = 0, + floatIndex = 0, + vector3Index = 0, + boundsIndex = 0, + colorIndex = 0, + stringIndex = 0, + quaternionIndex = 0, + animationCurveIndex = 0, + gameObjectIndex = 0, + componentIndex = 0, + bgCurveIndex = 0, + bgCurvePointComponentIndex = 0, + bgCurvePointGOIndex = 0; + + foreach (var field in fields) + { + int index; + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bool: + index = boolIndex++; + break; + case BGCurvePointField.TypeEnum.Int: + index = intIndex++; + break; + case BGCurvePointField.TypeEnum.Float: + index = floatIndex++; + break; + case BGCurvePointField.TypeEnum.Vector3: + index = vector3Index++; + break; + case BGCurvePointField.TypeEnum.Bounds: + index = boundsIndex++; + break; + case BGCurvePointField.TypeEnum.Color: + index = colorIndex++; + break; + case BGCurvePointField.TypeEnum.String: + index = stringIndex++; + break; + case BGCurvePointField.TypeEnum.Quaternion: + index = quaternionIndex++; + break; + case BGCurvePointField.TypeEnum.AnimationCurve: + index = animationCurveIndex++; + break; + case BGCurvePointField.TypeEnum.GameObject: + index = gameObjectIndex++; + break; + case BGCurvePointField.TypeEnum.Component: + index = componentIndex++; + break; + case BGCurvePointField.TypeEnum.BGCurve: + index = bgCurveIndex++; + break; + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + index = bgCurvePointComponentIndex++; + break; + case BGCurvePointField.TypeEnum.BGCurvePointGO: + index = bgCurvePointGOIndex++; + break; + default: + throw new UnityException("Unknown type " + field.Type); + } + + fieldName2Index[field.FieldName] = index; + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs.meta new file mode 100644 index 0000000..69f5610 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurve.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e70f079e2a6bf364e8185b765fbe61c0 +timeCreated: 1476942102 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs new file mode 100644 index 0000000..14352cf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs @@ -0,0 +1,421 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// Adaptive curve subdivision math. It split the spline into uneven parts, based on the curvature. + /// Strictly speaking, it still uses uniform splitting, but it can omit and add points when needed, resulting in better approximation and less points. + /// + public class BGCurveAdaptiveMath : BGCurveBaseMath + { + //------------------------------------------------------------------------ + //min tolerance value + public const float MinTolerance = 0.1f; + //max tolerance value + public const float MaxTolerance = 0.9999750f; + //distance tolerance (to avoid spamming points at one single location) + public const float DistanceTolerance = 0.01f; + //max recursion level + private const int RecursionLimit = 24; + + //force section to recalculate + private bool ignoreSectionChangedCheckOverride; + + //normalized tolerance + private float toleranceRatio; + //normalized tolerance squared + private float toleranceRatioSquared; + + //tolerance + private float tolerance; + + /// Create new math with config options + public BGCurveAdaptiveMath(BGCurve curve, ConfigAdaptive config) + : base(curve, config) + { + } + + /// Init math with new config and recalculate data + public override void Init(Config config) + { + var configAdaptive = (ConfigAdaptive) config; + + tolerance = Mathf.Clamp(configAdaptive.Tolerance, MinTolerance, MaxTolerance); + + //pow 4 + tolerance *= tolerance; + tolerance *= tolerance; + + //normalized + toleranceRatio = 1/(1 - tolerance); + toleranceRatioSquared = toleranceRatio*toleranceRatio; + + //if old tolerance is different- we force section recalculation + ignoreSectionChangedCheckOverride = this.config == null || Math.Abs(((ConfigAdaptive) this.config).Tolerance - tolerance) > BGCurve.Epsilon; + + //recalculate + base.Init(config); + } + + //Reset pooled section with new data and recalculates if needed + protected override bool Reset(SectionInfo section, BGCurvePointI @from, BGCurvePointI to, int pointsCount) + { + return section.Reset(@from, to, section.PointsCount, ignoreSectionChangedCheck || ignoreSectionChangedCheckOverride); + } + + protected override bool IsUseDistanceToAdjustTangents(SectionInfo section, SectionInfo prevSection) + { + return true; + } + + //approximate split section + //this method contains some intentional copy/paste + protected override void CalculateSplitSection(SectionInfo section, BGCurvePointI @from, BGCurvePointI to) + { + //if set to true, tangent formula will be used to calc tangents + var calcTangents = cacheTangent && !config.UsePointPositionsToCalcTangents; + + + var points = section.points; + var count = points.Count; + //move all existing points to the pool (the number of points depends on the curvature) + for (var i = 0; i < count; i++) poolPointInfos.Add(points[i]); + points.Clear(); + + //original points and control types + var p0 = section.OriginalFrom; + var p1 = section.OriginalFromControl; + var p2 = section.OriginalToControl; + var p3 = section.OriginalTo; + + //type of the curve (0-absent,3-both Bezier, 1 or 2 - one of the points has Bezier controls) + var type = (section.OriginalFromControlType != BGCurvePoint.ControlTypeEnum.Absent ? 2 : 0) + (section.OriginalToControlType != BGCurvePoint.ControlTypeEnum.Absent ? 1 : 0); + + //===================================== first point + SectionPointInfo firstPoint; + var poolCursor = poolPointInfos.Count - 1; + if (poolCursor >= 0) + { + firstPoint = poolPointInfos[poolCursor]; + poolPointInfos.RemoveAt(poolCursor); + } + else firstPoint = new SectionPointInfo(); + firstPoint.Position = p0; + firstPoint.DistanceToSectionStart = 0; + points.Add(firstPoint); + + //==================================== split recursively + switch (type) + { + case 3: + RecursiveCubicSplit(section, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z, 0, calcTangents, 0, 1); + break; + case 2: + RecursiveQuadraticSplit(section, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p3.x, p3.y, p3.z, 0, false, calcTangents, 0, 1); + break; + case 1: + RecursiveQuadraticSplit(section, p0.x, p0.y, p0.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z, 0, true, calcTangents, 0, 1); + break; + } + + //===================================== last point + SectionPointInfo lastPoint; + poolCursor = poolPointInfos.Count - 1; + if (poolCursor >= 0) + { + lastPoint = poolPointInfos[poolCursor]; + poolPointInfos.RemoveAt(poolCursor); + } + else lastPoint = new SectionPointInfo(); + lastPoint.Position = p3; + points.Add(lastPoint); + + + //calculate distances (and optionally tangents) + //if set to true, points positions will be used to calculate tangents + calcTangents = cacheTangent && config.UsePointPositionsToCalcTangents; + var prevPoint = points[0]; + for (var i = 1; i < points.Count; i++) + { + var point = points[i]; + + var pos = point.Position; + var prevPos = prevPoint.Position; + + var dX = (double) pos.x - prevPos.x; + var dY = (double) pos.y - prevPos.y; + var dZ = (double) pos.z - prevPos.z; + + //distance + point.DistanceToSectionStart = prevPoint.DistanceToSectionStart + ((float) Math.Sqrt(dX*dX + dY*dY + dZ*dZ)); + + //tangents + if (calcTangents) point.Tangent = Vector3.Normalize(pos - prevPos); + + prevPoint = point; + } + + //set first and last points tangents (cause they was omitted during recursive split) + if (cacheTangent) + { + if (config.UsePointPositionsToCalcTangents) + { + firstPoint.Tangent = (points[1].Position - firstPoint.Position).normalized; + lastPoint.Tangent = points[points.Count - 2].Tangent; + } + else + { + switch (type) + { + case 0: + firstPoint.Tangent = lastPoint.Tangent = (lastPoint.Position - firstPoint.Position).normalized; + break; + case 1: + firstPoint.Tangent = Vector3.Normalize(section.OriginalToControl - section.OriginalFrom); + lastPoint.Tangent = Vector3.Normalize(section.OriginalTo - section.OriginalToControl); + break; + case 2: + firstPoint.Tangent = Vector3.Normalize(section.OriginalFromControl - section.OriginalFrom); + lastPoint.Tangent = Vector3.Normalize(section.OriginalTo - section.OriginalFromControl); + break; + case 3: + firstPoint.Tangent = Vector3.Normalize(section.OriginalFromControl - section.OriginalFrom); + lastPoint.Tangent = Vector3.Normalize(section.OriginalTo - section.OriginalToControl); + break; + } + } + } + } + + + //------------------------------------------------------------------------ Quadratic + //this method contains some intentional copy/paste + private void RecursiveQuadraticSplit(SectionInfo section, double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, int level, bool useSecond, + bool calcTangents, double fromT, double toT) + { + if (level > RecursionLimit) return; + + // is curve flat + // http://www.malinc.se/m/DeCasteljauAndBezier.php + // sqr(b) + sqr(c) < sqr(a) * tolerance + var dx01 = x0 - x1; + var dy01 = y0 - y1; + var dz01 = z0 - z1; + + var dx12 = x1 - x2; + var dy12 = y1 - y2; + var dz12 = z1 - z2; + + var dx02 = x0 - x2; + var dy02 = y0 - y2; + var dz02 = z0 - z2; + + var a = dx02*dx02 + dy02*dy02 + dz02*dz02; + var b = dx01*dx01 + dy01*dy01 + dz01*dz01; + var c = dx12*dx12 + dy12*dy12 + dz12*dz12; + + var temp = a*toleranceRatioSquared - b - c; + + if (4*b*c < temp*temp || a + b + c < DistanceTolerance) return; + + //at this point we know, the curve is not flat + // split (Casteljau algorithm) + var x01 = (x0 + x1)*.5; + var y01 = (y0 + y1)*.5; + var z01 = (z0 + z1)*.5; + + var x12 = (x1 + x2)*.5; + var y12 = (y1 + y2)*.5; + var z12 = (z1 + z2)*.5; + + var x012 = (x01 + x12)*.5; + var y012 = (y01 + y12)*.5; + var z012 = (z01 + z12)*.5; + + + var t = calcTangents ? (fromT + toT)*.5 : .0; + + var pos = new Vector3((float) x012, (float) y012, (float) z012); + + //apply snapping + if (curve.SnapType == BGCurve.SnapTypeEnum.Curve) curve.ApplySnapping(ref pos); + + //split first section + RecursiveQuadraticSplit(section, x0, y0, z0, x01, y01, z01, x012, y012, z012, level + 1, useSecond, calcTangents, fromT, t); + + //add point + SectionPointInfo pointInfo; + var poolCursor = poolPointInfos.Count - 1; + if (poolCursor >= 0) + { + pointInfo = poolPointInfos[poolCursor]; + poolPointInfos.RemoveAt(poolCursor); + } + else pointInfo = new SectionPointInfo(); + pointInfo.Position = pos; + section.points.Add(pointInfo); + + //tangents + if (calcTangents) + { + var control = useSecond ? section.OriginalToControl : section.OriginalFromControl; + //idea.. optimize it + pointInfo.Tangent = Vector3.Normalize(2*(1 - (float) t)*(control - section.OriginalFrom) + 2*(float) t*(section.OriginalTo - control)); + } + + //split second section + RecursiveQuadraticSplit(section, x012, y012, z012, x12, y12, z12, x2, y2, z2, level + 1, useSecond, calcTangents, t, toT); + } + + + //------------------------------------------------------------------------ Cubic + //this method contains some intentional copy/paste + private void RecursiveCubicSplit(SectionInfo section, double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, + int level, bool calcTangents, double fromT, double toT) + { + if (level > RecursionLimit) return; + + // is curve flat + // http://www.malinc.se/m/DeCasteljauAndBezier.php + // sqr(b) + sqr(c) + sqr(d) < sqr(a) * tolerance + + var dx01 = x0 - x1; + var dy01 = y0 - y1; + var dz01 = z0 - z1; + + var dx12 = x1 - x2; + var dy12 = y1 - y2; + var dz12 = z1 - z2; + + var dx23 = x2 - x3; + var dy23 = y2 - y3; + var dz23 = z2 - z3; + + var dx03 = x0 - x3; + var dy03 = y0 - y3; + var dz03 = z0 - z3; + + var a = dx03*dx03 + dy03*dy03 + dz03*dz03; + var b = dx01*dx01 + dy01*dy01 + dz01*dz01; + var c = dx12*dx12 + dy12*dy12 + dz12*dz12; + var d = dx23*dx23 + dy23*dy23 + dz23*dz23; + + //idea.. optimize sqrt. Sqrt is expensive call, and 3 Sqrt calls is super expensive to say the least + if (Math.Sqrt(b*c) + Math.Sqrt(c*d) + Math.Sqrt(b*d) < (a*toleranceRatioSquared - b - c - d)*.5 || a + b + c + d < DistanceTolerance) return; + + //at this point we know, the curve is not flat + //split (Casteljau algorithm) + var x01 = (x0 + x1)*.5; + var y01 = (y0 + y1)*.5; + var z01 = (z0 + z1)*.5; + var x12 = (x1 + x2)*.5; + var y12 = (y1 + y2)*.5; + var z12 = (z1 + z2)*.5; + var x23 = (x2 + x3)*.5; + var y23 = (y2 + y3)*.5; + var z23 = (z2 + z3)*.5; + + var x012 = (x01 + x12)*.5; + var y012 = (y01 + y12)*.5; + var z012 = (z01 + z12)*.5; + var x123 = (x12 + x23)*.5; + var y123 = (y12 + y23)*.5; + var z123 = (z12 + z23)*.5; + + var x0123 = (x012 + x123)*.5; + var y0123 = (y012 + y123)*.5; + var z0123 = (z012 + z123)*.5; + + var t = calcTangents ? (fromT + toT)*.5 : .0; + + var pos = new Vector3((float) x0123, (float) y0123, (float) z0123); + + if (curve.SnapType == BGCurve.SnapTypeEnum.Curve) curve.ApplySnapping(ref pos); + + //split first section + RecursiveCubicSplit(section, x0, y0, z0, x01, y01, z01, x012, y012, z012, x0123, y0123, z0123, level + 1, calcTangents, fromT, t); + + //add point + SectionPointInfo pointInfo; + var poolCursor = poolPointInfos.Count - 1; + if (poolCursor >= 0) + { + pointInfo = poolPointInfos[poolCursor]; + poolPointInfos.RemoveAt(poolCursor); + } + else pointInfo = new SectionPointInfo(); + pointInfo.Position = pos; + section.points.Add(pointInfo); + + //tangent + if (calcTangents) + { + var tr = 1 - t; + //idea.. optimize it + pointInfo.Tangent = Vector3.Normalize(3*((float) (tr*tr))*(section.OriginalFromControl - section.OriginalFrom) + + 6*(float) (tr*t)*(section.OriginalToControl - section.OriginalFromControl) + + 3*(float) (t*t)*(section.OriginalTo - section.OriginalToControl)); + } + + + //split second section + RecursiveCubicSplit(section, x0123, y0123, z0123, x123, y123, z123, x23, y23, z23, x3, y3, z3, level + 1, calcTangents, t, toT); + } + + /// Configuration options for Adaptive Math + public class ConfigAdaptive : Config + { + /// + /// This parameter is used to calculate if curve's flat and no more splitting is required + /// Note: The final tolerance parameter, used by Math, is based on this value, but differs + /// + public float Tolerance = .2f; + + /// Construct new config + public ConfigAdaptive(Fields fields) : base(fields) + { + } + } + + public override string ToString() + { + return "Adaptive Math for curve (" + Curve + "), sections=" + SectionsCount; + } + } + + /* + Roger Willcocks flat criteria for quadratic (something wrong here) + var ax = 2*x1 - x2 - x0; + var ay = 2*y1 - y2 - y0; + var az = 2*z1 - z2 - z0; + ax *= ax; + ay *= ay; + az *= az; + + if (ax + ay + az < tolerance) return; +*/ + + /* + Roger Willcocks flat criteria for cubic (does not work well at all)- maybe a bbug or something- have no idea + var ax = 3*x1 - 2*x0 - x3; + var ay = 3*y1 - 2*y0 - y3; + var az = 3*z1 - 2*z0 - z3; + ax *= ax; + ay *= ay; + az *= az; + + var bx = 3*x2 - x0 - 2*x3; + var by = 3*y2 - y0 - 2*y3; + var bz = 3*z2 - z0 - 2*z3; + bx *= bx; + by *= by; + bz *= bz; + + if (Math.Max(ax, bx) + Math.Max(ay, by) + Math.Max(az, bz) < tolerance) return; +*/ +/* + // For Willckock's criteria: 16 and exponenta originate from the flatness calculation + tolerance *= tolerance*16; + */ +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs.meta new file mode 100644 index 0000000..88f470c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveAdaptiveMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a072c590a2e0f41498bf52d7125be6f5 +timeCreated: 1475717589 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs new file mode 100644 index 0000000..a4b273a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs @@ -0,0 +1,1587 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// Basic math operations for curves (Distance, Position, Tangent, Closest point ). + /// It caches some data for quick access and recalculate it if curve changes. + /// It uses uniform split with forward differencing algorithm, which is the fastest available (for uniform split). + /// + public class BGCurveBaseMath : BGCurveMathI, IDisposable + { + #region events + + //=============================================================================================== + // Events + //=============================================================================================== + + /// Change was requested by changed curve's data + public event EventHandler ChangeRequested; + + /// Math was changed + public event EventHandler Changed; + + #endregion + + #region fields + + //=============================================================================================== + // Fields + //=============================================================================================== + + /// all possible attributes (fields) to calculate + public enum Field + { + Position = 1, + Tangent = 2, + } + + /// which fields to precalculate + public enum Fields + { + Position = 1, + PositionAndTangent = 3, + } + + //curve + protected readonly BGCurve curve; + //what and how to calc + protected Config config; + + //cached data for length calculations + protected readonly List cachedSectionInfos = new List(); + + // pools for sections + protected readonly List poolSectionInfos = new List(); + // pools for points + protected readonly List poolPointInfos = new List(); + + //curve's length + protected float cachedLength; + + //should we calculate position? (This is probably always true) + protected bool cachePosition; + //should we calculate tangent? + protected bool cacheTangent; + + //closest point calculator + protected BGCurveCalculatorClosestPoint closestPointCalculator; + + // frame when data was recalculated + private int recalculatedAtFrame = -1; + // frame when math was created + private int createdAtFrame; + + // force section recalculation, even if it's not changed + protected bool ignoreSectionChangedCheck; + + //some coefficients (these are used by approximation algorithm) + private double h; + private double h2; + private double h3; + + /// Suppress all warnings, printed to the log + public bool SuppressWarning { get; set; } + + /// get Curve + public BGCurve Curve + { + get { return curve; } + } + + /// Get calculated sections data + public List SectionInfos + { + get { return cachedSectionInfos; } + } + + /// Access calculated section's data by index + public SectionInfo this[int i] + { + get { return cachedSectionInfos[i]; } + } + + /// How much sections in total + public int SectionsCount + { + get { return cachedSectionInfos.Count; } + } + + /// Get last used config + public Config Configuration + { + get { return config; } + } + + // if tangent is calculated and formula is needed + protected bool NeedTangentFormula + { + get { return !config.UsePointPositionsToCalcTangents && cacheTangent; } + } + + /// How much approximation points are used in total + public int PointsCount + { + get + { + if (SectionsCount == 0) return 0; + var count = 0; + var length = cachedSectionInfos.Count; + for (var i = 0; i < length; i++) count += cachedSectionInfos[i].PointsCount; + return count; + } + } + + #endregion + + #region constructors + + //=============================================================================================== + // Constructors + //=============================================================================================== + + /// Math with default config settings + public BGCurveBaseMath(BGCurve curve) : this(curve, new Config(Fields.Position)) + { + } + + /// Math with config settings + public BGCurveBaseMath(BGCurve curve, Config config) + { + this.curve = curve; + curve.Changed += CurveChanged; + Init(config ?? new Config(Fields.Position)); + } + + /// This is an old constructor, left for compatibility. Only Fields.PositionWorld is calculated. + /// Use another constructor to specify which fields and how need to be calculated. + [Obsolete("Use another constructors")] + public BGCurveBaseMath(BGCurve curve, bool traceChanges, int parts = 30, bool usePointPositionsToCalcTangents = false) + : this(curve, new Config(Fields.Position) {Parts = parts, UsePointPositionsToCalcTangents = usePointPositionsToCalcTangents}) + { + } + + #endregion + + #region Init + + //=============================================================================================== + // Init + //=============================================================================================== + /// Init math with new config and recalculate it's data + public virtual void Init(Config config) + { + //if we calculated positions before (but not tangent) we should skip the check if section was changed or not and force recalculation (cause positions may not change) + if (this.config != null) + { + ignoreSectionChangedCheck = this.config.Fields == Fields.Position && config.Fields == Fields.PositionAndTangent; + this.config.Update -= ConfigOnUpdate; + } + else + { + ignoreSectionChangedCheck = false; + } + + //assign new config + this.config = config; + config.Parts = Mathf.Clamp(config.Parts, 1, 1000); + this.config.Update += ConfigOnUpdate; + + createdAtFrame = Time.frameCount; + cachePosition = Field.Position.In(config.Fields.Val()); + cacheTangent = Field.Tangent.In(config.Fields.Val()); + + //No fields- no need to calculate or trace anything. + if (!cachePosition && !cacheTangent) + throw new UnityException("No fields were chosen. Create math like this: new BGCurveBaseMath(curve, new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.Position))"); + + //some additional init steps for subclasses + AfterInit(config); + + //calculate data, based on new config + Recalculate(true); + } + + //some additional initialization for subclasses + protected virtual void AfterInit(Config config) + { + } + + #endregion + + #region Public methods + + //=============================================================================================== + // Public methods + //=============================================================================================== + + //=========================================== Calculate by formula + + /// Calculate point world position between 2 points by a formula. This is a slow method + /// Ratio between (0,1) + /// Use local coordinates instead of world + public virtual Vector3 CalcPositionByT(BGCurvePoint @from, BGCurvePoint to, float t, bool useLocal = false) + { + t = Mathf.Clamp01(t); + + var fromPos = useLocal ? from.PositionLocal : from.PositionWorld; + var toPos = useLocal ? to.PositionLocal : to.PositionWorld; + + Vector3 result; + if (from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent) + { + //lerp + result = fromPos + ((toPos - fromPos)*t); + } + else + { + var fromPosHandle = useLocal ? from.ControlSecondLocal + fromPos : from.ControlSecondWorld; + var toPosHandle = useLocal ? to.ControlFirstLocal + toPos : to.ControlFirstWorld; + + result = (from.ControlType != BGCurvePoint.ControlTypeEnum.Absent && to.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + ? BGCurveFormulas.BezierCubic(t, fromPos, fromPosHandle, toPosHandle, toPos) + : BGCurveFormulas.BezierQuadratic(t, fromPos, (@from.ControlType == BGCurvePoint.ControlTypeEnum.Absent) ? toPosHandle : fromPosHandle, toPos); + } + return result; + } + + /// Calculate a tangent between 2 points by a formula. This is a slow method + /// Ratio between (0,1) + /// Use local coordinates instead of world + public virtual Vector3 CalcTangentByT(BGCurvePoint @from, BGCurvePoint to, float t, bool useLocal = false) + { + if (Curve.PointsCount < 2) return Vector3.zero; + + t = Mathf.Clamp01(t); + + var fromPos = useLocal ? from.PositionLocal : from.PositionWorld; + var toPos = useLocal ? to.PositionLocal : to.PositionWorld; + + Vector3 result; + if (from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent) + { + result = toPos - fromPos; + } + else + { + var fromPosHandle = useLocal ? from.ControlSecondLocal + fromPos : from.ControlSecondWorld; + var toPosHandle = useLocal ? to.ControlFirstLocal + toPos : to.ControlFirstWorld; + + result = (from.ControlType != BGCurvePoint.ControlTypeEnum.Absent && to.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + ? BGCurveFormulas.BezierCubicDerivative(t, fromPos, fromPosHandle, toPosHandle, toPos) + : BGCurveFormulas.BezierQuadraticDerivative(t, fromPos, (@from.ControlType == BGCurvePoint.ControlTypeEnum.Absent) ? toPosHandle : fromPosHandle, toPos); + } + + return result.normalized; + } + + + //=========================================== Generic methods + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false) + { + return CalcByDistance(cachedLength*distanceRatio, out tangent, useLocal); + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcByDistance(float distance, out Vector3 tangent, bool useLocal = false) + { + if (distance < 0f) distance = 0f; + else if (distance > cachedLength) distance = cachedLength; + + Vector3 position; + BinarySearchByDistance(distance, out position, out tangent, true, true); + + if (useLocal) + { + position = curve.transform.InverseTransformPoint(position); + tangent = curve.transform.InverseTransformDirection(tangent); + } + + return position; + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcByDistanceRatio(Field field, float distanceRatio, bool useLocal = false) + { + return CalcByDistance(field, cachedLength*distanceRatio, useLocal); + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcByDistance(Field field, float distance, bool useLocal = false) + { + var pointsCount = curve.PointsCount; + switch (pointsCount) + { + case 0: + return Vector3.zero; + case 1: + return field == Field.Position ? curve[0].PositionWorld : Vector3.zero; + } + + if (distance < 0f) distance = 0f; + else if (distance > cachedLength) distance = cachedLength; + + var calcPosition = field == Field.Position; + Vector3 position, tangent; + BinarySearchByDistance(distance, out position, out tangent, calcPosition, !calcPosition); + + if (useLocal) + { + switch (field) + { + case Field.Position: + position = curve.transform.InverseTransformPoint(position); + break; + case Field.Tangent: + tangent = curve.transform.InverseTransformDirection(tangent); + break; + } + } + + return calcPosition ? position : tangent; + } + + //=========================================== Position and Tangent + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcPositionAndTangentByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false) + { + return CalcByDistanceRatio(distanceRatio, out tangent, useLocal); + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcPositionAndTangentByDistance(float distance, out Vector3 tangent, bool useLocal = false) + { + return CalcByDistance(distance, out tangent, useLocal); + } + + //=========================================== Position + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcPositionByDistanceRatio(float distanceRatio, bool useLocal = false) + { + return CalcByDistanceRatio(Field.Position, distanceRatio, useLocal); + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcPositionByDistance(float distance, bool useLocal = false) + { + return CalcByDistance(Field.Position, distance, useLocal); + } + + //=========================================== Tangent + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcTangentByDistanceRatio(float distanceRatio, bool useLocal = false) + { + return CalcByDistanceRatio(Field.Tangent, distanceRatio, useLocal); + } + + //using useLocal is significantly slower. See interface for more comments + public virtual Vector3 CalcTangentByDistance(float distance, bool useLocal = false) + { + return CalcByDistance(Field.Tangent, distance, useLocal); + } + + + //=========================================== Find Secton's index + + //see interface for comments + public int CalcSectionIndexByDistance(float distance) + { + return FindSectionIndexByDistance(ClampDistance(distance)); + } + + //see interface for comments + public int CalcSectionIndexByDistanceRatio(float ratio) + { + return FindSectionIndexByDistance(DistanceByRatio(ratio)); + } + + //=========================================== Closest Point + + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + if (closestPointCalculator == null) closestPointCalculator = new BGCurveCalculatorClosestPoint(this); + float distance; + Vector3 tangent; + return closestPointCalculator.CalcPositionByClosestPoint(point, out distance, out tangent, skipSectionsOptimization, skipPointsOptimization); + } + + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + if (closestPointCalculator == null) closestPointCalculator = new BGCurveCalculatorClosestPoint(this); + Vector3 tangent; + return closestPointCalculator.CalcPositionByClosestPoint(point, out distance, out tangent, skipSectionsOptimization, skipPointsOptimization); + } + + //see interface for comments + public Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, out Vector3 tangent, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { + if (closestPointCalculator == null) closestPointCalculator = new BGCurveCalculatorClosestPoint(this); + return closestPointCalculator.CalcPositionByClosestPoint(point, out distance, out tangent, skipSectionsOptimization, skipPointsOptimization); + } + + + //=========================================== Total Distance + //see interface for comments + public virtual float GetDistance() + { + return cachedLength; + } + + //=========================================== Curve's point world coordinates (faster then using point.positionWord etc.) + + /// Get point's world position + public Vector3 GetPosition(int pointIndex) + { + var count = cachedSectionInfos.Count; + + if (count == 0 || count <= pointIndex) return curve[pointIndex].PositionWorld; + + return pointIndex < count ? cachedSectionInfos[pointIndex].OriginalFrom : cachedSectionInfos[pointIndex - 1].OriginalTo; + } + + /// Get point's world first control position + public Vector3 GetControlFirst(int pointIndex) + { + var count = cachedSectionInfos.Count; + + if (count == 0) return curve[pointIndex].ControlFirstWorld; + + if (pointIndex == 0) return curve.Closed ? cachedSectionInfos[count - 1].OriginalToControl : curve[0].ControlFirstWorld; + + return cachedSectionInfos[pointIndex - 1].OriginalToControl; + } + + /// Get point's world second control position + public Vector3 GetControlSecond(int pointIndex) + { + var count = cachedSectionInfos.Count; + + if (count == 0) return curve[pointIndex].ControlSecondWorld; + + if (pointIndex == count) return curve.Closed ? cachedSectionInfos[count - 1].OriginalFromControl : curve[pointIndex].ControlSecondWorld; + + return cachedSectionInfos[pointIndex].OriginalFromControl; + } + + + //=========================================== Misc + /// Is given field is calculated? + /// true if field is calculated + public virtual bool IsCalculated(Field field) + { + return ((int) field & (int) config.Fields) != 0; + } + + // C# standard dispose + public virtual void Dispose() + { + curve.Changed -= CurveChanged; + config.Update -= ConfigOnUpdate; + cachedSectionInfos.Clear(); + poolSectionInfos.Clear(); + } + + + //=========================================== Calculate and cache required data + + /// Calculates and cache all required data for performance reason. It is an expensive operation. + public virtual void Recalculate(bool force = false) + { + if (ChangeRequested != null) ChangeRequested(this, null); + + if (!force && config.ShouldUpdate != null && !config.ShouldUpdate()) return; + + var currentSectionsCount = cachedSectionInfos.Count; + if (curve.PointsCount < 2) + { + cachedLength = 0; + if (currentSectionsCount > 0) cachedSectionInfos.Clear(); + if (Changed != null) Changed(this, null); + return; + } + + //we should at least warn about non-optimal usage of Recalculate (with more than 1 update per frame) + if (recalculatedAtFrame != Time.frameCount || Time.frameCount == createdAtFrame) recalculatedAtFrame = Time.frameCount; + else + Warning("We noticed you are updating math more than once per frame. This is not optimal. " + + "If you use curve.ImmediateChangeEvents by some reason, try to use curve.Transaction to wrap all the changes to one single event."); + + + var pointsCount = curve.PointsCount; + var sectionsCount = curve.Closed ? pointsCount : pointsCount - 1; + + //coefficients + h = 1.0/config.Parts; + h2 = h*h; + h3 = h2*h; + + //ensure all sections inited + if (currentSectionsCount != sectionsCount) + { + if (currentSectionsCount < sectionsCount) + { + //not enough sections + var toAddCount = sectionsCount - currentSectionsCount; + + //try to get from the pool + var poolCount = poolSectionInfos.Count; + var toAddBeforePoolCount = toAddCount; + for (var i = poolCount - 1; i >= 0 && toAddCount > 0; i--, toAddCount--) cachedSectionInfos.Add(poolSectionInfos[i]); + + //pool was used + var usedPoolCount = toAddBeforePoolCount - toAddCount; + if (usedPoolCount != 0) poolSectionInfos.RemoveRange(poolSectionInfos.Count - usedPoolCount, usedPoolCount); + + // we need to create new sections (pool is empty) + if (toAddCount > 0) for (var i = 0; i < toAddCount; i++) cachedSectionInfos.Add(new SectionInfo()); + } + else + { + //too many sections + var toRemoveCount = currentSectionsCount - sectionsCount; + for (var i = sectionsCount; i < currentSectionsCount; i++) poolSectionInfos.Add(cachedSectionInfos[i]); + cachedSectionInfos.RemoveRange(currentSectionsCount - toRemoveCount, toRemoveCount); + } + } + + //calculate fields for each section + for (var i = 0; i < pointsCount - 1; i++) CalculateSection(i, cachedSectionInfos[i], i == 0 ? null : cachedSectionInfos[i - 1], curve[i], curve[i + 1]); + + var lastSection = cachedSectionInfos[sectionsCount - 1]; + if (curve.Closed) + { + CalculateSection(sectionsCount - 1, lastSection, cachedSectionInfos[sectionsCount - 2], curve[pointsCount - 1], curve[0]); + if (cacheTangent) AdjustBoundaryPointsTangents(cachedSectionInfos[0], lastSection); + } + + cachedLength = lastSection.DistanceFromEndToOrigin; + + if (Changed != null) Changed(this, null); + } + + #endregion + + #region protected methods + + //print a message to console if condition is met and calls callback method + protected virtual void Warning(string message, bool condition = true, Action callback = null) + { + if (!condition || !Application.isPlaying) return; + + if (!SuppressWarning) Debug.Log("BGCurve[BGCurveBaseMath] Warning! " + message + ". You can suppress all warnings by using BGCurveBaseMath.SuppressWarning=true;"); + + if (callback != null) callback(); + } + + + //calculates one single section data + // Performance: + // * for example: ~100 000 section points (1000 curve's points with 100 parts each) with both controls + // ~7.8 ms for Position + // ~13.5 ms for PositionAndTangent + protected virtual void CalculateSection(int index, SectionInfo section, SectionInfo prevSection, BGCurvePointI @from, BGCurvePointI to) + { + if (section == null) section = new SectionInfo(); + + section.DistanceFromStartToOrigin = prevSection == null ? 0 : prevSection.DistanceFromEndToOrigin; + + var straightAndOptimized = config.OptimizeStraightLines && @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + var pointsCount = straightAndOptimized ? 2 : config.Parts + 1; + + // do we need to recalc points? + if (Reset(section, @from, to, pointsCount)) + { + if (straightAndOptimized) + { + // ===================================================== Straight section with 2 points + Resize(section.points, 2); + + var startPoint = section.points[0]; + var endPoint = section.points[1]; + + startPoint.Position = section.OriginalFrom; + endPoint.Position = section.OriginalTo; + + //distance + endPoint.DistanceToSectionStart = Vector3.Distance(section.OriginalFrom, section.OriginalTo); + + //tangents + if (cacheTangent) startPoint.Tangent = endPoint.Tangent = (endPoint.Position - startPoint.Position).normalized; + } + else + { + // ===================================================== Section with {parts} smaller sections + CalculateSplitSection(section, @from, to); + } + if (cacheTangent) + { + section.OriginalFirstPointTangent = section[0].Tangent; + section.OriginalLastPointTangent = section[section.PointsCount - 1].Tangent; + } + } + + // we should adjust tangents for previous section's last point and first point of the current section + if (cacheTangent && prevSection != null) AdjustBoundaryPointsTangents(section, prevSection); + + section.DistanceFromEndToOrigin = section.DistanceFromStartToOrigin + section[section.PointsCount - 1].DistanceToSectionStart; + } + + //adjust neighbour adjacent points tangents + private void AdjustBoundaryPointsTangents(SectionInfo section, SectionInfo prevSection) + { + if (IsUseDistanceToAdjustTangents(section, prevSection)) + { + var distance1 = Vector3.SqrMagnitude(section[0].Position - section[1].Position); + var distance2 = Vector3.SqrMagnitude(prevSection[prevSection.PointsCount - 1].Position - prevSection[prevSection.PointsCount - 2].Position); + var overallDistance = distance1 + distance2; + + if (Math.Abs(overallDistance) < BGCurve.Epsilon) return; + + var ratio = distance1/overallDistance; + var reverseRatio = 1 - ratio; + + section[0].Tangent = prevSection[prevSection.PointsCount - 1].Tangent = Vector3.Normalize(new Vector3( + section.OriginalFirstPointTangent.x*ratio + prevSection.OriginalLastPointTangent.x*reverseRatio, + section.OriginalFirstPointTangent.y*ratio + prevSection.OriginalLastPointTangent.y*reverseRatio, + section.OriginalFirstPointTangent.z*ratio + prevSection.OriginalLastPointTangent.z*reverseRatio)); + } + else + { + //both tangents get adjusted + section[0].Tangent = prevSection[prevSection.PointsCount - 1].Tangent = Vector3.Normalize(new Vector3( + section.OriginalFirstPointTangent.x + prevSection.OriginalLastPointTangent.x, + section.OriginalFirstPointTangent.y + prevSection.OriginalLastPointTangent.y, + section.OriginalFirstPointTangent.z + prevSection.OriginalLastPointTangent.z)); + } + } + + //should we use distance between approximation points for adjusting boundary tangents + protected virtual bool IsUseDistanceToAdjustTangents(SectionInfo section, SectionInfo prevSection) + { + return config.OptimizeStraightLines && section.OriginalFromControlType == BGCurvePoint.ControlTypeEnum.Absent && + (section.OriginalToControlType == BGCurvePoint.ControlTypeEnum.Absent || prevSection.OriginalFromControlType == BGCurvePoint.ControlTypeEnum.Absent); + } + + //reset section's data and returns if recalculation is needed + protected virtual bool Reset(SectionInfo section, BGCurvePointI @from, BGCurvePointI to, int pointsCount) + { + return section.Reset(@from, to, pointsCount, ignoreSectionChangedCheck); + } + + + // this method contains some intentional 1) copy/paste 2) methods inlining 3) operators inlining- to increase performance + + /** + * Calculates one split section's data using forward differencing algorithm + * + * The technique of forward differencing allows us to compute the polynomial at t=0, + * and then incrementally calculate points by adding (and updating) the differences. + * + * Thanks to Russel Lindsay (https://gist.github.com/rlindsay/c55be560ec41144f521f) + * + * Formulas for difference between t and t+h for cubic, quadratic, and linear polynomials + * (notice that the difference between t and t+h for a cubic polynomial is quadratic ((3ak)t^2 + (3ak^2 + 2bk)t + ak^3 + bk^2 + ck), + * likewise the difference in the quadratic case is linear, and in the linear case is a constant) + * + * -------------------- + * Cubic polynomial (4 points, a, b, c, d) + * C(t) = a*t^3 + b*t^2 + c*t + d + * + * Cubic polynomial difference + * C(t + h) - C(t) http://www.wolframalpha.com/input/?i=%28a*%28t+%2B+h%29%5E3+%2B+b*%28t+%2B+h%29%5E2+%2B+c*%28t+%2B+h%29+%2B+d%29+-+%28a*t%5E3+%2B+b*t%5E2+%2B+c*t+%2B+d%29+ + * = ah^3 + 3ah^2 t + 3aht^2 + bh^2 + 2bht + ch + ---> i) = (3ah)t^2 + (3ah^2 + 2bh)t + ah^3 + bh^2 + ch + * + * -------------------- + * quadratic polynomial + * Q(t) = at^2 + bt + c + * + * quadratic polynomial difference + * Q(t + h) - Q(t) http://www.wolframalpha.com/input/?i=%28a%28t%2Bh%29%5E2+%2B+b%28t%2Bh%29+%2B+c%29+-+%28at%5E2+%2B+bt+%2B+c%29 + ---> ii) = (2ah)t + ah^2 + bh + * + * ------------------ + * linear polynomial + * L(t) = at + b + * + * linear polynomial difference + * L(t + h) - L(t) http://www.wolframalpha.com/input/?i=%28a%28t+%2B+h%29+%2B+b%29+-+%28at+%2B+b%29 + ---> iii) = ah + */ + + protected virtual void CalculateSplitSection(SectionInfo section, BGCurvePointI @from, BGCurvePointI to) + { + var parts = config.Parts; + Resize(section.points, parts + 1); + + var points = section.points; + + // all section's values + var fromPos = section.OriginalFrom; + var toPos = section.OriginalTo; + var control1 = section.OriginalFromControl; + var control2 = section.OriginalToControl; + + var controlFromAbsent = @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + var controlToAbsent = to.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + var noControls = controlFromAbsent && controlToAbsent; + var bothControls = !controlFromAbsent && !controlToAbsent; + if (!noControls && !bothControls && controlFromAbsent) control1 = control2; + + //snapping + var snapIsOn = curve.SnapType == BGCurve.SnapTypeEnum.Curve; + + //assign first last points directly to avoid accumulation errors + var firstPoint = points[0] ?? (section.points[0] = new SectionPointInfo()); + firstPoint.Position = fromPos; + var lastPoint = points[parts] ?? (section.points[parts] = new SectionPointInfo()); + lastPoint.Position = toPos; + + + if (noControls) + { + // ======================================================== NoControls + + var currentX = (double) fromPos.x; + var currentY = (double) fromPos.y; + var currentZ = (double) fromPos.z; + + var stepX = ((double) toPos.x - fromPos.x)/parts; + var stepY = ((double) toPos.y - fromPos.y)/parts; + var stepZ = ((double) toPos.z - fromPos.z)/parts; + + var fromToTangentWorld = Vector3.zero; + if (cacheTangent) fromToTangentWorld = (toPos - fromPos).normalized; + + lastPoint.DistanceToSectionStart = Vector3.Distance(toPos, fromPos); + var onePartDistance = lastPoint.DistanceToSectionStart/parts; + + //-------------------------------- Critical section + for (var i = 1; i < parts; i++) + { + var point = points[i]; + + currentX += stepX; + currentY += stepY; + currentZ += stepZ; + + var pos = new Vector3((float) currentX, (float) currentY, (float) currentZ); + + if (snapIsOn) curve.ApplySnapping(ref pos); + + point.Position = pos; + + //---------- tangents + if (cacheTangent) + { + if (config.UsePointPositionsToCalcTangents) + { + //-------- Calc by point's positions + var prevPoint = section[i - 1]; + var prevPosition = prevPoint.Position; + var tangent = new Vector3(pos.x - prevPosition.x, pos.y - prevPosition.y, pos.z - prevPosition.z); + //normalized inlined + var marnitude = (float) Math.Sqrt((double) tangent.x*(double) tangent.x + (double) tangent.y*(double) tangent.y + (double) tangent.z*(double) tangent.z); + tangent = ((double) marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x/marnitude, tangent.y/marnitude, tangent.z/marnitude) : Vector3.zero; + + prevPoint.Tangent = point.Tangent = tangent; + } + else point.Tangent = fromToTangentWorld; + } + + point.DistanceToSectionStart = onePartDistance*i; + } + //-------------------------------- Critical section ends + + //assign last point separately to get rid of accumulation errors + if (cacheTangent) firstPoint.Tangent = lastPoint.Tangent = fromToTangentWorld; + } + else + { + //for tangents + double tX = 0, tY = 0, tZ = 0, firstTDx = 0, firstTDy = 0, firstTDz = 0; + + if (bothControls) + { + // ======================================================== Both Controls (Cubic Bezier) + + /* coefficients for control points (it's a standard Bezier matrix) + * you can get these numbers by converting parametric equation to standard polinomial form + * + * | 1 0 0 0| |A| | A | + * |-3 3 0 0| * |B| = | -3A + 3B | + * | 3 -6 3 0| |C| | 3A - 6B + 3C | + * |-1 3 -3 1| |D| |-A + 3B - 3C + D| + * + * http://www.wolframalpha.com/input/?i=%7B%7B1,+0,+0,+0%7D,%7B-3,+3,+0,+0%7D,+%7B3,+-6,+3,+0%7D,+%7B-1,+3,+-3,+1%7D%7D*%7B%7Bp_0%7D,+%7Bp_1%7D,+%7Bp_2%7D,+%7Bp_3%7D%7D + * + */ + // the same as in above matrix (top down) + var cx = 3*((double) control1.x - fromPos.x); + var cy = 3*((double) control1.y - fromPos.y); + var cz = 3*((double) control1.z - fromPos.z); + + var bx = 3*((double) control2.x - control1.x) - cx; + var by = 3*((double) control2.y - control1.y) - cy; + var bz = 3*((double) control2.z - control1.z) - cz; + + var ax = (double) toPos.x - fromPos.x - cx - bx; + var ay = (double) toPos.y - fromPos.y - cy - by; + var az = (double) toPos.z - fromPos.z - cz - bz; + + var pointX = (double) fromPos.x; + var pointY = (double) fromPos.y; + var pointZ = (double) fromPos.z; + + var axH3 = ax*h3; + var ax6H3 = 6*axH3; + var ayH3 = ay*h3; + var ay6H3 = 6*ayH3; + var azH3 = az*h3; + var az6H3 = 6*azH3; + + var bxH2 = bx*h2; + var byH2 = by*h2; + var bzH2 = bz*h2; + + /* First Difference + * the difference between t and t+h. Since the curve is cubic, difference is (from Formula i, see header) + * i) (3ah)t^2 + (3ah^2 + 2bh)t + ah^3 + bh^2 + ch + * + * Since we are calculating from the start of the curve, t = 0. + * + * http://www.wolframalpha.com/input/?i=(a*(0+%2B+h)%5E3+%2B+b*(0+%2B+h)%5E2+%2B+c*(0+%2B+h)+%2B+d)+-+(a*0%5E3+%2B+b*0%5E2+%2B+c*0+%2B+d) + * D1 = ah^3 + bh^2 + ch + */ + var firstDx = axH3 + bxH2 + cx*h; + var firstDy = ayH3 + byH2 + cy*h; + var firstDz = azH3 + bzH2 + cz*h; + + /* + * Second Difference: + * + * the difference between two successive first differences. Since the form of the first difference is quadratic, the difference + * between two of them is (from Formula ii, see header ) + * ii) (2ah)t + ah^2 + bh + * + * Substituting + * t = 0 to calculate the difference at the start of the curve, + * a = 3ah, + * b = 3ah^2 + 2bh (see D1 calculation, Formula i ) + * we get + * D2 = (6ah^2)t + 6ah^3 + 2bh^2 http://www.wolframalpha.com/input/?i=%282*3*a*h*h%29t+%2B+3*a*h*h%5E2+%2B+%283*a*h%5E2+%2B+2*b*h%29h + * = 6ah^3 + 2bh^2 + */ + var secondDx = ax6H3 + 2*bxH2; + var secondDy = ay6H3 + 2*byH2; + var secondDz = az6H3 + 2*bzH2; + + /* + * Third difference: + * + * the difference between two successive second differences. since the form is linear + * iii) ah + * substituting + * a = 6ah^2 (see D2 calculation) + * D3 = 6ah^3 http://www.wolframalpha.com/input/?i=6*a*h%5E2+*+h + * + */ + var thirdDx = ax6H3; + var thirdDy = ay6H3; + var thirdDz = az6H3; + + + double secondTDx = 0, secondTDy = 0, secondTDz = 0; + if (cacheTangent && !config.UsePointPositionsToCalcTangents) + { + //the same thing as with positions + //parametric to polinomial standard + //3*(1-t)^2*(p1-p0) + 6*(1-t)*t*(p2-p1) + 3*t^2*(p3-p2)=(-3*p0+9*p1-9*p2+3*p3)*t^2 + (6*p0-12*p1+6*p2)*t + (3*p1-3*p0) + var tbx = 6*((double) fromPos.x - 2*control1.x + control2.x); + var tby = 6*((double) fromPos.y - 2*control1.y + control2.y); + var tbz = 6*((double) fromPos.z - 2*control1.z + control2.z); + + var tax = 3*((double) -fromPos.x + 3*control1.x - 3*control2.x + toPos.x); + var tay = 3*((double) -fromPos.y + 3*control1.y - 3*control2.y + toPos.y); + var taz = 3*((double) -fromPos.z + 3*control1.z - 3*control2.z + toPos.z); + + //temp + var taxH2 = tax*h2; + var tayH2 = tay*h2; + var tazH2 = taz*h2; + + + // ii) (2ah)t + ah^2 + bh, t=0 + firstTDx = taxH2 + tbx*h; + firstTDy = tayH2 + tby*h; + firstTDz = tazH2 + tbz*h; + + // iii) = ah, a=2ah + secondTDx = 2*taxH2; + secondTDy = 2*tayH2; + secondTDz = 2*tazH2; + + tX = cx; + tY = cy; + tZ = cz; + + //normalized inlined + var magnitude = Math.Sqrt(tX*tX + tY*tY + tZ*tZ); + firstPoint.Tangent = magnitude > 9.99999974737875E-06 ? new Vector3((float) (tX/magnitude), (float) (tY/magnitude), (float) (tZ/magnitude)) : Vector3.zero; + } + + //-------------------------------- Critical section + for (var i = 1; i < parts; i++) + { + var point = points[i]; + + pointX += firstDx; + pointY += firstDy; + pointZ += firstDz; + + firstDx += secondDx; + firstDy += secondDy; + firstDz += secondDz; + + secondDx += thirdDx; + secondDy += thirdDy; + secondDz += thirdDz; + + var pos = new Vector3((float) pointX, (float) pointY, (float) pointZ); + + if (snapIsOn) curve.ApplySnapping(ref pos); + + point.Position = pos; + + if (cacheTangent) + { + if (config.UsePointPositionsToCalcTangents) + { + //-------- Calc by point's positions + var prevPoint = section[i - 1]; + var prevPosition = prevPoint.Position; + var tangent = new Vector3(pos.x - prevPosition.x, pos.y - prevPosition.y, pos.z - prevPosition.z); + //normalized inlined + var marnitude = (float) Math.Sqrt((double) tangent.x*(double) tangent.x + (double) tangent.y*(double) tangent.y + (double) tangent.z*(double) tangent.z); + tangent = ((double) marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x/marnitude, tangent.y/marnitude, tangent.z/marnitude) : Vector3.zero; + + prevPoint.Tangent = point.Tangent = tangent; + } + else + { + tX += firstTDx; + tY += firstTDy; + tZ += firstTDz; + + firstTDx += secondTDx; + firstTDy += secondTDy; + firstTDz += secondTDz; + + //normalized inlined + var magnitude = Math.Sqrt(tX*tX + tY*tY + tZ*tZ); + point.Tangent = magnitude > 9.99999974737875E-06 ? new Vector3((float) (tX/magnitude), (float) (tY/magnitude), (float) (tZ/magnitude)) : Vector3.zero; + } + } + + // ---------- distance to section start (Vector3.Distance inlined) + var prevPos = section[i - 1].Position; + double deltaX = pos.x - prevPos.x; + double deltaY = pos.y - prevPos.y; + double deltaZ = pos.z - prevPos.z; + point.DistanceToSectionStart = section[i - 1].DistanceToSectionStart + ((float) Math.Sqrt(deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ)); + } + //-------------------------------- Critical section ends + } + else + { + // ======================================================== One Control (Quadratic Bezier) + // see comments for cubic bezier for more details + // parametric to polinomial standard form + // (1-t)^2*p0 + 2(1-t)*t*p1+t^2*p2 = (p0-2p1+p2)*t^2 + (-2p0+2p1)*t + p0 + + var bx = 2*((double) control1.x - fromPos.x); + var by = 2*((double) control1.y - fromPos.y); + var bz = 2*((double) control1.z - fromPos.z); + + var ax = (double) fromPos.x - 2*control1.x + toPos.x; + var ay = (double) fromPos.y - 2*control1.y + toPos.y; + var az = (double) fromPos.z - 2*control1.z + toPos.z; + + // ii) = (2ah)t + ah^2 + bh, t=0 + var firstDx = ax*h2 + bx*h; + var firstDy = ay*h2 + by*h; + var firstDz = az*h2 + bz*h; + + // iii) ah, a=2ah + var secondDx = 2*ax*h2; + var secondDy = 2*ay*h2; + var secondDz = 2*az*h2; + + var pointX = (double) fromPos.x; + var pointY = (double) fromPos.y; + var pointZ = (double) fromPos.z; + + if (cacheTangent && !config.UsePointPositionsToCalcTangents) + { + //the same thing as with positions + //parametric to polinomial standard + // 2*(1-t)*(p1-p0) + 2t*(p2-p1) = (2*p0-4*p1+2*p2)*t + (2*p1-2*p0) + var tax = 2*((double) fromPos.x - 2*control1.x + toPos.x); + var tay = 2*((double) fromPos.y - 2*control1.y + toPos.y); + var taz = 2*((double) fromPos.z - 2*control1.z + toPos.z); + + // iii) = ah + firstTDx = tax*h; + firstTDy = tay*h; + firstTDz = taz*h; + + tX = 2*((double) control1.x - fromPos.x); + tY = 2*((double) control1.y - fromPos.y); + tZ = 2*((double) control1.z - fromPos.z); + + //normalized inlined + var magnitude = Math.Sqrt(tX*tX + tY*tY + tZ*tZ); + firstPoint.Tangent = magnitude > 9.99999974737875E-06 ? new Vector3((float) (tX/magnitude), (float) (tY/magnitude), (float) (tZ/magnitude)) : Vector3.zero; + } + //-------------------------------- Critical section + for (var i = 1; i < parts; i++) + { + var point = points[i]; + + pointX += firstDx; + pointY += firstDy; + pointZ += firstDz; + + firstDx += secondDx; + firstDy += secondDy; + firstDz += secondDz; + + var pos = new Vector3((float) pointX, (float) pointY, (float) pointZ); + + if (snapIsOn) curve.ApplySnapping(ref pos); + + point.Position = pos; + + if (cacheTangent) + { + if (config.UsePointPositionsToCalcTangents) + { + //-------- Calc by point's positions + var prevPoint = section[i - 1]; + var prevPosition = prevPoint.Position; + var tangent = new Vector3(pos.x - prevPosition.x, pos.y - prevPosition.y, pos.z - prevPosition.z); + //normalized inlined + var marnitude = (float) Math.Sqrt((double) tangent.x*(double) tangent.x + (double) tangent.y*(double) tangent.y + (double) tangent.z*(double) tangent.z); + tangent = ((double) marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x/marnitude, tangent.y/marnitude, tangent.z/marnitude) : Vector3.zero; + + prevPoint.Tangent = point.Tangent = tangent; + } + else + { + tX += firstTDx; + tY += firstTDy; + tZ += firstTDz; + + //normalized inlined + var magnitude = Math.Sqrt(tX*tX + tY*tY + tZ*tZ); + point.Tangent = magnitude > 9.99999974737875E-06 ? new Vector3((float) (tX/magnitude), (float) (tY/magnitude), (float) (tZ/magnitude)) : Vector3.zero; + } + } + + // ---------- distance to section start (Vector3.Distance inlined) + var prevPos = section[i - 1].Position; + double deltaX = pos.x - prevPos.x; + double deltaY = pos.y - prevPos.y; + double deltaZ = pos.z - prevPos.z; + point.DistanceToSectionStart = section[i - 1].DistanceToSectionStart + ((float) Math.Sqrt(deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ)); + } + //-------------------------------- Critical section ends + } + + //last point's tangent + if (cacheTangent && !config.UsePointPositionsToCalcTangents) + { + tX += firstTDx; + tY += firstTDy; + tZ += firstTDz; + var magnitude = Math.Sqrt(tX*tX + tY*tY + tZ*tZ); + lastPoint.Tangent = magnitude > 9.99999974737875E-06 ? new Vector3((float) (tX/magnitude), (float) (tY/magnitude), (float) (tZ/magnitude)) : Vector3.zero; + } + } + + //last Point's distance + var beforeLastPoint = section[parts - 1]; + var beforeLastPos = beforeLastPoint.Position; + var lastPointPos = lastPoint.Position; + double dX = lastPointPos.x - beforeLastPos.x; + double dY = lastPointPos.y - beforeLastPos.y; + double dZ = lastPointPos.z - beforeLastPos.z; + lastPoint.DistanceToSectionStart = beforeLastPoint.DistanceToSectionStart + ((float) Math.Sqrt(dX*dX + dY*dY + dZ*dZ)); + + //last point's tangent + if (cacheTangent && config.UsePointPositionsToCalcTangents) + { + //-------- Calc by point's positions + + var tangent = new Vector3((float) dX, (float) dY, (float) dZ); + //normalized inlined + var marnitude = (float) Math.Sqrt((double) tangent.x*(double) tangent.x + (double) tangent.y*(double) tangent.y + (double) tangent.z*(double) tangent.z); + tangent = ((double) marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x/marnitude, tangent.y/marnitude, tangent.z/marnitude) : Vector3.zero; + + lastPoint.Tangent = tangent; + } + } + + + //search cached data and returns point's position or tangent at given distance from curve's start + // * for example (1000 sections with 100 points each, so 100 000 points) with 10000 Random searches ~7ms + protected virtual void BinarySearchByDistance(float distance, out Vector3 position, out Vector3 tangent, bool calculatePosition, bool calculateTangent) + { + var pointsCount = Curve.PointsCount; + if (pointsCount < 2 || cachedSectionInfos.Count == 0) + { + position = Vector3.zero; + tangent = Vector3.zero; + if (pointsCount == 1 && calculatePosition) position = Curve[0].PositionWorld; + } + + // field was not set in the constructor, so it was not calculated and can not be accessed. + // Example, use new BGCurveBaseMath(new BGCurveBaseMath.Params(GetComponent(), BGCurveBaseMath.Fields.PositionAndTangent)) + // to calculate world's position and tangent + if (calculateTangent && ((int) Field.Tangent & (int) config.Fields) == 0) + throw new UnityException("Can not calculate tangent, cause it was not included in the 'fields' constructor parameter. " + + "For example, use new BGCurveBaseMath(curve, new BGCurveBaseMath.Config(" + + "BGCurveBaseMath.Fields.PositionAndTangent))" + + "to calculate world's position and tangent"); + + + var targetSection = cachedSectionInfos[FindSectionIndexByDistance(distance)]; + + //after we found a section, let's search within this section + targetSection.CalcByDistance(distance - targetSection.DistanceFromStartToOrigin, out position, out tangent, calculatePosition, calculateTangent); + } + + //find section by distance + protected int FindSectionIndexByDistance(float distance) + { + // ----- critical section start + int low = 0, mid = 0, high = cachedSectionInfos.Count, i = 0; + while (low < high) + { + mid = (low + high) >> 1; + var item = cachedSectionInfos[mid]; + + //success + if (distance >= item.DistanceFromStartToOrigin && distance <= item.DistanceFromEndToOrigin) break; + + if (distance < item.DistanceFromStartToOrigin) high = mid; + else low = mid + 1; + + //just in case + if (i++ > 100) throw new UnityException("Something wrong: more than 100 iterations inside BinarySearch"); + } + // ----- critical section end + + return mid; + } + + + //convert ratio to distance + protected float DistanceByRatio(float distanceRatio) + { + return GetDistance()*Mathf.Clamp01(distanceRatio); + } + + //ensure distance is within proper range + protected float ClampDistance(float distance) + { + return Mathf.Clamp(distance, 0, GetDistance()); + } + + public override string ToString() + { + return "Base Math for curve (" + Curve + "), sections=" + SectionsCount; + } + + #endregion + + #region private methods + + //=============================================================================================== + // Private functions + //=============================================================================================== + + protected void Resize(List points, int size) + { + var pointCount = points.Count; + if (pointCount == size) return; + + //size mismatch + if (pointCount < size) + { + //we need more points + var poolIndex = poolPointInfos.Count - 1; + for (var i = pointCount; i < size; i++) points.Add(poolIndex >= 0 ? poolPointInfos[poolIndex--] : new SectionPointInfo()); + + //pool was used + if (poolIndex != poolPointInfos.Count - 1) poolPointInfos.RemoveRange(poolIndex + 1, poolPointInfos.Count - 1 - poolIndex); + } + else + { + //we need less points + for (var i = size; i < pointCount; i++) poolPointInfos.Add(points[i]); + + points.RemoveRange(size, pointCount - size); + } + } + + + private void CurveChanged(object sender, BGCurveChangedArgs e) + { + ignoreSectionChangedCheck = e != null && e.ChangeType == BGCurveChangedArgs.ChangeTypeEnum.Snap; + Recalculate(); + ignoreSectionChangedCheck = false; + } + + private void ConfigOnUpdate(object sender, EventArgs eventArgs) + { + Recalculate(true); + } + + #endregion + + #region Helper model classes + + //=============================================================================================== + // Helper classes + //=============================================================================================== + + + /// params for calculations + public class Config + { + /// Which fields to calculate and cache. Do not use more fields then needed. + public Fields Fields = Fields.Position; + + /// number of parts each curve's section will be devided to. Range[1, 1000] + public int Parts = 30; + + /// Use points position instead of formula to calc tangents. This can increase performace. + public bool UsePointPositionsToCalcTangents; + + /// Do not split straight lines during precalculation (use only 2 points per section).Tangents may suffer + public bool OptimizeStraightLines; + + /// If not null it can control if math should update it's data. Updating cached data takes some resources, so this param can control updating strategy + public Func ShouldUpdate; + + /// If not null math will update on this event + public event EventHandler Update; + + + public Config() + { + } + + /// Fields (from BGCurveBaseMath.Field) you want to precalculate and cache. + /// 'None' means- no precalculation and caching will occur, but as a result you will be able to use CalcPositionByT and CalcTangentByT methods only. + /// See class documentation for more info. + public Config(Fields fields) + { + Fields = fields; + } + + protected bool Equals(Config other) + { + return Fields == other.Fields && Parts == other.Parts && UsePointPositionsToCalcTangents == other.UsePointPositionsToCalcTangents && + OptimizeStraightLines == other.OptimizeStraightLines; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Config) obj); + } + + public override int GetHashCode() + { + var hashCode = (int) Fields; + hashCode = (hashCode*397) ^ Parts; + hashCode = (hashCode*397) ^ UsePointPositionsToCalcTangents.GetHashCode(); + hashCode = (hashCode*397) ^ OptimizeStraightLines.GetHashCode(); + return hashCode; + } + + /// Fire Updated event + public void FireUpdate() + { + if (Update != null) Update(this, null); + } + } + + /// information for one single section (between 2 points) of the curve + public class SectionInfo + { + /// distance from section start to curve start + public float DistanceFromStartToOrigin; + + /// distance from section end to curve start + public float DistanceFromEndToOrigin; + + //all the points in this section + protected internal readonly List points = new List(); + + + /// From location, used by calculation + public Vector3 OriginalFrom; + + /// To location, used by calculation + public Vector3 OriginalTo; + + /// From control type, used by calculation + public BGCurvePoint.ControlTypeEnum OriginalFromControlType; + + /// To control type, used by calculation + public BGCurvePoint.ControlTypeEnum OriginalToControlType; + + /// From control position, used by calculation + public Vector3 OriginalFromControl; + + /// To control position, used by calculation + public Vector3 OriginalToControl; + + // we need these 2 following fields, cause this section can get skipped while calculation, but adjacent sections may change, + // and this will affect adjacent points tangents + // so we need these "original tangents" to calculate final tangents in case this section will get skipped + /// First point tangent, calculated for the first time + public Vector3 OriginalFirstPointTangent; + + /// Last point tangent, calculated for the first time + public Vector3 OriginalLastPointTangent; + + /// Approximation points in the section + public List Points + { + get { return points; } + } + + /// Approximation points count + public int PointsCount + { + get { return points.Count; } + } + + /// Section's total distance + public float Distance + { + get { return DistanceFromEndToOrigin - DistanceFromStartToOrigin; } + } + + public override string ToString() + { + return "Section distance=(" + Distance + ")"; + } + + /// Get section's point by index + public SectionPointInfo this[int i] + { + get { return points[i]; } + set { points[i] = value; } + } + + /// Reset section's init data and returns true, if (re)calculation is needed + protected internal bool Reset(BGCurvePointI fromPoint, BGCurvePointI toPoint, int pointsCount, bool skipCheck) + { + var newFrom = fromPoint.PositionWorld; + var newTo = toPoint.PositionWorld; + var newFromControl = fromPoint.ControlSecondWorld; + var newToControl = toPoint.ControlFirstWorld; + + const float epsilon = 0.000001f; + if ( + !skipCheck + && points.Count == pointsCount + && OriginalFromControlType == fromPoint.ControlType + && OriginalToControlType == toPoint.ControlType + && Vector3.SqrMagnitude(new Vector3(OriginalFrom.x - newFrom.x, OriginalFrom.y - newFrom.y, OriginalFrom.z - newFrom.z)) < epsilon + && Vector3.SqrMagnitude(new Vector3(OriginalTo.x - newTo.x, OriginalTo.y - newTo.y, OriginalTo.z - newTo.z)) < epsilon + && Vector3.SqrMagnitude(new Vector3(OriginalFromControl.x - newFromControl.x, OriginalFromControl.y - newFromControl.y, OriginalFromControl.z - newFromControl.z)) < epsilon + && Vector3.SqrMagnitude(new Vector3(OriginalToControl.x - newToControl.x, OriginalToControl.y - newToControl.y, OriginalToControl.z - newToControl.z)) < epsilon + ) + return false; + + OriginalFrom = newFrom; + OriginalTo = newTo; + OriginalFromControlType = fromPoint.ControlType; + OriginalToControlType = toPoint.ControlType; + OriginalFromControl = newFromControl; + OriginalToControl = newToControl; + return true; + } + + //copy pasted binary search algorithm + public int FindPointIndexByDistance(float distanceWithinSection) + { + var pointsCountMinusOne = points.Count - 1; + + // ----- critical section start (copy paste) + int low = 0, mid = 0, high = points.Count, i = 0; + while (low < high) + { + mid = (low + high) >> 1; + var item = points[mid]; + + //success + if (!(distanceWithinSection < item.DistanceToSectionStart) && (mid == pointsCountMinusOne || points[mid + 1].DistanceToSectionStart >= distanceWithinSection)) break; + + if (distanceWithinSection < item.DistanceToSectionStart) high = mid; + else low = mid + 1; + + //just in case + if (i++ > 100) throw new UnityException("Something wrong: more than 100 iterations inside BinarySearch"); + } + // ----- critical section end + return mid; + } + + /// Calculates posiiton and distance by distance within this section. Note, it does not apply any checking for performance's sake + public void CalcByDistance(float distanceWithinSection, out Vector3 position, out Vector3 tangent, bool calculatePosition, bool calculateTangent) + { + position = Vector3.zero; + tangent = Vector3.zero; + + if (points.Count == 2) + { + //linear + var first = points[0]; + + if (Math.Abs(Distance) < BGCurve.Epsilon) + { + if (calculatePosition) position = first.Position; + if (calculateTangent) tangent = first.Tangent; + } + else + { + var ratio = distanceWithinSection/Distance; + var second = points[1]; + if (calculatePosition) position = Vector3.Lerp(first.Position, second.Position, ratio); + if (calculateTangent) tangent = Vector3.Lerp(first.Tangent, second.Tangent, ratio); + } + } + else + { + var pointIndex = FindPointIndexByDistance(distanceWithinSection); + var targetPoint = points[pointIndex]; + + //the very last point within section + if (pointIndex == points.Count - 1) + { + if (calculatePosition) position = targetPoint.Position; + if (calculateTangent) tangent = targetPoint.Tangent; + } + else + { + var nextPoint = points[pointIndex + 1]; + + //this is the distance between 2 points + var distanceBetweenTwoPoints = (nextPoint.DistanceToSectionStart - targetPoint.DistanceToSectionStart); + //this is smaller distance between 1st point and target distance. distanceWithinSection= the distance from section start to target distance + var distanceWithinTwoPoints = (distanceWithinSection - targetPoint.DistanceToSectionStart); + //zero division check + var ratio = Math.Abs(distanceBetweenTwoPoints) < BGCurve.Epsilon ? 0 : distanceWithinTwoPoints/distanceBetweenTwoPoints; + + //lerp target's field between 1st and 2nd points using a ratio, which is based on the distance between them + if (calculatePosition) position = Vector3.Lerp(targetPoint.Position, nextPoint.Position, ratio); + if (calculateTangent) tangent = Vector3.Lerp(targetPoint.Tangent, nextPoint.Tangent, ratio); + } + } + } + } + + /// information for one point within a section (BGCurveBaseMath.Section) + public class SectionPointInfo + { + /// point's world position + public Vector3 Position; + + + /// distance from the start of the section to this point + public float DistanceToSectionStart; + + /// point's world tangent + public Vector3 Tangent; + + //get field's value (position or tangent) + internal Vector3 GetField(Field field) + { + Vector3 result; + switch (field) + { + case Field.Position: + result = Position; + break; + case Field.Tangent: + result = Tangent; + break; + default: + throw new UnityException("Unknown field=" + field); + } + return result; + } + + //lerp field's value (position or tangent) between two points by ratio + internal Vector3 LerpTo(Field field, SectionPointInfo to, float ratio) + { + return Vector3.Lerp(GetField(field), to.GetField(field), ratio); + } + + + public override string ToString() + { + return "Point at (" + Position + ")"; + } + } + + #endregion + } + + #region Helper extensions for Field and Fields enums + + //=============================================================================================== + // Extensions + //=============================================================================================== + + //helper extension class for Field enum + public static class FieldExtensions + { + /// if given fieldEnum is contained in the mask + public static bool In(this BGCurveBaseMath.Field field, int mask) + { + return (field.Val() & mask) != 0; + } + + /// cast to int + public static int Val(this BGCurveBaseMath.Field field) + { + return (int) field; + } + } + + public static class FieldsExtensions + { + /// cast to int + public static int Val(this BGCurveBaseMath.Fields fields) + { + return (int) fields; + } + } + + #endregion +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs.meta new file mode 100644 index 0000000..e343af9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveBaseMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2d95a3b4385ca2245a96749f7eab3753 +timeCreated: 1458540196 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs new file mode 100644 index 0000000..50b6e30 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs @@ -0,0 +1,656 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// Closest point related calculations + /// + //this class contains some intentional copy/paste for the sake of performance + public class BGCurveCalculatorClosestPoint + { + // transitions ("safe" or not) + private static readonly int[] TransitionsForPartitions; + + // math to use for calculation + private readonly BGCurveBaseMath math; + + //reusable arrays to reduce GC + private bool[] excludedSections; + private float[] minSectionDistances; + + + static BGCurveCalculatorClosestPoint() + { + // Init transitions data + + //25=inside + const int nearPlane = (1 << 0) + (1 << 1) + (1 << 2) + (1 << 3) + (1 << 4) + (1 << 5) + (1 << 6) + (1 << 7) + (1 << 24); + const int farPlane = (1 << 16) + (1 << 17) + (1 << 18) + (1 << 19) + (1 << 20) + (1 << 21) + (1 << 22) + (1 << 23) + (1 << 26); + const int bottomPlane = (1 << 0) + (1 << 6) + (1 << 7) + (1 << 8) + (1 << 14) + (1 << 15) + (1 << 16) + (1 << 22) + (1 << 23); + const int topPlane = (1 << 2) + (1 << 3) + (1 << 4) + (1 << 10) + (1 << 11) + (1 << 12) + (1 << 18) + (1 << 19) + (1 << 20); + const int leftPlane = (1 << 0) + (1 << 1) + (1 << 2) + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 16) + (1 << 17) + (1 << 18); + const int rightPlane = (1 << 4) + (1 << 5) + (1 << 6) + (1 << 12) + (1 << 13) + (1 << 14) + (1 << 20) + (1 << 21) + (1 << 22); + + //transition from->to which is considered safe in terms of mininum closest point search + //total 27 partitions + TransitionsForPartitions = new[] + { + //z==0 (near) + /*0*/ nearPlane | leftPlane | bottomPlane, + /*1*/ nearPlane | leftPlane, + /*2*/ nearPlane | leftPlane | topPlane, + /*3*/ nearPlane | topPlane, + /*4*/ nearPlane | rightPlane | topPlane, + /*5*/ nearPlane | rightPlane, + /*6*/ nearPlane | rightPlane | bottomPlane, + /*7*/ nearPlane | bottomPlane, + + //z==1 (middle) + /*8*/ leftPlane | bottomPlane, + /*9*/ leftPlane, + /*10*/ leftPlane | topPlane, + /*11*/ topPlane, + /*12*/ rightPlane | topPlane, + /*13*/ rightPlane, + /*14*/ rightPlane | bottomPlane, + /*15*/ bottomPlane, + + //z==2 (far) + /*16*/ farPlane | leftPlane | bottomPlane, + /*17*/ farPlane | leftPlane, + /*18*/ farPlane | leftPlane | topPlane, + /*19*/ farPlane | topPlane, + /*20*/ farPlane | rightPlane | topPlane, + /*21*/ farPlane | rightPlane, + /*22*/ farPlane | rightPlane | bottomPlane, + /*23*/ farPlane | bottomPlane, + + //3 left partitions in the middle + /*24*/ nearPlane, + /*25*/ 0, //inside + /*26*/ farPlane, + }; + } + + public BGCurveCalculatorClosestPoint(BGCurveBaseMath math) + { + this.math = math; + } + + //this method contains some intentional copy/paste for the sake of performance + public Vector3 CalcPositionByClosestPoint(Vector3 targetPoint, out float distance, out Vector3 tangent, bool skipSectionsOptimization = false, bool skipPointsOptimization = false) + { +/* + minimalistic thing to do- iterate all lines and use closest point to line formula. + + 2 ideas for optimization: + 1) Iterate all sections first, calculate min bounding box and cut off those sections far away from it + 2) Iterate points, and calculate min sphere radius to contain the result point. Then partition the space by the bounding box around this sphere, and cut off + all points, that can not be contained in the box or intersect this box with a line; +*/ + + var sections = math.SectionInfos; + var sectionsCount = sections.Count; + if (sectionsCount == 0) + { + distance = 0; + tangent = Vector3.zero; + return math.Curve.PointsCount == 1 ? math.Curve[0].PositionWorld : Vector3.zero; + } + + + //========================================================================================================================== + // Section Bbox partitioning (4 passes total) + //========================================================================================================================== + var sectionsOptimizationOn = !skipSectionsOptimization && math.Configuration.Parts > 8; + var minSectionIndex = 0; + var minSectionMaxDistance = float.MaxValue; + if (sectionsOptimizationOn) + { + //----------------------- Section Bbox Partitioning 1st pass (calculate min AABB (Axis Aligned Bounding Box) by square distance between point and section's AABB) + Array.Resize(ref excludedSections, sectionsCount); + Array.Resize(ref minSectionDistances, sectionsCount); + + var minBounds = new Bounds(); + var minAabbDistance = float.MaxValue; + for (var i = 0; i < sectionsCount; i++) + { + var section = sections[i]; + + + var fromAbsent = section.OriginalFromControlType == BGCurvePoint.ControlTypeEnum.Absent; + var toAbsent = section.OriginalToControlType == BGCurvePoint.ControlTypeEnum.Absent; + + var originalFrom = section.OriginalFrom; + var originalTo = section.OriginalTo; + var originalToControl = section.OriginalToControl; + + var fromToMinX = originalFrom.x > originalTo.x ? originalTo.x : originalFrom.x; + var fromToMinY = originalFrom.y > originalTo.y ? originalTo.y : originalFrom.y; + var fromToMinZ = originalFrom.z > originalTo.z ? originalTo.z : originalFrom.z; + + var fromToMaxX = originalFrom.x < originalTo.x ? originalTo.x : originalFrom.x; + var fromToMaxY = originalFrom.y < originalTo.y ? originalTo.y : originalFrom.y; + var fromToMaxZ = originalFrom.z < originalTo.z ? originalTo.z : originalFrom.z; + + float minX, minY, minZ, maxX, maxY, maxZ; + if (fromAbsent) + { + if (toAbsent) + { + //No controls + minX = fromToMinX; + minY = fromToMinY; + minZ = fromToMinZ; + maxX = fromToMaxX; + maxY = fromToMaxY; + maxZ = fromToMaxZ; + } + else + { + //To Control Present + minX = fromToMinX > originalToControl.x ? originalToControl.x : fromToMinX; + minY = fromToMinY > originalToControl.y ? originalToControl.y : fromToMinY; + minZ = fromToMinZ > originalToControl.z ? originalToControl.z : fromToMinZ; + + maxX = fromToMaxX < originalToControl.x ? originalToControl.x : fromToMaxX; + maxY = fromToMaxY < originalToControl.y ? originalToControl.y : fromToMaxY; + maxZ = fromToMaxZ < originalToControl.z ? originalToControl.z : fromToMaxZ; + } + } + else + { + var originalFromControl = section.OriginalFromControl; + if (toAbsent) + { + //From Control Present + minX = fromToMinX > originalFromControl.x ? originalFromControl.x : fromToMinX; + minY = fromToMinY > originalFromControl.y ? originalFromControl.y : fromToMinY; + minZ = fromToMinZ > originalFromControl.z ? originalFromControl.z : fromToMinZ; + + maxX = fromToMaxX < originalFromControl.x ? originalFromControl.x : fromToMaxX; + maxY = fromToMaxY < originalFromControl.y ? originalFromControl.y : fromToMaxY; + maxZ = fromToMaxZ < originalFromControl.z ? originalFromControl.z : fromToMaxZ; + } + else + { + //Both Controls + var fromToControlToMinX = fromToMinX > originalToControl.x ? originalToControl.x : fromToMinX; + var fromToControlToMinY = fromToMinY > originalToControl.y ? originalToControl.y : fromToMinY; + var fromToControlToMinZ = fromToMinZ > originalToControl.z ? originalToControl.z : fromToMinZ; + + var fromToControlToMaxX = fromToMaxX < originalToControl.x ? originalToControl.x : fromToMaxX; + var fromToControlToMaxY = fromToMaxY < originalToControl.y ? originalToControl.y : fromToMaxY; + var fromToControlToMaxZ = fromToMaxZ < originalToControl.z ? originalToControl.z : fromToMaxZ; + + minX = fromToControlToMinX > originalFromControl.x ? originalFromControl.x : fromToControlToMinX; + minY = fromToControlToMinY > originalFromControl.y ? originalFromControl.y : fromToControlToMinY; + minZ = fromToControlToMinZ > originalFromControl.z ? originalFromControl.z : fromToControlToMinZ; + + maxX = fromToControlToMaxX < originalFromControl.x ? originalFromControl.x : fromToControlToMaxX; + maxY = fromToControlToMaxY < originalFromControl.y ? originalFromControl.y : fromToControlToMaxY; + maxZ = fromToControlToMaxZ < originalFromControl.z ? originalFromControl.z : fromToControlToMaxZ; + } + } + + var deltaX = maxX - minX; + var deltaY = maxY - minY; + var deltaZ = maxZ - minZ; + var extents = new Vector3(deltaX*.5f, deltaY*.5f, deltaZ*.5f); + minBounds.extents = extents; + minBounds.center = new Vector3(minX + extents.x, minY + extents.y, minZ + extents.z); + + + var sqrDistance = minBounds.SqrDistance(targetPoint); + excludedSections[i] = false; + minSectionDistances[i] = sqrDistance; + + if (!(minAabbDistance > sqrDistance)) continue; + + minAabbDistance = sqrDistance; + minSectionIndex = i; + } + + //calc max (between points and their related controls) + var minSection = sections[minSectionIndex]; + minSectionMaxDistance = MaxDistance(minSection, targetPoint) - BGCurve.Epsilon; + + //----------------------- Section Bbox Partitioning 2nd pass (1) cut off sections, which min distance to point more than max distance to min sections AABB and 2) adjusting min section ) + var sectionsLeft = 0; + var maxDistanceChanged = false; + var start = minSectionIndex; + var end = Mathf.Max(start + 1, sectionsCount - start); + for (var i = 1; i < end; i++) + { + //the reason why we iterate simulteneously- to decrease chances of MaxDistance expensive calls + //to end + var j = start + i; + if (j < sectionsCount) + { + var section = sections[j]; + + if (minSectionDistances[j] > minSectionMaxDistance) excludedSections[j] = true; + else + { + var sectionDistance = MaxDistance(section, targetPoint); + if (minSectionMaxDistance > sectionDistance) + { + minSectionMaxDistance = sectionDistance; + maxDistanceChanged = true; + } + sectionsLeft++; + } + } + + //to zero (copy/pasted) + j = start - i; + if (j >= 0) + { + var section = sections[j]; + + if (minSectionDistances[j] > minSectionMaxDistance) excludedSections[j] = true; + else + { + var sectionDistance = MaxDistance(section, targetPoint); + if (minSectionMaxDistance > sectionDistance) + { + minSectionMaxDistance = sectionDistance; + maxDistanceChanged = true; + } + sectionsLeft++; + } + } + } + + + //----------------------- Section Bbox Partitioning 3rd pass (since minSectionMaxDistance may be changed in 2nd pass, we need to iterate sections and filter them again) + if (maxDistanceChanged && sectionsLeft > 1) + for (var i = 0; i < sectionsCount; i++) if (!excludedSections[i] && minSectionDistances[i] > minSectionMaxDistance) excludedSections[i] = true; + } + + //========================================================================================================================== + // Lines AABB partitioning + //========================================================================================================================== + var pointsOptimizationOn = !skipPointsOptimization; + var closestLineMaxDistance = float.MaxValue; + var fromDistance = float.MaxValue; + var fromLess = true; + var resetFrom = true; + if (pointsOptimizationOn) + { + for (var i = 0; i < sectionsCount; i++) + { + if (sectionsOptimizationOn && excludedSections[i]) + { + resetFrom = true; + continue; + } + + var section = sections[i]; + var points = section.Points; + var pointsCount = points.Count; + + if (resetFrom) + { + resetFrom = false; + fromDistance = Vector3.SqrMagnitude(section[0].Position - targetPoint); + fromLess = fromDistance <= closestLineMaxDistance; + } + + for (var j = 1; j < pointsCount; j++) + { + var to = points[j]; + + var toPos = to.Position; + + //sqr magnitude inlined + var deltaX = toPos.x - targetPoint.x; + var deltaY = toPos.y - targetPoint.y; + var deltaZ = toPos.z - targetPoint.z; + var toDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + var toLess = toDistance <= closestLineMaxDistance; + + if (fromLess && toLess) closestLineMaxDistance = fromDistance > toDistance ? fromDistance : toDistance; + + fromLess = toLess; + fromDistance = toDistance; + } + } + + //====================================================================== Section Bbox partitioning (again) + //----------------------- Section Bbox Partitioning 4th pass (cause closestLineMaxDistance may be smaller than minSectionMaxDistance we used before) + if (sectionsOptimizationOn && closestLineMaxDistance < minSectionMaxDistance) + for (var i = 0; i < sectionsCount; i++) if (!excludedSections[i] && minSectionDistances[i] > closestLineMaxDistance) excludedSections[i] = true; + } + + + //================================================================================================ + // Final Pass + //================================================================================================ + var firstPoint = sections[0][0]; + var fromPoint = firstPoint; + var result = fromPoint.Position; + var minDistance = Vector3.SqrMagnitude(targetPoint - fromPoint.Position); + var sectionIndex = 0; + var pointIndex = 0; + var resultLerp = 0f; + + var fromPartition = -1; + var resetFromPoint = true; + + + Vector3 min = Vector3.zero, max = Vector3.zero; + if (pointsOptimizationOn) + { + //bounding Box over sphere (for points optimization) + var radius = (float) Math.Sqrt(closestLineMaxDistance); + min = new Vector3(targetPoint.x - radius, targetPoint.y - radius, targetPoint.z - radius); + max = new Vector3(targetPoint.x + radius, targetPoint.y + radius, targetPoint.z + radius); + } + + for (var i = 0; i < sectionsCount; i++) + { + if (sectionsOptimizationOn && excludedSections[i]) + { + resetFromPoint = true; + continue; + } + + + var section = sections[i]; + var points = section.Points; + + if (resetFromPoint) + { + resetFromPoint = false; + fromPoint = section[0]; + + if (pointsOptimizationOn) + { + //------------------------------------------ points optimization + //xy quadrant clockwise (0-7) + var fromPos = fromPoint.Position; + var zSet = false; + if (fromPos.x < min.x) + { + if (fromPos.y < min.y) fromPartition = 0; + else if (fromPos.y > max.y) fromPartition = 2; + else fromPartition = 1; + } + else if (fromPos.x > max.x) + { + if (fromPos.y < min.y) fromPartition = 6; + else if (fromPos.y > max.y) fromPartition = 4; + else fromPartition = 5; + } + else + { + if (fromPos.y < min.y) fromPartition = 7; + else if (fromPos.y > max.y) fromPartition = 3; + else + { + if (fromPos.z > max.z) fromPartition = 26; + else if (fromPos.z < min.z) fromPartition = 24; + else fromPartition = 25; + zSet = true; + } + } + //z shift + if (!zSet) + { + if (fromPos.z > max.z) fromPartition = fromPartition | 16; + else if (fromPos.z > min.z) fromPartition = fromPartition | 8; + } + } + } + + var pointsCount = points.Count; + for (var j = 1; j < pointsCount; j++) + { + var toPoint = points[j]; + var toPointPos = toPoint.Position; + + var excludedByOptimization = false; + var toPartition = -1; + if (pointsOptimizationOn) + { + //------------------------------------------ points optimization + // copy/pasted + var zSet = false; + if (toPointPos.x < min.x) + { + if (toPointPos.y < min.y) toPartition = 0; + else if (toPointPos.y > max.y) toPartition = 2; + else toPartition = 1; + } + else if (toPointPos.x > max.x) + { + if (toPointPos.y < min.y) toPartition = 6; + else if (toPointPos.y > max.y) toPartition = 4; + else toPartition = 5; + } + else + { + if (toPointPos.y < min.y) toPartition = 7; + else if (toPointPos.y > max.y) toPartition = 3; + else + { + //center + if (toPointPos.z > max.z) toPartition = 26; + else if (toPointPos.z < min.z) toPartition = 24; + else toPartition = 25; //inside + zSet = true; + } + } + //z shift + if (!zSet) + { + if (toPointPos.z > max.z) toPartition = toPartition | 16; + else if (toPointPos.z > min.z) toPartition = toPartition | 8; + } + + excludedByOptimization = (TransitionsForPartitions[fromPartition] & (1 << toPartition)) != 0; + } + + + if (!excludedByOptimization) + { + float ratio; + var gettingCloser = false; + //============================================================================= Get closest point on line formula: Line(from->to), Point(targetPoint) + // closest on line + double pointX; + double pointY; + double pointZ; + + var fromPos = fromPoint.Position; + var toPos = toPoint.Position; + + var fromTargetX = (double) targetPoint.x - (double) fromPos.x; + var fromTargetY = (double) targetPoint.y - (double) fromPos.y; + var fromTargetZ = (double) targetPoint.z - (double) fromPos.z; + + var fromToX = (double) toPos.x - (double) fromPos.x; + var fromToY = (double) toPos.y - (double) fromPos.y; + var fromToZ = (double) toPos.z - (double) fromPos.z; + + //sqr magnitude inlined + var fromToSquaredDistance = (float) (fromToX*fromToX + fromToY*fromToY + fromToZ*fromToZ); + + + if (Math.Abs(fromToSquaredDistance) < BGCurve.Epsilon) + { + gettingCloser = true; + ratio = 1; + pointX = toPos.x; + pointY = toPos.y; + pointZ = toPos.z; + } + else + { + // dot inlined + var dot = (float) (fromTargetX*fromToX + fromTargetY*fromToY + fromTargetZ*fromToZ); + + if (dot < 0) + { + ratio = 0; + pointX = fromPos.x; + pointY = fromPos.y; + pointZ = fromPos.z; + } + else if (dot > fromToSquaredDistance) + { + gettingCloser = true; + ratio = 1; + pointX = toPos.x; + pointY = toPos.y; + pointZ = toPos.z; + } + else + { + var dotRatio = dot / fromToSquaredDistance; + ratio = dotRatio; + pointX = fromPos.x + fromToX*dotRatio; + pointY = fromPos.y + fromToY*dotRatio; + pointZ = fromPos.z + fromToZ*dotRatio; + } + } + + //------------------------------------------------------ Compare with min distance + //sqr magnitude inlined + var deltaX = (double) targetPoint.x - (double) pointX; + var deltaY = (double) targetPoint.y - (double) pointY; + var deltaZ = (double) targetPoint.z - (double) pointZ; + var sqrMagnitude = (float) (deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ); + if (sqrMagnitude < minDistance) + { + minDistance = sqrMagnitude; + result.x = (float) pointX; + result.y = (float) pointY; + result.z = (float) pointZ; + sectionIndex = i; + + if (gettingCloser) + { + //if we are getting closer-> simply move the pointer to current point + if (j == pointsCount - 1 && i < sectionsCount - 1) + { + //if it's the last point in the current section-> move pointer to 1st point of the next section (to calc distances correctly) + sectionIndex = i + 1; + pointIndex = 0; + } + else + { + pointIndex = j; + } + + resultLerp = 0; + } + else + { + //current closest point somewhere on this line (resultLerp show how far from [j - 1] to [j]) + pointIndex = j - 1; + resultLerp = ratio; + } + } + } + + fromPoint = toPoint; + fromPartition = toPartition; + } + } + + //================================================================================================ + // Final result + //================================================================================================ + var resultSection = sections[sectionIndex]; + if (resultLerp > 0 && resultLerp < 1 && pointIndex < resultSection.PointsCount - 1) + { + var lerpFrom = resultSection[pointIndex]; + var lerpTo = resultSection[pointIndex + 1]; + + tangent = Vector3.Lerp(lerpFrom.Tangent, lerpTo.Tangent, resultLerp); + distance = sections[sectionIndex].DistanceFromStartToOrigin + Mathf.Lerp(lerpFrom.DistanceToSectionStart, lerpTo.DistanceToSectionStart, resultLerp); + } + else + { + var resultPoint = sections[sectionIndex][pointIndex]; + + tangent = resultPoint.Tangent; + distance = sections[sectionIndex].DistanceFromStartToOrigin + resultPoint.DistanceToSectionStart; + } + + return result; + } + + //max distance between a point and a section + private static float MaxDistance(BGCurveBaseMath.SectionInfo section, Vector3 position) + { +// var fromDistance = Vector3.SqrMagnitude(section.OriginalFrom - position); + var deltaX = section.OriginalFrom.x - position.x; + var deltaY = section.OriginalFrom.y - position.y; + var deltaZ = section.OriginalFrom.z - position.z; + var fromDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + +// var toDistance = Vector3.SqrMagnitude(section.OriginalTo - position); + deltaX = section.OriginalTo.x - position.x; + deltaY = section.OriginalTo.y - position.y; + deltaZ = section.OriginalTo.z - position.z; + var toDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + + var fromControlAbsent = section.OriginalFromControlType == BGCurvePoint.ControlTypeEnum.Absent; + var toControlAbsent = section.OriginalToControlType == BGCurvePoint.ControlTypeEnum.Absent; + float maxDistance; + if (fromControlAbsent && toControlAbsent) + { + maxDistance = Mathf.Max(fromDistance, toDistance); + } + else + { + if (fromControlAbsent) + { + // var toControlDistance = Vector3.SqrMagnitude(section.OriginalToControl - position); + deltaX = section.OriginalToControl.x - position.x; + deltaY = section.OriginalToControl.y - position.y; + deltaZ = section.OriginalToControl.z - position.z; + var toControlDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + + maxDistance = Mathf.Max(Mathf.Max(fromDistance, toDistance), toControlDistance); + } + else if (toControlAbsent) + { + // var fromControlDistance = Vector3.SqrMagnitude(section.OriginalFromControl - position); + deltaX = section.OriginalFromControl.x - position.x; + deltaY = section.OriginalFromControl.y - position.y; + deltaZ = section.OriginalFromControl.z - position.z; + var fromControlDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + + maxDistance = Mathf.Max(Mathf.Max(fromDistance, toDistance), fromControlDistance); + } + else + { + // var fromControlDistance = Vector3.SqrMagnitude(section.OriginalFromControl - position); + deltaX = section.OriginalFromControl.x - position.x; + deltaY = section.OriginalFromControl.y - position.y; + deltaZ = section.OriginalFromControl.z - position.z; + var fromControlDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + // var toControlDistance = Vector3.SqrMagnitude(section.OriginalToControl - position); + deltaX = section.OriginalToControl.x - position.x; + deltaY = section.OriginalToControl.y - position.y; + deltaZ = section.OriginalToControl.z - position.z; + var toControlDistance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ; + + maxDistance = Mathf.Max(Mathf.Max(Mathf.Max(fromDistance, toDistance), fromControlDistance), toControlDistance); + } + } + return maxDistance; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs.meta new file mode 100644 index 0000000..83a8d0d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveCalculatorClosestPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 40763d37e0dc903468aa5813eb0d99d0 +timeCreated: 1474035777 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs new file mode 100644 index 0000000..d268b7b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs @@ -0,0 +1,179 @@ +using System; + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// THIS NEED TO BE REWORKED. + /// + /// Curve's change information. It's used only if Use curve.UseEventsArgs=true + /// + /// Multiple- muliple changes + /// CurveTransform- curve transform changed + /// Points- point(s) was added or removed or swapped, or 'closed' attribute changed + /// Point - point position changed + /// PointControl - point's controls changed + /// PointControlType -point's control type changed + /// Fields -point's fields changed + /// + public class BGCurveChangedArgs : EventArgs, ICloneable + { + //reusable event instance + private static readonly BGCurveChangedArgs Instance = new BGCurveChangedArgs(); + + + //all possible types of changes + public enum ChangeTypeEnum + { + Multiple, + CurveTransform, + Points, + Point, + Fields, + Snap, + Curve + } + + //type of the change + private ChangeTypeEnum changeType; + + //changed curve + private BGCurve curve; + //changed point + private BGCurvePointI point; + //event message + private string message; + //multiple changes + private BGCurveChangedArgs[] multipleChanges; + + /// Type of the change + public ChangeTypeEnum ChangeType + { + get { return changeType; } + } + + /// Changed curve + public BGCurve Curve + { + get { return curve; } + } + + /// Change message + public string Message + { + get { return message; } + } + + /// Multiple changes + public BGCurveChangedArgs[] MultipleChanges + { + get { return multipleChanges; } + } + + /* + public BGCurveChangedArgs(BGCurve curve, ChangeTypeEnum changeType) + { + this.curve = curve; + this.changeType = changeType; + } + + public BGCurveChangedArgs(BGCurve curve, BGCurvePoint point, ChangeTypeEnum changeType) : this(curve, changeType) + { + this.point = point; + } + + public BGCurveChangedArgs(BGCurve curve, BGCurveChangedArgs[] multipleChanges) + { + this.curve = curve; + changeType = ChangeTypeEnum.Multiple; + this.multipleChanges = multipleChanges; + } + */ + + private BGCurveChangedArgs() + { + } + + /// Init and get event instance + public static BGCurveChangedArgs GetInstance(BGCurve curve, ChangeTypeEnum type, string message) + { + Instance.curve = curve; + Instance.changeType = type; + Instance.message = message; + Instance.multipleChanges = null; + Instance.point = null; + return Instance; + } + + /// Init and get event instance + public static BGCurveChangedArgs GetInstance(BGCurve curve, BGCurveChangedArgs[] changes, string changesInTransaction) + { + Instance.curve = curve; + Instance.changeType = ChangeTypeEnum.Multiple; + Instance.message = BGCurve.EventTransaction; + Instance.multipleChanges = changes; + Instance.point = null; + return Instance; + } + + /// Init and get event instance + public static BGCurveChangedArgs GetInstance(BGCurve curve, BGCurvePointI point, string changesInTransaction) + { + Instance.curve = curve; + Instance.changeType = ChangeTypeEnum.Point; + Instance.message = BGCurve.EventTransaction; + Instance.point = point; + return Instance; + } + + /// Clone event + public object Clone() + { + return new BGCurveChangedArgs + { + changeType = changeType, + curve = curve, + multipleChanges = multipleChanges, + message = message, + point = point + }; + } + + protected bool Equals(BGCurveChangedArgs other) + { + return changeType == other.changeType && Equals(curve, other.curve) ; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((BGCurveChangedArgs) obj); + } + + public override int GetHashCode() + { + var hashCode = (int) changeType; + hashCode = (hashCode*397) ^ (curve != null ? curve.GetHashCode() : 0); + return hashCode; + } + + /// Before change event + public class BeforeChange : EventArgs + { + public static readonly BeforeChange BeforeChangeInstance = new BeforeChange(); + + public string Operation; + + private BeforeChange() + { + } + + public static BeforeChange GetInstance(string operation) + { + BeforeChangeInstance.Operation = operation; + return BeforeChangeInstance; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs.meta new file mode 100644 index 0000000..192bddf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveChangedArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 42a0fb8b80d3c5747ad89e7288172f3a +timeCreated: 1459523844 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs new file mode 100644 index 0000000..274d721 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs @@ -0,0 +1,290 @@ +using System; +using UnityEngine; + + +namespace BansheeGz.BGSpline.Curve +{ + /// + /// Do not use it. This is an old deprecated math, using parametric formulas to get position and tangent. + /// It does not have any advantage over BGCurveBaseMath, which is slightly faster and have a little lesser memory footprint. + /// We leave this class for testing and reference purposes only. + /// + [Obsolete("Use BGCurveBaseMath. This class is for testing purpose only")] + public class BGCurveFormulaMath : BGCurveBaseMath + { + // cached data (t=some ratio [0,1], tr=1-t, t2=t*t, etc.). + //position + private float[] bakedT; + private float[] bakedT2; + private float[] bakedTr2; + private float[] bakedT3; + private float[] bakedTr3; + private float[] bakedTr2xTx3; + private float[] bakedT2xTrx3; + private float[] bakedTxTrx2; + + //tangent related + private float[] bakedTr2x3; + private float[] bakedTxTrx6; + private float[] bakedT2x3; + private float[] bakedTx2; + private float[] bakedTrx2; + + public BGCurveFormulaMath(BGCurve curve, Config config) + : base(curve, config) + { + } + + //some additional init + protected override void AfterInit(Config config) + { + //let's bake some data + var parts = config.Parts; + var sectionPointsCount = parts + 1; + + Array.Resize(ref bakedT, sectionPointsCount); + + Array.Resize(ref bakedT2, sectionPointsCount); + Array.Resize(ref bakedTr2, sectionPointsCount); + Array.Resize(ref bakedT3, sectionPointsCount); + Array.Resize(ref bakedTr3, sectionPointsCount); + + Array.Resize(ref bakedTr2xTx3, sectionPointsCount); + Array.Resize(ref bakedT2xTrx3, sectionPointsCount); + Array.Resize(ref bakedTxTrx2, sectionPointsCount); + + if (NeedTangentFormula) + { + Array.Resize(ref bakedTr2x3, sectionPointsCount); + Array.Resize(ref bakedTxTrx6, sectionPointsCount); + Array.Resize(ref bakedT2x3, sectionPointsCount); + Array.Resize(ref bakedTx2, sectionPointsCount); + Array.Resize(ref bakedTrx2, sectionPointsCount); + } + + for (var i = 0; i <= parts; i++) + { + var t = i/(float) parts; + var tr = 1 - t; + var t2 = t*t; + var tr2 = tr*tr; + + bakedT[i] = t; + + bakedT2[i] = t2; + bakedTr2[i] = tr2; + bakedT3[i] = t2*t; + bakedTr3[i] = tr2*tr; + + bakedTr2xTx3[i] = 3*tr2*t; + bakedT2xTrx3[i] = 3*tr*t2; + bakedTxTrx2[i] = 2*tr*t; + + if (!NeedTangentFormula) continue; + + + bakedTr2x3[i] = 3*tr2; + bakedTxTrx6[i] = 6*tr*t; + bakedT2x3[i] = 3*t2; + bakedTx2[i] = 2*t; + bakedTrx2[i] = 2*tr; + } + } + + //standard c# dispose + public override void Dispose() + { + base.Dispose(); + + var emptyArray = new float[0]; + bakedT = emptyArray; + bakedT2 = emptyArray; + bakedTr2 = emptyArray; + bakedT3 = emptyArray; + bakedTr3 = emptyArray; + bakedTr2xTx3 = emptyArray; + bakedT2xTrx3 = emptyArray; + bakedTxTrx2 = emptyArray; + + bakedTr2x3 = emptyArray; + bakedTxTrx6 = emptyArray; + bakedT2x3 = emptyArray; + bakedTx2 = emptyArray; + bakedTrx2 = emptyArray; + } + + //calculate one split section data + protected override void CalculateSplitSection(SectionInfo section, BGCurvePointI @from, BGCurvePointI to) + { + Resize(section.points, config.Parts + 1); + + //======================================== + // Calculate points + //======================================== + //-----------section data + var fromPos = section.OriginalFrom; + var toPos = section.OriginalTo; + var control1 = section.OriginalFromControl; + var control2 = section.OriginalToControl; + + var controlFromAbsent = @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + var controlToAbsent = to.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + var noControls = controlFromAbsent && controlToAbsent; + var bothControls = !controlFromAbsent && !controlToAbsent; + if (!noControls && !bothControls && controlFromAbsent) control1 = control2; + + //snapping + var snapIsOn = curve.SnapType == BGCurve.SnapTypeEnum.Curve; + + + //-----------calc some data + + // no controls + Vector3 fromTo = Vector3.zero, fromToTangentWorld = Vector3.zero; + if (noControls) + { + fromTo = toPos - fromPos; + if (cacheTangent) fromToTangentWorld = (to.PositionWorld - @from.PositionWorld).normalized; + } + + // tangent related + Vector3 control1MinusFrom = Vector3.zero, control2MinusControl1 = Vector3.zero, toMinusControl2 = Vector3.zero, toMinusControl1 = Vector3.zero; + if (!config.UsePointPositionsToCalcTangents && cacheTangent) + { + control1MinusFrom = control1 - fromPos; + if (bothControls) + { + control2MinusControl1 = control2 - control1; + toMinusControl2 = toPos - control2; + } + else + { + toMinusControl1 = toPos - control1; + } + } + + + //----------- Critical block starts + var length = bakedT.Length; + for (var i = 0; i < length; i++) + { + var point = section.points[i] ?? (section.points[i] = new SectionPointInfo()); + + Vector3 pos; + + if (noControls) + { + // ================= NoControls + // ---------- position + var t = bakedT[i]; + pos = new Vector3(fromPos.x + fromTo.x * t, fromPos.y + fromTo.y * t, fromPos.z + fromTo.z * t); + + if (snapIsOn) curve.ApplySnapping(ref pos); + + point.Position = pos; + + //---------- tangents + if (cacheTangent) point.Tangent = fromToTangentWorld; + } + else + { + // ================= At least One control + //---------- position + + if (bothControls) + { + var tr3 = bakedTr3[i]; + var tr2xTx3 = bakedTr2xTx3[i]; + var t2xTrx3 = bakedT2xTrx3[i]; + var t3 = bakedT3[i]; + + pos = new Vector3(tr3 * fromPos.x + tr2xTx3 * control1.x + t2xTrx3 * control2.x + t3 * toPos.x, + tr3 * fromPos.y + tr2xTx3 * control1.y + t2xTrx3 * control2.y + t3 * toPos.y, + tr3 * fromPos.z + tr2xTx3 * control1.z + t2xTrx3 * control2.z + t3 * toPos.z); + } + else + { + var tr2 = bakedTr2[i]; + var txTrx2 = bakedTxTrx2[i]; + var t2 = bakedT2[i]; + + pos = new Vector3(tr2 * fromPos.x + txTrx2 * control1.x + t2 * toPos.x, + tr2 * fromPos.y + txTrx2 * control1.y + t2 * toPos.y, + tr2 * fromPos.z + txTrx2 * control1.z + t2 * toPos.z); + } + + if (snapIsOn) curve.ApplySnapping(ref pos); + + point.Position = pos; + + + //---------- tangents + if (cacheTangent) + { + if (config.UsePointPositionsToCalcTangents) + { + //-------- Calc by point's positions + //we skip 1st point, cause we do not have enough info for it. we'll set it at the next step + if (i != 0) + { + var prevPoint = section[i - 1]; + + var prevPosition = prevPoint.Position; + + var tangent = new Vector3(pos.x - prevPosition.x, pos.y - prevPosition.y, pos.z - prevPosition.z); + //Vector3.normalized inlined (tangent=tangent.normalized) + var marnitude = (float)Math.Sqrt((double)tangent.x * (double)tangent.x + (double)tangent.y * (double)tangent.y + (double)tangent.z * (double)tangent.z); + tangent = ((double)marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x / marnitude, tangent.y / marnitude, tangent.z / marnitude) : Vector3.zero; + + prevPoint.Tangent = tangent; + + //we will adjust it later (if there is another section after this one , otherwise- no more data for more precise calculation) + if (i == config.Parts) point.Tangent = prevPoint.Tangent; + } + } + else + { + //-------- Calc by a formula + Vector3 tangent; + if (bothControls) + { + var tr2x3 = bakedTr2x3[i]; + var txTrx6 = bakedTxTrx6[i]; + var t2x3 = bakedT2x3[i]; + tangent = new Vector3(tr2x3 * control1MinusFrom.x + txTrx6 * control2MinusControl1.x + t2x3 * toMinusControl2.x, + tr2x3 * control1MinusFrom.y + txTrx6 * control2MinusControl1.y + t2x3 * toMinusControl2.y, + tr2x3 * control1MinusFrom.z + txTrx6 * control2MinusControl1.z + t2x3 * toMinusControl2.z); + } + else + { + var trx2 = bakedTrx2[i]; + var tx2 = bakedTx2[i]; + tangent = new Vector3(trx2 * control1MinusFrom.x + tx2 * toMinusControl1.x, + trx2 * control1MinusFrom.y + tx2 * toMinusControl1.y, + trx2 * control1MinusFrom.z + tx2 * toMinusControl1.z); + } + + //Vector3.normalized inlined (tangent=tangent.normalized) + var marnitude = (float)Math.Sqrt((double)tangent.x * (double)tangent.x + (double)tangent.y * (double)tangent.y + (double)tangent.z * (double)tangent.z); + tangent = ((double)marnitude > 9.99999974737875E-06) ? new Vector3(tangent.x / marnitude, tangent.y / marnitude, tangent.z / marnitude) : Vector3.zero; + + // set tangent + point.Tangent = tangent; + } + } + } + + + if (i == 0) continue; + + // ---------- distance to section start (Vector3.Distance inlined) + var prevPos = section[i - 1].Position; + double x = pos.x - prevPos.x; + double y = pos.y - prevPos.y; + double z = pos.z - prevPos.z; + point.DistanceToSectionStart = section[i - 1].DistanceToSectionStart + ((float)Math.Sqrt(x * x + y * y + z * z)); + } + //----------- Critical block ends + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs.meta new file mode 100644 index 0000000..b35740a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulaMath.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 53f2137c1b19f4641861ad8607f250af +timeCreated: 1475717228 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs new file mode 100644 index 0000000..7ce3b14 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs @@ -0,0 +1,52 @@ +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// Spline related formulas. + public static class BGCurveFormulas + { + /// Cubic Bezier curve interpolation. More info + // P0=from, P1=fromControl, P2=toControl, P3=to + public static Vector3 BezierCubic(float t, Vector3 from, Vector3 fromControl, Vector3 toControl, Vector3 to) + { + // tr= t reverse + var tr = 1 - t; + var tr2 = tr*tr; + var t2 = t*t; + + return tr*tr2*from + 3*tr2*t*fromControl + 3*tr*t2*toControl + t*t2*to; + } + + /// Quadratic Bezier curve interpolation. More info + // P0=from, P1=control, P2 = to + public static Vector3 BezierQuadratic(float t, Vector3 from, Vector3 control, Vector3 to) + { + // tr= t reverse + var tr = 1 - t; + var tr2 = tr*tr; + var t2 = t*t; + + return tr2*from + 2*tr*t*control + t2*to; + } + + /// Cubic Bezier curve derivative. More info + // P0=from, P1=fromControl, P2=toControl, P3=to + public static Vector3 BezierCubicDerivative(float t, Vector3 from, Vector3 fromControl, Vector3 toControl, Vector3 to) + { + // tr= t reverse + var tr = 1 - t; + + return 3*(tr*tr)*(fromControl - from) + 6*tr*t*(toControl - fromControl) + 3*(t*t)*(to - toControl); + } + + /// Quadratic Bezier curve derivative. More info + // P0=from, P1=control, P2 = to + public static Vector3 BezierQuadraticDerivative(float t, Vector3 from, Vector3 control, Vector3 to) + { + // tr= t reverse + var tr = 1 - t; + + return 2*tr*(control - from) + 2*t*(to - control); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs.meta new file mode 100644 index 0000000..a250dc4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveFormulas.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 076c586f3afa833488d8fc4e60e81684 +timeCreated: 1472028225 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs new file mode 100644 index 0000000..29977c1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs @@ -0,0 +1,129 @@ +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// This is an interface for curve's Math solver + public interface BGCurveMathI + { + + //=============================================================================================== + // Generic (position or tangent) + //=============================================================================================== + + /// Calculate spline's field value by distance ratio. + /// field to retrieve (like position or tangent etc.) + /// Ratio between (0,1) + /// Use local coordinates instead of world + /// result field's value + Vector3 CalcByDistanceRatio(BGCurveBaseMath.Field field, float distanceRatio, bool useLocal = false); + + /// Calculate spline's field value by distance. + /// field to retrieve + /// distance from the curve's start between (0, GetDistance()) + /// Use local coordinates instead of world + /// result field's value + Vector3 CalcByDistance(BGCurveBaseMath.Field field, float distance, bool useLocal = false); + + //=============================================================================================== + // Position and tangent + //=============================================================================================== + /// Calculate both spline's fields (position and tangent) by distance ratio. + /// Ratio between (0,1) + /// result tangent + /// Use local coordinates instead of world + /// result position + Vector3 CalcByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false); + + /// Calculate both curve's fields (position and tangent) by distance. + /// distance from the curve's start between (0, GetDistance()) + /// result tangent + /// Use local coordinates instead of world + /// result position + Vector3 CalcByDistance(float distance, out Vector3 tangent, bool useLocal = false); + + /// Calculate approximate spline's point position using distance ratio. + /// Ratio between (0,1) + /// result tangent + /// Use local coordinates instead of world + /// result position + Vector3 CalcPositionAndTangentByDistanceRatio(float distanceRatio, out Vector3 tangent, bool useLocal = false); + + /// Calculate approximate spline's point position using distance. + /// distance from curve's start between (0, GetDistance()) + /// result tangent + /// Use local coordinates instead of world + /// result position + Vector3 CalcPositionAndTangentByDistance(float distance, out Vector3 tangent, bool useLocal = false); + + //=============================================================================================== + // Position + //=============================================================================================== + /// Calculate approximate spline's point position using distance ratio. + /// Ratio between (0,1) + /// Use local coordinates instead of world + Vector3 CalcPositionByDistanceRatio(float distanceRatio, bool useLocal = false); + + /// Calculate approximate spline's point position using distance. + /// distance from curve's start between (0, GetDistance()) + /// Use local coordinates instead of world + Vector3 CalcPositionByDistance(float distance, bool useLocal = false); + + //=============================================================================================== + // Tangent + //=============================================================================================== + /// Calculate approximate spline's tangent using distance ratio. + /// Ratio between (0,1) + /// Use local coordinates instead of world + Vector3 CalcTangentByDistanceRatio(float distanceRatio, bool useLocal = false); + + /// Calculate approximate spline's tangent using distance. + /// distance from curve's start between (0, GetDistance()) + /// Use local coordinates instead of world + Vector3 CalcTangentByDistance(float distance, bool useLocal = false); + + //=============================================================================================== + // Section index + //=============================================================================================== + /// Calculate spline's section using distance. + /// distance from curve's start between (0, GetDistance()) + int CalcSectionIndexByDistance(float distance); + + /// Calculate spline's section using distance ratio. + /// Ratio between (0,1) + int CalcSectionIndexByDistanceRatio(float ratio); + + //=============================================================================================== + // By closest point + //=============================================================================================== + /// Calculate spline's world point position by a point, which is closest to a given point. + /// Point's position + /// Skip any optimization at section level, if any + /// Skip any optimization at approximation points level, if any + /// Position on the spline, which is closest to a given point + Vector3 CalcPositionByClosestPoint(Vector3 point, bool skipSectionsOptimization = false, bool skipPointsOptimization = false); + + /// Calculate spline's world point position and distance by a point, which is closest to a given point. + /// Point's position + /// Result distance from the start of the spline + /// Skip any optimization at section level, if any + /// Skip any optimization at approximation points level, if any + /// Position on the spline, which is closest to a given point + Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, bool skipSectionsOptimization = false, bool skipPointsOptimization = false); + + /// Calculate spline's world point position, distance and tangent by a point, which is closest to a given point. + /// Point's position + /// Result distance from the start of the spline + /// Result tangent + /// Skip any optimization at section level, if any + /// Skip any optimization at approximation points level, if any + /// Position on the spline, which is closest to a given point + Vector3 CalcPositionByClosestPoint(Vector3 point, out float distance, out Vector3 tangent, bool skipSectionsOptimization = false, bool skipPointsOptimization = false); + + //=============================================================================================== + // Total spline's length + //=============================================================================================== + /// Get spline's approximate total distance + /// Spline's total distance + float GetDistance(); + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs.meta new file mode 100644 index 0000000..d58dd1d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveMathI.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dbf2e4dc3f6bfad45936d71c418d16e3 +timeCreated: 1477133076 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs new file mode 100644 index 0000000..fe2a4c6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs @@ -0,0 +1,817 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// One inlined point data + // !!! Note, there is a BGCurvePointGO class, partially copied from this class + [Serializable] + public class BGCurvePoint : BGCurvePointI + { + + #region enums + + /// possible point's control types + public enum ControlTypeEnum + { + /// no control point + Absent, + + /// 2 points, symmetrical to each other + BezierSymmetrical, + + /// 2 points, independant + BezierIndependant + } + + /// helper enum for system fields + public enum FieldEnum + { + PositionWorld, + PositionLocal, + ControlFirstWorld, + ControlFirstLocal, + ControlSecondWorld, + ControlSecondLocal + } + + #endregion + + #region constructors + + /// All coordinates are Local by default. positionLocal relative to curve's transform, controls are relative to positionLocal. Set useWorldCoordinates to true to use world coordinates + public BGCurvePoint(BGCurve curve, Vector3 position, bool useWorldCoordinates = false) : this(curve, position, ControlTypeEnum.Absent, useWorldCoordinates) + { + } + + /// All coordinates are Local by default. positionLocal relative to curve's transform, controls are relative to positionLocal. Set useWorldCoordinates to true to use world coordinates + public BGCurvePoint(BGCurve curve, Vector3 position, ControlTypeEnum controlType, bool useWorldCoordinates = false) + : this(curve, position, controlType, Vector3.zero, Vector3.zero, useWorldCoordinates) + { + } + + /// All coordinates are Local by default. positionLocal relative to curve's transform, controls are relative to positionLocal. Set useWorldCoordinates to true to use world coordinates + public BGCurvePoint(BGCurve curve, Vector3 position, ControlTypeEnum controlType, Vector3 controlFirst, Vector3 controlSecond, bool useWorldCoordinates = false) + : this(curve, null , position, controlType, controlFirst, controlSecond, useWorldCoordinates) + { + } + + /// All coordinates are Local by default. positionLocal relative to curve's transform, controls are relative to positionLocal. Set useWorldCoordinates to true to use world coordinates + public BGCurvePoint(BGCurve curve, Transform pointTransform, Vector3 position, ControlTypeEnum controlType, Vector3 controlFirst, Vector3 controlSecond, bool useWorldCoordinates = false ) + { + this.curve = curve; + this.controlType = controlType; + this.pointTransform = pointTransform; + + if (useWorldCoordinates) + { + positionLocal = curve.transform.InverseTransformPoint(position); + controlFirstLocal = curve.transform.InverseTransformDirection(controlFirst - position); + controlSecondLocal = curve.transform.InverseTransformDirection(controlSecond - position); + } + else + { + positionLocal = position; + controlFirstLocal = controlFirst; + controlSecondLocal = controlSecond; + } + } + + #endregion + + #region fields + + //control type + [SerializeField] private ControlTypeEnum controlType; + + //relative to curve position + [SerializeField] private Vector3 positionLocal; + + //relative to point position + [SerializeField] private Vector3 controlFirstLocal; + [SerializeField] private Vector3 controlSecondLocal; + + [SerializeField] private Transform pointTransform; + + + //point's curve + [SerializeField] private BGCurve curve; + + //custom fields values for all points. it's an array with only one element. the reason why we store it like this- is to reduce storage and serialization costs. + [SerializeField] private FieldsValues[] fieldsValues; + + /// The curve, point's belong to + public BGCurve Curve + { + get { return curve; } + } + + /// This field is not meant for use outside of BGCurve package + //all fields values + public FieldsValues PrivateValuesForFields + { + get + { + if (fieldsValues == null || fieldsValues.Length < 1 || fieldsValues[0] == null) fieldsValues = new[] {new FieldsValues()}; + return fieldsValues[0]; + } + set + { + if (fieldsValues == null || fieldsValues.Length < 1 || fieldsValues[0] == null) fieldsValues = new[] {new FieldsValues()}; + fieldsValues[0] = value; + } + } + + // =============================================== Position + //see interface for comments + public Vector3 PositionLocal + { + get { return pointTransform == null ? positionLocal : curve.transform.InverseTransformPoint(pointTransform.position); } + set { SetPosition(value); } + } + + //see interface for comments + public Vector3 PositionLocalTransformed + { + get + { + return pointTransform == null + ? curve.transform.TransformPoint(positionLocal) - curve.transform.position + : pointTransform.position - curve.transform.position; + } + set { SetPosition(value + curve.transform.position, true); } + } + + //see interface for comments + public Vector3 PositionWorld + { + get { return pointTransform == null ? curve.transform.TransformPoint(positionLocal) : pointTransform.position; } + set { SetPosition(value, true); } + } + + + // =============================================== First Handle + //see interface for comments + public Vector3 ControlFirstLocal + { + get { return controlFirstLocal; } + set { SetControlFirstLocal(value); } + } + + //see interface for comments + public Vector3 ControlFirstLocalTransformed + { + get { return (pointTransform == null ? curve.transform : pointTransform).TransformVector(controlFirstLocal); } + set + { + var transform = pointTransform == null ? curve.transform : pointTransform; + SetControlFirstLocal(transform.InverseTransformVector(value)); + } + } + + //see interface for comments + public Vector3 ControlFirstWorld + { + get + { + if (pointTransform == null) + return curve.transform.TransformPoint(new Vector3(positionLocal.x + controlFirstLocal.x, positionLocal.y + controlFirstLocal.y, positionLocal.z + controlFirstLocal.z)); + + return pointTransform.position + pointTransform.TransformVector(controlFirstLocal); + } + set + { + var pos = pointTransform == null ? curve.transform.InverseTransformPoint(value) - positionLocal : pointTransform.InverseTransformVector(value - pointTransform.position); + SetControlFirstLocal(pos); + } + } + + + // =============================================== Second Handle + //see interface for comments + public Vector3 ControlSecondLocal + { + get { return controlSecondLocal; } + set { SetControlSecondLocal(value); } + } + + //see interface for comments + public Vector3 ControlSecondLocalTransformed + { + get { return (pointTransform == null ? curve.transform : pointTransform).TransformVector(controlSecondLocal); } + set + { + var transform = pointTransform == null ? curve.transform : pointTransform; + SetControlSecondLocal(transform.InverseTransformVector(value)); + } + } + + + //see interface for comments + public Vector3 ControlSecondWorld + { + get + { + if (pointTransform == null) + return curve.transform.TransformPoint(new Vector3(positionLocal.x + controlSecondLocal.x, positionLocal.y + controlSecondLocal.y, positionLocal.z + controlSecondLocal.z)); + + return pointTransform.position + pointTransform.TransformVector(controlSecondLocal); + } + set + { + var pos = pointTransform == null ? curve.transform.InverseTransformPoint(value) - positionLocal : pointTransform.InverseTransformVector(value - pointTransform.position); + SetControlSecondLocal(pos); + } + } + + + // =============================================== Control type + //see interface for comments + public ControlTypeEnum ControlType + { + get { return controlType; } + set + { + if (controlType == value) return; + + curve.FireBeforeChange(BGCurve.EventPointControlType); + + controlType = value; + + if (controlType == ControlTypeEnum.BezierSymmetrical) controlSecondLocal = -controlFirstLocal; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControlType) : null, sender: this); + } + } + + + // =============================================== Transform + public Transform PointTransform + { + get { return pointTransform; } + set + { + if (pointTransform == value) return; + + curve.FireBeforeChange(BGCurve.EventPointTransform); + + var oldTransformNull = pointTransform == null && value != null; + var newTransformNull = value == null && pointTransform != null; + + //we need to transfer system fields + var control1 = ControlFirstLocalTransformed; + var control2 = ControlSecondLocalTransformed; + var positionWorld = PositionWorld; + + pointTransform = value; + + // transfer system fields + if (pointTransform != null) + { + pointTransform.position = positionWorld; + controlFirstLocal = pointTransform.InverseTransformVector(control1); + controlSecondLocal = pointTransform.InverseTransformVector(control2); + } + else + { + positionLocal = curve.transform.InverseTransformPoint(positionWorld); + controlFirstLocal = curve.transform.InverseTransformVector(control1); + controlSecondLocal = curve.transform.InverseTransformVector(control2); + } + + + // inform curve + if (oldTransformNull) curve.PrivateTransformForPointAdded(curve.IndexOf(this)); + else if (newTransformNull) curve.PrivateTransformForPointRemoved(curve.IndexOf(this)); + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointTransform) : null, sender: this); + } + } + + #endregion + + #region custom fields + + //=============================================================================================== + // Custom Fields (see interface for comments) + //=============================================================================================== + //----------------------------------- Getters + public T GetField(string name) + { + var type = typeof(T); + var value = GetField(name, type); + var field = (T) value; + return field; + } + + public float GetFloat(string name) + { + return PrivateValuesForFields.floatValues[curve.IndexOfFieldValue(name)]; + } + + public bool GetBool(string name) + { + return PrivateValuesForFields.boolValues[curve.IndexOfFieldValue(name)]; + } + + public int GetInt(string name) + { + return PrivateValuesForFields.intValues[curve.IndexOfFieldValue(name)]; + } + + public Vector3 GetVector3(string name) + { + return PrivateValuesForFields.vector3Values[curve.IndexOfFieldValue(name)]; + } + + public Quaternion GetQuaternion(string name) + { + return PrivateValuesForFields.quaternionValues[curve.IndexOfFieldValue(name)]; + } + + public Bounds GetBounds(string name) + { + return PrivateValuesForFields.boundsValues[curve.IndexOfFieldValue(name)]; + } + + public Color GetColor(string name) + { + return PrivateValuesForFields.colorValues[curve.IndexOfFieldValue(name)]; + } + + public object GetField(string name, Type type) + { + return FieldTypes.GetField(curve, type, name, PrivateValuesForFields); + } + + //----------------------------------- Setters + public void SetField(string name, T value) + { + SetField(name, value, typeof(T)); + } + + public void SetField(string name, object value, Type type) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + FieldTypes.SetField(curve, type, name, value, PrivateValuesForFields); + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetFloat(string name, float value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.floatValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetBool(string name, bool value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.boolValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetInt(string name, int value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.intValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetVector3(string name, Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.vector3Values[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetQuaternion(string name, Quaternion value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.quaternionValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetBounds(string name, Bounds value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.boundsValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetColor(string name, Color value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.colorValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + #endregion + + #region Misc public methods + + //================================================================================ + // Misc public functions + //================================================================================ + /// return system Vector 3 field + public Vector3 Get(FieldEnum field) + { + Vector3 result; + switch (field) + { + //position + case FieldEnum.PositionWorld: + result = PositionWorld; + break; + case FieldEnum.PositionLocal: + result = positionLocal; + break; + + //first control + case FieldEnum.ControlFirstWorld: + result = ControlFirstWorld; + break; + case FieldEnum.ControlFirstLocal: + result = controlFirstLocal; + break; + + //second control + case FieldEnum.ControlSecondWorld: + result = ControlSecondWorld; + break; + default: + result = controlSecondLocal; + break; + } + return result; + } + + //see interface for comments + + public override string ToString() + { + return "Point [localPosition=" + positionLocal + "]"; + } + + #endregion + + #region private methods + + //set local position + private void SetPosition(Vector3 value, bool worldSpaceIsUsed = false) + { + curve.FireBeforeChange(BGCurve.EventPointPosition); + + //snapping + if (curve.SnapType != BGCurve.SnapTypeEnum.Off) + { + if (worldSpaceIsUsed) curve.ApplySnapping(ref value); + else + { + //we need to transfer space before applying snapping + var pos = curve.transform.TransformPoint(value); + if (curve.ApplySnapping(ref pos)) value = curve.transform.InverseTransformPoint(pos); + } + } + + + //assign position + if (pointTransform == null) + { + if (worldSpaceIsUsed) + { + var localPos = curve.transform.InverseTransformPoint(value); + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) localPos = curve.Apply2D(localPos); + positionLocal = localPos; + } + else + { + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + positionLocal = value; + } + } + else + { + //2d mode with curve's transform changed is not working correctly + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + pointTransform.position = worldSpaceIsUsed ? value : curve.transform.TransformPoint(value); + } + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointPosition) : null, sender: this); + } + + //set local control 1 + private void SetControlFirstLocal(Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointControl); + + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + + if (controlType == ControlTypeEnum.BezierSymmetrical) controlSecondLocal = -value; + + controlFirstLocal = value; + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControl) : null, sender: this); + } + + //set local control 2 (it's basically copy/paste from SetControlFirstLocal, but we can not use delegates here because of performance) + private void SetControlSecondLocal(Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointControl); + + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + + if (controlType == ControlTypeEnum.BezierSymmetrical) controlFirstLocal = -value; + + controlSecondLocal = value; + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControl) : null, sender: this); + } + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + // field deleted callback + public static void PrivateFieldDeleted(BGCurvePointField field, int indexOfField, FieldsValues fieldsValues) + { + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bool: + Ensure(ref fieldsValues.boolValues); + fieldsValues.boolValues = BGCurve.Remove(fieldsValues.boolValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Int: + Ensure(ref fieldsValues.intValues); + fieldsValues.intValues = BGCurve.Remove(fieldsValues.intValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Float: + Ensure(ref fieldsValues.floatValues); + fieldsValues.floatValues = BGCurve.Remove(fieldsValues.floatValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Vector3: + Ensure(ref fieldsValues.vector3Values); + fieldsValues.vector3Values = BGCurve.Remove(fieldsValues.vector3Values, indexOfField); + break; + case BGCurvePointField.TypeEnum.Bounds: + Ensure(ref fieldsValues.boundsValues); + fieldsValues.boundsValues = BGCurve.Remove(fieldsValues.boundsValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Color: + Ensure(ref fieldsValues.colorValues); + fieldsValues.colorValues = BGCurve.Remove(fieldsValues.colorValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.String: + Ensure(ref fieldsValues.stringValues); + fieldsValues.stringValues = BGCurve.Remove(fieldsValues.stringValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Quaternion: + Ensure(ref fieldsValues.quaternionValues); + fieldsValues.quaternionValues = BGCurve.Remove(fieldsValues.quaternionValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.AnimationCurve: + Ensure(ref fieldsValues.animationCurveValues); + fieldsValues.animationCurveValues = BGCurve.Remove(fieldsValues.animationCurveValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.GameObject: + Ensure(ref fieldsValues.gameObjectValues); + fieldsValues.gameObjectValues = BGCurve.Remove(fieldsValues.gameObjectValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.Component: + Ensure(ref fieldsValues.componentValues); + fieldsValues.componentValues = BGCurve.Remove(fieldsValues.componentValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.BGCurve: + Ensure(ref fieldsValues.bgCurveValues); + fieldsValues.bgCurveValues = BGCurve.Remove(fieldsValues.bgCurveValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + Ensure(ref fieldsValues.bgCurvePointComponentValues); + fieldsValues.bgCurvePointComponentValues = BGCurve.Remove(fieldsValues.bgCurvePointComponentValues, indexOfField); + break; + case BGCurvePointField.TypeEnum.BGCurvePointGO: + Ensure(ref fieldsValues.bgCurvePointGOValues); + fieldsValues.bgCurvePointGOValues = BGCurve.Remove(fieldsValues.bgCurvePointGOValues, indexOfField); + break; + default: + throw new ArgumentOutOfRangeException("field.Type", field.Type, "Unsupported type " + field.Type); + } + } + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + // field added callback + public static void PrivateFieldAdded(BGCurvePointField field, FieldsValues fieldsValues) + { + var type = FieldTypes.GetType(field.Type); + var item = BGReflectionAdapter.IsValueType(type) ? Activator.CreateInstance(type) : null; + + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bool: + Ensure(ref fieldsValues.boolValues); + fieldsValues.boolValues = BGCurve.Insert(fieldsValues.boolValues, fieldsValues.boolValues.Length, (bool) item); + break; + case BGCurvePointField.TypeEnum.Int: + Ensure(ref fieldsValues.intValues); + fieldsValues.intValues = BGCurve.Insert(fieldsValues.intValues, fieldsValues.intValues.Length, (int) item); + break; + case BGCurvePointField.TypeEnum.Float: + Ensure(ref fieldsValues.floatValues); + fieldsValues.floatValues = BGCurve.Insert(fieldsValues.floatValues, fieldsValues.floatValues.Length, (float) item); + break; + case BGCurvePointField.TypeEnum.Vector3: + Ensure(ref fieldsValues.vector3Values); + fieldsValues.vector3Values = BGCurve.Insert(fieldsValues.vector3Values, fieldsValues.vector3Values.Length, (Vector3) item); + break; + case BGCurvePointField.TypeEnum.Bounds: + Ensure(ref fieldsValues.boundsValues); + fieldsValues.boundsValues = BGCurve.Insert(fieldsValues.boundsValues, fieldsValues.boundsValues.Length, (Bounds) item); + break; + case BGCurvePointField.TypeEnum.Color: + Ensure(ref fieldsValues.colorValues); + fieldsValues.colorValues = BGCurve.Insert(fieldsValues.colorValues, fieldsValues.colorValues.Length, (Color) item); + break; + case BGCurvePointField.TypeEnum.String: + Ensure(ref fieldsValues.stringValues); + fieldsValues.stringValues = BGCurve.Insert(fieldsValues.stringValues, fieldsValues.stringValues.Length, (string) item); + break; + case BGCurvePointField.TypeEnum.Quaternion: + Ensure(ref fieldsValues.quaternionValues); + fieldsValues.quaternionValues = BGCurve.Insert(fieldsValues.quaternionValues, fieldsValues.quaternionValues.Length, (Quaternion) item); + break; + case BGCurvePointField.TypeEnum.AnimationCurve: + Ensure(ref fieldsValues.animationCurveValues); + fieldsValues.animationCurveValues = BGCurve.Insert(fieldsValues.animationCurveValues, fieldsValues.animationCurveValues.Length, (AnimationCurve) item); + break; + case BGCurvePointField.TypeEnum.GameObject: + Ensure(ref fieldsValues.gameObjectValues); + fieldsValues.gameObjectValues = BGCurve.Insert(fieldsValues.gameObjectValues, fieldsValues.gameObjectValues.Length, (GameObject) item); + break; + case BGCurvePointField.TypeEnum.Component: + Ensure(ref fieldsValues.componentValues); + fieldsValues.componentValues = BGCurve.Insert(fieldsValues.componentValues, fieldsValues.componentValues.Length, (Component) item); + break; + case BGCurvePointField.TypeEnum.BGCurve: + Ensure(ref fieldsValues.bgCurveValues); + fieldsValues.bgCurveValues = BGCurve.Insert(fieldsValues.bgCurveValues, fieldsValues.bgCurveValues.Length, (BGCurve) item); + break; + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + Ensure(ref fieldsValues.bgCurvePointComponentValues); + fieldsValues.bgCurvePointComponentValues = BGCurve.Insert(fieldsValues.bgCurvePointComponentValues, fieldsValues.bgCurvePointComponentValues.Length, (BGCurvePointComponent) item); + break; + case BGCurvePointField.TypeEnum.BGCurvePointGO: + Ensure(ref fieldsValues.bgCurvePointGOValues); + fieldsValues.bgCurvePointGOValues = BGCurve.Insert(fieldsValues.bgCurvePointGOValues, fieldsValues.bgCurvePointGOValues.Length, (BGCurvePointGO) item); + break; + default: + throw new ArgumentOutOfRangeException("field.Type", field.Type, "Unsupported type " + field.Type); + } + } + + //ensure list is not null + private static void Ensure(ref T[] array) + { + if (array == null) array = new T[0]; + } + + #endregion + + #region helper classes + + //================================================================================ + // Values for the fields + //================================================================================ + /// All values for custom fields + //the reason we store it like this- is to reduce memory and serialization cost + [Serializable] + public sealed class FieldsValues + { + // c# + [SerializeField] public bool[] boolValues; + [SerializeField] public int[] intValues; + [SerializeField] public float[] floatValues; + [SerializeField] public string[] stringValues; + + // Unity structs + [SerializeField] public Vector3[] vector3Values; + [SerializeField] public Bounds[] boundsValues; + [SerializeField] public Color[] colorValues; + [SerializeField] public Quaternion[] quaternionValues; + + // Unity objects + [SerializeField] public AnimationCurve[] animationCurveValues; + [SerializeField] public GameObject[] gameObjectValues; + [SerializeField] public Component[] componentValues; + + // BGCurve + [SerializeField] public BGCurve[] bgCurveValues; + [SerializeField] public BGCurvePointComponent[] bgCurvePointComponentValues; + [SerializeField] public BGCurvePointGO[] bgCurvePointGOValues; + } + + //================================================================================ + // Types for the fields + //================================================================================ + /// Types for custom fields + public static class FieldTypes + { + private static readonly Dictionary> type2fieldGetter = new Dictionary>(); + private static readonly Dictionary> type2fieldSetter = new Dictionary>(); + private static readonly Dictionary type2Type = new Dictionary(); + + static FieldTypes() + { + // All these getters/setters are used only for classes now. For structs and primitives there is overriden getXXX setXXX methods (to get rid of boxing/unboxing). + //primitives + Register(BGCurvePointField.TypeEnum.Bool, typeof(bool), (value, index) => value.boolValues[index], (value, index, o) => value.boolValues[index] = Convert.ToBoolean((object) o)); + Register(BGCurvePointField.TypeEnum.Int, typeof(int), (value, index) => value.intValues[index], (value, index, o) => value.intValues[index] = Convert.ToInt32((object) o)); + Register(BGCurvePointField.TypeEnum.Float, typeof(float), (value, index) => value.floatValues[index], (value, index, o) => value.floatValues[index] = Convert.ToSingle((object) o)); + + //string + Register(BGCurvePointField.TypeEnum.String, typeof(string), (value, index) => value.stringValues[index], (value, index, o) => value.stringValues[index] = (string) o); + + //unity structs and classes + Register(BGCurvePointField.TypeEnum.Vector3, typeof(Vector3), (value, index) => value.vector3Values[index], (value, index, o) => value.vector3Values[index] = (Vector3) o); + Register(BGCurvePointField.TypeEnum.Bounds, typeof(Bounds), (value, index) => + { + var r = value.boundsValues[index]; + return r; + }, (value, index, o) => value.boundsValues[index] = (Bounds) o); + Register(BGCurvePointField.TypeEnum.Quaternion, typeof(Quaternion), (value, index) => value.quaternionValues[index], + (value, index, o) => value.quaternionValues[index] = (Quaternion) o); + Register(BGCurvePointField.TypeEnum.Color, typeof(Color), (value, index) => value.colorValues[index], (value, index, o) => value.colorValues[index] = (Color) o); + Register(BGCurvePointField.TypeEnum.AnimationCurve, typeof(AnimationCurve), (value, index) => value.animationCurveValues[index], + (value, index, o) => value.animationCurveValues[index] = (AnimationCurve) o); + + //unity GO and components + Register(BGCurvePointField.TypeEnum.GameObject, typeof(GameObject), (value, index) => value.gameObjectValues[index], + (value, index, o) => value.gameObjectValues[index] = (GameObject) o); + Register(BGCurvePointField.TypeEnum.Component, typeof(Component), (value, index) => value.componentValues[index], + (value, index, o) => value.componentValues[index] = (Component) o); + + //bg curve related + Register(BGCurvePointField.TypeEnum.BGCurve, typeof(BGCurve), (value, index) => value.bgCurveValues[index], (value, index, o) => value.bgCurveValues[index] = (BGCurve) o); + Register(BGCurvePointField.TypeEnum.BGCurvePointComponent, typeof(BGCurvePointComponent), (value, index) => value.bgCurvePointComponentValues[index], + (value, index, o) => value.bgCurvePointComponentValues[index] = (BGCurvePointComponent) o); + Register(BGCurvePointField.TypeEnum.BGCurvePointGO, typeof(BGCurvePointGO), (value, index) => value.bgCurvePointGOValues[index], + (value, index, o) => value.bgCurvePointGOValues[index] = (BGCurvePointGO) o); + } + + // register data about one type + private static void Register(BGCurvePointField.TypeEnum typeEnum, Type type, Func getter, Action setter) + { + type2Type[typeEnum] = type; + type2fieldGetter[type] = getter; + type2fieldSetter[type] = setter; + } + + /// Get c# type(class), used for value of custom field with type "type" + public static Type GetType(BGCurvePointField.TypeEnum type) + { + return type2Type[type]; + } + + /// retrieve value for particular field with name "name" and type "type" + public static object GetField(BGCurve curve, Type type, string name, FieldsValues values) + { + Func getter; + if (!type2fieldGetter.TryGetValue(type, out getter)) throw new UnityException("Unsupported type for a field, type= " + type); + + return getter(values, IndexOfFieldRelative(curve, name)); + } + + /// set value for particular field with name "name" and type "type" + public static void SetField(BGCurve curve, Type type, string name, object value, FieldsValues values) + { + Action setter; + if (!type2fieldSetter.TryGetValue(type, out setter)) throw new UnityException("Unsupported type for a field, type= " + type); + + setter(values, IndexOfFieldRelative(curve, name), value); + } + + //get the index of field's value within array of values + private static int IndexOfFieldRelative(BGCurve curve, string name) + { + var result = curve.IndexOfFieldValue(name); + + if (result < 0) throw new UnityException("Can not find a field with name " + name); + + return result; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs.meta new file mode 100644 index 0000000..3df06c5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 21ab56f25c33efa44a87617a91ebd7eb +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs new file mode 100644 index 0000000..f9b0031 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs @@ -0,0 +1,191 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// Point, attached to a separate Component (MonoBehaviour) + // this class uses composition pattern + public class BGCurvePointComponent : MonoBehaviour, BGCurvePointI + { + [SerializeField] private BGCurvePoint point; + + public BGCurve Curve + { + get { return point.Curve; } + } + + public Vector3 PositionLocal + { + get { return point.PositionLocal; } + set { point.PositionLocal = value; } + } + + public Vector3 PositionLocalTransformed + { + get { return point.PositionLocalTransformed; } + set { point.PositionLocalTransformed = value; } + } + + public Vector3 PositionWorld + { + get { return point.PositionWorld; } + set { point.PositionWorld = value; } + } + + public Vector3 ControlFirstLocal + { + get { return point.ControlFirstLocal; } + set { point.ControlFirstLocal = value; } + } + + public Vector3 ControlFirstLocalTransformed + { + get { return point.ControlFirstLocalTransformed; } + set { point.ControlFirstLocalTransformed = value; } + } + + public Vector3 ControlFirstWorld + { + get { return point.ControlFirstWorld; } + set { point.ControlFirstWorld = value; } + } + + public Vector3 ControlSecondLocal + { + get { return point.ControlSecondLocal; } + set { point.ControlSecondLocal = value; } + } + + public Vector3 ControlSecondLocalTransformed + { + get { return point.ControlSecondLocalTransformed; } + set { point.ControlSecondLocalTransformed = value; } + } + + public Vector3 ControlSecondWorld + { + get { return point.ControlSecondWorld; } + set { point.ControlSecondWorld = value; } + } + + public BGCurvePoint.ControlTypeEnum ControlType + { + get { return point.ControlType; } + set { point.ControlType = value; } + } + + public Transform PointTransform + { + get { return point.PointTransform; } + set { point.PointTransform = value; } + } + + public float GetFloat(string name) + { + return point.GetFloat(name); + } + + public bool GetBool(string name) + { + return point.GetBool(name); + } + + public int GetInt(string name) + { + return point.GetInt(name); + } + + public Vector3 GetVector3(string name) + { + return point.GetVector3(name); + } + + public Quaternion GetQuaternion(string name) + { + return point.GetQuaternion(name); + } + + public Bounds GetBounds(string name) + { + return point.GetBounds(name); + } + + public Color GetColor(string name) + { + return point.GetColor(name); + } + + public T GetField(string name) + { + return point.GetField(name); + } + + public object GetField(string name, Type type) + { + return point.GetField(name, type); + } + + public void SetField(string name, object value, Type type) + { + point.SetField(name, value, type); + } + + public void SetField(string name, T value) + { + point.SetField(name, value); + } + + public void SetFloat(string name, float value) + { + point.SetFloat(name, value); + } + + public void SetBool(string name, bool value) + { + point.SetBool(name, value); + } + + public void SetInt(string name, int value) + { + point.SetInt(name, value); + } + + public void SetVector3(string name, Vector3 value) + { + point.SetVector3(name, value); + } + + public void SetQuaternion(string name, Quaternion value) + { + point.SetQuaternion(name, value); + } + + public void SetBounds(string name, Bounds value) + { + point.SetBounds(name, value); + } + + public void SetColor(string name, Color value) + { + point.SetColor(name, value); + } + + public BGCurvePoint Point + { + get { return point; } + } + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + // this should be called once at creating time + public void PrivateInit(BGCurvePoint point) + { + this.point = point; + hideFlags = HideFlags.HideInInspector; + } + + public override string ToString() + { + return point == null ? "no data" : (point +" as Component"); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs.meta new file mode 100644 index 0000000..c8664ec --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8cdc035869a65674f92b3b83794effb9 +timeCreated: 1475051178 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs new file mode 100644 index 0000000..1ae12b6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs @@ -0,0 +1,152 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// Meta data (name, type and settings) for custom point's field + [Serializable] + public class BGCurvePointField : MonoBehaviour + { + // all possible types for the field's value. + // Note, even if your desired type is not supported, + // you still can use it via Unity's standard Component type (assign any MonoBehaviour derived script to it) or via GameObject + public enum TypeEnum + { + //C# + Bool = 0, + Int = 1, + Float = 2, + String = 3, + + //Unity structs + Vector3 = 100, + Bounds = 101, + Color = 102, + Quaternion = 103, + + //Unity classes + AnimationCurve = 200, + GameObject = 201, + Component = 202, + + //BG related + BGCurve = 300, + BGCurvePointComponent = 301, + BGCurvePointGO= 302 + } + + //BGCurve + [SerializeField] private BGCurve curve; + //field's name. It should be unique, not null, English chars only, 16 chars max + [SerializeField] private string fieldName; + //field's type + [SerializeField] private TypeEnum type; + +#if UNITY_EDITOR + // ============================================== !!! This is editor ONLY fields +#pragma warning disable 0414 + + [SerializeField] private bool showHandles = true; + [SerializeField] private int handlesType; + [SerializeField] private Color handlesColor = Color.white; + [SerializeField] private bool showInPointsMenu = true; +#pragma warning restore 0414 +#endif + /// Field's name. It should be unique, not null, English chars only, 16 chars max + public string FieldName + { + get { return fieldName; } + set + { + if (string.Equals(FieldName, value)) return; + CheckName(curve, value, true); + + curve.FireBeforeChange(BGCurve.EventFieldName); + + fieldName = value; + curve.PrivateUpdateFieldsValuesIndexes(); + + curve.FireChange(BGCurveChangedArgs.GetInstance(curve, BGCurveChangedArgs.ChangeTypeEnum.Fields, BGCurve.EventFieldName), sender: this); + } + } + + /// Field's type + public TypeEnum Type + { + //type can not be changed + get { return type; } + } + + /// Owning curve + public BGCurve Curve + { + get { return curve; } + } + + + /// Init the field. It should be called once at creation + public void Init(BGCurve curve, string fieldName, TypeEnum type) + { + if (!string.IsNullOrEmpty(this.fieldName)) throw new UnityException("You can not init twice."); + + CheckName(curve, fieldName, true); + this.curve = curve; + this.fieldName = fieldName; + this.type = type; + } + + /// Check if name is ok. It should be unique, not null, English chars only, 16 chars max + public static string CheckName(BGCurve curve, string name, bool throwException = false) + { + string error = null; + if (string.IsNullOrEmpty(name)) error = "Field's name can not be null"; + else if (name.Length > 16) error = "Name should be 16 chars max. Current name has " + name.Length + " chars."; + else + { + var firstChar = name[0]; + if (!((firstChar >= 'A' && firstChar <= 'Z') || (firstChar >= 'a' && firstChar <= 'z'))) error = "Name should start with a English letter."; + else + { + for (var i = 1; i < name.Length; i++) + { + var @char = name[i]; + if ((@char >= 'A' && @char <= 'Z') || (@char >= 'a' && @char <= 'z') || (@char >= '0' && @char <= '9')) continue; + + error = "Name should contain English letters or numbers only."; + break; + } + if (error==null && curve.HasField(name)) error = "Field with name '" + name + "' already exists."; + } + } + + if (throwException && error != null) throw new UnityException(error); + + return error; + } + + //---------------------------------- Object overrides + + protected bool Equals(BGCurvePointField other) + { + return Equals(curve, other.curve) && string.Equals(fieldName, other.fieldName); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((BGCurvePointField) obj); + } + + public override int GetHashCode() + { + return (curve != null ? curve.GetHashCode() : 0) ^ (fieldName != null ? fieldName.GetHashCode() : 0); + } + + public override string ToString() + { + return fieldName; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs.meta new file mode 100644 index 0000000..e147864 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointField.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 06627f7d7396a40418f87b2a58e6ddbe +timeCreated: 1474917757 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs new file mode 100644 index 0000000..a4c399a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs @@ -0,0 +1,649 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// Point, attached to separate GameObject + [DisallowMultipleComponent] + // Note, some code was copy pasted from BGCurvePoint class + public class BGCurvePointGO : MonoBehaviour, BGCurvePointI + { + #region fields + + //control type + [SerializeField] private BGCurvePoint.ControlTypeEnum controlType; + + //relative to curve position + [SerializeField] private Vector3 positionLocal; + + //relative to point position + [SerializeField] private Vector3 controlFirstLocal; + [SerializeField] private Vector3 controlSecondLocal; + + //transform for using as point position + [SerializeField] private Transform pointTransform; + + + //point's curve + [SerializeField] private BGCurve curve; + + //custom fields values for all points. it's an array with only one element. the reason why we store it like this- is to reduce storage and serialization costs. + [SerializeField] private BGCurvePoint.FieldsValues[] fieldsValues; + + /// The curve, point's belong to + public BGCurve Curve + { + get { return curve; } + } + + /// This field is not meant for use outside of BGCurve package + //all fields values + public BGCurvePoint.FieldsValues PrivateValuesForFields + { + get + { + if (fieldsValues == null || fieldsValues.Length < 1 || fieldsValues[0] == null) fieldsValues = new[] {new BGCurvePoint.FieldsValues()}; + return fieldsValues[0]; + } + set + { + if (fieldsValues == null || fieldsValues.Length < 1 || fieldsValues[0] == null) fieldsValues = new[] {new BGCurvePoint.FieldsValues()}; + fieldsValues[0] = value; + } + } + + + // =============================================== Position + + //see interface for comments + public Vector3 PositionLocal + { + get + { + if (pointTransform != null) return curve.transform.InverseTransformPoint(pointTransform.position); + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return positionLocal; + case BGCurve.PointsModeEnum.GameObjectsTransform: + return curve.transform.InverseTransformPoint(transform.position); + default: + throw WrongMode(); + } + } + set { SetPosition(value); } + } + + //see interface for comments + public Vector3 PositionLocalTransformed + { + get + { + if(pointTransform != null) return pointTransform.position - curve.transform.position; + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return curve.transform.TransformPoint(positionLocal) - curve.transform.position; + case BGCurve.PointsModeEnum.GameObjectsTransform: + return transform.position - curve.transform.position; + default: + throw WrongMode(); + } + } + set { SetPosition(value + curve.transform.position, true); } + } + + //see interface for comments + public Vector3 PositionWorld + { + get + { + if (pointTransform != null) return pointTransform.position; + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return curve.transform.TransformPoint(positionLocal); + case BGCurve.PointsModeEnum.GameObjectsTransform: + return transform.position; + default: + throw WrongMode(); + } + } + set { SetPosition(value, true); } + } + + + // =============================================== First Handle + //see interface for comments + public Vector3 ControlFirstLocal + { + get { return controlFirstLocal; } + set { SetControlFirstLocal(value); } + } + + //see interface for comments + public Vector3 ControlFirstLocalTransformed + { + get { return TargetTransform.TransformVector(controlFirstLocal); } + set { SetControlFirstLocal(TargetTransform.InverseTransformVector(value)); } + } + + + //see interface for comments + public Vector3 ControlFirstWorld + { + get + { + if (pointTransform != null) return pointTransform.position + pointTransform.TransformVector(controlFirstLocal); + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return curve.transform.TransformPoint(new Vector3(positionLocal.x + controlFirstLocal.x, positionLocal.y + controlFirstLocal.y, positionLocal.z + controlFirstLocal.z)); + case BGCurve.PointsModeEnum.GameObjectsTransform: + return transform.position + transform.TransformVector(controlFirstLocal); + default: + throw WrongMode(); + } + } + set + { + Vector3 localPos; + if (pointTransform != null) localPos = pointTransform.InverseTransformVector(value - pointTransform.position); + else + { + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + localPos = curve.transform.InverseTransformPoint(value) - PositionLocal; + break; + case BGCurve.PointsModeEnum.GameObjectsTransform: + localPos = transform.InverseTransformVector(value - transform.position); + break; + default: + throw WrongMode(); + } + } + SetControlFirstLocal(localPos); + } + } + + + // =============================================== Second Handle + //see interface for comments + public Vector3 ControlSecondLocal + { + get { return controlSecondLocal; } + set { SetControlSecondLocal(value); } + } + + //see interface for comments + public Vector3 ControlSecondLocalTransformed + { + get { return TargetTransform.TransformVector(controlSecondLocal); } + set { SetControlSecondLocal(TargetTransform.InverseTransformVector(value)); } + } + + + //see interface for comments + public Vector3 ControlSecondWorld + { + get + { + if (pointTransform != null) return pointTransform.position + pointTransform.TransformVector(controlSecondLocal); + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return curve.transform.TransformPoint(new Vector3(positionLocal.x + controlSecondLocal.x, positionLocal.y + controlSecondLocal.y, positionLocal.z + controlSecondLocal.z)); + case BGCurve.PointsModeEnum.GameObjectsTransform: + return transform.position + transform.TransformVector(controlSecondLocal); + default: + throw WrongMode(); + } + } + set + { + Vector3 localPos; + if (pointTransform != null) localPos = pointTransform.InverseTransformVector(value - pointTransform.position); + else + { + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + localPos = curve.transform.InverseTransformPoint(value) - PositionLocal; + break; + case BGCurve.PointsModeEnum.GameObjectsTransform: + localPos = transform.InverseTransformVector(value - transform.position); + break; + default: + throw WrongMode(); + } + } + SetControlSecondLocal(localPos); + } + } + + // =============================================== Control type + //see interface for comments + public BGCurvePoint.ControlTypeEnum ControlType + { + get { return controlType; } + set + { + if (controlType == value) return; + + curve.FireBeforeChange(BGCurve.EventPointControlType); + + controlType = value; + + if (controlType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical) controlSecondLocal = -controlFirstLocal; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControlType) : null, sender: this); + } + } + + // =============================================== Transform + public Transform PointTransform + { + get { return pointTransform; } + set + { + if (pointTransform == value) return; + + curve.FireBeforeChange(BGCurve.EventPointTransform); + + var oldTransformNull = pointTransform == null && value != null; + var newTransformNull = value == null && pointTransform != null; + + //we need to transfer system fields + var control1 = ControlFirstLocalTransformed; + var control2 = ControlSecondLocalTransformed; + var positionWorld = PositionWorld; + + pointTransform = value; + + // transfer system fields + if (pointTransform != null) + { + pointTransform.position = positionWorld; + controlFirstLocal = pointTransform.InverseTransformVector(control1); + controlSecondLocal = pointTransform.InverseTransformVector(control2); + } + else + { + switch (curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + positionLocal = curve.transform.InverseTransformPoint(positionWorld); + controlFirstLocal = curve.transform.InverseTransformVector(control1); + controlSecondLocal = curve.transform.InverseTransformVector(control2); + break; + case BGCurve.PointsModeEnum.GameObjectsTransform: + transform.position = positionWorld; + controlFirstLocal = transform.InverseTransformVector(control1); + controlSecondLocal = transform.InverseTransformVector(control2); + break; + default: + throw new ArgumentOutOfRangeException("curve.PointsMode"); + } + } + + + // inform curve + if (oldTransformNull) curve.PrivateTransformForPointAdded(curve.IndexOf(this)); + else if (newTransformNull) curve.PrivateTransformForPointRemoved(curve.IndexOf(this)); + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointTransform) : null, sender: this); + } + } + + + //target transform (used to calculate control positions) + private Transform TargetTransform + { + get + { + if (pointTransform != null) return pointTransform; + + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + return curve.transform; + case BGCurve.PointsModeEnum.GameObjectsTransform: + return transform; + default: + throw WrongMode(); + } + } + } + + #endregion + + #region custom fields + + //=============================================================================================== + // Custom Fields (see interface for comments) + //=============================================================================================== + //----------------------------------- Getters + public T GetField(string name) + { + var type = typeof(T); + var value = GetField(name, type); + var field = (T) value; + return field; + } + + public float GetFloat(string name) + { + return PrivateValuesForFields.floatValues[curve.IndexOfFieldValue(name)]; + } + + public bool GetBool(string name) + { + return PrivateValuesForFields.boolValues[curve.IndexOfFieldValue(name)]; + } + + public int GetInt(string name) + { + return PrivateValuesForFields.intValues[curve.IndexOfFieldValue(name)]; + } + + public Vector3 GetVector3(string name) + { + return PrivateValuesForFields.vector3Values[curve.IndexOfFieldValue(name)]; + } + + public Quaternion GetQuaternion(string name) + { + return PrivateValuesForFields.quaternionValues[curve.IndexOfFieldValue(name)]; + } + + public Bounds GetBounds(string name) + { + return PrivateValuesForFields.boundsValues[curve.IndexOfFieldValue(name)]; + } + + public Color GetColor(string name) + { + return PrivateValuesForFields.colorValues[curve.IndexOfFieldValue(name)]; + } + + public object GetField(string name, Type type) + { + return BGCurvePoint.FieldTypes.GetField(curve, type, name, PrivateValuesForFields); + } + + //----------------------------------- Setters + public void SetField(string name, T value) + { + SetField(name, value, typeof(T)); + } + + public void SetField(string name, object value, Type type) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + BGCurvePoint.FieldTypes.SetField(curve, type, name, value, PrivateValuesForFields); + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetFloat(string name, float value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.floatValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetBool(string name, bool value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.boolValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetInt(string name, int value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.intValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetVector3(string name, Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.vector3Values[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetQuaternion(string name, Quaternion value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.quaternionValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetBounds(string name, Bounds value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.boundsValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + public void SetColor(string name, Color value) + { + curve.FireBeforeChange(BGCurve.EventPointField); + + PrivateValuesForFields.colorValues[curve.IndexOfFieldValue(name)] = value; + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointField) : null, sender: this); + } + + #endregion + + #region Misc public methods + + //================================================================================ + // Misc public functions + //================================================================================ + + public override string ToString() + { + return "Point [localPosition=" + positionLocal + "]"; + } + + #endregion + + #region private methods + + //set position + private void SetPosition(Vector3 value, bool worldSpaceIsUsed = false) + { + curve.FireBeforeChange(BGCurve.EventPointPosition); + + //snapping + if (curve.SnapType != BGCurve.SnapTypeEnum.Off) + { + if (worldSpaceIsUsed) curve.ApplySnapping(ref value); + else + { + //we need to transfer space before applying snapping + var pos = curve.transform.TransformPoint(value); + if (curve.ApplySnapping(ref pos)) value = curve.transform.InverseTransformPoint(pos); + } + } + + + //assign position + if (pointTransform != null) + { + //2d mode with curve's transform changed is not working correctly + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + pointTransform.position = worldSpaceIsUsed ? value : curve.transform.TransformPoint(value); + } + else + { + switch (Curve.PointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + if (worldSpaceIsUsed) + { + var localPos = curve.transform.InverseTransformPoint(value); + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) localPos = curve.Apply2D(localPos); + positionLocal = localPos; + } + else + { + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + positionLocal = value; + } + break; + case BGCurve.PointsModeEnum.GameObjectsTransform: + if (worldSpaceIsUsed) + { + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.transform.TransformPoint(curve.Apply2D(curve.transform.InverseTransformPoint(value))); + transform.position = value; + } + else + { + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + transform.position = curve.transform.TransformPoint(value); + } + break; + default: + throw WrongMode(); + } + } + + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointPosition) : null, sender: this); + } + + + //set local control 1 + private void SetControlFirstLocal(Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointControl); + + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + + if (controlType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical) controlSecondLocal = -value; + + controlFirstLocal = value; + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControl) : null, sender: this); + } + + //set local control 2 (it's basically copy/paste from SetControlFirstLocal, but we can not use delegates here because of performance) + private void SetControlSecondLocal(Vector3 value) + { + curve.FireBeforeChange(BGCurve.EventPointControl); + + if (curve.Mode2D != BGCurve.Mode2DEnum.Off) value = curve.Apply2D(value); + + if (controlType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical) controlFirstLocal = -value; + + controlSecondLocal = value; + curve.FireChange(curve.UseEventsArgs ? BGCurveChangedArgs.GetInstance(Curve, this, BGCurve.EventPointControl) : null, sender: this); + } + + #endregion + + #region Not copy pasted + + //================================================================================= + // This is not copy/pasted part + //================================================================================= + + /// all methods, prefixed with Private, are not meant to be called from outside of BGCurve package + //Init with data. No events are fired. point==null for pointsMode switching. + public void PrivateInit(BGCurvePoint point, BGCurve.PointsModeEnum pointsMode) + { + if (point != null) + { + // init from new point + curve = point.Curve; + controlType = point.ControlType; + pointTransform = point.PointTransform; + + switch (pointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + positionLocal = point.PositionLocal; + controlFirstLocal = point.ControlFirstLocal; + controlSecondLocal = point.ControlSecondLocal; + break; + case BGCurve.PointsModeEnum.GameObjectsTransform: + transform.localPosition = point.PositionLocal; + + //transformed locals are always the same + var targetTransform = pointTransform != null ? pointTransform : transform; + controlFirstLocal = targetTransform.InverseTransformVector(point.ControlFirstLocalTransformed); + controlSecondLocal = targetTransform.InverseTransformVector(point.ControlSecondLocalTransformed); + break; + default: + throw new ArgumentOutOfRangeException("pointsMode", pointsMode, null); + } + } + else + { + // change pointsMode + Transform targetTransform; + switch (pointsMode) + { + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + { + if (Curve.PointsMode != BGCurve.PointsModeEnum.GameObjectsTransform) + throw new ArgumentOutOfRangeException("Curve.PointsMode", "Curve points mode should be equal to GameObjectsTransform"); + + positionLocal = transform.localPosition; + + //transformed locals are always the same + targetTransform = pointTransform != null ? pointTransform : curve.transform; + break; + } + case BGCurve.PointsModeEnum.GameObjectsTransform: + { + if (Curve.PointsMode != BGCurve.PointsModeEnum.GameObjectsNoTransform) + throw new ArgumentOutOfRangeException("Curve.PointsMode", "Curve points mode should be equal to GameObjectsNoTransform"); + + transform.position = PositionWorld; + + //transformed locals are always the same + targetTransform = pointTransform != null ? pointTransform : transform; + break; + } + default: + throw new ArgumentOutOfRangeException("pointsMode", pointsMode, null); + } + + controlFirstLocal = targetTransform.InverseTransformVector(ControlFirstLocalTransformed); + controlSecondLocal = targetTransform.InverseTransformVector(ControlSecondLocalTransformed); + + } + } + + + //creates wrong pointMode exception + private static ArgumentOutOfRangeException WrongMode() + { + return new ArgumentOutOfRangeException("Curve.PointsMode"); + } + + #endregion + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs.meta new file mode 100644 index 0000000..453bdf1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointGO.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 225ae2218b76c4f4980b49b463e9ab12 +timeCreated: 1476535139 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs new file mode 100644 index 0000000..98c4db0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs @@ -0,0 +1,103 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// This is interface for one single curve's point + public interface BGCurvePointI + { + /// The Curve, this point is attached to + BGCurve Curve { get; } + + //==================================================================== + // system fields + //==================================================================== + /// Local position. It's relative to curve's origin. All transformations are ignored + Vector3 PositionLocal { get; set; } + /// Local position. It's relative to curve's origin. All transformations are applied + Vector3 PositionLocalTransformed { get; set; } + /// World position. + Vector3 PositionWorld { get; set; } + + /// Local position for first control (inbound). It's relative to point's position, all transformations are ignored + Vector3 ControlFirstLocal { get; set; } + /// Local position for first control (inbound). It's relative to point's position with all transformations applied + Vector3 ControlFirstLocalTransformed { get; set; } + /// World position for first control (inbound) + Vector3 ControlFirstWorld { get; set; } + + /// Local position for second control (outbound). It's relative to point's position, all transformations are ignored + Vector3 ControlSecondLocal { get; set; } + /// Local position for second control (outbound). It's relative to point's position with all transformations applied + Vector3 ControlSecondLocalTransformed { get; set; } + /// World position for second control (outbound) + Vector3 ControlSecondWorld { get; set; } + + /// Point's controls type. + BGCurvePoint.ControlTypeEnum ControlType { get; set; } + + /// Use this transform as point's position. + Transform PointTransform { get; set; } + + //==================================================================== + // custom fields + //==================================================================== + + // we need overriden getters/setters for structs/primitives to avoid boxing/unboxing + + //------------------------------- Getters + /// Get custom field value. + T GetField(string name); + /// Get custom field value. + object GetField(string name, Type type); + + /// Get float custom field value. + float GetFloat(string name); + + /// Get bool custom field value. + bool GetBool(string name); + + /// Get int custom field value. + int GetInt(string name); + + /// Get Vector3 custom field value. + Vector3 GetVector3(string name); + + /// Get Quaternion custom field value. + Quaternion GetQuaternion(string name); + + /// Get Bounds custom field value. + Bounds GetBounds(string name); + + /// Get Color custom field value. + Color GetColor(string name); + + + //------------------------------- Setters + /// Set custom field value. + void SetField(string name, T value); + /// Set custom field value. + void SetField(string name, object value, Type type); + + /// Set float custom field value. + void SetFloat(string name, float value); + + /// Set bool custom field value. + void SetBool(string name, bool value); + + /// Set int custom field value. + void SetInt(string name, int value); + + /// Set Vector3 custom field value. + void SetVector3(string name, Vector3 value); + + /// Set Quaternion custom field value. + void SetQuaternion(string name, Quaternion value); + + /// Set Bounds custom field value. + void SetBounds(string name, Bounds value); + + /// Set Color custom field value. + void SetColor(string name, Color value); + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs.meta new file mode 100644 index 0000000..1facdb0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurvePointI.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 38ff6611c69f3da4d8e7aa49ed3bbe53 +timeCreated: 1475050532 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs new file mode 100644 index 0000000..8ff3e0d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs @@ -0,0 +1,60 @@ +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ + /// This is an indicator class, showing that GameObject is used as transform for Curve's point. It is used by Editor only + public class BGCurveReferenceToPoint : MonoBehaviour + { + [SerializeField] private BGCurvePointComponent pointComponent; + [SerializeField] private BGCurvePointGO pointGo; + + /// referenced point + public BGCurvePointI Point + { + get { return pointGo != null ? (BGCurvePointI) pointGo : pointComponent; } + set + { + if (value == null) + { + pointGo = null; + pointComponent = null; + } + else + { + if (value is BGCurvePointGO) + { + pointGo = (BGCurvePointGO) value; + pointComponent = null; + } + else if (value is BGCurvePointComponent) + { + pointComponent = (BGCurvePointComponent) value; + pointGo = null; + } + else + { + pointGo = null; + pointComponent = null; + } + } + } + } + + /// find referenced point, attached to target gameobject + public static BGCurveReferenceToPoint GetReferenceToPoint(BGCurvePointI point) + { + if (point.PointTransform == null) return null; + var referencesToPoints = point.PointTransform.GetComponents(); + if (referencesToPoints.Length == 0) return null; + + + var length = referencesToPoints.Length; + for (var i = 0; i < length; i++) + { + var referencesToPoint = referencesToPoints[i]; + if (referencesToPoint.Point == point) return referencesToPoint; + } + return null; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs.meta new file mode 100644 index 0000000..eeef629 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveReferenceToPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7c9402229daf9f443a9b18c328178235 +timeCreated: 1477988451 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs new file mode 100644 index 0000000..f8a7a13 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs @@ -0,0 +1,366 @@ +using System; +using UnityEngine; + +namespace BansheeGz.BGSpline.Curve +{ +#if UNITY_EDITOR + // ========================== This class is supposed to work in Editor ONLY + + /// Warning!! This class is for Editor ONLY. It contains curve settings + // many tooltips and range attributes are currently not used + [Serializable] + public class BGCurveSettings + { + #region Fields & enums + + public enum HandlesTypeEnum + { + Configurable, + Standard, + FreeMove + } + + public enum ShowCurveModeEnum + { + CurveSelected, + CurveOrParentSelected, + Always + } + + + //=============================================================== Curve itself + [SerializeField] [Tooltip("Hide Game Object's handles")] private bool hideHandles; + + [SerializeField] [Tooltip("Distance from the camera, at which new points are created")] private float newPointDistance = 2; + + [SerializeField] [Tooltip("Show curve in the scene or not. If not, all handles are disabled as well")] private bool showCurve = true; + + [SerializeField] [Tooltip("Show curve mode")] private ShowCurveModeEnum showCurveMode = ShowCurveModeEnum.CurveOrParentSelected; + + [SerializeField] [Range(1, 50)] [Tooltip("Number of sections between two curves points.\r\n It's used for displaying in editor only")] private int sections = 20; + + + [SerializeField] [Tooltip("Show Points Menu buttons in the editor (for Points tab)")] private bool showPointMenu = true; + + //tangents + [SerializeField] [Tooltip("Show points tangents in the scene")] private bool showTangents; + [SerializeField] [Tooltip("Point tangent arrow size in the scene")] [Range(.3f, 2)] private float tangentsSize = .7f; + [SerializeField] [Tooltip("Point tangent color in the scene")] private Color tangentsColor = Color.white; + [SerializeField] [Range(1, 3)] [Tooltip("Number of tangents for every section")] private int tangentsPerSection = 1; + + // control type for new points + [SerializeField] [Tooltip("Control type for new points")] private BGCurvePoint.ControlTypeEnum controlType; + + [SerializeField] [Tooltip("Curve is drawn on top of objects")] private bool vRay; + + [SerializeField] [Tooltip("Curve's color in the scene")] private Color lineColor = Color.red; + + + //=============================================================== Control Type field + + [SerializeField] [Tooltip("Show points control types in the editor (for Points tab)")] private bool showPointControlType = true; + + //=============================================================== Position field + + [SerializeField] [Tooltip("Show points positions in the editor (for Points tab)")] private bool showPointPosition = true; + + [SerializeField] [Tooltip("Show points handles in the scene")] private bool showHandles = true; + + + [SerializeField] [Tooltip("Points handles type" + + "\r\n 1)FreeMove- standard Unity freemove handles" + + "\r\n 2)Standard-standard handles" + + "\r\n 3)Configurable- configurable handles")] private HandlesTypeEnum handlesType = HandlesTypeEnum.Configurable; + + + [SerializeField] private SettingsForHandles handlesSettings = new SettingsForHandles(); + + [SerializeField] [Tooltip("Show points positions labels in the scene ")] private bool showLabels = true; + + [SerializeField] [Tooltip("Point's labels color in the scene")] private Color labelColor = Color.white; + + + [SerializeField] [Tooltip("Show points positions in the scene")] private bool showPositions; + + [SerializeField] [Tooltip("Point's labels color when selected in the scene")] private Color labelColorSelected = Color.green; + + [SerializeField] [Tooltip("Show spheres at points locations in the scene")] private bool showSpheres = true; + + [SerializeField] [Range(.01f, 1)] [Tooltip("Point's sphere radius in the scene")] private float sphereRadius = .1f; + + [SerializeField] [Tooltip("Point's sphere color in the scene")] private Color sphereColor = Color.red; + + + //=============================================================== Controls fields + + [SerializeField] [Tooltip("Show points controls positions in the editor (for Points tab)")] private bool showPointControlPositions = true; + + [SerializeField] [Tooltip("Show points control handles in the scene")] private bool showControlHandles = true; + + [SerializeField] [Tooltip("Points control handles type\r\n 1)FreeMove- standard Unity freemove handles\r\n " + + "2)Standard-standard handles\r\n 3)Configurable- configurable handles")] private HandlesTypeEnum controlHandlesType = HandlesTypeEnum.Configurable; + + [SerializeField] private SettingsForHandles controlHandlesSettings = new SettingsForHandles {AxisScale = .7f, PlanesScale = .7f, Alpha = .7f}; + + [SerializeField] [Tooltip("Points control handles color")] private Color controlHandlesColor = Color.cyan; + + [SerializeField] [Tooltip("Show points control labels in the scene ")] private bool showControlLabels = true; + + [SerializeField] [Tooltip("Show points control positions in the scene")] private bool showControlPositions; + + [SerializeField] [Tooltip("Control point's labels color in the scene")] private Color labelControlColor = Color.yellow; + + //=============================================================== Transform field + + [SerializeField] [Tooltip("Show points transform field in the editor (for Points tab)")] private bool showTransformField; + + //=============================================================== Misc + + [SerializeField] private bool existing; + + #endregion + + #region Props + + public bool HideHandles + { + get { return hideHandles; } + set { hideHandles = value; } + } + + public float NewPointDistance + { + get { return newPointDistance; } + set { newPointDistance = value; } + } + + public bool ShowPointControlType + { + get { return showPointControlType; } + set { showPointControlType = value; } + } + + public bool ShowPointPosition + { + get { return showPointPosition; } + set { showPointPosition = value; } + } + + public bool ShowPointControlPositions + { + get { return showPointControlPositions; } + set { showPointControlPositions = value; } + } + + public bool ShowPointMenu + { + get { return showPointMenu; } + set { showPointMenu = value; } + } + + public bool ShowCurve + { + get { return showCurve; } + set { showCurve = value; } + } + + public ShowCurveModeEnum ShowCurveMode + { + get { return showCurveMode; } + set { showCurveMode = value; } + } + + public bool ShowHandles + { + get { return showHandles; } + set { showHandles = value; } + } + + public bool ShowTangents + { + get { return showTangents; } + set { showTangents = value; } + } + + public float TangentsSize + { + get { return tangentsSize; } + set { tangentsSize = value; } + } + + public Color TangentsColor + { + get { return tangentsColor; } + set { tangentsColor = value; } + } + + public int TangentsPerSection + { + get { return Mathf.Clamp(tangentsPerSection, 1, 3); } + set { tangentsPerSection = Mathf.Clamp(value, 1, 3); } + } + + public HandlesTypeEnum HandlesType + { + get { return handlesType; } + set { handlesType = value; } + } + + public SettingsForHandles HandlesSettings + { + get { return handlesSettings; } + set { handlesSettings = value; } + } + + public int Sections + { + get { return Mathf.Clamp(sections, 1, 50); } + set { sections = Mathf.Clamp(value, 1, 50); } + } + + public bool VRay + { + get { return vRay; } + set { vRay = value; } + } + + public Color LineColor + { + get { return lineColor; } + set { lineColor = value; } + } + + public bool ShowControlHandles + { + get { return showControlHandles; } + set { showControlHandles = value; } + } + + public HandlesTypeEnum ControlHandlesType + { + get { return controlHandlesType; } + set { controlHandlesType = value; } + } + + public SettingsForHandles ControlHandlesSettings + { + get { return controlHandlesSettings; } + set { controlHandlesSettings = value; } + } + + public Color ControlHandlesColor + { + get { return controlHandlesColor; } + set { controlHandlesColor = value; } + } + + public bool ShowLabels + { + get { return showLabels; } + set { showLabels = value; } + } + + public bool ShowPositions + { + get { return showPositions; } + set { showPositions = value; } + } + + public bool ShowControlPositions + { + get { return showControlPositions; } + set { showControlPositions = value; } + } + + public Color LabelColor + { + get { return labelColor; } + set { labelColor = value; } + } + + public Color LabelColorSelected + { + get { return labelColorSelected; } + set { labelColorSelected = value; } + } + + public bool ShowSpheres + { + get { return showSpheres; } + set { showSpheres = value; } + } + + public float SphereRadius + { + get { return sphereRadius; } + set { sphereRadius = value; } + } + + public Color SphereColor + { + get { return sphereColor; } + set { sphereColor = value; } + } + + public BGCurvePoint.ControlTypeEnum ControlType + { + get { return controlType; } + set { controlType = value; } + } + + public bool Existing + { + get { return existing; } + set { existing = value; } + } + + public bool ShowControlLabels + { + get { return showControlLabels; } + set { showControlLabels = value; } + } + + public Color LabelControlColor + { + get { return labelControlColor; } + set { labelControlColor = value; } + } + + public bool ShowTransformField + { + get { return showTransformField; } + set { showTransformField = value; } + } + + #endregion + + #region classes + + [Serializable] + public class SettingsForHandles + { + public bool RemoveX; + public bool RemoveY; + public bool RemoveZ; + + public bool RemoveXZ; + public bool RemoveXY; + public bool RemoveYZ; + + [Range(.5f, 1.5f)] public float AxisScale = 1; + + [Range(.5f, 1.5f)] public float PlanesScale = 1; + + [Range(.5f, 1f)] public float Alpha = 1; + + + public bool Disabled + { + get { return RemoveX && RemoveY && RemoveZ && RemoveXY && RemoveXZ && RemoveYZ; } + } + } + + #endregion + } +#endif +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs.meta new file mode 100644 index 0000000..8652f11 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGCurveSettings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5330eda6cdebde54585ac3d72c6979d4 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs new file mode 100644 index 0000000..03a6157 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs @@ -0,0 +1,71 @@ +using System; + +#if NETFX_CORE +using System.Reflection; +using System.Collections.Generic; +#endif + +namespace BansheeGz.BGSpline.Curve +{ + /// Reflection related stuff + //thanks to qwerty + public static class BGReflectionAdapter + { +#if NETFX_CORE + public static object[] GetCustomAttributes(Type type, Type attributeType, bool inherit) + { + var enumerator = type.GetTypeInfo().GetCustomAttributes(attributeType, inherit); + var result = new List(); + foreach(var item in enumerator) result.Add(item); + return result.ToArray(); + } + + public static bool IsAbstract(Type type) + { + return type.GetTypeInfo().IsAbstract; + } + + public static bool IsClass(Type type) + { + return type.GetTypeInfo().IsClass; + } + + public static bool IsSubclassOf(Type type, Type typeToCheck) + { + return type.GetTypeInfo().IsSubclassOf(typeToCheck); + } + + public static bool IsValueType(Type type) + { + return type.GetTypeInfo().IsValueType; + } +#else + + public static object[] GetCustomAttributes(Type type, Type attributeType, bool inherit) + { + return type.GetCustomAttributes(attributeType, inherit); + } + + public static bool IsAbstract(Type type) + { + return type.IsAbstract; + } + + public static bool IsClass(Type type) + { + return type.IsClass; + } + + public static bool IsSubclassOf(Type type, Type typeToCheck) + { + return type.IsSubclassOf(typeToCheck); + } + + public static bool IsValueType(Type type) + { + return type.IsValueType; + } + +#endif + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs.meta new file mode 100644 index 0000000..5559ad1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Curve/BGReflectionAdapter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f27a57cfa8411464a9eeaf545adb9782 +timeCreated: 1481951176 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor.meta new file mode 100644 index 0000000..a9eebb8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c14afad4dd4b6ca45bb6d96cdc5a10ba +folderAsset: yes +timeCreated: 1458400581 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc.meta new file mode 100644 index 0000000..3e3aa6c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5e85ccb67b51ad4419baa0304f8171c0 +folderAsset: yes +timeCreated: 1472482935 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs new file mode 100644 index 0000000..97870a1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs @@ -0,0 +1,55 @@ +using System; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof (BGCcCursorChangeLinear))] + public class BGCcCursorChangeLinearEditor : BGCcEditor + { + private GUIContent speedFieldContent; + private GUIContent delayFieldContent; + + private BGCcCursorChangeLinear ChangeLinear + { + get { return (BGCcCursorChangeLinear) cc; } + } + + protected override void InternalOnInspectorGUI() + { + BGEditorUtility.Assign(ref speedFieldContent, () => new GUIContent("Speed Field", "Speed field to take a speed from. Each point will have it's own speed. Should be a float field.")); + BGEditorUtility.Assign(ref delayFieldContent, () => new GUIContent("Delay Field", "Delay field to take a delay from. Each point will have it's own delay. Should be a float field.")); + + //speed + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.CustomField(speedFieldContent, cc.Curve, ChangeLinear.SpeedField, BGCurvePointField.TypeEnum.Float, field => ChangeLinear.SpeedField = field); + + if (ChangeLinear.SpeedField == null) EditorGUILayout.PropertyField(serializedObject.FindProperty("speed")); + }); + + //delay + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.CustomField(delayFieldContent, cc.Curve, ChangeLinear.DelayField, BGCurvePointField.TypeEnum.Float, field => ChangeLinear.DelayField = field); + + if (ChangeLinear.DelayField == null) EditorGUILayout.PropertyField(serializedObject.FindProperty("delay")); + }); + + + EditorGUILayout.PropertyField(serializedObject.FindProperty("overflowControl")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("adjustByTotalLength")); + + try + { + //by some reason NullReferenceException exceptions are fired at certain GUI passes + EditorGUILayout.PropertyField(serializedObject.FindProperty("pointReachedEvent")); + } + catch (NullReferenceException) + { + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs.meta new file mode 100644 index 0000000..045e573 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorChangeLinearEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4692c2e962ea94945bf21a4a27e5cb01 +timeCreated: 1472632339 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs new file mode 100644 index 0000000..dbb0cc0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs @@ -0,0 +1,11 @@ +using BansheeGz.BGSpline.Components; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //we need it cause a curve can have multiple cursors and we have to be able to chose between them + [CustomPropertyDrawer(typeof (BGCcCursor), true)] + public class BGCcCursorDrawer : BGCcChoseDrawer + { + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs.meta new file mode 100644 index 0000000..6651100 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 833c28bf8ee4eef4a86a4a1923b07370 +timeCreated: 1473056718 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs new file mode 100644 index 0000000..fe64e9e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using BansheeGz.BGSpline.Components; +using UnityEditor; + +//add points filter + pager for Editor + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof (BGCcCursor))] + public class BGCcCursorEditor : BGCcEditor + { + private BGCcCursor Cursor + { + get { return (BGCcCursor) cc; } + } + + protected override void ShowHandlesSettings() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("handlesScale")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("handlesColor")); + } + + protected override void InternalOnInspectorGUI() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("distance")); + + var distanceRatio = Cursor.DistanceRatio; + var newValue = EditorGUILayout.Slider("Distance Ratio", distanceRatio, 0, 1); + if (BGEditorUtility.AnyChange(distanceRatio, newValue)) Cursor.DistanceRatio = newValue; + } + + protected override void InternalOnSceneGUI() + { + var cursor = Cursor; + + if (cursor == null) return; + + var position = cursor.CalculatePosition(); + + var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get(cursor, "handlesScale")); + BGEditorUtility.SwapHandlesColor(BGPrivateField.Get(cursor, "handlesColor"), () => + { + Handles.ArrowCap(0, position + Vector3.up*handleSize*1.2f, Quaternion.LookRotation(Vector3.down), handleSize); + Handles.SphereCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize*.15f); + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs.meta new file mode 100644 index 0000000..bd278ce --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 956394c991ece5441b4221426379b206 +timeCreated: 1472497101 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs new file mode 100644 index 0000000..8e35a8d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs @@ -0,0 +1,13 @@ +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + + public class BGCcCursorObjectEditor : BGCcEditor + { + protected override void InternalOnInspectorGUI() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("objectToManipulate")); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs.meta new file mode 100644 index 0000000..bb0b5a8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: adad197ec8512394b850b4507ad76e42 +timeCreated: 1472771193 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs new file mode 100644 index 0000000..92c344f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs @@ -0,0 +1,133 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof(BGCcCursorObjectRotate))] + public class BGCcCursorObjectRotateEditor : BGCcCursorObjectEditor + { + private GUIContent rotationFieldContent; + private GUIContent revolutionsFieldContent; + private GUIContent clockwiseFieldContent; + + private BGCcCursorObjectRotate ObjectRotate + { + get { return (BGCcCursorObjectRotate) cc; } + } + + protected override void ShowHandlesSettings() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("handlesScale")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("handlesColor")); + } + + protected override void InternalOnInspectorGUI() + { + base.InternalOnInspectorGUI(); + + // reusable labels + BGEditorUtility.Assign(ref rotationFieldContent, + () => new GUIContent("Rotation Field", "Rotation field to take a rotation from. Each point will have it's own rotation. Should be a Quaternion field.")); + BGEditorUtility.Assign(ref revolutionsFieldContent, + () => new GUIContent("Revolutions Field", "Field to store additional revolutions around tangent. It should be an int field.")); + BGEditorUtility.Assign(ref clockwiseFieldContent, + () => new GUIContent("Revolutions Clockwise Field", "Field to store if the rotation around tangent should be clockwise. It should be a bool field.")); + + + //type of the rotation 1) tangent (without field) 2) by field's values + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.CustomField(rotationFieldContent, cc.Curve, ObjectRotate.RotationField, BGCurvePointField.TypeEnum.Quaternion, field => ObjectRotate.RotationField = field); + + if (ObjectRotate.RotationField != null) + { + //============================== field is used + + BGEditorUtility.VerticalBox(() => + { + // additional revolutions + BGEditorUtility.CustomField(revolutionsFieldContent, cc.Curve, ObjectRotate.RevolutionsAroundTangentField, BGCurvePointField.TypeEnum.Int, + field => ObjectRotate.RevolutionsAroundTangentField = field); + if (ObjectRotate.RevolutionsAroundTangentField == null) EditorGUILayout.PropertyField(serializedObject.FindProperty("revolutionsAroundTangent")); + + // clockwise? + BGEditorUtility.CustomField(clockwiseFieldContent, cc.Curve, ObjectRotate.RevolutionsClockwiseField, + BGCurvePointField.TypeEnum.Bool, field => ObjectRotate.RevolutionsClockwiseField = field); + + if (ObjectRotate.RevolutionsClockwiseField == null) EditorGUILayout.PropertyField(serializedObject.FindProperty("revolutionsClockwise")); + }); + } + else + { + //============================== no field- tangent is used + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("upMode")); + switch (ObjectRotate.UpMode) + { + case BGCcCursorObjectRotate.RotationUpEnum.WorldCustom: + case BGCcCursorObjectRotate.RotationUpEnum.LocalCustom: + case BGCcCursorObjectRotate.RotationUpEnum.TargetParentUpCustom: + EditorGUILayout.PropertyField(serializedObject.FindProperty("upCustom")); + break; + } + }); + } + }); + + + //interpolation + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("rotationInterpolation")); + + switch (ObjectRotate.RotationInterpolation) + { + case BGCcCursorObjectRotate.RotationInterpolationEnum.Lerp: + EditorGUILayout.PropertyField(serializedObject.FindProperty("lerpSpeed")); + break; + case BGCcCursorObjectRotate.RotationInterpolationEnum.Slerp: + EditorGUILayout.PropertyField(serializedObject.FindProperty("slerpSpeed")); + break; + } + }); + + EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetAngle")); + } + + protected override void InternalOnSceneGUI() + { + var curve = ObjectRotate.Curve; + + if (curve == null || curve.PointsCount == 0) return; + + BGCcCursor cursor; + try + { + cursor = ObjectRotate.Cursor; + } + catch (MissingReferenceException) + { + return; + } + + if (cursor == null) return; + + var math = cursor.Math; + + if (math == null || !math.IsCalculated(BGCurveBaseMath.Field.Tangent)) return; + + var position = cursor.CalculatePosition(); + + //by field + var result = Quaternion.identity; + if (!ObjectRotate.TryToCalculateRotation(ref result)) return; + + var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get(ObjectRotate, "handlesScale")); + BGEditorUtility.SwapHandlesColor(BGPrivateField.Get(ObjectRotate, "handlesColor"), () => { Handles.ArrowCap(0, position, result, handleSize); }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs.meta new file mode 100644 index 0000000..59e046b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectRotateEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 266bbca06f7204b49acadb4414d50a4e +timeCreated: 1472502623 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs new file mode 100644 index 0000000..8cfe006 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof(BGCcCursorObjectScale))] + public class BGCcCursorObjectScaleEditor : BGCcCursorObjectEditor + { + private GUIContent scaleFieldContent; + + private BGCcCursorObjectScale ObjectScale + { + get { return (BGCcCursorObjectScale)cc; } + } + + protected override void InternalOnInspectorGUI() + { + base.InternalOnInspectorGUI(); + + BGEditorUtility.Assign(ref scaleFieldContent, () => new GUIContent("Scale Field", "Scale field to take a scale from. Each point will have it's own scale. Should be Vector3 field.")); + + BGEditorUtility.CustomField(scaleFieldContent, cc.Curve, ObjectScale.ScaleField, BGCurvePointField.TypeEnum.Vector3, field => + { + ObjectScale.ScaleField = field; + }); + } + + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs.meta new file mode 100644 index 0000000..efe1d42 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectScaleEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5f25eaece0b3d1a4f8bfc3205c5201b8 +timeCreated: 1476115388 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs new file mode 100644 index 0000000..1a586ff --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs @@ -0,0 +1,10 @@ +using BansheeGz.BGSpline.Components; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof (BGCcCursorObjectTranslate))] + public class BGCcCursorObjectTranslateEditor : BGCcCursorObjectEditor + { + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs.meta new file mode 100644 index 0000000..28c2457 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcCursorObjectTranslateEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2e7270fc1194afd4f9ba2d7e8ea9c78c +timeCreated: 1472495980 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs new file mode 100644 index 0000000..728c70c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs @@ -0,0 +1,117 @@ +using System; +using BansheeGz.BGSpline.Components; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof(BGCcMath))] + public class BGCcMathEditor : BGCcEditor + { + private BGCcMath Math + { + get { return ((BGCcMath) cc); } + } + + + protected override void InternalOnEnable() + { + //ensure math is created and listeners attached + var math = Math.Math; + math.SuppressWarning = math.SuppressWarning; + } + + protected override void InternalOnInspectorGUI() + { + BGEditorUtility.Horizontal(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("fields")); +// if (GUILayout.Button("Update")) Math.Recalculate(); + }); + + + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("mathType")); + + switch (Math.MathType) + { + case BGCcMath.MathTypeEnum.Base: + EditorGUILayout.PropertyField(serializedObject.FindProperty("sectionParts")); + break; + case BGCcMath.MathTypeEnum.Adaptive: + EditorGUILayout.PropertyField(serializedObject.FindProperty("tolerance")); + break; + } + }); + + EditorGUILayout.PropertyField(serializedObject.FindProperty("optimizeStraightLines")); + + if (Math.Fields == BGCurveBaseMath.Fields.PositionAndTangent) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("usePositionToCalculateTangents")); + } + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("updateMode")); + if (Math.UpdateMode == BGCcMath.UpdateModeEnum.RendererVisible) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("rendererForUpdateCheck")); + } + }); + + try + { + //by some reason NullReferenceException exceptions are fired at certain GUI passes + EditorGUILayout.PropertyField(serializedObject.FindProperty("mathChangedEvent")); + } + catch (NullReferenceException) + { + } + } + + protected override void ShowHandlesSettings() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresScale")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresColor")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresCount")); + } + + protected override void InternalOnUndoRedo() + { + if (Math != null) Math.Recalculate(); + } + + + protected override void InternalOnSceneGUI() + { + var mathCc = Math; + + if (mathCc == null || mathCc.Math == null || mathCc.Math.SectionsCount == 0) return; + + if (mathCc.Curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off) mathCc.Recalculate(); + + var math = mathCc.Math; + + var sphereScale = BGPrivateField.Get(mathCc, "spheresScale"); + + BGEditorUtility.SwapHandlesColor(BGPrivateField.Get(mathCc, "spheresColor"), () => + { + var count = BGPrivateField.Get(mathCc, "spheresCount"); + + for (var i = 0; i < math.SectionsCount; i++) + { + var section = math[i]; + var points = section.Points; + for (var j = 0; j < points.Count; j++) + { + var pos = points[j].Position; + Handles.SphereCap(0, pos, Quaternion.identity, sphereScale*BGEditorUtility.GetHandleSize(pos, .07f)); + if (count-- <= 0) return; + } + } + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs.meta new file mode 100644 index 0000000..e15b928 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcMathEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a541fa5a221b56f44b68ed52c066a05b +timeCreated: 1472499639 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs new file mode 100644 index 0000000..bc2c981 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs @@ -0,0 +1,101 @@ +using BansheeGz.BGSpline.Components; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof(BGCcSplitterPolyline))] + public class BGCcSplitterPolylineEditor : BGCcEditor + { + protected bool paramsChanged; + private bool listenersAdded; + + private BGCcSplitterPolyline Splitter + { + get { return (BGCcSplitterPolyline) cc; } + } + + protected override void InternalOnEnable() + { + if (!Splitter.enabled) return; + + if (Application.isPlaying) return; + Splitter.AddListeners(); + listenersAdded = true; + Splitter.InvalidateData(); + } + + protected override void InternalOnDestroy() + { + if (Application.isPlaying) return; + + if (Splitter != null) Splitter.RemoveListeners(); + } + + protected override void InternalOnInspectorGUI() + { + if (!listenersAdded) InternalOnEnable(); + + paramsChanged = false; + BGEditorUtility.ChangeCheck(() => + { + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("splitMode")); + + switch (Splitter.SplitMode) + { + case BGCcSplitterPolyline.SplitModeEnum.PartsTotal: + EditorGUILayout.PropertyField(serializedObject.FindProperty("partsTotal")); + break; + case BGCcSplitterPolyline.SplitModeEnum.PartsPerSection: + EditorGUILayout.PropertyField(serializedObject.FindProperty("partsPerSection")); + break; + } + }); + + EditorGUILayout.PropertyField(serializedObject.FindProperty("doNotOptimizeStraightLines")); + + AdditionalParams(); + }, () => paramsChanged = true); + } + + protected virtual void AdditionalParams() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("useLocal")); + } + + protected override void ShowHandlesSettings() + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresScale")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresColor")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("spheresCount")); + } + + protected override void InternalOnSceneGUI() + { + var splitter = Splitter; + if (splitter == null) return; + + var positions = splitter.Positions; + + if (positions == null || positions.Count == 0) return; + + var sphereScale = BGPrivateField.Get(splitter, "spheresScale"); + + BGEditorUtility.SwapHandlesColor(BGPrivateField.Get(splitter, "spheresColor"), () => + { + var count = Mathf.Min(positions.Count, BGPrivateField.Get(splitter, "spheresCount")); + + var localToWorldMatrix = splitter.transform.localToWorldMatrix; + for (var i = 0; i < count; i++) + { + var position = positions[i]; + if (splitter.UseLocal) position = localToWorldMatrix.MultiplyPoint(position); + + Handles.SphereCap(0, position, Quaternion.identity, sphereScale*BGEditorUtility.GetHandleSize(position, .07f)); + } + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs.meta new file mode 100644 index 0000000..2015976 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcSplitterPolylineEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43309ae1504d40645bdf732681273088 +timeCreated: 1474944881 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs new file mode 100644 index 0000000..f06003d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using BansheeGz.BGSpline.Components; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + + [CustomEditor(typeof(BGCcTriangulate2D))] + public class BGCcTriangulate2DEditor : BGCcSplitterPolylineEditor + { + + private BGCcTriangulate2D Triangulate2D + { + get { return (BGCcTriangulate2D)cc; } + } + + protected override void AdditionalParams() + { + var updateEveryFrameProperty = serializedObject.FindProperty("updateEveryFrame"); + + EditorGUILayout.PropertyField(updateEveryFrameProperty); + EditorGUILayout.PropertyField(serializedObject.FindProperty("flip")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleUV")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetUV")); + BGEditorUtility.VerticalBox(() => + { + var doubleSidedProperty = serializedObject.FindProperty("doubleSided"); + EditorGUILayout.PropertyField(doubleSidedProperty); + if (doubleSidedProperty.boolValue) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleBackUV")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetBackUV")); + } + }); + + //launch coroutine + if (updateEveryFrameProperty.boolValue != Triangulate2D.UpdateEveryFrame && Application.isPlaying && updateEveryFrameProperty.boolValue) Triangulate2D.UpdateEveryFrame = true; + } + + protected override void InternalOnInspectorGUIPost() + { + if (paramsChanged) Triangulate2D.UpdateUI(); + } + + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs.meta new file mode 100644 index 0000000..4ea1ae1 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcTriangulate2DEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5883d53d633a9954482d82352bb39465 +timeCreated: 1476470318 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs new file mode 100644 index 0000000..7a89aff --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs @@ -0,0 +1,33 @@ +using BansheeGz.BGSpline.Components; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof (BGCcVisualizationLineRenderer))] + public class BGCcVisualizationLineRendererEditor : BGCcSplitterPolylineEditor + { + + private BGCcVisualizationLineRenderer LineRenderer + { + get { return (BGCcVisualizationLineRenderer) cc; } + } + + protected override void InternalOnInspectorGUI() + { + base.InternalOnInspectorGUI(); + + EditorGUILayout.PropertyField(serializedObject.FindProperty("updateAtStart")); + + } + + protected override void AdditionalParams() + { + //we no need useLocal param, cause it depends on LineRenderer itself + } + + protected override void InternalOnInspectorGUIPost() + { + if (paramsChanged) LineRenderer.UpdateUI(); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs.meta new file mode 100644 index 0000000..307263e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Cc/BGCcVisualizationLineRendererEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fc136e2fcbf2c97468e0b45cf219d5e6 +timeCreated: 1472500588 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve.meta new file mode 100644 index 0000000..3dfc6b2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6817f9bdaece0b449a012e1592389b6f +folderAsset: yes +timeCreated: 1472482776 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs new file mode 100644 index 0000000..e778871 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs @@ -0,0 +1,173 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +namespace BansheeGz.BGSpline.Editor +{ + public class BGCcEditor : UnityEditor.Editor + { + public event EventHandler ChangedParent; + + + protected BGCc cc; + private Type parentClass; + + //================================================================= Unity callbacks + protected virtual void OnEnable() + { + cc = (BGCc) target; + + if (cc == null) return; + + //get all required components + parentClass = cc.GetParentClass(); + + + InternalOnEnable(); + + cc.ChangedParams -= ChangedParams; + cc.ChangedParams += ChangedParams; + + Undo.undoRedoPerformed -= InternalOnUndoRedo; + Undo.undoRedoPerformed += InternalOnUndoRedo; + } + + + protected virtual void OnDestroy() + { + Undo.undoRedoPerformed -= InternalOnUndoRedo; + cc.ChangedParams -= ChangedParams; + InternalOnDestroy(); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + + var componentChanged = BGEditorUtility.ChangeCheck(() => + { + //custom fields + InternalOnInspectorGUI(); + + // ------------- parents + if (parentClass != null) + { + var possibleParents = cc.GetComponents(parentClass); + if (possibleParents.Length > 1) + { + BGEditorUtility.Horizontal(() => + { + GUILayout.Space(10); + BGEditorUtility.VerticalBox(() => + { + var myParent = cc.GetParent(parentClass); + var options = new string[possibleParents.Length]; + var index = 0; + for (var i = 0; i < possibleParents.Length; i++) + { + var possibleParent = possibleParents[i]; + if (possibleParent == myParent) index = i; + options[i] = ((BGCc)possibleParent).CcName; + } + + //show popup + var label = BGCc.GetDescriptor(parentClass).Name ?? parentClass.Name; + var newIndex = EditorGUILayout.Popup(label, index, options); + if (newIndex != index) + { + Undo.RecordObject(cc, "parent change"); + cc.SetParent((BGCc) possibleParents[newIndex]); + if (ChangedParent != null) ChangedParent(this, null); + } + }); + }); + } + } + }); + + + //-------------- handles + if (cc.SupportHandles && !BGCurveSettingsForEditor.CcInspectorHandlesOff) + { + BGEditorUtility.Horizontal(() => + { + GUILayout.Space(10); + BGEditorUtility.VerticalBox(() => + { + var showHandlesProperty = serializedObject.FindProperty("showHandles"); + EditorGUILayout.PropertyField(showHandlesProperty); + if (cc.SupportHandlesSettings && showHandlesProperty.boolValue) BGEditorUtility.Indent(1, ShowHandlesSettings); + }); + }); + } + + //-------------- status + var info = cc.Info; + BGEditorUtility.HelpBox(info, MessageType.Info, !string.IsNullOrEmpty(info)); + + //-------------- warning + var warning = cc.Warning; + BGEditorUtility.HelpBox(warning, MessageType.Warning, !string.IsNullOrEmpty(warning)); + + //-------------- error + var error = cc.Error; + BGEditorUtility.HelpBox(error, MessageType.Error, !string.IsNullOrEmpty(error)); + + if (!GUI.changed) return; + + Undo.RecordObject(cc, "fields change"); + + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(cc); + + if (componentChanged) cc.FireChangedParams(); + + InternalOnInspectorGUIPost(); + } + + protected virtual void ShowHandlesSettings() + { + } + + + private void ChangedParams(object sender, EventArgs e) + { + Repaint(); + } + + + public virtual void OnSceneGUI() + { + if (!cc.SupportHandles || !BGPrivateField.GetShowHandles(cc)) return; + InternalOnSceneGUI(); + } + + + //================================================================= Internal to override + + protected virtual void InternalOnEnable() + { + } + + protected virtual void InternalOnDestroy() + { + } + + protected virtual void InternalOnInspectorGUI() + { + } + + protected virtual void InternalOnSceneGUI() + { + } + + protected virtual void InternalOnInspectorGUIPost() + { + } + + protected virtual void InternalOnUndoRedo() + { + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs.meta new file mode 100644 index 0000000..2ad57bf --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCcEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 60c2111cab2041a4890fd960ef4748ae +timeCreated: 1472495704 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs new file mode 100644 index 0000000..e581b55 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs @@ -0,0 +1,520 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //idea.. do points paging + [CustomEditor(typeof(BGCurve))] + public class BGCurveEditor : UnityEditor.Editor + { + private const int ToolBarHeight = 20; + + //static + private static readonly Color32 LockViewActiveColor = new Color32(255, 252, 58, 255); + internal static BGOverlayMessage OverlayMessage; + //for curves, which are not selected in hierarchy + private static readonly Dictionary curve2Painter = new Dictionary(); + private static BGCurvePainterGizmo CurrentGizmoPainter; + private static BGCurve CurrentCurve; + private static Texture2D headerTexture; + + // non-static + private BGCurveEditorTab[] editors; + + private Texture2D[] headers; + + private Rect toolBarRect; + private Texture2D stickerTextureOk; + private Texture2D stickerTextureActive; + private Texture2D stickerTextureWarning; + private Texture2D stickerTextureError; + private Texture2D settingsTexture; + + private GUIStyle stickerStyle; + + public BGCurve Curve { get; private set; } + public BGCurveBaseMath Math { get; private set; } + + public static bool lastPlayMode; + + private BGTransformMonitor transformMonitor; + + //selected points + private BGCurveEditorPointsSelection editorSelection; + private int undoGroup = -1; + + protected void OnEnable() + { + Curve = (BGCurve) target; + + //wth + if (Curve == null) return; + + CurrentCurve = Curve; + transformMonitor = BGTransformMonitor.GetMonitor(Curve); + + + var settings = BGPrivateField.GetSettings(Curve); + + + //painter and math + if (curve2Painter.ContainsKey(Curve)) + { + curve2Painter[Curve].Dispose(); + curve2Painter.Remove(Curve); + } + + Math = NewMath(Curve, settings); + CurrentGizmoPainter = new BGCurvePainterGizmo(Math); + + + //overlay + BGEditorUtility.Assign(ref OverlayMessage, () => new BGOverlayMessage()); + + //probably we do not need it for play mode.. probably + if (!Application.isPlaying) + { + //they are not persistent + Curve.ImmediateChangeEvents = true; + Curve.BeforeChange += BeforeCurveChange; + Curve.Changed += CurveChanged; + } + + + if (!settings.Existing) + { + //newly created + settings.Existing = true; + + var defaultSettings = BGCurveSettingsOperations.LoadDefault(); + if (defaultSettings != null) BGPrivateField.SetSettings(Curve, defaultSettings); + } + + //load textures + BGEditorUtility.Assign(ref headerTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCurveLogo123)); + stickerTextureOk = BGEditorUtility.Texture1X1(new Color32(46, 143, 168, 255)); + stickerTextureError = BGEditorUtility.Texture1X1(new Color32(255, 0, 0, 255)); + stickerTextureWarning = BGEditorUtility.Texture1X1(new Color32(255, 206, 92, 255)); + stickerTextureActive = BGEditorUtility.Texture1X1(new Color32(44, 160, 90, 255)); + + //selection + editorSelection = new BGCurveEditorPointsSelection(Curve, this); + + // editors + editors = new BGCurveEditorTab[] + { + new BGCurveEditorPoints(this, serializedObject, editorSelection), new BGCurveEditorComponents(this, serializedObject), + new BGCurveEditorFields(this, serializedObject, editorSelection), new BGCurveEditorSettings(this, serializedObject) + }; + + headers = editors.Select(editor => editor.Header2D).ToArray(); + foreach (var editor in editors) editor.OnEnable(); + + //do it every frame + EditorApplication.update -= OverlayMessage.Check; + EditorApplication.update += OverlayMessage.Check; + + Undo.undoRedoPerformed -= InternalOnUndoRedo; + Undo.undoRedoPerformed += InternalOnUndoRedo; + } + + private static BGCurveBaseMath NewMath(BGCurve curve, BGCurveSettings settings) + { + return new BGCurveBaseMath(curve, NewConfig(settings)); + } + + private static BGCurveBaseMath.Config NewConfig(BGCurveSettings settings) + { + return new BGCurveBaseMath.Config(settings.ShowTangents ? BGCurveBaseMath.Fields.PositionAndTangent : BGCurveBaseMath.Fields.Position) {Parts = settings.Sections}; + } + + private static void AdjustMath(BGCurveSettings settings, BGCurveBaseMath math) + { + if (settings.Sections != math.Configuration.Parts + || (settings.ShowTangents && !math.IsCalculated(BGCurveBaseMath.Field.Tangent)) + || (!settings.ShowTangents && math.IsCalculated(BGCurveBaseMath.Field.Tangent))) + { + math.Init(NewConfig(settings)); + } + } + + private void CurveChanged(object sender, BGCurveChangedArgs e) + { + if (Curve == null) return; + + if (undoGroup > 0) Undo.CollapseUndoOperations(undoGroup); + undoGroup = -1; + EditorUtility.SetDirty(Curve); + + if (Curve.FieldsCount > 0) foreach (var field in Curve.Fields) EditorUtility.SetDirty(field); + + var pointsMode = Curve.PointsMode; + if (Curve.PointsCount > 0 && pointsMode != BGCurve.PointsModeEnum.Inlined) + { + switch (pointsMode) + { + case BGCurve.PointsModeEnum.Components: + foreach (var point in Curve.Points) EditorUtility.SetDirty((BGCurvePointComponent) point); + break; + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + case BGCurve.PointsModeEnum.GameObjectsTransform: + foreach (var point in Curve.Points) + { + var curvePointGo = (BGCurvePointGO) point; + EditorUtility.SetDirty(curvePointGo); + EditorUtility.SetDirty(curvePointGo.gameObject); + } + break; + } + } + + foreach (var editor in editors) editor.OnCurveChanged(e); + + transformMonitor.CheckForChange(); + } + + private void BeforeCurveChange(object sender, BGCurveChangedArgs.BeforeChange e) + { +// Undo.IncrementCurrentGroup(); + undoGroup = Undo.GetCurrentGroup(); + + var operation = e != null && e.Operation != null ? e.Operation : "Curve change"; + + Undo.RecordObject(Curve, operation); + + + if (Curve.FieldsCount > 0) foreach (var field in Curve.Fields) Undo.RecordObject(field, operation); + + var pointsMode = Curve.PointsMode; + if (Curve.PointsCount > 0) + { + var points = Curve.Points; + foreach (var point in points) if (point.PointTransform != null) Undo.RecordObject(point.PointTransform, operation); + + if (pointsMode != BGCurve.PointsModeEnum.Inlined) + { + switch (pointsMode) + { + case BGCurve.PointsModeEnum.Components: + foreach (var point in points) Undo.RecordObject((BGCurvePointComponent) point, operation); + break; + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + case BGCurve.PointsModeEnum.GameObjectsTransform: + foreach (var point in points) + { + var pointGo = (BGCurvePointGO) point; + Undo.RecordObject(pointGo, operation); + if (pointsMode == BGCurve.PointsModeEnum.GameObjectsTransform) Undo.RecordObject(pointGo.transform, operation); + } + break; + } + } + } + } + + public void OnDisable() + { + try + { + EditorApplication.update -= OverlayMessage.Check; + } + catch (ArgumentException) + { + return; + } + + if (editors != null) foreach (var editor in editors) if (editor != null) editor.OnDisable(); + + if (transformMonitor != null) transformMonitor.Release(); + + Dispose(); + } + + + private void Dispose() + { + CurrentCurve = null; + CurrentGizmoPainter = null; + Undo.undoRedoPerformed -= InternalOnUndoRedo; + + if (Math != null) Math.Dispose(); + Math = null; + } + + private void InternalOnUndoRedo() + { + transformMonitor.CheckForChange(); + + Curve.PrivateUpdateFieldsValuesIndexes(); + + if (BGCurve.IsGoMode(Curve.PointsMode)) BGPrivateField.Invoke(Curve, BGCurve.MethodSetPointsNames); + + foreach (var editor in editors) editor.OnUndoRedo(); + + if (Math != null) Math.Recalculate(); + + Repaint(); + SceneView.RepaintAll(); + } + + public void OnDestroy() + { + if (editors != null) foreach (var editor in editors) if (editor != null) editor.OnDestroy(); + + Curve.BeforeChange -= BeforeCurveChange; + Curve.Changed -= CurveChanged; + + Dispose(); + + Tools.hidden = false; + } + + public override void OnInspectorGUI() + { + //adjust math if needed + AdjustMath(BGPrivateField.GetSettings(Curve), Math); + + //styles + BGEditorUtility.Assign(ref stickerStyle, () => new GUIStyle("Label") {fontSize = 18, alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState {textColor = Color.white}}); + BGEditorUtility.Assign(ref settingsTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSettingsIcon123)); + + serializedObject.Update(); + + // =========== Header + DrawLogo(); + + // =========== lock view + BGEditorUtility.Horizontal(() => + { + var temp = BGCurveSettingsForEditor.LockView; + BGCurveSettingsForEditor.LockView = BGEditorUtility.ButtonOnOff(ref temp, "Lock view", "Disable selection of any object in the scene, except points", LockViewActiveColor, + new GUIContent("Turn Off", "Click to turn this mode off"), + new GUIContent("Turn On", "Click to turn this mode on")); + + if (GUILayout.Button(settingsTexture, GUILayout.MaxWidth(24), GUILayout.MaxHeight(24))) BGCurveSettingsForEditorWindow.Open(); + }); + + //warning + BGEditorUtility.HelpBox("You can not chose another objects in the scene, except points.", MessageType.Warning, + BGCurveSettingsForEditor.LockView, () => GUILayout.Space(8)); + + // =========== Tabs + if (BGCurveSettingsForEditor.CurrentTab < 0 || BGCurveSettingsForEditor.CurrentTab > headers.Length - 1) BGCurveSettingsForEditor.CurrentTab = 0; + var newTab = GUILayout.Toolbar(BGCurveSettingsForEditor.CurrentTab, headers, GUILayout.Height(ToolBarHeight)); + //do not move this method(GUILayoutUtility.GetLastRect() is used) + ShowStickers(); + if (BGCurveSettingsForEditor.CurrentTab != newTab) GUI.FocusControl(""); + BGCurveSettingsForEditor.CurrentTab = newTab; + editors[BGCurveSettingsForEditor.CurrentTab].OnInspectorGui(); + + if (!GUI.changed) return; // if no change- return + + foreach (var editor in editors) editor.OnApply(); + + transformMonitor.CheckForChange(); + } + + //shows error sticker if any component has error + private void ShowStickers() + { + if (Event.current.type == EventType.Repaint) toolBarRect = GUILayoutUtility.GetLastRect(); + + const int height = 18; + var oneTabWidth = toolBarRect.width/editors.Length; + + for (var i = 0; i < editors.Length; i++) + { + var editor = editors[i]; + var error = MessageType.None; + var message = editor.GetStickerMessage(ref error); + if (message == null) continue; + + //show sticker + var width = stickerStyle.CalcSize(new GUIContent(message)).x; + + var rect = new Rect(toolBarRect.x + oneTabWidth*(i + 1) - width, toolBarRect.y + 1, width, height); + + GUI.DrawTexture(rect, GetStickerTexture(error, i)); + GUI.Label(rect, message, stickerStyle); + } + } + + private Texture2D GetStickerTexture(MessageType error, int index) + { + return error == MessageType.Error + ? stickerTextureError + : error == MessageType.Warning + ? stickerTextureWarning + : BGCurveSettingsForEditor.CurrentTab == index + ? stickerTextureActive + : stickerTextureOk; + } + + protected virtual void DrawLogo() + { + DrawLogo(headerTexture); + } + + + protected static void DrawLogo(Texture2D logo) + { + var rect = GUILayoutUtility.GetRect(0, 0); + rect.width = logo.width*.5f; + rect.height = logo.height*.5f; + rect.y += 1; + GUILayout.Space(rect.height + 1); + GUI.DrawTexture(rect, logo); + } + + public void OnSceneGUI() + { + var settings = BGPrivateField.GetSettings(Curve); + + AdjustMath(settings, Math); + + if (Curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off) Math.Recalculate(true); + + + if (settings.HandlesSettings != null && settings.HandlesType == BGCurveSettings.HandlesTypeEnum.Configurable + || settings.ControlHandlesSettings != null && settings.ControlHandlesType == BGCurveSettings.HandlesTypeEnum.Configurable) BGEditorUtility.ReloadSnapSettings(); + + + OverlayMessage.OnSceneGui(); + + var frustum = GeometryUtility.CalculateFrustumPlanes(SceneView.currentDrawingSceneView.camera); + + // process all editors + foreach (var editor in editors) editor.OnSceneGui(frustum); + + editorSelection.Process(Event.current); + + + transformMonitor.CheckForChange(); + } + + public static void AddPoint(BGCurve curve, BGCurvePoint point, int index) + { + BGPrivateField.Invoke(curve, BGCurve.MethodAddPoint, point, index, GetPointProvider(curve.PointsMode, curve)); + } + + public static void DeletePoint(BGCurve curve, int index) + { + BGPrivateField.Invoke(curve, BGCurve.MethodDeletePoint, new[] {typeof(int), typeof(Action)}, index, GetPointDestroyer(curve.PointsMode, curve)); + } + + public static void DeletePoints(BGCurve curve, BGCurvePointI[] points) + { + BGPrivateField.Invoke(curve, BGCurve.MethodDeletePoint, new[] {typeof(BGCurvePointI[]), typeof(Action)}, points, GetPointDestroyer(curve.PointsMode, curve)); + } + + + public static Func GetPointProvider(BGCurve.PointsModeEnum pointsMode, BGCurve curve) + { + //init provider + Func provider = null; + switch (pointsMode) + { + case BGCurve.PointsModeEnum.Components: + provider = () => Undo.AddComponent(curve.gameObject); + break; + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + case BGCurve.PointsModeEnum.GameObjectsTransform: + provider = () => + { + var pointGO = new GameObject(); + var transform = pointGO.transform; + transform.parent = curve.transform; + transform.localRotation = Quaternion.identity; + transform.localPosition = Vector3.zero; + transform.localScale = Vector3.one; + + Undo.RegisterCreatedObjectUndo(pointGO, "Create point"); + var point = Undo.AddComponent(pointGO); + return point; + }; + break; + } + return provider; + } + + public static Action GetPointDestroyer(BGCurve.PointsModeEnum pointsMode, BGCurve curve) + { + //init destroyer + Action destroyer = null; + switch (pointsMode) + { + case BGCurve.PointsModeEnum.Components: + destroyer = point => Undo.DestroyObjectImmediate((UnityEngine.Object) point); + break; + case BGCurve.PointsModeEnum.GameObjectsNoTransform: + case BGCurve.PointsModeEnum.GameObjectsTransform: + destroyer = point => Undo.DestroyObjectImmediate(((MonoBehaviour) point).gameObject); + break; + } + return destroyer; + } + + + [MenuItem("GameObject/Create Other/BansheeGz/BG Curve")] + public static void CreateCurve(MenuCommand command) + { + var curveObject = new GameObject("BGCurve"); + Undo.RegisterCreatedObjectUndo(curveObject, "Undo Create BGCurve"); + curveObject.AddComponent(); + Selection.activeGameObject = curveObject; + } + + [DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Selected | GizmoType.InSelectionHierarchy)] + public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) + { + var playMode = EditorApplication.isPlaying; + + if (lastPlayMode != playMode) + { + lastPlayMode = playMode; + + foreach (var painterGizmo in curve2Painter) painterGizmo.Value.Dispose(); + curve2Painter.Clear(); + } + + var settings = BGPrivateField.GetSettings(curve); + if (!ComplyForDrawGizmos(curve, gizmoType, settings)) return; + + if (CurrentCurve != null && curve.GetInstanceID() == CurrentCurve.GetInstanceID()) + { + if (CurrentGizmoPainter != null) CurrentGizmoPainter.DrawCurve(); + } + else + { + //curve is not selected in hierarchy + var painter = BGEditorUtility.Ensure(curve2Painter, curve, () => new BGCurvePainterGizmo(NewMath(curve, settings), true)); + AdjustMath(settings, painter.Math); + if (curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off && !Application.isPlaying) painter.Math.Recalculate(); + painter.DrawCurve(); + } + } + + public static bool ComplyForDrawGizmos(BGCurve curve, GizmoType gizmoType, BGCurveSettings settings) + { + if (curve.PointsCount == 0) return false; + + if (!settings.ShowCurve) return false; + if (Selection.Contains(curve.gameObject) && settings.VRay) return false; + if (settings.ShowCurveMode == BGCurveSettings.ShowCurveModeEnum.CurveSelected && !Comply(gizmoType, GizmoType.Selected)) return false; + + if (BGCurvePointGOEditor.PointSelected) return true; + + if (settings.ShowCurveMode == BGCurveSettings.ShowCurveModeEnum.CurveOrParentSelected && !Comply(gizmoType, GizmoType.InSelectionHierarchy)) return false; + return true; + } + + public static bool Comply(GizmoType gizmoType, GizmoType toCompare) + { + return (gizmoType & toCompare) != 0; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs.meta new file mode 100644 index 0000000..80ff9aa --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93887c59e11763c4791cc3f6063e3ff0 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs new file mode 100644 index 0000000..b66491c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs @@ -0,0 +1,661 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using Object = UnityEngine.Object; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCurveEditorComponents : BGCurveEditorTab + { + private const int ConnectorLineAlpha = 100; + private const int HeaderAlpha = 25; + private const int HeaderFoldedAlpha = 75; + + private static bool customEditorsOn = true; + + + private Texture2D collapseTexture; + private Texture2D expandTexture; + private Texture2D addTexture; + private Texture2D deleteTexture; + private Texture2D whiteTexture; + private Texture2D onTexture; + private Texture2D offTexture; + private Texture2D handlesOnTexture; + private Texture2D handlesOffTexture; + + private readonly Tree tree; + private BGCc[] components; + + public BGCurveEditorComponents(BGCurveEditor editor, SerializedObject curveObject) + : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGComponents123)) + { + tree = new Tree(Curve); + } + + + private bool HasError + { + get { return AnyComponentHasError(Curve); } + } + + private bool HasWarning + { + get { return AnyComponentHasWarning(Curve); } + } + + // ================================================================================ Inspector + public override void OnInspectorGui() + { + BGEditorUtility.Assign(ref whiteTexture, () => BGEditorUtility.Texture1X1(Color.white)); + BGEditorUtility.Assign(ref collapseTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCollapseAll123)); + BGEditorUtility.Assign(ref expandTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGExpandAll123)); + BGEditorUtility.Assign(ref addTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123)); + BGEditorUtility.Assign(ref deleteTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123)); + BGEditorUtility.Assign(ref onTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGOn123)); + BGEditorUtility.Assign(ref offTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGOff123)); + BGEditorUtility.Assign(ref handlesOnTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHandlesOn123)); + BGEditorUtility.Assign(ref handlesOffTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHandlesOff123)); + + + components = Curve.GetComponents(); + var length = components.Length; + + tree.Refresh(components); + + if (tree.InitException != null) + { + EditorGUILayout.HelpBox("There was an error initializing editors for component's Tree View: " + tree.InitException.Message + + "\r\n\r\nYou still can use default Unity's editors for components below.", MessageType.Error); + return; + } + + + var hasError = HasError; + var hasWarning = HasWarning; + + BGEditorUtility.HorizontalBox(() => + { + EditorGUILayout.LabelField("Components: " + length + " (" + (hasError ? "Error" : "Ok") + ")"); + + GUILayout.FlexibleSpace(); + + // turn on/off handles + if (BGEditorUtility.ButtonWithIcon(BGCurveSettingsForEditor.CcInspectorHandlesOff ? handlesOffTexture : handlesOnTexture, "Turn on/off handles settings in Inspector")) + { + BGCurveSettingsForEditor.CcInspectorHandlesOff = !BGCurveSettingsForEditor.CcInspectorHandlesOff; + } + EditorGUILayout.Separator(); + + // turn on/off colored tree + if (BGEditorUtility.ButtonWithIcon(customEditorsOn ? onTexture : offTexture, "Use custom UI for components (colored tree) and hide standard unity editors for components")) + { + customEditorsOn = !customEditorsOn; + tree.Refresh(null, true); + } + EditorGUILayout.Separator(); + + if (length > 0) + { + // collapse/expand + if (BGEditorUtility.ButtonWithIcon(collapseTexture, "Collapse all components")) tree.ExpandCollapseAll(true); + EditorGUILayout.Separator(); + if (BGEditorUtility.ButtonWithIcon(expandTexture, "Expand all components")) tree.ExpandCollapseAll(false); + EditorGUILayout.Separator(); + + + // delete all Ccs + if (BGEditorUtility.ButtonWithIcon(deleteTexture, "Delete all components") + && BGEditorUtility.Confirm("Delete", "Are you sure you want to delete " + length + " component(s)?", "Delete")) tree.Delete(); + EditorGUILayout.Separator(); + } + + //add new Cc + if (BGEditorUtility.ButtonWithIcon(addTexture, "Add new component")) BGCcAddWindow.Open(Curve, type => AddComponent(Curve, type)); + }); + + + if (length > 0) + { + // warnings/errors + if (hasWarning || hasError) + { + for (var i = 0; i < components.Length; i++) + { + var component = components[i]; + + var name = (component.Descriptor != null ? component.Descriptor.Name + " " : "") + component.CcName; + + var error = component.Error; + if (!string.IsNullOrEmpty(error)) BGEditorUtility.HelpBox("Component error [" + name + "]: " + error, MessageType.Error); + + var warning = component.Warning; + if (!string.IsNullOrEmpty(warning)) BGEditorUtility.HelpBox("Component warning [" + name + "]: " + warning, MessageType.Warning); + } + } + else BGEditorUtility.HelpBox("No warnings or errors", MessageType.Info); + + // tree GUI + tree.OnInspectorGui(); + } + else + EditorGUILayout.HelpBox( + "Hit the Plus icon to add a component" + + "\r\n" + + "\r\n" + + "Components allows to add functionality without any scripting." + , MessageType.Info); + + + if (hasError ^ HasError || hasWarning ^ HasWarning) EditorApplication.RepaintHierarchyWindow(); + } + + private static BGCc AddComponent(BGCurve curve, Type type) + { + var newCc = Undo.AddComponent(curve.gameObject, type); + if (newCc == null) return null; + + var bgCc = ((BGCc) newCc); + UnityEditorInternal.InternalEditorUtility.SetIsInspectorExpanded(bgCc, true); + bgCc.AddedInEditor(); + EditorUtility.SetDirty(curve.gameObject); + return bgCc; + } + + public override void OnEnable() + { + tree.Refresh(); + } + + public override void OnDisable() + { + tree.OnDestroy(); + } + + public override void OnSceneGui(Plane[] frustum) + { + if (!customEditorsOn) return; + + tree.OnSceneGui(); + } + + public override string GetStickerMessage(ref MessageType type) + { + var length = Curve.GetComponents().Length; + if (length != 0) + { + bool hasError = false, hasWarning = false; + ComponentsStatus(Curve, ref hasError, ref hasWarning); + type = hasError ? MessageType.Error : hasWarning ? MessageType.Warning : MessageType.None; + } + + return type != MessageType.None ? "!!" : "" + length; + } + + + public static bool AnyComponentHasError(BGCurve curve) + { + var components = curve.GetComponents(); + if (components == null || components.Length == 0) return false; + return components.Any(t => t.HasError()); + } + + public static bool AnyComponentHasWarning(BGCurve curve) + { + var components = curve.GetComponents(); + if (components == null || components.Length == 0) return false; + return components.Any(t => t.HasWarning()); + } + + public static void ComponentsStatus(BGCurve curve, ref bool hasError, ref bool hasWarning) + { + var components = curve.GetComponents(); + if (components == null || components.Length == 0) return; + + foreach (var component in components) + { + if (component.HasError()) hasError = true; + if (component.HasWarning()) hasWarning = true; + } + } + + + // ================================================================================ Tree + //tree structure of Cc's + internal sealed class Tree : BGTreeView + { + private Dictionary level2LinkTexture = GetLevel2LinkTexture(); + + private static Dictionary GetLevel2LinkTexture() + { + return new Dictionary + { + {0, BGEditorUtility.Texture1X1(new Color32(255, 0, 0, ConnectorLineAlpha))}, + {1, BGEditorUtility.Texture1X1(new Color32(0, 255, 0, ConnectorLineAlpha))}, + {2, BGEditorUtility.Texture1X1(new Color32(0, 0, 255, ConnectorLineAlpha))}, + {3, BGEditorUtility.Texture1X1(new Color32(255, 255, 0, ConnectorLineAlpha))}, + }; + } + + private readonly Dictionary level2Color = new Dictionary + { + {0, new Color32(255, 0, 0, HeaderAlpha)}, + {1, new Color32(0, 255, 0, HeaderAlpha)}, + {2, new Color32(0, 0, 255, HeaderAlpha)}, + {3, new Color32(255, 255, 0, HeaderAlpha)}, + }; + + private readonly Dictionary level2FoldedColor = new Dictionary + { + {0, new Color32(255, 0, 0, HeaderFoldedAlpha)}, + {1, new Color32(0, 255, 0, HeaderFoldedAlpha)}, + {2, new Color32(0, 0, 255, HeaderFoldedAlpha)}, + {3, new Color32(255, 255, 0, HeaderFoldedAlpha)}, + }; + + private readonly Texture2D whiteTexture; + + + private readonly Dictionary> type2NodeList = new Dictionary>(); + + public BGCurve Curve; + public BGCc.CcException InitException; + + private int count; + + public Tree(BGCurve curve) : base(new Config(2, 8, 0, 2, 0)) + { + Curve = curve; + + whiteTexture = BGEditorUtility.Texture1X1(Color.white); + } + + public void Refresh(BGCc[] components = null, bool force = false) + { + if (components == null) components = Curve.GetComponents(); + + //it should be enough + if (count == components.Length && !force) return; + + SetHideFlag(components, customEditorsOn ? HideFlags.HideInInspector : HideFlags.None); + + //Recalc + var instanceId2Collapsed = new Dictionary(); + //try to preserve expanded/collapsed state + if (Roots.Count > 0) foreach (var root in Roots) root.FillState(instanceId2Collapsed); + + OnDestroy(); + Roots.Clear(); + type2NodeList.Clear(); + + + if (!customEditorsOn) return; + + + try + { + InitException = null; + + //try to init custom tree view for components + count = components.Length; + foreach (var cc in components) + { + var node = new CcNode(this, cc); + + if (instanceId2Collapsed.ContainsKey(cc.GetInstanceID())) node.Collapsed = true; + + var type = cc.GetType(); + + if (!type2NodeList.ContainsKey(type)) type2NodeList[type] = new List(); + + type2NodeList[type].Add(node); + } + + foreach (var list in type2NodeList.Values) foreach (var node in list) if (!node.Processed) node.ProcessStructure(); + } + catch (BGCc.CcException e) + { + InitException = e; + //fallback (show default stuff) + SetHideFlag(components, HideFlags.None); + } + } + + private static void SetHideFlag(BGCc[] components, HideFlags hideFlags) + { + foreach (var component in components) component.hideFlags = hideFlags; + } + + + public CcNode Get(BGCc cc) + { + var nodes = type2NodeList[cc.GetType()]; + + return nodes.FirstOrDefault(node => node.Cc == cc); + } + + public void Delete() + { + foreach (var root in Roots) root.Delete(); + + GUIUtility.ExitGUI(); + } + + public void OnDestroy() + { + foreach (var root in Roots) root.OnDestroy(); + } + + public override Texture2D GetLinkTexture(int level) + { + if (level2LinkTexture[0] == null) level2LinkTexture = GetLevel2LinkTexture(); + return level2LinkTexture.Count > level ? level2LinkTexture[level] : whiteTexture; + } + + private Color GetColor(int level, bool collapsed, Func defaultColor) + { + return level2Color.Count > level ? (collapsed ? level2FoldedColor[level] : level2Color[level]) : defaultColor(); + } + + public void OnSceneGui() + { + foreach (var root in Roots) root.OnSceneGui(); + } + + public override void OnInspectorGui() + { + if (!customEditorsOn) + { + EditorGUILayout.HelpBox("You disabled tree view. Use standard Unity editors below to change parameters.", MessageType.Warning); + return; + } + + + try + { + for (var i = 0; i < Roots.Count; i++) + { + var root = Roots[i]; + if (i != 0) EditorGUILayout.Separator(); + root.OnInspectorGui(); + } + } + catch (BGEditorUtility.ExitException) + { + Refresh(); + GUIUtility.ExitGUI(); + } + } + + // ================================================================================ Tree Node + // one cc + internal sealed class CcNode : BGTreeNode + { + public bool Processed; + //Cc= Curve's component + public readonly BGCc Cc; + private readonly BGCc.CcDescriptor descriptor; + + private readonly Texture2D enabledTexture; + private readonly Texture2D disabledTexture; + private readonly Texture2D helpTexture; + private readonly Texture2D deleteTexture; + private readonly Texture2D addTexture; + private readonly Texture2D changeNameTexture; + + private GUIStyle headerFoldoutStyle; + private GUIStyle headerFoldoutStyleDisabled; + private GUIStyle okStyle; + private GUIStyle errorStyle; + private GUIStyle coloredBoxStyle; + + + private readonly BGCcEditor ccEditor; + private readonly MethodInfo onSceneGuiMethod; + private readonly Type parentType; + private GUIStyle headerBoxStyle; + + + public override bool Collapsed + { + get { return !UnityEditorInternal.InternalEditorUtility.GetIsInspectorExpanded(Cc); } + set { UnityEditorInternal.InternalEditorUtility.SetIsInspectorExpanded(Cc, !value); } + } + + internal CcNode(Tree tree, BGCc cc) : base(tree) + { + Cc = cc; + descriptor = cc.Descriptor; + + var editor = UnityEditor.Editor.CreateEditor(cc); + + if (!(editor is BGCcEditor)) throw new BGCc.CcException("Unable to init an Editor for " + cc.GetType() + ": editor does not extend from BGCcEditor."); + + ccEditor = (BGCcEditor) editor; + ccEditor.ChangedParent += ChangedParent; +// UnityEditor.Editor.CreateCachedEditor(cc, null, ref ccEditor); + + onSceneGuiMethod = ccEditor.GetType().GetMethod("OnSceneGUI", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + + enabledTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickYes123); + disabledTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickNo123); + helpTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHelp123); + deleteTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); + addTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); + changeNameTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCcEditName123); + + parentType = cc.GetParentClass(); + } + + private Tree MyTree + { + get { return (Tree) Tree; } + } + + private void ChangedParent(object sender, EventArgs e) + { + MyTree.Refresh(null, true); + } + + public override void ProcessStructure() + { + if (parentType == null) + { + MyTree.Roots.Add(this); + } + else + { + Parent = MyTree.Get(Cc.GetParent(parentType)); + } + Processed = true; + } + + //true if exit gui pass + public override void OnInspectorGuiInternal(int level) + { + BGEditorUtility.Assign(ref okStyle, () => new GUIStyle("Label") {normal = {textColor = new Color32(66, 166, 33, 255)}, fontStyle = FontStyle.Bold}); + BGEditorUtility.Assign(ref errorStyle, () => new GUIStyle("Label") {normal = {textColor = new Color32(166, 66, 33, 255)}, fontStyle = FontStyle.Bold}); + BGEditorUtility.Assign(ref headerBoxStyle, () => new GUIStyle {padding = new RectOffset(4, 4, 4, 4)}); + BGEditorUtility.Assign(ref headerFoldoutStyle, () => new GUIStyle(EditorStyles.foldout) {fontStyle = FontStyle.Bold, clipping = TextClipping.Clip}); + BGEditorUtility.Assign(ref headerFoldoutStyleDisabled, () => new GUIStyle(headerFoldoutStyle) {normal = {textColor = Color.gray}}); + + var color = MyTree.GetColor(level, Collapsed, () => Color.white); + color.a = ConnectorLineAlpha; + + //colored box + BGEditorUtility.SwapGuiColor(color, () => EditorGUILayout.BeginVertical(BGEditorUtility.Assign(ref coloredBoxStyle, () => new GUIStyle("Box") + { + padding = new RectOffset(), + margin = new RectOffset(), + border = new RectOffset(4, 4, 4, 4), + normal = {background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWhite123)} + }))); + + //header + HeaderUi(level, !String.IsNullOrEmpty(Cc.Error)); + + + if (!Collapsed) + { + BGEditorUtility.VerticalBox(() => + { + //show inspector + ccEditor.OnInspectorGUI(); + }); + } + + //do not remove it (EditorGUILayout.BeginVertical is a little higher- colored box) + EditorGUILayout.EndVertical(); + } + + private void HeaderUi(int level, bool hasError) + { + var color = MyTree.GetColor(level, Collapsed, () => new Color(0, 0, 0, 0)); + BGEditorUtility.SwapGuiBackgroundColor(color, () => + { + BGEditorUtility.Horizontal(headerBoxStyle, () => + { + BGEditorUtility.Indent(1, () => + { + var content = new GUIContent(descriptor == null ? Cc.GetType().Name : descriptor.Name + " (" + BGEditorUtility.Trim(Cc.CcName, 10) + ")", + descriptor == null ? null : descriptor.Description); + var width = headerFoldoutStyle.CalcSize(content).x + 16; + + BGEditorUtility.SwapLabelWidth((int) width, () => + { + //foldout (we dont use layout version cause it does not support clickin on labels) + Collapsed = EditorGUI.Foldout( + GUILayoutUtility.GetRect(width, 16f), + Collapsed, + content, + true, + Cc.enabled ? headerFoldoutStyle : headerFoldoutStyleDisabled); + }); + }); + + GUILayout.FlexibleSpace(); + + // status(error or Ok) + EditorGUI.LabelField(GUILayoutUtility.GetRect(70, 16, EditorStyles.label), hasError ? "Error" : "Ok.", hasError ? errorStyle : okStyle); + + + //help url + if (!String.IsNullOrEmpty(Cc.HelpURL)) + { + if (BGEditorUtility.ButtonWithIcon(helpTexture, "Open help in the browser")) Application.OpenURL(Cc.HelpURL); + EditorGUILayout.Separator(); + } + + //change name + if (BGEditorUtility.ButtonWithIcon(changeNameTexture, "Change the name")) BGCcChangeNameWindow.Open(Cc); + EditorGUILayout.Separator(); + + //add a child + if (BGEditorUtility.ButtonWithIcon(addTexture, "Add a component, which is dependant on this component")) + BGCcAddWindow.Open(MyTree.Curve, type => + { + //cache some data + var gameObject = Cc.Curve.gameObject; + var oldComponents = gameObject.GetComponents(); + var currentCcType = Cc.GetType(); + + //add + var addedCc = AddComponent(MyTree.Curve, type); + if (addedCc == null) return; + + //we need to process all the way up to the Cc and link Ccs to right (newly created) parents + var parentClass = addedCc.GetParentClass(); + var recursionLimit = 16; + var cc = addedCc; + while (parentClass!=null && recursionLimit-- > 0) + { + if (currentCcType == parentClass) + { + //we reached the current Cc + cc.SetParent(Cc); + break; + } + + //going up + var possibleParents = gameObject.GetComponents(parentClass); + var parent = possibleParents.Where(possibleParent => !oldComponents.Contains(possibleParent)).Cast().FirstOrDefault(); + + if (parent == null) break; + + cc.SetParent(parent); + cc = parent; + parentClass = cc.GetParentClass(); + } + }, Cc.GetType()); + EditorGUILayout.Separator(); + + + //enable/disable + if (BGEditorUtility.ButtonWithIcon(Cc.enabled ? enabledTexture : disabledTexture, "Enable/disable a component")) Enable(!Cc.enabled); + EditorGUILayout.Separator(); + + //delete + if (!BGEditorUtility.ButtonWithIcon(deleteTexture, "Remove this component")) return; + + + //remove + Delete(); + + EditorUtility.SetDirty(MyTree.Curve.gameObject); + + //not sure how to make proper exit + throw new BGEditorUtility.ExitException(); + }); + }); + } + + private void Enable(bool enabled) + { + Cc.enabled = enabled; + IterateChildren(node => node.Enable(enabled)); + } + + public void Delete() + { + IterateChildren(node => node.Delete()); + + if (ccEditor != null) + { + ccEditor.ChangedParent -= ChangedParent; + Object.DestroyImmediate(ccEditor); + } + + Undo.DestroyObjectImmediate(Cc); + } + + public void OnDestroy() + { + IterateChildren(node => node.OnDestroy()); + + if (ccEditor == null) return; + + ccEditor.ChangedParent -= ChangedParent; + Object.DestroyImmediate(ccEditor); + } + + public void OnSceneGui() + { + IterateChildren(node => node.OnSceneGui()); + + if (onSceneGuiMethod != null) onSceneGuiMethod.Invoke(ccEditor, null); + } + + public void FillState(Dictionary instanceId2Collapsed) + { + if (Collapsed) instanceId2Collapsed[Cc.GetInstanceID()] = true; + + IterateChildren(node => node.FillState(instanceId2Collapsed)); + } + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs.meta new file mode 100644 index 0000000..4708210 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorComponents.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e8f1f93e9ec8ac46a3c01f3077087df +timeCreated: 1471761097 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs new file mode 100644 index 0000000..18d9b6f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs @@ -0,0 +1,982 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCurveEditorFields : BGCurveEditorTab + { + //label width in percents + private const int LabelWidth = 30; + + // ====================================== Fields + private readonly Texture2D deleteIcon; + private readonly Texture2D addIcon; + + + private TableUi systemUi; + private TableUi customUi; + + private SystemField[] systemFields; + private PointField[] customFields; + private string newFieldName; + private BGCurvePointField.TypeEnum newFieldType; + private readonly BGCurveEditorPointsSelection editorSelection; + + public BGCurveEditorFields(BGCurveEditor editor, SerializedObject curveObject, BGCurveEditorPointsSelection editorSelection) + : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGFields123)) + { + this.editorSelection = editorSelection; + + addIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); + deleteIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); + } + + + // ================================================================================ Inspector + public override void OnInspectorGui() + { + var settings = BGPrivateField.GetSettings(Curve); + + BGEditorUtility.HelpBox("Curve UI is disabled in settings. All handles are disabled too.", MessageType.Warning, !settings.ShowCurve); + + BGEditorUtility.Assign(ref customUi, () => new TableUi("Custom fields", new[] {"#", "Name", "Type", "?", "Delete"}, new[] {5, 40, 40, 5, 10})); + BGEditorUtility.Assign(ref systemUi, () => new TableUi("System fields", new[] {"Name", "Value"}, new[] {LabelWidth, 100 - LabelWidth})); + + BGEditorUtility.Assign(ref systemFields, () => new[] + { + (SystemField) new SystemFieldPosition(settings), + new SystemFieldControls(settings), + new SystemFieldControlsType(settings), + new SystemFieldTransform(settings), + }); + + var fields = Curve.Fields; + var hasFields = fields != null && fields.Length > 0; + + if (hasFields && (customFields == null || customFields.Length != fields.Length) || !hasFields && customFields != null && customFields.Length != fields.Length) + { + customFields = new PointField[fields.Length]; + + for (var i = 0; i < fields.Length; i++) customFields[i] = new PointField(fields[i], i, deleteIcon); + } + + + //warnings + BGEditorUtility.HelpBox("All handles for positions are disabled.", MessageType.Warning, settings.HandlesSettings.Disabled); + BGEditorUtility.HelpBox("All handles for controls are disabled.", MessageType.Warning, settings.ControlHandlesSettings.Disabled); + + //====================== Custom fields + customUi.Init(); + //add row + customUi.NextColumn(rect => EditorGUI.LabelField(rect, "Name"), 12); + customUi.NextColumn(rect => newFieldName = EditorGUI.TextField(rect, newFieldName), 28); + customUi.NextColumn(rect => BGEditorUtility.PopupField(rect, newFieldType, @enum => newFieldType = (BGCurvePointField.TypeEnum) @enum), 50); + customUi.NextColumn(rect => + { + if (!GUI.Button(rect, addIcon)) return; + + if (NameHasError(Curve, newFieldName)) return; + + BGPrivateField.Invoke(Curve, BGCurve.MethodAddField, newFieldName, newFieldType, (Func) (() => Undo.AddComponent(Curve.gameObject))); + GUIUtility.hotControl = 0; + GUIUtility.ExitGUI(); + }, 10); + + customUi.NextRow(); + var warning = ""; + + if (customFields == null || customFields.Length == 0) customUi.NextRow("Name should be 16 chars max, starts with a letter and contain English chars and numbers only."); + else + { + //header + customUi.DrawHeaders(); + + //fields + var quaternionWithHandlesCount = 0; + + BGEditorUtility.ChangeCheck(() => + { + foreach (var customField in customFields) + { + if (customField.Field.Type == BGCurvePointField.TypeEnum.Quaternion && BGPrivateField.GetHandlesType(customField.Field) != 0) quaternionWithHandlesCount++; + customField.Ui(customUi); + } + }, SceneView.RepaintAll); + + if (quaternionWithHandlesCount > 1) warning = "You have more than one Quaternion field with Handles enabled. Only first field will be shown in Scene View"; + //footer + customUi.NextRow("?- Show in Points Menu/Scene View"); + } + //inform layout manager + GUILayoutUtility.GetRect(customUi.Width, customUi.Height); + + BGEditorUtility.HelpBox(warning, MessageType.Warning, warning.Length > 0); + + //====================== System fields + systemUi.Init(); + + BGEditorUtility.ChangeCheck(() => + { + foreach (var field in systemFields) field.Ui(systemUi); + }, SceneView.RepaintAll); + + //inform layout manager + GUILayoutUtility.GetRect(systemUi.Width, systemUi.Height); + GUILayout.Space(4); + } + + private static bool NameHasError(BGCurve curve, string name) + { + var error = BGCurvePointField.CheckName(curve, name); + if (error == null) return false; + + BGEditorUtility.Inform("Error", error); + return true; + } + + + public override string GetStickerMessage(ref MessageType type) + { + return "" + Curve.FieldsCount; + } + + + public override void OnSceneGui(Plane[] frustum) + { + if (Curve.PointsCount == 0) return; + + //show handles (including labels) if any + PointField.OnSceneGui(frustum, Curve, Settings, editorSelection); + } + + //=================================================== UI Builder (idea.. refactor it later) + private sealed class TableUi + { + private const float Offset = 10; + private const int TitleOffset = 10; + + private readonly string[] headers; //headers + private readonly int[] sizes; //column sizes percentages + private readonly float height; //line height + + private readonly GUIStyle headerStyle; + private readonly GUIStyle cellStyle; + private readonly GUIStyle titleStyle; + private readonly GUIStyle centeredLabelStyle; + + private readonly string title; + + public GUIStyle CenteredLabelStyle + { + get { return centeredLabelStyle; } + } + + + private Rect lastRect; //last rect from Layout manager + + public float Width { get; private set; } + + public float Height + { + get { return rows*height + Offset; } + } + + public int[] Sizes + { + get { return sizes; } + } + + private float rows; //not data, but ui lines + private Vector2 cursor; + private int currentColumn; + + public TableUi(string title, string[] headers, int[] sizes) + { + this.headers = headers; + this.sizes = sizes; + this.title = title; + + headerStyle = new GUIStyle(GetStyle(BGEditorUtility.Image.BGBoxWithBorder123)); + centeredLabelStyle = new GUIStyle("Label") {alignment = TextAnchor.MiddleCenter}; + + cellStyle = GetStyle(BGEditorUtility.Image.BGTableCell123); + titleStyle = GetStyle(BGEditorUtility.Image.BGTableTitle123); + titleStyle.border = titleStyle.padding = new RectOffset(TitleOffset, TitleOffset, 2, 2); + + height = cellStyle.CalcSize(new GUIContent("Test")).y; + + Init(); + } + + public void Init() + { + //---------------------------------- init sizes + lastRect = GUILayoutUtility.GetLastRect(); + Width = lastRect.width; + cursor = new Vector2(lastRect.xMin, lastRect.yMax + Offset); + rows = 0; + currentColumn = 0; + + //---------------------------------- title + EditorGUI.LabelField(new Rect(cursor.x, cursor.y, titleStyle.CalcSize(new GUIContent(title)).x + TitleOffset*2, height), title, titleStyle); + NextRow(); + } + + //---------------------------------- headers + public void DrawHeaders() + { + for (var i = 0; i < headers.Length; i++) NextColumn(rect => EditorGUI.LabelField(rect, headers[i]), sizes[i], true); + NextRow(); + } + + private static GUIStyle GetStyle(BGEditorUtility.Image background) + { + return new GUIStyle("Label") + { + padding = new RectOffset(2, 2, 2, 2), + border = new RectOffset(2, 2, 2, 2), + normal = new GUIStyleState + { + background = BGEditorUtility.LoadTexture2D(background) + } + }; + } + + public void NextColumn(string label, Action action, int widthInPercent = 0, GUIStyle labelStyle = null, bool header = false) + { + var columnWidth = Width*(widthInPercent > 0 ? widthInPercent : sizes[currentColumn])/100f; + + var rect = new Rect(cursor.x, cursor.y, columnWidth, height); + EditorGUI.LabelField(rect, "", header ? headerStyle : cellStyle); + + if (label != null) + { + rect.width /= 2; + EditorGUI.LabelField(rect, label, labelStyle ?? GUI.skin.label); + rect.x += rect.width; + } + + if (action != null) action(rect); + + cursor.x += columnWidth; + currentColumn++; + } + + public void NextColumn(Action action, int widthInPercent = 0, bool header = false) + { + NextColumn(null, action, widthInPercent, header: header); + } + + public void NextColumn(string label, string description, int widthInPercent = 0, bool header = false) + { + NextColumn(rect => EditorGUI.LabelField(rect, new GUIContent(label, description)), widthInPercent, header); + } + + public void NextRow() + { + cursor.x = lastRect.xMin; + cursor.y += height; + currentColumn = 0; + rows++; + } + + public void NextRow(string message) + { + EditorGUI.LabelField(new Rect(cursor.x, cursor.y, Width, height), message, cellStyle); + NextRow(); + } + } + + //=========================================================================================== Custom fields + private sealed class PointField + { + private enum HandlesType + { + None, + Label, + Direction, + DistanceFromPoint, + Bounds, + BoundsAroundPoint, + Link, + Rotation + } + + private readonly BGCurvePointField field; + private readonly int index; + private readonly Texture2D deleteIcon; + + private static readonly Dictionary Type2SupportHandles = new Dictionary(); + private static readonly Dictionary Type2Handles = new Dictionary(); + + private static readonly Func FieldWithHandlesPredicate = + field => BGPrivateField.GetShowHandles(field) && SupportHandles(field.Type) && BGPrivateField.GetHandlesType(field) != 0; + + private static readonly Func FieldWithLabelPredicate = field => BGPrivateField.GetHandlesType(field) == (int) HandlesType.Label; + + private static Color[] handlesColor; + private static GUIStyle labelStyle; + private static GUIStyle selectedlabelStyle; + + private static bool[] visiblePoints; + private static Color32 latestLabelBackColor; + + public BGCurvePointField Field + { + get { return field; } + } + + static PointField() + { + Register(BGCurvePointField.TypeEnum.Bool, new Enum[] {HandlesType.None, HandlesType.Label}); + Register(BGCurvePointField.TypeEnum.Int, new Enum[] {HandlesType.None, HandlesType.Label}); + Register(BGCurvePointField.TypeEnum.Float, new Enum[] {HandlesType.None, HandlesType.Label, HandlesType.DistanceFromPoint}); + Register(BGCurvePointField.TypeEnum.String, new Enum[] {HandlesType.None, HandlesType.Label}); + + Register(BGCurvePointField.TypeEnum.Vector3, new Enum[] {HandlesType.None, HandlesType.Label, HandlesType.Direction, HandlesType.BoundsAroundPoint}); + Register(BGCurvePointField.TypeEnum.Bounds, new Enum[] {HandlesType.None, HandlesType.Bounds}); + Register(BGCurvePointField.TypeEnum.Quaternion, new Enum[] {HandlesType.None, HandlesType.Rotation}); + Register(BGCurvePointField.TypeEnum.Color, new Enum[] {HandlesType.None, HandlesType.Label}); + + Register(BGCurvePointField.TypeEnum.GameObject, new Enum[] {HandlesType.None, HandlesType.Label, HandlesType.Link}); + Register(BGCurvePointField.TypeEnum.Component, new Enum[] {HandlesType.None, HandlesType.Label}); + + Register(BGCurvePointField.TypeEnum.BGCurve, new Enum[] {HandlesType.None, HandlesType.Link}); + Register(BGCurvePointField.TypeEnum.BGCurvePointComponent, new Enum[] {HandlesType.None, HandlesType.Label, HandlesType.Link}); + Register(BGCurvePointField.TypeEnum.BGCurvePointGO, new Enum[] {HandlesType.None, HandlesType.Label, HandlesType.Link}); + } + + private static void Register(BGCurvePointField.TypeEnum typeEnum, Enum[] handlesTypes) + { + Type2SupportHandles[typeEnum] = true; + Type2Handles[typeEnum] = handlesTypes; + } + + public PointField(BGCurvePointField field, int index, Texture2D deleteIcon) + { + this.field = field; + this.index = index; + this.deleteIcon = deleteIcon; + } + + public void Ui(TableUi ui) + { + var cursor = 0; + + // ========================== First row + //number + ui.NextColumn("" + index, "Field's index", GetWidth(ui, ref cursor)); + + //name + ui.NextColumn(rect => + { + BGEditorUtility.TextField(rect, field.FieldName, s => + { + if (NameHasError(field.Curve, s)) return; + Change(() => field.FieldName = s); + }, true); + }, GetWidth(ui, ref cursor)); + + //type + ui.NextColumn(field.Type.ToString(), "Field's Type", GetWidth(ui, ref cursor)); + + //show in Points menu + ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowInPointsMenu(field), b => Change(() => BGPrivateField.SetShowInPointsMenu(field, b))), + GetWidth(ui, ref cursor)); + + //delete icon + ui.NextColumn(rect => + { + if (!GUI.Button(rect, deleteIcon) || !BGEditorUtility.Confirm("Delete", "Are you sure you want to delete '" + field.FieldName + "' field?", "Delete")) return; + + BGPrivateField.Invoke(field.Curve, BGCurve.MethodDeleteField, field, (Action) Undo.DestroyObjectImmediate); + + GUIUtility.ExitGUI(); + }, GetWidth(ui, ref cursor)); + + //\r\n + ui.NextRow(); + + // ========================== Second row + //does not support + if (!SupportHandles(field.Type)) return; + + ui.NextColumn(" Handles", "Field's index", 25); + + //handles type + ui.NextColumn( + rect => BGEditorUtility.PopupField(rect, (HandlesType) BGPrivateField.GetHandlesType(field), Type2Handles[field.Type], + b => Change(() => BGPrivateField.SetHandlesType(field, (int) ((HandlesType) b)))), 30); + + //Handles color + ui.NextColumn(rect => BGEditorUtility.ColorField(rect, BGPrivateField.GetHandlesColor(field), b => Change(() => BGPrivateField.SetHandlesColor(field, b))), 30); + + //show handles in Scene View + ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowHandles(field), b => Change(() => BGPrivateField.SetShowHandles(field, b))), 5); + + //empty column under delete button + ui.NextColumn(rect => EditorGUI.LabelField(rect, ""), 10); + + //\r\n + ui.NextRow(); + } + + private void Change(Action action) + { + Undo.RecordObject(field, "Field change"); + action(); + EditorUtility.SetDirty(field); + } + + private static bool SupportHandles(BGCurvePointField.TypeEnum typeEnum) + { + return Type2SupportHandles.ContainsKey(typeEnum); + } + + private static int GetWidth(TableUi ui, ref int cursor) + { + var widthInPercent = ui.Sizes[cursor]; + cursor++; + return widthInPercent; + } + + public static void OnSceneGui(Plane[] frustum, BGCurve curve, BGCurveSettings settings, BGCurveEditorPointsSelection editorSelection) + { + Array.Resize(ref visiblePoints, curve.PointsCount); + curve.ForEach((point, i, count) => visiblePoints[i] = GeometryUtility.TestPlanesAABB(frustum, new Bounds(point.PositionWorld, Vector3.one))); + + + var fieldsCount = curve.FieldsCount; + var fields = curve.Fields; + var showPointsNumbers = settings.ShowLabels; + + var fieldsWithHandlesCount = 0; + var fieldsWithLabelCount = 0; + if (fieldsCount > 0) + { + fieldsWithHandlesCount = fields.Count(FieldWithHandlesPredicate); + if (fieldsWithHandlesCount > 0) + { + Array.Resize(ref handlesColor, fieldsWithHandlesCount); + var cursor = 0; + for (var i = 0; i < fieldsCount; i++) + { + var f = fields[i]; + if (!FieldWithHandlesPredicate(f)) continue; + + if (FieldWithLabelPredicate(f)) fieldsWithLabelCount++; + handlesColor[cursor++] = BGPrivateField.GetHandlesColor(f); + } + } + } + + // nothing to show + if (!showPointsNumbers && fieldsWithHandlesCount == 0) return; + + + if (fieldsWithHandlesCount > 0) + { + //not a label + curve.ForEach((point, i, length) => + { + if (!visiblePoints[i]) return; + + var pos = point.PositionWorld; + + var quanterionShown = false; + var fieldCursor = 0; + for (var j = 0; j < fields.Length; j++) + { + var field = fields[j]; + var handlesType = (HandlesType) BGPrivateField.GetHandlesType(field); + + if (handlesType == 0) continue; + + if (handlesType == HandlesType.Label) + { + fieldCursor++; + continue; + } + + var color = handlesColor[fieldCursor++]; + switch (handlesType) + { + case HandlesType.DistanceFromPoint: + BGEditorUtility.SwapHandlesColor(color, () => + Handles.CircleCap(0, pos, Quaternion.LookRotation(SceneView.currentDrawingSceneView.camera.transform.position - pos), point.GetField(field.FieldName))); + break; + case HandlesType.BoundsAroundPoint: + Bounds bounds; + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bounds: + bounds = point.GetField(field.FieldName); + bounds.center = pos; + break; + default: + //vector3 + var vector3 = point.GetField(field.FieldName); + bounds = new Bounds(pos, vector3); + break; + } + BGEditorUtility.DrawBound(bounds, new Color(color.r, color.g, color.b, 0.05f), color); + break; + case HandlesType.Bounds: + var boundsValue = point.GetField(field.FieldName); + if (boundsValue.extents != Vector3.zero) + { + BGEditorUtility.DrawBound(boundsValue, new Color(color.r, color.g, color.b, 0.05f), color); + BGEditorUtility.SwapHandlesColor(color, () => Handles.DrawDottedLine(boundsValue.center, pos, 4)); + } + break; + case HandlesType.Direction: + var vector3Value = point.GetField(field.FieldName); + if (vector3Value != Vector3.zero) + BGEditorUtility.SwapHandlesColor(color, () => Handles.ArrowCap(0, pos, Quaternion.LookRotation(vector3Value), vector3Value.magnitude)); + break; + case HandlesType.Rotation: + if (quanterionShown) break; + + quanterionShown = true; + + var quaternionValue = point.GetField(field.FieldName); + if (quaternionValue.x < BGCurve.Epsilon && quaternionValue.y < BGCurve.Epsilon && quaternionValue.z < BGCurve.Epsilon && quaternionValue.w < BGCurve.Epsilon) + quaternionValue = Quaternion.identity; + + var newValue = Handles.RotationHandle(quaternionValue, pos); + point.SetField(field.FieldName, newValue); + + + BGEditorUtility.SwapHandlesColor(color, () => + { + var rotated = newValue*Vector3.forward*BGEditorUtility.GetHandleSize(pos, 2); + var toPos = pos + rotated; + Handles.ArrowCap(0, toPos, newValue, 1); + Handles.DrawDottedLine(pos, toPos, 10); + }); + break; + case HandlesType.Link: + switch (field.Type) + { + case BGCurvePointField.TypeEnum.GameObject: + var go = point.GetField(field.FieldName); + if (go != null) BGEditorUtility.SwapHandlesColor(color, () => Handles.DrawDottedLine(go.transform.position, pos, 4)); + break; + case BGCurvePointField.TypeEnum.BGCurve: + var bgCurve = point.GetField(field.FieldName); + if (bgCurve != null) BGEditorUtility.SwapHandlesColor(color, () => Handles.DrawDottedLine(bgCurve.transform.position, pos, 4)); + break; + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + var pointComponent = point.GetField(field.FieldName); + if (pointComponent != null) BGEditorUtility.SwapHandlesColor(color, () => Handles.DrawDottedLine(pointComponent.PositionWorld, pos, 4)); + break; + case BGCurvePointField.TypeEnum.BGCurvePointGO: + var pointGO = point.GetField(field.FieldName); + if (pointGO != null) BGEditorUtility.SwapHandlesColor(color, () => Handles.DrawDottedLine(pointGO.PositionWorld, pos, 4)); + break; + } + break; + } + } + }); + } + + // nothing more to show + if (!showPointsNumbers && fieldsWithLabelCount == 0) return; + + //=============================== Labels + + //styles + var labelColor = settings.LabelColor; + var selectedColor = settings.LabelColorSelected; + var backColor = BGCurveSettingsForEditor.ColorForLabelBackground; + + if (labelStyle == null || labelStyle.normal.textColor != labelColor || labelStyle.normal.background == null + || latestLabelBackColor.r != backColor.r || latestLabelBackColor.g != backColor.g || latestLabelBackColor.b != backColor.b || latestLabelBackColor.a != backColor.a) + { + latestLabelBackColor = backColor; + labelStyle = new GUIStyle("Label") + { + richText = true, + border = new RectOffset(2, 2, 2, 2), + clipping = TextClipping.Overflow, + wordWrap = false, + normal = + { + background = BGEditorUtility.TextureWithBorder(8, 1, backColor, new Color32(backColor.r, backColor.g, backColor.b, 255)), + textColor = labelColor + } + }; + + selectedlabelStyle = new GUIStyle(labelStyle) + { + normal = + { + background = BGEditorUtility.TextureWithBorder(8, 1, new Color(selectedColor.r, selectedColor.g, selectedColor.b, .1f), selectedColor), + textColor = selectedColor + } + }; + } + + + curve.ForEach((point, i, length) => + { + if (!visiblePoints[i]) return; + + var pos = point.PositionWorld; + + var style = !editorSelection.Contains(point) ? labelStyle : selectedlabelStyle; + var text = ""; + + //point numbers and pos + if (showPointsNumbers) + { + text += "# : " + i + "\r\n"; + if (settings.ShowPositions) text += "P : " + pos + "\r\n"; + } + + //fields + if (fieldsWithLabelCount > 0) + { + for (var j = 0; j < fieldsCount; j++) + { + var field = fields[j]; + if (!FieldWithHandlesPredicate(field) || !FieldWithLabelPredicate(field)) continue; + + text += BGEditorUtility.ColorIt(curve.IndexOf(field) + " : " + point.GetField(field.FieldName, BGCurvePoint.FieldTypes.GetType(field.Type)), + BGEditorUtility.ToHex(BGPrivateField.GetHandlesColor(field))) + "\r\n"; + } + } + + var normalized = (SceneView.currentDrawingSceneView.camera.transform.position - pos).normalized; + var handleSize = BGEditorUtility.GetHandleSize(pos, .25f); + var shiftLeft = -Vector3.Cross(normalized, Vector3.up); + var shiftBottom = Vector3.Cross(normalized, Vector3.right)*.3f; + Handles.Label(pos + handleSize*shiftLeft + handleSize*shiftBottom, text.Substring(0, text.Length - 2), style); + }); + } + } + + //=========================================================================================== Abstract system field + private abstract class SystemField + { + protected readonly BGCurveSettings Settings; + + public virtual bool ShowInPointsMenu { get; set; } + + private readonly GUIContent title; + + protected SystemField(BGCurveSettings settings, GUIContent title) + { + this.title = title; + Settings = settings; + } + + public virtual void Ui(TableUi ui) + { + ui.NextColumn(rect => EditorGUI.LabelField(rect, title), 100, true); + ui.NextRow(); + + // show in point menu + NextBoolRow(ui, "Show in Points Menu", "Show in Points Menu (Points Tab)", ShowInPointsMenu, newValue => ShowInPointsMenu = newValue); + } + + protected void NextBoolRow(TableUi ui, string label, string tooltip, bool value, Action valueSetter) + { + ui.NextColumn(label, tooltip); + ui.NextColumn(rect => BGEditorUtility.ToggleField(rect, value, valueSetter)); + ui.NextRow(); + } + + protected void NextEnumRow(TableUi ui, string label, string tooltip, Enum value, Action valueSetter) + { + ui.NextColumn(label, tooltip); + ui.NextColumn(rect => BGEditorUtility.PopupField(rect, value, valueSetter)); + ui.NextRow(); + } + + protected void NextSliderRow(TableUi ui, string label, string tooltip, float value, float from, float to, Action valueSetter) + { + ui.NextColumn(label, tooltip); + ui.NextColumn(rect => BGEditorUtility.SliderField(rect, value, @from, to, valueSetter)); + ui.NextRow(); + } + + protected void NextColorRow(TableUi ui, string label, string tooltip, Color color, Action func) + { + ui.NextColumn(label, tooltip); + ui.NextColumn(rect => BGEditorUtility.ColorField(rect, color, func)); + ui.NextRow(); + } + } + + //=========================================================================================== Abstract Vector(s) Based Field + private abstract class SystemVectorField : SystemField + { + public virtual bool ShowHandles { get; set; } + + public virtual BGCurveSettings.HandlesTypeEnum HandlesType { get; set; } + + public virtual BGCurveSettings.SettingsForHandles HandlesSettings + { + get { return null; } + } + + public virtual bool ShowLabels { get; set; } + public virtual bool ShowPositions { get; set; } + public virtual Color LabelColor { get; set; } + + protected SystemVectorField(BGCurveSettings settings, GUIContent title) + : base(settings, title) + { + } + + private void Next3BoolRow(TableUi ui, string label, string tooltip, + string xLabel, string yLabel, string zLabel, + bool xValue, bool yValue, bool zValue, + Action xSetter, Action ySetter, Action zSetter) + { + ui.NextColumn(label, tooltip); + const int widthInPercent = (100 - LabelWidth)/3; + ui.NextColumn(xLabel, rect => BGEditorUtility.ToggleField(rect, xValue, xSetter), widthInPercent, ui.CenteredLabelStyle); + ui.NextColumn(yLabel, rect => BGEditorUtility.ToggleField(rect, yValue, ySetter), widthInPercent, ui.CenteredLabelStyle); + ui.NextColumn(zLabel, rect => BGEditorUtility.ToggleField(rect, zValue, zSetter), widthInPercent, ui.CenteredLabelStyle); + ui.NextRow(); + } + + public override void Ui(TableUi ui) + { + base.Ui(ui); + + NextBoolRow(ui, "Show Handles", "Show handles in Scene View", ShowHandles, newValue => ShowHandles = newValue); + if (ShowHandles) + { + NextEnumRow(ui, " Handles Types", "Type for the handle", HandlesType, newValue => HandlesType = (BGCurveSettings.HandlesTypeEnum) newValue); + + if (HandlesType == BGCurveSettings.HandlesTypeEnum.Configurable) + { + NextSliderRow(ui, " Handles Axis Size", "Size of the Axis handles in Scene View", HandlesSettings.AxisScale, .5f, 1.5f, newValue => HandlesSettings.AxisScale = newValue); + NextSliderRow(ui, " Handles Plane Size", "Size of the Plane handles in Scene View", HandlesSettings.PlanesScale, .5f, 1.5f, + newValue => HandlesSettings.PlanesScale = newValue); + NextSliderRow(ui, " Handles Alpha", "Alpha color of handles in Scene View", HandlesSettings.Alpha, .5f, 1f, newValue => HandlesSettings.Alpha = newValue); + + Next3BoolRow(ui, " Remove Axis", "Remove Axis handles", + "X", "Y", "Z", + HandlesSettings.RemoveX, HandlesSettings.RemoveY, HandlesSettings.RemoveZ, + newValue => HandlesSettings.RemoveX = newValue, newValue => HandlesSettings.RemoveY = newValue, newValue => HandlesSettings.RemoveZ = newValue + ); + + Next3BoolRow(ui, " Remove Planes", "Remove Planes handles", + "XZ", "XY", "YZ", + HandlesSettings.RemoveXZ, HandlesSettings.RemoveXY, HandlesSettings.RemoveYZ, + newValue => HandlesSettings.RemoveXZ = newValue, newValue => HandlesSettings.RemoveXY = newValue, newValue => HandlesSettings.RemoveYZ = newValue + ); + } + } + + NextBoolRow(ui, "Show Labels", "Show labels in Scene View", ShowLabels, newValue => ShowLabels = newValue); + if (ShowLabels) + { + NextBoolRow(ui, " Show Positions", "Show vector positions in Scene View", ShowPositions, newValue => ShowPositions = newValue); + NextColorRow(ui, " Labels color", "Color for labels in Scene View", LabelColor, newValue => LabelColor = newValue); + AdditionalLabelFields(ui); + } + } + + protected virtual void AdditionalLabelFields(TableUi ui) + { + } + } + + //=========================================================================================== Position + private sealed class SystemFieldPosition : SystemVectorField + { + public override bool ShowHandles + { + get { return Settings.ShowHandles; } + set { Settings.ShowHandles = value; } + } + + public override BGCurveSettings.SettingsForHandles HandlesSettings + { + get { return Settings.HandlesSettings; } + } + + public override BGCurveSettings.HandlesTypeEnum HandlesType + { + get { return Settings.HandlesType; } + set { Settings.HandlesType = value; } + } + + public override bool ShowInPointsMenu + { + get { return Settings.ShowPointPosition; } + set { Settings.ShowPointPosition = value; } + } + + public override bool ShowLabels + { + get { return Settings.ShowLabels; } + set { Settings.ShowLabels = value; } + } + + public override bool ShowPositions + { + get { return Settings.ShowPositions; } + set { Settings.ShowPositions = value; } + } + + public override Color LabelColor + { + get { return Settings.LabelColor; } + set { Settings.LabelColor = value; } + } + + private Color LabelColorSelected + { + get { return Settings.LabelColorSelected; } + set { Settings.LabelColorSelected = value; } + } + + private bool ShowSpheres + { + get { return Settings.ShowSpheres; } + set { Settings.ShowSpheres = value; } + } + + private float SpheresRadius + { + get { return Settings.SphereRadius; } + set { Settings.SphereRadius = value; } + } + + private Color SpheresColor + { + get { return Settings.SphereColor; } + set { Settings.SphereColor = value; } + } + + public SystemFieldPosition(BGCurveSettings settings) + : base(settings, new GUIContent("Positions", "Point's positions")) + { + } + + protected override void AdditionalLabelFields(TableUi ui) + { + NextColorRow(ui, "Labels color for selected", "Color for labels in Scene View, when they are selected", LabelColorSelected, newValue => LabelColorSelected = newValue); + } + + public override void Ui(TableUi ui) + { + base.Ui(ui); + + NextBoolRow(ui, "Show spheres", "Show spheres at points positions in Scene View", ShowSpheres, b => ShowSpheres = b); + if (ShowSpheres) + { + NextSliderRow(ui, " Sphere radius", "Sphere radius in Scene View", SpheresRadius, .01f, 1, f => SpheresRadius = f); + NextColorRow(ui, " Sphere color", "Sphere color in Scene View", SpheresColor, f => SpheresColor = f); + } + } + } + + //=========================================================================================== Controls + private sealed class SystemFieldControls : SystemVectorField + { + public override bool ShowHandles + { + get { return Settings.ShowControlHandles; } + set { Settings.ShowControlHandles = value; } + } + + public override BGCurveSettings.HandlesTypeEnum HandlesType + { + get { return Settings.ControlHandlesType; } + set { Settings.ControlHandlesType = value; } + } + + + public override BGCurveSettings.SettingsForHandles HandlesSettings + { + get { return Settings.ControlHandlesSettings; } + } + + public override bool ShowInPointsMenu + { + get { return Settings.ShowPointControlPositions; } + set { Settings.ShowPointControlPositions = value; } + } + + public override bool ShowLabels + { + get { return Settings.ShowControlLabels; } + set { Settings.ShowControlLabels = value; } + } + + public override bool ShowPositions + { + get { return Settings.ShowControlPositions; } + set { Settings.ShowControlPositions = value; } + } + + private Color HandlesColor + { + get { return Settings.ControlHandlesColor; } + set { Settings.ControlHandlesColor = value; } + } + + public override Color LabelColor + { + get { return Settings.LabelControlColor; } + set { Settings.LabelControlColor = value; } + } + + + public SystemFieldControls(BGCurveSettings settings) + : base(settings, new GUIContent("Controls", "Point's Bezier control positions")) + { + } + + public override void Ui(TableUi ui) + { + base.Ui(ui); + + NextColorRow(ui, "Handles Color", "Color of handles in Scene View", HandlesColor, newValue => HandlesColor = newValue); + } + } + + + //=========================================================================================== Control Type + private sealed class SystemFieldControlsType : SystemField + { + public override bool ShowInPointsMenu + { + get { return Settings.ShowPointControlType; } + set { Settings.ShowPointControlType = value; } + } + + public SystemFieldControlsType(BGCurveSettings settings) + : base(settings, new GUIContent("Control Type", "Point's control type (Absent, Bezier)")) + { + } + } + + //=========================================================================================== Transform Field + private sealed class SystemFieldTransform : SystemField + { + public override bool ShowInPointsMenu + { + get { return Settings.ShowTransformField; } + set { Settings.ShowTransformField = value; } + } + + public SystemFieldTransform(BGCurveSettings settings) + : base(settings, new GUIContent("Transform", "Transform to use as point's position")) + { + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs.meta new file mode 100644 index 0000000..6b40990 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorFields.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7939caedfb503f9489e4f0524336a58b +timeCreated: 1471761766 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs new file mode 100644 index 0000000..a5c7938 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs @@ -0,0 +1,526 @@ +using System; +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + //one single point's GUI + public class BGCurveEditorPoint + { + private readonly Texture2D deleteTexture; + private readonly Texture2D addBeforeTexture; + private readonly Texture2D moveUpTexture; + private readonly Texture2D moveDownTexture; + private readonly Texture2D copyTexture; + private readonly Texture2D pasteTexture; + + private readonly BGCurveEditorPointsSelection editorSelection; + private readonly Func mathProvider; + + private GUIStyle controlLabelStyle; + + public BGCurveEditorPoint(Func mathProvider, BGCurveEditorPointsSelection editorSelection) + { + this.mathProvider = mathProvider; + this.editorSelection = editorSelection; + + //textures + deleteTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); + addBeforeTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); + moveUpTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGMoveUp123); + moveDownTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGMoveDown123); + copyTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCopy123); + pasteTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPaste123); + } + + internal void OnInspectorGui(BGCurvePointI point, int index, BGCurveSettings settings) + { + var mode2D = point.Curve.Mode2D; + + + //point transform + if (point.Curve.PointsMode != BGCurve.PointsModeEnum.Inlined && point.PointTransform != null) + { + var referenceToPoint = BGCurveReferenceToPoint.GetReferenceToPoint(point); + if (referenceToPoint == null) point.PointTransform.gameObject.AddComponent().Point = point; + } + + BGEditorUtility.HorizontalBox(() => + { + if (editorSelection != null) editorSelection.InspectorSelectionRect(point); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.SwapLabelWidth(60, () => + { + if (!settings.ShowPointPosition && !settings.ShowPointControlType) + { + BGEditorUtility.Horizontal(() => + { + //nothing to show- only label + EditorGUILayout.LabelField("Point " + index); + PointButtons(point, index, settings); + }); + BGEditorUtility.StartIndent(1); + } + else + { + //control type + if (settings.ShowPointControlType) + { + BGEditorUtility.Horizontal(() => + { + point.ControlType = (BGCurvePoint.ControlTypeEnum) EditorGUILayout.EnumPopup("Point " + index, point.ControlType); + PointButtons(point, index, settings); + }); + BGEditorUtility.StartIndent(1); + } + + //position + if (settings.ShowPointPosition) + { + if (!settings.ShowPointControlType) + { + BGEditorUtility.Horizontal(() => + { + PositionField("Point " + index, point, mode2D, index); + PointButtons(point, index, settings); + }); + BGEditorUtility.StartIndent(1); + } + else PositionField("Pos", point, mode2D, index); + } + } + }); + + // control positions + if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent && settings.ShowPointControlPositions) + { + // 1st + ControlField(point, mode2D, 1); + + // 2nd + ControlField(point, mode2D, 2); + } + + //transform + if (settings.ShowTransformField) + BGEditorUtility.ComponentField("Transform", point.PointTransform, transform => + { + if (transform != null) + { + Undo.RecordObject(transform, "Object moved"); + + if (point.Curve.PointsMode != BGCurve.PointsModeEnum.Inlined) Undo.AddComponent(transform.gameObject).Point = point; + } + + if (point.PointTransform != null) + { + var referenceToPoint = BGCurveReferenceToPoint.GetReferenceToPoint(point); + if (referenceToPoint != null) Undo.DestroyObjectImmediate(referenceToPoint); + } + + point.PointTransform = transform; + }); + + + //fields + if (point.Curve.FieldsCount > 0) ShowFields(point); + + BGEditorUtility.EndIndent(1); + }); + }); + } + + private void ControlField(BGCurvePointI point, BGCurve.Mode2DEnum mode2D, int index) + { + Vector3 pos; + string tooltipDetails, details; + Action newValueAction; + switch (BGCurveSettingsForEditor.InspectorControlCoordinateSpace) + { + case BGCurveSettingsForEditor.CoordinateSpaceEnum.Local: + tooltipDetails = "local"; + details = "L"; + if (index == 1) + { + pos = point.ControlFirstLocal; + newValueAction = vector3 => point.ControlFirstLocal = vector3; + } + else + { + pos = point.ControlSecondLocal; + newValueAction = vector3 => point.ControlSecondLocal = vector3; + } + break; + case BGCurveSettingsForEditor.CoordinateSpaceEnum.LocalTransformed: + tooltipDetails = "local transformed"; + details = "LT"; + + if (index == 1) + { + pos = point.ControlFirstLocalTransformed; + newValueAction = vector3 => point.ControlFirstLocalTransformed = vector3; + } + else + { + pos = point.ControlSecondLocalTransformed; + newValueAction = vector3 => point.ControlSecondLocalTransformed = vector3; + } + break; + case BGCurveSettingsForEditor.CoordinateSpaceEnum.World: + tooltipDetails = "world"; + details = "W"; + + if (index == 1) + { + pos = point.ControlFirstWorld; + newValueAction = vector3 => point.ControlFirstWorld = vector3; + } + else + { + pos = point.ControlSecondWorld; + newValueAction = vector3 => point.ControlSecondWorld = vector3; + } + break; + default: + throw new ArgumentOutOfRangeException("BGCurveSettingsForEditor.InspectorPointControlsCoordinates"); + } + + var label = "Control " + index + " (" + details + ")"; + var tooltip = "Point " + (index == 0 ? "1st" : "2nd") + " control position in " + tooltipDetails + " space. You can change points space in BGCurve Editor settings (gear icon)"; + + + + if (mode2D == BGCurve.Mode2DEnum.Off) BGEditorUtility.Vector3Field(label, tooltip, pos, newValueAction); + else Vector2Field(label, tooltip, pos, mode2D, newValueAction); + + } + + private void PositionField(string name, BGCurvePointI point, BGCurve.Mode2DEnum mode2D, int index) + { + var math = mathProvider(); + + Vector3 pos; + Action newValueAction; + string tooltipDetails; + string details; + switch (BGCurveSettingsForEditor.InspectorPointCoordinateSpace) + { + case BGCurveSettingsForEditor.CoordinateSpaceEnum.World: + pos = math == null ? point.PositionWorld : math.GetPosition(index); + newValueAction = vector3 => point.PositionWorld = vector3; + tooltipDetails = "world"; + details = "W"; + break; + case BGCurveSettingsForEditor.CoordinateSpaceEnum.LocalTransformed: + pos = point.PositionLocalTransformed; + newValueAction = vector3 => point.PositionLocalTransformed = vector3; + tooltipDetails = "local transformed"; + details = "LT"; + break; + case BGCurveSettingsForEditor.CoordinateSpaceEnum.Local: + pos = point.PositionLocal; + newValueAction = vector3 => point.PositionLocal = vector3; + tooltipDetails = "local"; + details = "L"; + break; + default: + throw new ArgumentOutOfRangeException("BGCurveSettingsForEditor.InspectorPointCoordinates"); + } + + BGEditorUtility.SwapLabelWidth(80, () => + { + var label = name + "(" + details + ")"; + var tooltip = "Point's position in " + tooltipDetails + " space. You can change points space in BGCurve Editor settings (gear icon)"; + + if (mode2D == BGCurve.Mode2DEnum.Off) BGEditorUtility.Vector3Field(label, tooltip, pos, newValueAction); + else Vector2Field(label, tooltip, pos, mode2D, newValueAction); + }); + } + + private void Vector2Field(string label, string tooltip, Vector3 value, BGCurve.Mode2DEnum mode2D, Action newValueAction) + { + Vector2 val; + switch (mode2D) + { + case BGCurve.Mode2DEnum.XY: + val = value; + break; + case BGCurve.Mode2DEnum.XZ: + val = new Vector2(value.x, value.z); + break; + case BGCurve.Mode2DEnum.YZ: + val = new Vector2(value.y, value.z); + break; + default: + throw new ArgumentOutOfRangeException("mode2D", mode2D, null); + } + + BGEditorUtility.Vector2Field(label, tooltip, val, vector2 => + { + Vector3 newValue; + switch (mode2D) + { + case BGCurve.Mode2DEnum.XY: + newValue = vector2; + break; + case BGCurve.Mode2DEnum.XZ: + newValue = new Vector3(vector2.x, 0, vector2.y); + break; + case BGCurve.Mode2DEnum.YZ: + newValue = new Vector3(0, vector2.x, vector2.y); + break; + default: + throw new ArgumentOutOfRangeException("mode2D", mode2D, null); + } + newValueAction(newValue); + }); + } + + + private static void ShowFields(BGCurvePointI point) + { + foreach (var field in point.Curve.Fields.Where(BGPrivateField.GetShowInPointsMenu)) ShowField(point, field); + } + + public static void ShowField(BGCurvePointI point, BGCurvePointField field, Action animationCurveCallback = null) + { + var name = point.Curve.IndexOf(field) + ") " + field.FieldName; + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bool: + BGEditorUtility.BoolField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Int: + BGEditorUtility.IntField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Float: + BGEditorUtility.FloatField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Vector3: + BGEditorUtility.Vector3Field(name, null, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Bounds: + BGEditorUtility.BoundsField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Color: + BGEditorUtility.ColorField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.String: + BGEditorUtility.TextField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v), false); + break; + case BGCurvePointField.TypeEnum.AnimationCurve: + BGEditorUtility.Horizontal(() => + { + BGEditorUtility.AnimationCurveField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + + if (animationCurveCallback != null && GUILayout.Button("Set", GUILayout.Width(40))) animationCurveCallback(field.FieldName, point.GetField(field.FieldName)); + }); + + break; + case BGCurvePointField.TypeEnum.Quaternion: + BGEditorUtility.QuaternionField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.GameObject: + BGEditorUtility.GameObjectField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.Component: + BGEditorUtility.ComponentChoosableField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.BGCurve: + BGEditorUtility.BGCurveField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + BGEditorUtility.Horizontal(() => + { + BGEditorUtility.BGCurvePointComponentField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + var currentPoint = point.GetField(field.FieldName); + + if (currentPoint == null || currentPoint.Curve.PointsCount < 2) return; + + var indexOfField = currentPoint.Curve.IndexOf(currentPoint); + + if (GUILayout.Button("" + indexOfField, GUILayout.Width(40))) BGCurveChosePointWindow.Open(indexOfField, currentPoint.Curve, c => point.SetField(field.FieldName, c)); + }); + break; + case BGCurvePointField.TypeEnum.BGCurvePointGO: + BGEditorUtility.BGCurvePointGOField(name, point.GetField(field.FieldName), v => point.SetField(field.FieldName, v)); + break; + } + } + + + private void PointButtons(BGCurvePointI point, int index, BGCurveSettings settings) + { + if (!settings.ShowPointMenu) return; + + var curve = point.Curve; + + //================== Copy + if (BGEditorUtility.ButtonWithIcon(copyTexture, PointCopyPaste.Instance.CopyTooltip)) PointCopyPaste.Instance.Copy(point); + GUILayout.Space(2); + + //================== Paste + if (BGEditorUtility.ButtonWithIcon(pasteTexture, PointCopyPaste.Instance.PasteTooltip)) PointCopyPaste.Instance.Paste(point); + GUILayout.Space(2); + + //================== Add before + if (BGEditorUtility.ButtonWithIcon(addBeforeTexture, "Insert a point before this point")) + BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index); + GUILayout.Space(2); + + + //=========================== Move Up + if (index > 0 && BGEditorUtility.ButtonWithIcon(moveUpTexture, "Move the point up")) curve.Swap(index - 1, index); + GUILayout.Space(2); + + //=========================== Move Down + if (index < curve.PointsCount - 1 && BGEditorUtility.ButtonWithIcon(moveDownTexture, "Move the point down")) curve.Swap(index, index + 1); + GUILayout.Space(2); + + + //=========================== Delete + if (BGEditorUtility.ButtonWithIcon(deleteTexture, "Delete the point")) + { + BGCurveEditor.DeletePoint(curve, index); + if (editorSelection != null) editorSelection.Remove(point); + GUIUtility.ExitGUI(); + } + } + + + public void OnSceneGUI(BGCurvePointI point, int index, BGCurveSettings settings, Quaternion rotation, Plane[] frustum) + { + var math = mathProvider(); + var positionWorld = math == null ? point.Curve[index].PositionWorld : math.GetPosition(index); + + //adjust rotation + if (point.PointTransform != null) rotation = BGCurveEditorPoints.GetRotation(point.PointTransform); + else if (point.Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform) rotation = BGCurveEditorPoints.GetRotation(((BGCurvePointGO) point).transform); + + if (settings.ShowControlHandles && settings.ShowCurve && (editorSelection == null || !editorSelection.HasSelected() || editorSelection.SingleSelected(point))) + { + // ============================================== Controls Handles + if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + { + var controlFirstWorld = math == null ? point.Curve[index].ControlFirstWorld : math.GetControlFirst(index); + var controlSecondWorld = math == null ? point.Curve[index].ControlSecondWorld : math.GetControlSecond(index); + + BGEditorUtility.SwapHandlesColor(settings.ControlHandlesColor, () => + { + Handles.DrawLine(positionWorld, controlFirstWorld); + Handles.DrawLine(positionWorld, controlSecondWorld); + + if (ShowingHandles) + { + // control handles different types + var newPositionFirst = BGEditorUtility.Handle(GetUniqueNumber(index) - 1, settings.ControlHandlesType, controlFirstWorld, rotation, settings.ControlHandlesSettings); + var newPositionSecond = BGEditorUtility.Handle(GetUniqueNumber(index) - 2, settings.ControlHandlesType, controlSecondWorld, rotation, settings.ControlHandlesSettings); + + if (BGEditorUtility.AnyChange(controlFirstWorld, newPositionFirst)) point.ControlFirstWorld = newPositionFirst; + if (BGEditorUtility.AnyChange(controlSecondWorld, newPositionSecond)) point.ControlSecondWorld = newPositionSecond; + } + }); + + if (settings.ShowControlLabels) + { + ShowControlLabel(settings, frustum, controlFirstWorld, point.ControlFirstLocal, "1"); + ShowControlLabel(settings, frustum, controlSecondWorld, point.ControlSecondLocal, "2"); + } + } + } + + //if only one point is selected and this is the selected point- do not print anything further + if (editorSelection != null && editorSelection.HasSelected() && editorSelection.SingleSelected(point)) return; + + // ============================================== Move Handles + if ((editorSelection == null || !editorSelection.HasSelected()) && settings.ShowCurve && settings.ShowHandles && ShowingHandles) + { + var newPos = BGEditorUtility.Handle(GetUniqueNumber(index), settings.HandlesType, positionWorld, rotation, settings.HandlesSettings); + + if (BGEditorUtility.AnyChange(positionWorld, newPos)) point.PositionWorld = newPos; + } + } + + private static bool ShowingHandles + { + get { return Tools.current != Tool.View; } + } + + private void ShowControlLabel(BGCurveSettings settings, Plane[] frustum, Vector3 positionWorld, Vector3 positionLocal, string label) + { + BGEditorUtility.Assign(ref controlLabelStyle, () => new GUIStyle("Label") {normal = new GUIStyleState {textColor = settings.LabelControlColor}}); + + if (GeometryUtility.TestPlanesAABB(frustum, new Bounds(positionWorld, Vector3.one))) + Handles.Label(positionWorld, label + (settings.ShowControlPositions ? " " + positionLocal : ""), controlLabelStyle); + } + + + //this is to generate Unity UGUI ids (for handles). + private static int GetUniqueNumber(int index) + { + return (-index - 1)*3; + } + + private sealed class PointCopyPaste + { + public static readonly PointCopyPaste Instance = new PointCopyPaste(); + + public readonly string CopyTooltip = "Copy " + + "\r\n1) ControlType, " + + "\r\n2) Position (Local), " + + "\r\n3) Control1 (LocalTransformed), " + + "\r\n4) Control2 (LocalTransformed), " + + "\r\n5) PointTransform"; + + public string PasteTooltip; + + private BGCurvePoint.ControlTypeEnum controlType; + private Vector3 positionLocal; + private Vector3 control1LocalTransformed; + private Vector3 control2LocalTransformed; + private Transform pointTransform; + + private PointCopyPaste() + { + InitPasteTooltip(); + } + + public void Copy(BGCurvePointI point) + { + controlType = point.ControlType; + positionLocal = point.PositionLocal; + control1LocalTransformed = point.ControlFirstLocalTransformed; + control2LocalTransformed = point.ControlSecondLocalTransformed; + pointTransform = point.PointTransform; + + InitPasteTooltip(); + } + + private void InitPasteTooltip() + { + PasteTooltip = "Paste " + + "\r\n1) ControlType=" + controlType + + "\r\n2) Position (Local)=" + positionLocal + + "\r\n3) Control1 (LocalTransformed)=" + control1LocalTransformed + + "\r\n4) Control2 (LocalTransformed)=" + control2LocalTransformed + + "\r\n5) PointTransform=" + pointTransform; + } + + public void Paste(BGCurvePointI point) + { + point.Curve.Transaction(() => + { + point.ControlType = controlType; + point.PositionLocal = positionLocal; + point.ControlFirstLocalTransformed = control1LocalTransformed; + point.ControlSecondLocalTransformed = control2LocalTransformed; + point.PointTransform = pointTransform; + }); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs.meta new file mode 100644 index 0000000..780b617 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b3d23774d53900447be90cd0a79f7bed +timeCreated: 1458524671 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs new file mode 100644 index 0000000..2c37ccd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs @@ -0,0 +1,538 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //GUI for all points + public class BGCurveEditorPoints : BGCurveEditorTab + { + // ====================================== Static const + private static readonly Color32 HiddenPointMenuColor = new Color32(144, 195, 212, 255); + + private static readonly GUIContent[] XZLabels = {new GUIContent("X"), new GUIContent("Z")}; + private static readonly GUIContent[] YZLabels = {new GUIContent("Y"), new GUIContent("Z")}; + + // ====================================== Fields + private readonly Texture2D convertAll2D; + private readonly Texture2D addPointIcon; + + private readonly SerializedProperty closedProperty; + private readonly SerializedProperty pointsModeProperty; + private readonly SerializedProperty controlTypeProperty; + private readonly SerializedProperty mode2DProperty; + private readonly SerializedProperty snapTypeProperty; + private readonly SerializedProperty snapDistanceProperty; + private readonly SerializedProperty snapAxisProperty; + private readonly SerializedProperty snapTriggerInteractionProperty; + private readonly SerializedProperty snapToBackFacesProperty; + private readonly SerializedProperty eventModeProperty; + private readonly SerializedProperty forceChangedEventModeProperty; + + //point + private readonly BGCurveEditorPoint editorPoint; + //painting a curve in the scene + private BGCurvePainterGizmo painter; + + private readonly BGSceneViewOverlay overlay; + private readonly BGCurveEditorPointsSelection editorSelection; + private readonly SerializedObject serializedObject; + private readonly List pointTransformTrackers = new List(); + + private GUIContent syncContent; + + + public BGCurveEditorPoints(BGCurveEditor editor, SerializedObject serializedObject, BGCurveEditorPointsSelection editorSelection) + : base(editor, serializedObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPoints123)) + { + this.serializedObject = serializedObject; + this.editorSelection = editorSelection; + + //textures + convertAll2D = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); + addPointIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); + + //point + editorPoint = new BGCurveEditorPoint(() => Editor.Math, editorSelection); + + //closed or not + closedProperty = serializedObject.FindProperty("closed"); + + //how points are stored + pointsModeProperty = serializedObject.FindProperty("pointsMode"); + + //2d mode + mode2DProperty = serializedObject.FindProperty("mode2D"); + + //snapping + snapTypeProperty = serializedObject.FindProperty("snapType"); + snapAxisProperty = serializedObject.FindProperty("snapAxis"); + snapDistanceProperty = serializedObject.FindProperty("snapDistance"); + snapTriggerInteractionProperty = serializedObject.FindProperty("snapTriggerInteraction"); + snapToBackFacesProperty = serializedObject.FindProperty("snapToBackFaces"); + + //force update + forceChangedEventModeProperty = serializedObject.FindProperty("forceChangedEventMode"); + + //event type + eventModeProperty = serializedObject.FindProperty("eventMode"); + + //settings + controlTypeProperty = serializedObject.FindProperty("settings").FindPropertyRelative("controlType"); + + //Context menu + overlay = new BGSceneViewOverlay(this, editorSelection); + + //for GameObjects points which use transforms + UpdatePointsTrackers(); + } + + + // ================================================================================ Inspector + public override void OnInspectorGui() + { + var settings = Settings; + + editorSelection.Reset(); + + // ======================================== Top section + InspectorTopSection(); + + // ======================================== Points + GUILayout.Space(5); + + if (Curve.PointsCount > 0) + { + BGEditorUtility.VerticalBox(() => + { + var temp = BGCurveSettingsForEditor.DisableInspectorPointMenu; + BGCurveSettingsForEditor.DisableInspectorPointMenu = BGEditorUtility.ButtonOnOff(ref temp, "Points menu [" + Curve.PointsCount + "]", "Show points in Editor inspector", + HiddenPointMenuColor, + new GUIContent("Show", "Click to show points menu"), + new GUIContent("Hide", "Click to hide points menu"), () => + { + const string title = "Reverse points"; + + if (!GUILayout.Button(new GUIContent(title, "Reverse all points, but keep curve intact"))) return; + + if (Curve.PointsCount < 2) + { + BGEditorUtility.Inform(title, "There should be at least 2 points. Curve has " + Curve.PointsCount); + return; + } + if (!BGEditorUtility.Confirm(title, "Are you sure you want to reverse the order of " + Curve.PointsCount + " points? Curve will remain intact.", "Reverse")) return; + + Curve.Reverse(); + }); + + //show points! + if (!BGCurveSettingsForEditor.DisableInspectorPointMenu) + SwapVector2Labels(Curve.Mode2D, () => Curve.ForEach((point, index, count) => editorPoint.OnInspectorGui(point, index, settings))); + }); + + // ======================================== Selections operations + editorSelection.InspectorSelectionOperations(); + + //warning + BGEditorUtility.HelpBox("Selection mode is on", MessageType.Warning, !editorSelection.Changed && editorSelection.HasSelected()); + } + else + { + BGEditorUtility.HorizontalBox(() => + { + EditorGUILayout.LabelField("No points!"); + + if (BGEditorUtility.ButtonWithIcon(addPointIcon, "Add new point at (0,0,0) local coordinates")) + BGCurveEditor.AddPoint(Curve, new BGCurvePoint(Curve, Vector3.zero, settings.ControlType, Vector3.right, Vector3.left), 0); + }); + } + + if (!editorSelection.Changed) return; + + Editor.Repaint(); + SceneView.RepaintAll(); + } + + + private void InspectorTopSection() + { + if (Curve.PointsCount == 0) + EditorGUILayout.HelpBox( + "1) Ctrl + LeftClick in scene view to add a point and snap it to " + + "\r\n a) 3D mode: mesh with collider" + + "\r\n b) 2D mode: curve's 2D plane." + + "\r\n" + + "\r\n2) Ctrl + Shift + LeftClick in Scene View to add a point unconditionally at some distance, specified in the settings." + + "\r\n" + + "\r\n3) Hold control over existing point or selection to access Scene View menu" + + "\r\n" + + "\r\n4) Hold shift + drag to use rectangular selection in Scene View" + , MessageType.Info); + + + try + { + // Curve's block + BGEditorUtility.VerticalBox(() => + { + //closed + EditorGUILayout.PropertyField(closedProperty); + + + //point's store mode + BGEditorUtility.Horizontal(() => + { + EditorGUILayout.PropertyField(pointsModeProperty); + + BGEditorUtility.DisableGui(() => + { + BGEditorUtility.Assign(ref syncContent, () => new GUIContent("Sync", "Sort points Game Objects and update names")); + + if (!GUILayout.Button(syncContent)) return; + + BGPrivateField.Invoke(Curve, BGCurve.MethodSetPointsNames); + }, !BGCurve.IsGoMode(Curve.PointsMode)); + }); + + + //2D mode + BGEditorUtility.Horizontal(() => + { + EditorGUILayout.PropertyField(mode2DProperty); + BGEditorUtility.DisableGui(() => + { + if (!GUILayout.Button("Apply", GUI.skin.button, GUILayout.Width(80))) return; + + Curve.FireBeforeChange(BGCurve.Event2D); + Curve.Apply2D(Curve.Mode2D); + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.Event2D)); + }, mode2DProperty.enumValueIndex == 0); + }); + + //snapping + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.Horizontal(() => + { + EditorGUILayout.PropertyField(snapTypeProperty); + + BGEditorUtility.DisableGui(() => + { + if (!GUILayout.Button("Apply", GUI.skin.button, GUILayout.Width(80))) return; + + Curve.FireBeforeChange(BGCurve.EventSnapType); + Curve.ApplySnapping(); + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Snap, BGCurve.EventSnapType)); + }, snapTypeProperty.enumValueIndex == 0); + }); + + if (snapTypeProperty.enumValueIndex == 0) return; + + EditorGUILayout.PropertyField(snapAxisProperty); + EditorGUILayout.PropertyField(snapDistanceProperty); + EditorGUILayout.PropertyField(snapTriggerInteractionProperty); + EditorGUILayout.PropertyField(snapToBackFacesProperty); + + BGEditorUtility.LayerMaskField("Snap Layer Mask", Curve.SnapLayerMask, i => + { + Curve.FireBeforeChange(BGCurve.EventSnapTrigger); + Curve.SnapLayerMask = i; + Curve.ApplySnapping(); + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Snap, BGCurve.EventSnapTrigger)); + }); + }); + + //event mode + EditorGUILayout.PropertyField(eventModeProperty); + + //force update + EditorGUILayout.PropertyField(forceChangedEventModeProperty); + + //convert control type + BGEditorUtility.Horizontal(() => + { + EditorGUILayout.PropertyField(controlTypeProperty); + + if (!BGEditorUtility.ButtonWithIcon(convertAll2D, "Convert control types for all existing points ", 44)) return; + + var settings = Settings; + + foreach (var point in Curve.Points.Where(point => point.ControlType != settings.ControlType)) point.ControlType = settings.ControlType; + }); + }); + } + catch (BGEditorUtility.ExitException) + { + GUIUtility.ExitGUI(); + } + } + + // ================================================================================ Scene + public override void OnSceneGui(Plane[] frustum) + { + var settings = Settings; + + var curveRotation = GetRotation(Curve.transform); + + if (Curve.PointsCount != 0 && settings.VRay) + { + painter = painter ?? new BGCurvePainterHandles(Editor.Math); + painter.DrawCurve(); + } + + Curve.ForEach((point, index, count) => editorPoint.OnSceneGUI(point, index, settings, curveRotation, frustum)); + + //tangents + if (settings.ShowCurve && settings.ShowTangents && Editor.Math.SectionsCount > 0 && Editor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent)) + { + BGEditorUtility.SwapHandlesColor(settings.TangentsColor, () => + { + var math = Editor.Math; + var sectionsCount = math.SectionsCount; + var sections = math.SectionInfos; + + for (var i = 0; i < sectionsCount; i++) + { + var section = sections[i]; + var points = section.Points; + ShowTangent(points[0].Position, points[0].Tangent, settings.TangentsSize); + if (settings.TangentsPerSection > 1) + { + var sectionLength = section.Distance; + var part = sectionLength/settings.TangentsPerSection; + for (var j = 1; j < settings.TangentsPerSection; j++) + { + var distanceWithinSection = part*j; + Vector3 position; + Vector3 tangent; + section.CalcByDistance(distanceWithinSection, out position, out tangent, true, true); + ShowTangent(position, tangent, settings.TangentsSize); + } + } + } + }); + } + + + editorSelection.Scene(curveRotation); + + overlay.Process(Event.current); + + CheckPointsTransforms(); + } + + private void CheckPointsTransforms() + { + var skipAction = false; + foreach (var tracker in pointTransformTrackers) skipAction |= tracker.CheckForChange(skipAction); + } + + private static void ShowTangent(Vector3 position, Vector3 tangent, float size) + { + if (tangent.sqrMagnitude > 0.0001f) Handles.ArrowCap(0, position, Quaternion.LookRotation(tangent), BGEditorUtility.GetHandleSize(position, size)); + } + + public static Quaternion GetRotation(Transform transform) + { + return Tools.pivotRotation == PivotRotation.Global ? Quaternion.identity : transform.rotation; + } + + + public override void OnApply() + { + var curve = Editor.Curve; + var settings = Settings; + + // ============================================== Closed + if (curve.Closed != closedProperty.boolValue) + { + Curve.FireBeforeChange(BGCurve.EventClosed); + serializedObject.ApplyModifiedProperties(); + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.EventClosed)); + } + + if ((int) curve.ForceChangedEventMode != forceChangedEventModeProperty.enumValueIndex) + { + Curve.FireBeforeChange(BGCurve.EventForceUpdate); + serializedObject.ApplyModifiedProperties(); + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Curve, BGCurve.EventForceUpdate)); + } + + // ============================================== Points store mode + if ((int) Curve.PointsMode != pointsModeProperty.enumValueIndex) + { + var newPointsMode = (BGCurve.PointsModeEnum) pointsModeProperty.enumValueIndex; + + //ask for confirmation in case changes may affect something else + if ((Curve.PointsMode == BGCurve.PointsModeEnum.Components) && !BGEditorUtility.Confirm("Convert Points", + "Are you sure you want to convert points? All existing references to these points will be lost.", "Convert")) return; + + if ((Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsNoTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsTransform || + Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsNoTransform) + && !BGEditorUtility.Confirm("Convert Points", "Are you sure you want to convert points? All existing GameObjects for points will be deleted.", "Convert")) return; + + editorSelection.Clear(); + + //invoke convert + BGPrivateField.Invoke(Curve, BGCurve.MethodConvertPoints, newPointsMode, + BGCurveEditor.GetPointProvider(newPointsMode, Curve), + BGCurveEditor.GetPointDestroyer(Curve.PointsMode, Curve)); + + //this call is not required + // serializedObject.ApplyModifiedProperties(); + } + + // ============================================== 2D mode + if ((int) curve.Mode2D != mode2DProperty.enumValueIndex) + { + Curve.FireBeforeChange(BGCurve.Event2D); + serializedObject.ApplyModifiedProperties(); + + var oldEventMode = Curve.EventMode; + Curve.EventMode = BGCurve.EventModeEnum.NoEvents; + + //force points recalc + Curve.Apply2D(Curve.Mode2D); + + if (BGEditorUtility.Confirm("Editor handles change", "Do you want to adjust configurable Editor handles (in Scene View) to chosen mode? This affects only current curve.", "Yes")) + { + if (Curve.Mode2D != BGCurve.Mode2DEnum.Off) + { + Apply2D(settings.HandlesSettings); + Apply2D(settings.ControlHandlesSettings); + } + else + { + Apply3D(settings.HandlesSettings); + Apply3D(settings.ControlHandlesSettings); + } + } + + Curve.EventMode = oldEventMode; + + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.Event2D)); + } + + // ============================================== Snapping + if ((int) curve.SnapType != snapTypeProperty.enumValueIndex) SnappingChanged(BGCurve.EventSnapType); + + if ((int) curve.SnapAxis != snapAxisProperty.enumValueIndex) SnappingChanged(BGCurve.EventSnapAxis); + + if (Math.Abs((int) curve.SnapDistance - snapDistanceProperty.floatValue) > BGCurve.Epsilon) SnappingChanged(BGCurve.EventSnapDistance); + + if ((int) curve.SnapTriggerInteraction != snapTriggerInteractionProperty.enumValueIndex) SnappingChanged(BGCurve.EventSnapTrigger); + + if (curve.SnapToBackFaces != snapToBackFacesProperty.boolValue) SnappingChanged(BGCurve.EventSnapBackfaces); + + // ============================================== Event mode + if ((int) curve.EventMode != eventModeProperty.enumValueIndex) serializedObject.ApplyModifiedProperties(); + + // ============================================== Control Type + if ((int) settings.ControlType != controlTypeProperty.enumValueIndex) serializedObject.ApplyModifiedProperties(); + } + + private void SnappingChanged(string eventMessage) + { + Curve.FireBeforeChange(eventMessage); + + serializedObject.ApplyModifiedProperties(); + + Curve.ApplySnapping(); + + Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Snap, eventMessage)); + } + + private void Apply3D(BGCurveSettings.SettingsForHandles handlesSettings) + { + handlesSettings.RemoveX = handlesSettings.RemoveY = handlesSettings.RemoveZ = handlesSettings.RemoveXY = handlesSettings.RemoveXZ = handlesSettings.RemoveYZ = false; + } + + private void Apply2D(BGCurveSettings.SettingsForHandles handlesSettings) + { + handlesSettings.RemoveX = Curve.Mode2D == BGCurve.Mode2DEnum.YZ; + handlesSettings.RemoveY = Curve.Mode2D == BGCurve.Mode2DEnum.XZ; + handlesSettings.RemoveZ = Curve.Mode2D == BGCurve.Mode2DEnum.XY; + + handlesSettings.RemoveXY = Curve.Mode2D == BGCurve.Mode2DEnum.XZ || Curve.Mode2D == BGCurve.Mode2DEnum.YZ; + handlesSettings.RemoveXZ = Curve.Mode2D == BGCurve.Mode2DEnum.XY || Curve.Mode2D == BGCurve.Mode2DEnum.YZ; + handlesSettings.RemoveYZ = Curve.Mode2D == BGCurve.Mode2DEnum.XZ || Curve.Mode2D == BGCurve.Mode2DEnum.XY; + } + + + public override string GetStickerMessage(ref MessageType type) + { + return "" + Curve.PointsCount; + } + + public override void OnUndoRedo() + { + editorSelection.OnUndoRedo(); + } + + public override void OnCurveChanged(BGCurveChangedArgs args) + { + if (args == null || string.IsNullOrEmpty(args.Message) || Curve.PointsMode != BGCurve.PointsModeEnum.GameObjectsTransform) return; + + if (args.ChangeType != BGCurveChangedArgs.ChangeTypeEnum.Point && args.ChangeType != BGCurveChangedArgs.ChangeTypeEnum.Points) return; + + if (!( + args.Message.Equals(BGCurve.EventAddPoint) || args.Message.Equals(BGCurve.EventAddPoints) + || args.Message.Equals(BGCurve.EventClearAllPoints) || args.Message.Equals(BGCurve.EventDeletePoints) + )) return; + + UpdatePointsTrackers(); + } + + private void UpdatePointsTrackers() + { + if (pointTransformTrackers.Count > 0) foreach (var tracker in pointTransformTrackers) tracker.Release(); + + pointTransformTrackers.Clear(); + + //for GameObjectsTransform mode + if (Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform) + Curve.ForEach((point, index, count) => pointTransformTrackers.Add(BGTransformMonitor.GetMonitor(((BGCurvePointGO) point).transform, transform => Curve.FireChange(null)))); + + //for points transforms + Curve.ForEach((point, index, count) => + { + if (point.PointTransform != null) pointTransformTrackers.Add(BGTransformMonitor.GetMonitor(point.PointTransform, transform => Curve.FireChange(null))); + }); + } + + public static void SwapVector2Labels(BGCurve.Mode2DEnum mode2D, Action action) + { + var needToSwap = mode2D != BGCurve.Mode2DEnum.Off && mode2D != BGCurve.Mode2DEnum.XY; + GUIContent[] oldLabels = null; + if (needToSwap) + { + oldLabels = BGPrivateField.Get(typeof(EditorGUI), "s_XYLabels"); + GUIContent[] newLabels; + switch (mode2D) + { + case BGCurve.Mode2DEnum.XZ: + newLabels = XZLabels; + break; + case BGCurve.Mode2DEnum.YZ: + newLabels = YZLabels; + break; + default: + throw new ArgumentOutOfRangeException("mode2D", mode2D, null); + } + BGPrivateField.Set(typeof(EditorGUI), "s_XYLabels", newLabels); + } + + try + { + action(); + } + finally + { + if (needToSwap) BGPrivateField.Set(typeof(EditorGUI), "s_XYLabels", oldLabels); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs.meta new file mode 100644 index 0000000..3503252 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPoints.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5efec0dbdba6a2a4e94b0ac6db243cc6 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs new file mode 100644 index 0000000..6878da7 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs @@ -0,0 +1,617 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + //helper class for points selection inside editor + public class BGCurveEditorPointsSelection + { + private static readonly Color SelectedBackgroundColor = new Color32(157, 246, 246, 40); + + + private readonly Texture2D tickNoTexture; + private readonly Texture2D tickYesTexture; + private readonly Texture2D deleteTexture; + private readonly Texture2D selectAllTexture; + private readonly Texture2D deselectAllTexture; + private readonly Texture2D convertAllTexture; + + + private readonly List points = new List(); + + private bool groupSelectionStarted; + private bool groupSelectionIsSelecting; + + private BGCurveSettings settings; + + public bool Changed { get; private set; } + + public int CountSelected + { + get { return points.Count; } + } + + private readonly BGCurve curve; + private readonly BGRectangularSelection selectionRectangle; + + private BGCurvePoint.ControlTypeEnum controlType = BGCurvePoint.ControlTypeEnum.Absent; + + private BGEditorUtility.EventCanceller eventCanceller; + + //do not want to use events + private int lastCurveCount; + private readonly PointsContainer pointsContainer; + + public BGCurveEditorPointsSelection(BGCurve curve, BGCurveEditor editor) + { + this.curve = curve; + selectionRectangle = new BGRectangularSelection(editor, this); + + tickNoTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickNo123); + tickYesTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickYes123); + deleteTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); + selectAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectAll123); + deselectAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDeSelectAll123); + convertAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); + pointsContainer = new PointsContainer(this); + } + + public bool HasSelected() + { + return CountSelected > 0; + } + + internal void Clear() + { + Changed = Changed || HasSelected(); + points.Clear(); + } + + public bool Contains(BGCurvePointI point) + { + return points.Contains(point); + } + + //if we selecting or removing selection + public void GroupSelection(BGCurvePointI point) + { + if (groupSelectionIsSelecting) Add(point); + else Remove(point); + } + + public bool Add(BGCurvePointI point) + { + if (Contains(point)) return false; + + Changed = true; + points.Add(point); + return true; + } + + public bool Remove(BGCurvePointI point) + { + if (!Contains(point)) return false; + Changed = true; + points.Remove(point); + return true; + } + + private void SetX(float x) + { + foreach (var point in points) + { + var positionWorld = point.PositionWorld; + point.PositionWorld = new Vector3(x, positionWorld.y, positionWorld.z); + } + } + + private void SetY(float y) + { + foreach (var point in points) + { + var positionWorld = point.PositionWorld; + point.PositionWorld = new Vector3(positionWorld.x, y, positionWorld.z); + } + } + + private void SetZ(float z) + { + foreach (var point in points) + { + var positionWorld = point.PositionWorld; + point.PositionWorld = new Vector3(positionWorld.x, positionWorld.y, z); + } + } + + public void Reset() + { + Changed = false; + settings = BGPrivateField.GetSettings(curve); + } + + //draw interactible selection icon control + public void InspectorSelectionRect(BGCurvePointI point) + { + var currentEvent = Event.current; + var rect = GUILayoutUtility.GetRect(24, 24, 24, 24, new GUIStyle {fixedWidth = 24, fixedHeight = 24, stretchWidth = false, stretchHeight = false}); + if (currentEvent.isMouse) + { + if (currentEvent.type == EventType.mouseDown) + { + if (rect.Contains(currentEvent.mousePosition)) + { + groupSelectionStarted = true; + groupSelectionIsSelecting = !Contains(point); + GroupSelection(point); + } + } + else if (groupSelectionStarted) + { + switch (currentEvent.type) + { + case EventType.MouseUp: + groupSelectionStarted = false; + break; + case EventType.MouseDrag: + if (rect.Contains(currentEvent.mousePosition)) GroupSelection(point); + break; + } + } + } + + var selected = Contains(point); + var selectedTexture = selected ? tickYesTexture : tickNoTexture; + var labelStyle = selected ? new GUIStyle("Label") {normal = new GUIStyleState {textColor = settings.LabelColorSelected}} : EditorStyles.label; + EditorGUI.LabelField(rect, new GUIContent(selectedTexture, "Click to (de)select a point, or click and drag to (de)select multiple points. " + + "Hold shift to use rectangular selection"), labelStyle); + } + + //OnInspectorGui for selection + public void InspectorSelectionOperations() + { + BGEditorUtility.VerticalBox(() => + { + // ================================================ Global operations + BGEditorUtility.HorizontalBox(() => + { + BGEditorUtility.SwapLabelWidth(80, () => EditorGUILayout.LabelField("Selected (" + points.Count + ")")); + + if (BGEditorUtility.ButtonWithIcon(deleteTexture, "Delete selected points")) if (!DeleteSelected()) return; + + GUILayout.Space(4); + if (BGEditorUtility.ButtonWithIcon(selectAllTexture, "Select all points", 35)) + { + Changed = Changed || points.Count != curve.PointsCount; + + points.Clear(); + + foreach (var point1 in curve.Points) points.Add(point1); + } + + GUILayout.Space(4); + + if (BGEditorUtility.ButtonWithIcon(deselectAllTexture, "Deselect all points", 35)) Clear(); + }); + + + // ================================================ Selections operations + // skip mouse buttons events which change selection + if (Changed) return; + + GUILayout.Space(5); + if (HasSelected()) + { + BGEditorUtility.SwapGuiBackgroundColor(SelectedBackgroundColor, () => + { + BGEditorUtility.VerticalBox(() => + { + var averagePositionSelected = GetAveragePosition(); + + // ===================================================== Control handles + BGEditorUtility.Horizontal(() => + { + controlType = (BGCurvePoint.ControlTypeEnum) EditorGUILayout.EnumPopup("Controls", controlType); + if (!BGEditorUtility.ButtonWithIcon(convertAllTexture, "Set control type for all selected points", 44)) return; + + SetControlTypeForSelected(controlType); + }); + + // ===================================================== Average positions & delete + BGEditorUtility.Vector3Field("Average position", "Average points position. Change several points positions at once, keeping distance difference intact", + averagePositionSelected, + newAverage => + { + var delta = newAverage - averagePositionSelected; + curve.Transaction(() => + { + foreach (var point in points) point.PositionWorld += delta; + }); + }); + // ===================================================== Set position directly + BGEditorUtility.Vector3Field("Set position", "Set points position directly", + averagePositionSelected, + newPosition => + { + curve.Transaction(() => + { + if (BGEditorUtility.AnyChange(averagePositionSelected.x, newPosition.x)) SetX(newPosition.x); + if (BGEditorUtility.AnyChange(averagePositionSelected.y, newPosition.y)) SetY(newPosition.y); + if (BGEditorUtility.AnyChange(averagePositionSelected.z, newPosition.z)) SetZ(newPosition.z); + }); + }); + + // ===================================================== Set control positions directly + var count = 0; + var averageControl1Sum = Vector3.zero; + var averageControl2Sum = Vector3.zero; + foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) + { + count++; + averageControl1Sum += point.ControlFirstLocal; + averageControl2Sum += point.ControlSecondLocal; + } + + if (count != 0) + { + //has points with bezier controls + BGEditorUtility.Vector3Field("Set Control 1", "Set 1st control position directly", + averageControl1Sum/count, + newPosition => + { + curve.Transaction( + () => + { + foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) point.ControlFirstLocal = newPosition; + }); + }); + + BGEditorUtility.Vector3Field("Set Control 2", "Set 2nd control position directly", + averageControl2Sum/count, + newPosition => + { + curve.Transaction( + () => + { + foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) point.ControlSecondLocal = newPosition; + }); + }); + } + + + // ===================================================== Custom fields + if (curve.FieldsCount > 0) + { + var fields = curve.Fields; + pointsContainer.UpdateFields(); + foreach (var field in fields) BGCurveEditorPoint.ShowField(pointsContainer, field, pointsContainer.AnimationCurveChanged); + } + }); + }); + } + else BGEditorUtility.HelpBox("Hold shift to use rectangular selection\r\nClick or click+drag over tick icons to (de)select points", MessageType.Info, curve.PointsCount > 0); + }); + } + + public void SetControlTypeForSelected(BGCurvePoint.ControlTypeEnum controlType) + { + curve.Transaction(() => + { + foreach (var point in points) point.ControlType = controlType; + }); + } + + public bool DeleteSelected() + { + if (points.Count == 0) + { + BGEditorUtility.Inform("Error", "Chose at least one point to delete"); + return false; + } + + if (!BGEditorUtility.Confirm("Delete points confirmation", "Are you sure you want to remove " + points.Count + " point(s)?", "Delete")) return false; + + BGCurveEditor.DeletePoints(curve, points.ToArray()); + + Clear(); + return true; + } + + public Vector3 GetAveragePosition() + { + return points.Aggregate(Vector3.zero, (current, point) => current + point.PositionWorld)/points.Count; + } + + // OnSceneGui + public void Scene(Quaternion rotation) + { + if (lastCurveCount != curve.PointsCount) + { + lastCurveCount = curve.PointsCount; + OnUndoRedo(); + } + + if (!HasSelected()) return; + + BGEditorUtility.Assign(ref settings, () => BGPrivateField.GetSettings(curve)); + + //group operation for selected points + var text = " Selected [" + points.Count + "]"; + var average = GetAveragePosition(); + Handles.Label(average + BGEditorUtility.GetHandleSize(average)*Vector3.up*.25f, text, new GUIStyle("Label") {normal = new GUIStyleState {textColor = settings.LabelColorSelected}}); + + var newAverage = BGEditorUtility.Handle(-10, settings.HandlesType, average, rotation, settings.HandlesSettings); + + if (BGEditorUtility.AnyChange(average, newAverage)) + { + curve.Transaction(() => + { + var delta = newAverage - average; + foreach (var selectedPoint in points) selectedPoint.PositionWorld += delta; + }); + } + } + + public bool SingleSelected(BGCurvePointI point) + { + return points.Count == 1 && Contains(point); + } + + public void Process(Event currentEvent) + { + if (currentEvent.type == EventType.mouseDown) + { + if (currentEvent.button == 0) + { + if ((!currentEvent.control && currentEvent.shift) || BGCurveSettingsForEditor.LockView) + { + var cancelEvent = Tools.viewTool != ViewTool.FPS && Tools.current != Tool.View /*&& Tools.current != Tool.None*/ && !currentEvent.isKey; + if (cancelEvent) eventCanceller = new BGEditorUtility.EventCanceller(); + + if (currentEvent.shift && !BGCurveSettingsForEditor.DisableRectangularSelection) selectionRectangle.On(); + else if (cancelEvent) BGCurveEditor.OverlayMessage.Display("The Scene view is locked.\r\n Set 'Lock View' (in the BGCurve Editor) to false to unlock."); + } + } + else if (currentEvent.button == 1 && selectionRectangle.IsOn) + { + //glitch with right click + GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive); + } + } + else if (currentEvent.type == EventType.mouseUp) + { + SceneView.RepaintAll(); + selectionRectangle.Off(); + BGEditorUtility.Release(ref eventCanceller); + } + + + selectionRectangle.Process(currentEvent); + } + + public void OnUndoRedo() + { + if (CountSelected == 0) return; + + for (var i = points.Count - 1; i >= 0; i--) if (curve.IndexOf(points[i]) < 0) points.RemoveAt(i); + } + + public void ForEach(Func action) + { + if (CountSelected == 0) return; + + //not sure if it can be converted to LINQ + foreach (var point in points) if (action(point)) return; + } + + private sealed class PointsContainer : BGCurvePointI + { + private readonly Dictionary name2Value = new Dictionary(); + private readonly BGCurveEditorPointsSelection selection; + //we reuse the list to reduce GC + private readonly List existingKeys = new List(); + + public BGCurve Curve { get; private set; } + public Vector3 PositionLocal { get; set; } + public Vector3 PositionLocalTransformed { get; set; } + public Vector3 PositionWorld { get; set; } + public Vector3 ControlFirstLocal { get; set; } + public Vector3 ControlFirstLocalTransformed { get; set; } + public Vector3 ControlFirstWorld { get; set; } + public Vector3 ControlSecondLocal { get; set; } + public Vector3 ControlSecondLocalTransformed { get; set; } + public Vector3 ControlSecondWorld { get; set; } + public BGCurvePoint.ControlTypeEnum ControlType { get; set; } + public Transform PointTransform { get; set; } + + public PointsContainer(BGCurveEditorPointsSelection selection) + { + this.selection = selection; + Curve = selection.curve; + +// var animationCurve = new AnimationCurve(); + } + + public T GetField(string name) + { + var type = typeof(T); + var value = GetField(name, type); + var field = (T) value; + return field; + } + + public void SetField(string name, T value) + { + SetField(name, value, typeof(T)); + } + + + public object GetField(string name, Type type) + { + return name2Value[name]; + } + + public void SetField(string name, object value, Type type) + { + name2Value[name] = value; + + selection.ForEach(p => + { + p.SetField(name, value, type); + return false; + }); + } + + public float GetFloat(string name) + { + throw new NotImplementedException(); + } + + public bool GetBool(string name) + { + throw new NotImplementedException(); + } + + public int GetInt(string name) + { + throw new NotImplementedException(); + } + + public Vector3 GetVector3(string name) + { + throw new NotImplementedException(); + } + + public Bounds GetBounds(string name) + { + throw new NotImplementedException(); + } + + public Quaternion GetQuaternion(string name) + { + throw new NotImplementedException(); + } + + public Color GetColor(string name) + { + throw new NotImplementedException(); + } + + public void SetFloat(string name, float value) + { + throw new NotImplementedException(); + } + + public void SetBool(string name, bool value) + { + throw new NotImplementedException(); + } + + public void SetInt(string name, int value) + { + throw new NotImplementedException(); + } + + public void SetVector3(string name, Vector3 value) + { + throw new NotImplementedException(); + } + + public void SetQuaternion(string name, Quaternion value) + { + throw new NotImplementedException(); + } + + public void SetBounds(string name, Bounds value) + { + throw new NotImplementedException(); + } + + public void SetColor(string name, Color value) + { + throw new NotImplementedException(); + } + + public void AnimationCurveChanged(string name, AnimationCurve animationCurve) + { + selection.ForEach(p => + { + var pointCurve = p.GetField(name); + pointCurve.keys = animationCurve.keys; + pointCurve.postWrapMode = animationCurve.postWrapMode; + pointCurve.preWrapMode = animationCurve.preWrapMode; + return false; + }); + } + + // make sure all fields are present + public void UpdateFields() + { + var fields = Curve.Fields; + + existingKeys.Clear(); + + if (name2Value.Count > 0) foreach (var key in name2Value.Keys) existingKeys.Add(key); + + if (fields.Length != 0) + { + foreach (var field in fields) + { + var fieldName = field.FieldName; + + existingKeys.Remove(fieldName); + + if (name2Value.ContainsKey(field.FieldName)) continue; + + //add new value + switch (field.Type) + { + case BGCurvePointField.TypeEnum.Bool: + name2Value[fieldName] = false; + break; + case BGCurvePointField.TypeEnum.Int: + name2Value[fieldName] = 0; + break; + case BGCurvePointField.TypeEnum.Float: + name2Value[fieldName] = 0f; + break; + case BGCurvePointField.TypeEnum.String: + name2Value[fieldName] = ""; + break; + case BGCurvePointField.TypeEnum.Vector3: + name2Value[fieldName] = new Vector3(); + break; + case BGCurvePointField.TypeEnum.Bounds: + name2Value[fieldName] = new Bounds(); + break; + case BGCurvePointField.TypeEnum.Color: + name2Value[fieldName] = new Color(); + break; + case BGCurvePointField.TypeEnum.Quaternion: + name2Value[fieldName] = Quaternion.identity; + break; + case BGCurvePointField.TypeEnum.AnimationCurve: + name2Value[fieldName] = new AnimationCurve(); + break; + case BGCurvePointField.TypeEnum.GameObject: + case BGCurvePointField.TypeEnum.Component: + case BGCurvePointField.TypeEnum.BGCurve: + case BGCurvePointField.TypeEnum.BGCurvePointComponent: + case BGCurvePointField.TypeEnum.BGCurvePointGO: + name2Value[fieldName] = null; + break; + default: + throw new ArgumentOutOfRangeException("field.Type"); + } + } + } + + //remove unused keys + if (existingKeys.Count > 0) foreach (var key in existingKeys) name2Value.Remove(key); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs.meta new file mode 100644 index 0000000..f38ba27 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorPointsSelection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 441a0da564bef264fb9baaada36283ea +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs new file mode 100644 index 0000000..6699a19 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs @@ -0,0 +1,166 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCurveEditorSettings : BGCurveEditorTab + { + private static bool showSaveLoad; + private string newAssetName; + private string lastOperation; + + //anim props + private readonly BGEditorUtility.BoolAnimatedProperty showCurveProp; + private SerializedProperty settings; + + + public BGCurveEditorSettings(BGCurveEditor editor, SerializedObject serializedObject) + : base(editor, serializedObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSettings123)) + { + //anim props + showCurveProp = new BGEditorUtility.BoolAnimatedProperty(editor, serializedObject.FindProperty("settings"), "showCurve"); + } + + public override void OnInspectorGui() + { + settings = SerializedObject.FindProperty("settings"); + var settingsObj = Settings; + + // Save & Load + showSaveLoad = EditorGUILayout.Foldout(showSaveLoad, "Save and load settings"); + if (showSaveLoad) + { + BGEditorUtility.VerticalBox(() => + { + var path = BGCurveSettingsOperations.GetPath(); + + BGEditorUtility.HelpBox("Folder is not set", MessageType.Info, path == null, () => + { + EditorGUILayout.LabelField("Folder", path); + + BGEditorUtility.HelpBox("Folder is not found", MessageType.Warning, !BGCurveSettingsOperations.IsValid(path), () => + { + // ================================= Load settings + var all = BGCurveSettingsOperations.GetAll(); + + BGEditorUtility.HelpBox("Folder does not have any settings", MessageType.Warning, all == null || all.Length == 0, () => + { + BGEditorUtility.Horizontal(() => + { + var options = new List {new GUIContent("")}; + options.AddRange(all.Select(setting => new GUIContent(setting))); + var selected = EditorGUILayout.Popup(new GUIContent("Load", "Load a specified settings for current object"), 0, options.ToArray()); + if (selected > 0) + { + var newSettings = BGCurveSettingsOperations.Load(options[selected].text); + if (newSettings != null) + { + BGPrivateField.SetSettings(Curve, newSettings); + EditorUtility.SetDirty(Curve); + lastOperation = options[selected].text + " was loaded"; + } + else lastOperation = "Unable to load a settings " + options[selected].text; + } + + if (GUILayout.Button(new GUIContent("Reload", "Reload settings from disk. This operation does not change settings for the curent object."))) + { + BGCurveSettingsOperations.Reload(BGCurveSettingsOperations.GetPath()); + lastOperation = "Settings was reloaded from disk"; + } + }); + }); + + // ================================= Save settings + BGEditorUtility.Horizontal(() => + { + newAssetName = EditorGUILayout.TextField(new GUIContent("Save", "Save current setting on disk"), newAssetName); + if (!GUILayout.Button(new GUIContent("Save", "Save current setting on disk"))) return; + + if (newAssetName == null || newAssetName.Trim().Equals("")) BGEditorUtility.Inform("Invalid asset name", "Please, enter the name for new asset"); + else lastOperation = BGCurveSettingsOperations.Save(settingsObj, newAssetName) ? newAssetName + " was saved on disk" : "Unable to save " + newAssetName + " on disk"; + }); + + BGEditorUtility.HelpBox(lastOperation, MessageType.Info, lastOperation != null); + }); + }); + + BGEditorUtility.Horizontal(() => + { + if (GUILayout.Button(new GUIContent("Save as default", "Save current settings as default for future curves"))) + { + lastOperation = BGCurveSettingsOperations.SaveDefault(settingsObj) ? "Current settings was saved as default" : "Unable to save settings on disk as default"; + } + + if (GUILayout.Button(new GUIContent("Chose a folder", "Chose a folder where to store settings files"))) BGCurveSettingsOperations.ChoseDir(); + }); + }); + } + + EditorGUILayout.HelpBox("All fields settings are under Fields tab", MessageType.Warning); + + BGEditorUtility.ChangeCheck(() => + { + //Points + BGEditorUtility.VerticalBox(() => + { + //Hide handles + EditorGUILayout.PropertyField(Find("hideHandles")); + + EditorGUILayout.PropertyField(Find("newPointDistance")); + EditorGUILayout.PropertyField(Find("showPointMenu")); + }); + + var tangentProp = Find("showTangents"); + + //curve + BGEditorUtility.FadeGroup(showCurveProp, () => + { + EditorGUILayout.PropertyField(Find("showCurveMode")); + EditorGUILayout.PropertyField(Find("sections")); + EditorGUILayout.PropertyField(Find("vRay")); + BGEditorUtility.HelpBox("VRay will work only if object is selected.", MessageType.Warning, Find("vRay").boolValue && Find("showCurveMode").enumValueIndex != 0); + EditorGUILayout.PropertyField(Find("lineColor")); + + //tangents + BGEditorUtility.VerticalBox(() => + { + EditorGUILayout.PropertyField(tangentProp); + if (settingsObj.ShowTangents) + { + BGEditorUtility.Indent(1, () => + { + EditorGUILayout.PropertyField(Find("tangentsSize")); + EditorGUILayout.PropertyField(Find("tangentsPerSection")); + EditorGUILayout.PropertyField(Find("tangentsColor")); + }); + } + }); + }); + }, () => + { + //if any change + SerializedObject.ApplyModifiedProperties(); + SceneView.RepaintAll(); + }); + } + + private SerializedProperty Find(string name) + { + return settings.FindPropertyRelative(name); + } + + + public override void OnEnable() + { + Tools.hidden = Settings.HideHandles; + } + + + public override void OnApply() + { + Tools.hidden = Settings.HideHandles; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs.meta new file mode 100644 index 0000000..a4d2c24 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorSettings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e1df90c7c52e81b44be91984d29ff247 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs new file mode 100644 index 0000000..576258b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs @@ -0,0 +1,79 @@ +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + public abstract class BGCurveEditorTab + { + public readonly BGCurveEditor Editor; + public readonly SerializedObject SerializedObject; + public readonly BGCurve Curve; + + private readonly Texture2D header2D; + + public Texture2D Header2D + { + get { return header2D; } + } + + public BGCurveSettings Settings + { + get { return BGPrivateField.GetSettings(Curve); } + } + + protected BGCurveEditorTab(BGCurveEditor editor, SerializedObject serializedObject, Texture2D header2D) + { + Editor = editor; + Curve = editor.Curve; + SerializedObject = serializedObject; + this.header2D = header2D; + } + + + // standard onInspector call + public abstract void OnInspectorGui(); + + //standard onscene + public virtual void OnSceneGui(Plane[] frustum) + { + } + + + // standard onEnable + public virtual void OnEnable() + { + } + + //editor disabled callback + public virtual void OnDisable() + { + } + + //editor removed callback + public virtual void OnDestroy() + { + } + + + //after applying the changes + public virtual void OnApply() + { + } + + + //sticker message (on toolbar) + public virtual string GetStickerMessage(ref MessageType type) + { + return null; + } + + public virtual void OnUndoRedo() + { + } + + public virtual void OnCurveChanged(BGCurveChangedArgs args) + { + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs.meta new file mode 100644 index 0000000..3d03904 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveEditorTab.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0d58f9d2731617f47a5feea3ca370779 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs new file mode 100644 index 0000000..788d0f2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs @@ -0,0 +1,49 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomPropertyDrawer(typeof(BGCurvePointComponent), true)] + public class BGCurvePointComponentDrawer : BGPropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // idea.. partially copy/pasted from BGCcChoseDrawer + // this is a required startup call + SetUp(position, property, label, () => + { + if (!(property.objectReferenceValue != null)) DrawProperty(property); + else + { + var point = (BGCurvePointComponent) property.objectReferenceValue; + + var pointCount = point.Curve.PointsCount; + + if (pointCount < 2) DrawProperty(property); + else + { + var pointIndex = point.Curve.IndexOf(point); + var buttonContent = new GUIContent("" + pointIndex, "Object has multiple components attached. Click to chose."); + + var buttonWidth = GUI.skin.button.CalcSize(buttonContent).x; + + Rect.width -= buttonWidth; + EditorGUI.PropertyField(Rect, property); + + + if (GUI.Button(new Rect(Rect) {width = buttonWidth, x = Rect.xMax}, buttonContent)) + { + BGCurveChosePointWindow.Open(pointIndex, point.Curve, newPoint => + { + property.objectReferenceValue = newPoint; + property.serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(property.serializedObject.targetObject); + }); + } + } + } + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs.meta new file mode 100644 index 0000000..54d0e1b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointComponentDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 83b0dba0ac76f224da8f2bef4a936744 +timeCreated: 1475061550 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs new file mode 100644 index 0000000..010426e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs @@ -0,0 +1,80 @@ +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; +using UnityEngineInternal; + +namespace BansheeGz.BGSpline.Editor +{ + //bug in editor while curve is rotated in 2d mode (position overflow to super big values while being dragged in SceneView) + [CustomEditor(typeof(BGCurvePointGO))] + public class BGCurvePointGOEditor : UnityEditor.Editor + { + public static bool PointSelected; + + private BGCurvePointI point; + private BGCurveEditorPoint pointEditor; + + private BGCurveEditor curveEditor; + private BGTransition.SwayTransition pointIndicatorTransition; + private Texture2D pointSelectedTexture; + + protected virtual BGCurvePointI Point + { + get { return (BGCurvePointI) target; } + } + + protected virtual void OnEnable() + { + point = Point; + + pointEditor = new BGCurveEditorPoint(() => null, null); + + if (curveEditor != null) curveEditor.OnDestroy(); + + curveEditor = (BGCurveEditor) CreateEditor(point.Curve); + + pointSelectedTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointSelected123); + + PointSelected = true; + } + + + void OnDisable() + { + PointSelected = false; + if (curveEditor != null) curveEditor.OnDisable(); + } + + void OnDestroy() + { + PointSelected = false; + if (curveEditor != null) curveEditor.OnDestroy(); + } + + public override void OnInspectorGUI() + { + var curve = point.Curve; + + BGCurveEditorPoints.SwapVector2Labels(curve.Mode2D, () => pointEditor.OnInspectorGui(point, curve.IndexOf(point), BGPrivateField.GetSettings(curve))); + } + + public virtual void OnSceneGUI() + { + BGEditorUtility.Assign(ref pointIndicatorTransition, () => new BGTransition.SwayTransition(30, 30, 1)); + + BGSceneViewOverlay.DrawHandlesGuiTexture(BGEditorUtility.GetSceneViewPosition(point.PositionWorld), pointIndicatorTransition, pointSelectedTexture); + + + curveEditor.OnSceneGUI(); + + // animation is off for now +// SceneView.RepaintAll(); + } + + [DrawGizmo(GizmoType.Selected)] + public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) + { + BGCurveEditor.DrawGizmos(curve, gizmoType); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs.meta new file mode 100644 index 0000000..45e0020 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurvePointGOEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 252e4a88e6bc93a47ba0fce8ecbba329 +timeCreated: 1476925566 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs new file mode 100644 index 0000000..c6ee651 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs @@ -0,0 +1,87 @@ +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + [CustomEditor(typeof(BGCurveReferenceToPoint))] + public class BGCurveReferenceToPointEditor : BGCurvePointGOEditor + { + private BGCurveReferenceToPoint pointReference; + + private BGTransformMonitor transformMonitor; + + protected override BGCurvePointI Point + { + get { return pointReference.Point; } + } + + protected override void OnEnable() + { + pointReference = (BGCurveReferenceToPoint) target; + + var point = pointReference.Point; + if (!IsValid(point)) + { + //no need for it anymore + DestroyImmediate(pointReference); + return; + } + + var allComponents = pointReference.GetComponents(); + if (allComponents.Any(component => component != pointReference && component.Point == pointReference.Point)) + { + DestroyImmediate(pointReference); + return; + } + + transformMonitor = BGTransformMonitor.GetMonitor(pointReference.transform, transform => point.Curve.FireChange(null)); + + base.OnEnable(); + } + + public void OnDestroy() + { + if (transformMonitor != null) transformMonitor.Release(); + transformMonitor = null; + pointReference = null; + } + + + private static bool IsValid(BGCurvePointI point) + { + return point != null && point.Curve != null && point.Curve.IndexOf(point) >= 0; + } + + public override void OnInspectorGUI() + { + transformMonitor.CheckForChange(); + + var point = pointReference.Point; + + if (!IsValid(point)) return; + + BGEditorUtility.DisableGui(() => EditorGUILayout.TextField("BGCurve", point.Curve.gameObject.name)); + + base.OnInspectorGUI(); + } + + public override void OnSceneGUI() + { + var point = pointReference.Point; + + if (!IsValid(point)) return; + + transformMonitor.CheckForChange(); + + base.OnSceneGUI(); + } + + [DrawGizmo(GizmoType.Selected)] + public new static void DrawGizmos(BGCurve curve, GizmoType gizmoType) + { + BGCurvePointGOEditor.DrawGizmos(curve, gizmoType); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs.meta new file mode 100644 index 0000000..c82ad65 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGCurveReferenceToPointEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 559b4471bb9f69d42b854d355126983a +timeCreated: 1477988941 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs new file mode 100644 index 0000000..70f08e3 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs @@ -0,0 +1,189 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Editor +{ + public static class BGNewPointPositionManager + { + //multiply tangent by this constant for new points, inserted after all points. + private const float DistanceToControlMultiplier = .2f; + + //multiply tangent by this constant for points, inserted between 2 existing points. + private const float DistanceToTangentMultiplier = .05f; + + //multiply tangent by this constant for points, which positions can not be derived + private const float DistanceToTangentNoDataMultiplier = 1.5f; + + private static BGCurvePoint point; + + public static BGCurvePoint CreatePoint(Vector3 position, BGCurve curve, BGCurvePoint.ControlTypeEnum controlType, int parts, bool ensureNew) + { + float distanceToPreviousPoint; + float distanceToNextPoint; + return CreatePoint(position, curve, controlType, parts, out distanceToPreviousPoint, out distanceToNextPoint, ensureNew); + } + + public static BGCurvePoint CreatePoint(Vector3 position, BGCurve curve, BGCurvePoint.ControlTypeEnum controlType, int parts, out float distanceToPreviousPoint, out float distanceToNextPoint, + bool ensureNew) + { + distanceToPreviousPoint = -1; + distanceToNextPoint = -1; + + if (curve.PointsCount == 0) + { + //first point + Vector3 control; + switch (curve.Mode2D) + { + case BGCurve.Mode2DEnum.YZ: + control = Vector3.forward; + break; + default: + // BGCurve.Mode2DEnum.XY: + // BGCurve.Mode2DEnum.Off: + // BGCurve.Mode2DEnum.XZ: + control = Vector3.right; + break; + } + return curve.CreatePointFromLocalPosition(curve.ToLocal(position), controlType, control, -control); + } + + parts = Mathf.Clamp(parts, 1, 50); + + //we no need no events (maybe check if point was actually added to a curve for events firing?) + var oldSuppress = curve.SupressEvents; + curve.SupressEvents = true; + + //create a point with no controls first + BGCurvePoint newPoint; + if (ensureNew) + { + newPoint = curve.CreatePointFromWorldPosition(position, BGCurvePoint.ControlTypeEnum.Absent); + } + else + { + if (point == null || point.Curve != curve) point = curve.CreatePointFromWorldPosition(position, BGCurvePoint.ControlTypeEnum.Absent); + newPoint = point; + newPoint.PositionWorld = position; + newPoint.ControlFirstLocal = Vector3.zero; + newPoint.ControlSecondLocal = Vector3.zero; + } + + if(curve.Mode2DOn) curve.Apply2D(newPoint); + + //adjacent points + var previousPoint = curve[curve.PointsCount - 1]; + var nextPoint = curve.Closed ? curve[0] : null; + + //direction + var tangent = BGEditorUtility.CalculateTangent(newPoint, previousPoint, nextPoint, 1/(float) parts); + if (tangent.sqrMagnitude < 0.0001f) + { + //whatever + switch (curve.Mode2D) + { + case BGCurve.Mode2DEnum.Off: + case BGCurve.Mode2DEnum.XY: + case BGCurve.Mode2DEnum.XZ: + tangent = Vector3.right; + break; + case BGCurve.Mode2DEnum.YZ: + tangent = Vector3.up; + break; + } + } + + //length + distanceToPreviousPoint = BGEditorUtility.CalculateDistance(previousPoint, newPoint, parts); + float minDistance; + if (nextPoint != null) + { + distanceToNextPoint = BGEditorUtility.CalculateDistance(newPoint, nextPoint, parts); + minDistance = Math.Min(distanceToPreviousPoint, distanceToNextPoint); + } + else + { + minDistance = distanceToPreviousPoint; + } + var length = minDistance*DistanceToControlMultiplier; + + + //we need local tangent for controls + tangent = curve.ToLocalDirection(tangent); + + + + newPoint.ControlSecondLocal = tangent*length; + + newPoint.ControlFirstLocal = -newPoint.ControlSecondLocal; + + + newPoint.ControlType = controlType; + + curve.SupressEvents = oldSuppress; + return newPoint; + } + + public static BGCurvePoint InsertBefore(BGCurve curve, int index, BGCurvePoint.ControlTypeEnum controlType, int parts) + { + var newPoint = CreatePointByPointsCount(curve, controlType); + if (newPoint != null) return newPoint; + + if (index == 0 && !curve.Closed) + return InsertNoData(curve, controlType, BGEditorUtility.CalculateTangent(curve[0], curve[1], 0f), curve[0].ControlFirstLocal, curve[0].PositionWorld, false); + + return CreatePointBetween(curve, index == 0 ? curve[curve.PointsCount - 1] : curve[index - 1], curve[index], parts, controlType); + } + + + public static BGCurvePoint InsertAfter(BGCurve curve, int index, BGCurvePoint.ControlTypeEnum controlType, int parts) + { + var newPoint = CreatePointByPointsCount(curve, controlType); + if (newPoint != null) return newPoint; + + var pointsCount = curve.PointsCount; + if (index == pointsCount - 1 && !curve.Closed) + { + var lastPoint = curve[pointsCount - 1]; + return InsertNoData(curve, controlType, BGEditorUtility.CalculateTangent(curve[pointsCount - 2], lastPoint, 1f), lastPoint.ControlSecondLocal, lastPoint.PositionWorld, true); + } + + return CreatePointBetween(curve, curve[index], index == pointsCount - 1 ? curve[0] : curve[index + 1], parts, controlType); + } + + private static BGCurvePoint CreatePointByPointsCount(BGCurve curve, BGCurvePoint.ControlTypeEnum controlType) + { + var pointsCount = curve.PointsCount; + + switch (pointsCount) + { + case 0: + throw new UnityException("You can not use this method with no points on the curve. pointsCount==0"); + case 1: + return curve.CreatePointFromLocalPosition(Vector3.forward, controlType, Vector3.right, Vector3.left); + } + return null; + } + + private static BGCurvePoint InsertNoData(BGCurve curve, BGCurvePoint.ControlTypeEnum controlType, Vector3 tangent, Vector3 control, Vector3 positionWorld, bool inverseTangent) + { + var controlMagnitude = control.magnitude; + if (controlMagnitude < 1) controlMagnitude = 1; + + var pos = positionWorld - tangent*controlMagnitude*DistanceToTangentNoDataMultiplier*(inverseTangent ? -1 : 1); + + return curve.CreatePointFromWorldPosition(pos, controlType, pos - tangent, pos + tangent); + } + + private static BGCurvePoint CreatePointBetween(BGCurve curve, BGCurvePointI previousPoint, BGCurvePointI nextPoint, int parts, BGCurvePoint.ControlTypeEnum controlType) + { + var newPos = BGEditorUtility.CalculatePosition(previousPoint, nextPoint, .5f); + var tangent = BGEditorUtility.CalculateTangent(previousPoint, nextPoint, .5f); + + var scaledTangent = tangent*DistanceToTangentMultiplier*BGEditorUtility.CalculateDistance(previousPoint, nextPoint, parts); + + return curve.CreatePointFromLocalPosition(curve.ToLocal(newPos), controlType, curve.ToLocalDirection(-scaledTangent), curve.ToLocalDirection(scaledTangent)); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs.meta new file mode 100644 index 0000000..9a921a4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGNewPointPositionManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aec4164ed8f499945a786507eac50af5 +timeCreated: 1472342782 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs new file mode 100644 index 0000000..75e76ab --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs @@ -0,0 +1,174 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGRectangularSelection + { + private const int BorderTextureSize = 8; + private static readonly Color BorderColor = new Color32(255, 255, 255, 100); + + private Texture2D back; + private readonly Texture2D borderHorizontal; + private readonly Texture2D borderVertical; + + private readonly BGCurve curve; + private readonly BGCurveEditorPointsSelection selection; + private readonly BGCurveEditor editor; + + private Vector2 start; + private bool selectionWasMade; + public bool IsOn { get; private set; } + + private Color backColor = BGCurveSettingsForEditor.ColorForRectangularSelection; + + public BGRectangularSelection(BGCurveEditor editor, BGCurveEditorPointsSelection selection) + { + this.editor = editor; + this.selection = selection; + curve = editor.Curve; + + borderHorizontal = CreateBorder(false); + borderVertical = CreateBorder(true); + } + + private Texture2D CreateBorder(bool vertical) + { + var texture = vertical ? new Texture2D(1, BorderTextureSize) : new Texture2D(BorderTextureSize, 1); + + var noColor = new Color(); + for (var i = 0; i < BorderTextureSize; i++) + { + var color = i > 3 ? noColor : BorderColor; + + if (vertical) texture.SetPixel(0, i, color); + else texture.SetPixel(i, 0, color); + } + texture.Apply(false); + return texture; + } + + + public void On() + { + IsOn = true; + selectionWasMade = false; + start = Event.current.mousePosition; + SceneView.RepaintAll(); + + //colors and texture + if (back == null || backColor != BGCurveSettingsForEditor.ColorForRectangularSelection) + { + backColor = BGCurveSettingsForEditor.ColorForRectangularSelection; + back = BGEditorUtility.Texture1X1(backColor); + } + } + + public void Off() + { + if (!IsOn) return; + IsOn = false; + + if (selectionWasMade) return; + + if (selection.HasSelected()) + { + selection.Clear(); + SceneView.RepaintAll(); + } + } + + public void Process(Event currentEvent) + { + if (!IsOn) return; + + var end = currentEvent.mousePosition; + + //we check if mouse pointer was moved + if (!selectionWasMade && (end - start).sqrMagnitude > 1) selectionWasMade = true; + + if (!selectionWasMade) return; + + var rect = new Rect(Math.Min(start.x, end.x), Math.Min(start.y, end.y), Math.Abs(start.x - end.x), Math.Abs(start.y - end.y)); + + //========================= Model + //update points + UpdatePoints(rect); + + //========================= UI + Ui(rect); + + SceneView.RepaintAll(); + editor.Repaint(); + } + + private void UpdatePoints(Rect rect) + { + var sceneViewHeight = BGEditorUtility.GetSceneViewHeight(); + + var math = editor.Math; + + curve.ForEach((point, index, count) => + { + //add or remove from selection + if (rect.Contains(BGEditorUtility.GetSceneViewPosition(math.GetPosition(index), sceneViewHeight))) selection.Add(point); + else selection.Remove(point); + }); + + if (!selection.Changed) return; + + selection.Reset(); + } + + + private void Ui(Rect rect) + { + Handles.BeginGUI(); + + var size = rect.size; + var width = Mathf.FloorToInt(Math.Abs(size.x)); + var height = Mathf.FloorToInt(Math.Abs(size.y)); + if (width == 0 || height == 0) return; + + //------ back + GUI.DrawTexture(rect, back, ScaleMode.StretchToFill); + + //------ borders + //top + DrawBorder(new Rect(rect) {width = width, height = height == 1 ? 1 : 2}, false); + if (height <= 2) return; + + //bottom + DrawBorder(new Rect(rect) {y = rect.yMax - 2, width = width, height = 2}, false); + + if (width <= 4 || height <= 4) return; + + //left + DrawBorder(new Rect(rect) {width = 2}, true); + //right + DrawBorder(new Rect(rect) {x = rect.xMax - 2, width = 2}, true); + + Handles.EndGUI(); + } + + private void DrawBorder(Rect rect, bool vertical) + { + float widthScale = 1, heightScale = 1; + Texture2D texture; + if (vertical) + { + texture = borderVertical; + heightScale = rect.height/BorderTextureSize; + } + else + { + texture = borderHorizontal; + widthScale = rect.width/BorderTextureSize; + } + + GUI.DrawTextureWithTexCoords(rect, texture, new Rect(0, 0, widthScale, heightScale)); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs.meta new file mode 100644 index 0000000..68f8ff0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Curve/BGRectangularSelection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 16379b7aa6eabc740a4a2086e6c30bff +timeCreated: 1472269887 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra.meta new file mode 100644 index 0000000..e44154d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b5ef7e0d16af7b04b9ae146bb3d792c6 +folderAsset: yes +timeCreated: 1473056753 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs new file mode 100644 index 0000000..2e2bfb5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs @@ -0,0 +1,340 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCcAddWindow : EditorWindow + { + private const int IconSize = 48; + private const int HeaderHeight = 12; + + private static readonly Vector2 WindowSize = new Vector2(700, 400); + + + private static Tree tree; + + private static Texture2D headerImage; + private static Texture2D noImage; + private static Texture2D boxWithBorderImage; + private static GUIStyle nameStyle; + private static GUIStyle disabledStyle; + private static GUIStyle filterStyle; + + private static Action action; + private static BGCcAddWindow instance; + + private static int tab; + private Vector2 scrollPos; + + internal static void Open(BGCurve curve, Action action, Type dependsOnType = null) + { + BGCcAddWindow.action = action; + + noImage = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCcNoImage123); + + tree = new Tree(curve, dependsOnType); + + instance = BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + //styles + AssighSyles(); + + + //draw header + DrawHeader(); + + + if (tree.Roots.Count == 0) + { + Message("Did not find any component"); + } + else + { + BGEditorUtility.VerticalBox(() => + { + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + tree.OnInspectorGui(); + EditorGUILayout.EndScrollView(); + + }); + } + } + + private static void Message(string message) + { + EditorGUILayout.LabelField(message, new GUIStyle("Label") + { + fontSize = 22, + wordWrap = true + }, GUILayout.Height(200)); + } + + private static void DrawHeader() + { + BGEditorUtility.HorizontalBox(() => { GUILayout.Label(" "); }); + GUI.DrawTexture(GUILayoutUtility.GetLastRect(), boxWithBorderImage); + + var rect = new Rect(new Vector2(40, 10), new Vector2(headerImage.width*HeaderHeight/(float) headerImage.height, HeaderHeight)); + GUI.DrawTexture(rect, headerImage); + + if (tree.DependsOnType != null) + GUI.Label(new Rect(rect) {x = rect.xMax + 10, height = 16, width = 400, y = rect.y - 2}, "Filter: Dependent on [" + tree.DependsOnType.Name + "]", filterStyle); + } + + private static void AssighSyles() + { + BGEditorUtility.Assign(ref nameStyle, () => new GUIStyle("Label") + { + alignment = TextAnchor.MiddleCenter, + clipping = TextClipping.Clip, + wordWrap = true, + fontStyle = FontStyle.Bold, + normal = + { + textColor = Color.black, + background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123) + } + }); + BGEditorUtility.Assign(ref disabledStyle, () => new GUIStyle("Label") + { + alignment = TextAnchor.MiddleCenter, + normal = + { + textColor = Color.red, + background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123) + } + }); + BGEditorUtility.Assign(ref filterStyle, () => new GUIStyle("Label") + { + fontStyle = FontStyle.Bold, + normal = + { + textColor = Color.red + } + }); + BGEditorUtility.Assign(ref headerImage, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCurveComponents123)); + BGEditorUtility.Assign(ref boxWithBorderImage, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123)); + } + + + //thanks to Bunny83 + public static Type[] GetAllSubTypes(Type targetType) + { + var result = new List(); + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblies) result.AddRange(from type in assembly.GetTypes() where type.IsClass where !type.IsAbstract where type.IsSubclassOf(targetType) select type); + return result.ToArray(); + } + + //=================================================================== Inner classes + + //================================================= Tree + private sealed class Tree : BGTreeView + { + private readonly Dictionary type2Node = new Dictionary(); + + public BGCurve Curve { get; private set; } + + public Type DependsOnType { get; private set; } + + public Tree(BGCurve curve, Type dependsOnType) + : base(new Config(0, (int) (IconSize*.9f), (int) (IconSize*.5f), 2, 16)) + { + Curve = curve; + DependsOnType = dependsOnType; + + //------------- load all BGCc subclasses + var typesList = GetAllSubTypes(typeof (BGCc)); + foreach (var node in from type in typesList + let descriptor = BGCc.GetDescriptor(type) + let single = BGCc.IsSingle(type) + select new CcNode(this, descriptor != null ? new CcData(type, single, descriptor) : new CcData(type, single, type.Name))) + { + try + { + node.CcData.ParentType = BGCc.GetParentClass(node.CcData.Type); + } + catch (Exception e) + { + Debug.LogException(e); + continue; + } + type2Node[node.CcData.Type] = node; + } + + foreach (var node in type2Node.Values) if (!node.Processed) node.ProcessStructure(); + } + + public CcNode this[Type type] + { + get { return type2Node[type]; } + } + + public override void OnInspectorGui() + { + if (DependsOnType == null) base.OnInspectorGui(); + else + { + var node = type2Node[DependsOnType]; + if (node == null) + { + Message("Error: Can not find component " + DependsOnType); + } + else if (!node.HasChildren) + { + Message("Component [" + node.CcData.Name + "] does not have any children"); + } + else + { + node.OnInspectorGui(); + } + } + } + } + + //================================================= Tree node + private sealed class CcNode : BGTreeNode + { + private readonly CcData ccData; + private readonly bool singleAndAdded; + private Texture2D addIcon; + + + private GUIStyle nameStyle; + private GUIStyle descriptionStyle; + private GUIStyle addedStyle; + + + public CcData CcData + { + get { return ccData; } + } + + public bool Processed { get; private set; } + + private Tree MyTree + { + get { return (Tree) Tree; } + } + + public CcNode(Tree tree, CcData ccData) + : base(tree) + { + this.ccData = ccData; + singleAndAdded = ccData.Single && tree.Curve.GetComponent(ccData.Type) != null; + } + + public override void OnInspectorGuiInternal(int level) + { + const int offset = 2; + + if (singleAndAdded) GUI.enabled = false; + if (GUILayout.Button("", GUILayout.Height(IconSize + offset*2))) + { + action(ccData.Type); + instance.Close(); + } + if (singleAndAdded) GUI.enabled = true; + + // Draw on top of the button (no more Layout stuff) + var buttonRect = GUILayoutUtility.GetLastRect(); + + + var iconRect = new Rect(buttonRect.x + offset, buttonRect.y + offset, IconSize, IconSize); + GUI.DrawTexture(iconRect, ccData.Icon); + +/* + //already added + if (singleAndAdded) GUI.DrawTexture(new Rect(iconRect) {x = iconRect.xMax + offset, width = offset*8}, + BGEUtil.Assign(ref addIcon, () => BGEUtil.LoadTexture2D(BGEUtil.Image.BGCcAdded123))); +*/ + if (singleAndAdded) + { + var oldMatrix = GUI.matrix; + BGEditorUtility.Assign(ref addedStyle, () => new GUIStyle("Box") + { + fontSize = 14, + fontStyle = FontStyle.Bold, + normal = {textColor = Color.red, background = BGEditorUtility.Texture1X1(new Color(1,0,0,.2f))} + }); + var content = new GUIContent("added"); + var labelSize = addedStyle.CalcSize(content); + var pivotPoint = new Vector2(iconRect.xMax, iconRect.center.y) + new Vector2(labelSize.y*.5f, 0); + GUIUtility.RotateAroundPivot(-90, pivotPoint); + GUI.Label(new Rect(pivotPoint - labelSize*.5f, labelSize), content, addedStyle); + GUI.matrix = oldMatrix; + } + + + //name + var nameStartX = iconRect.xMax + offset*12; + var nameRect = new Rect(nameStartX, iconRect.y, buttonRect.width - nameStartX, IconSize/3f); + EditorGUI.LabelField(nameRect, ccData.Name, BGEditorUtility.Assign(ref nameStyle, () => new GUIStyle("Label") {fontStyle = FontStyle.Bold})); + + //description + var descriptionRect = new Rect(nameStartX, nameRect.yMax + offset, nameRect.width, IconSize*2/3f); + EditorGUI.LabelField(descriptionRect, ccData.Description, BGEditorUtility.Assign(ref descriptionStyle, () => new GUIStyle("Label") {wordWrap = true})); + } + + + public override void ProcessStructure() + { + if (ccData.ParentType == null) + { + MyTree.Roots.Add(this); + } + else + { + Parent = MyTree[CcData.ParentType]; + } + Processed = true; + } + } + + //================================================= CC data + private sealed class CcData + { + public Type Type { get; private set; } + + public Type ParentType { get; set; } + + public string Description { get; private set; } + + public string Name { get; private set; } + + public Texture2D Icon { get; private set; } + + public bool Single { get; private set; } + + public CcData(Type type, bool single, BGCc.CcDescriptor ccDescriptor) + : this(type, single, ccDescriptor.Name) + { + Description = ccDescriptor.Description; + if (!string.IsNullOrEmpty(ccDescriptor.Image)) Icon = BGEditorUtility.LoadCcTexture2D(ccDescriptor.Image) ?? noImage; + } + + public CcData(Type type, bool single, string name) + { + Type = type; + + Name = name; + Icon = noImage; + Single = single; + + if (string.IsNullOrEmpty(Name)) Name = Type.Name; + } + + public override string ToString() + { + return Type.Name + ": " + Name; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs.meta new file mode 100644 index 0000000..2d35f25 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcAddWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a20bb7d90ed1356459501898772114a8 +timeCreated: 1472483253 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs new file mode 100644 index 0000000..2a40676 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCcChangeNameWindow : EditorWindow + { + private static readonly Vector2 WindowSize = new Vector2(400, 50); + + private static BGCc current; + private static string ccName; + private static BGCcChangeNameWindow instance; + + + private Vector2 scrollPos; + private GUIStyle boxStyle; + + + internal static void Open(BGCc current) + { + BGCcChangeNameWindow.current = current; + + ccName = current.CcName; + + instance = BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + BGEditorUtility.SwapLabelWidth(60, () => + { + BGEditorUtility.Horizontal(BGEditorUtility.Assign(ref boxStyle, () => new GUIStyle("Box") {padding = new RectOffset(8, 8, 8, 8)}), () => + { + ccName = EditorGUILayout.TextField("Name", ccName); + + GUILayout.Space(8); + + if (GUILayout.Button("Save and Close")) + { + if (!string.Equals(ccName, current.CcName)) + { + Undo.RecordObject(current, "Change name"); + current.CcName = ccName; + EditorUtility.SetDirty(current); + } + instance.Close(); + } + }); + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs.meta new file mode 100644 index 0000000..210ac3a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChangeNameWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec708301478213148abdd926189518ae +timeCreated: 1473063970 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs new file mode 100644 index 0000000..0217c41 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public abstract class BGCcChoseDrawer : BGPropertyDrawer where T : BGCc + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // this is a required startup call + SetUp(position, property, label, () => + { + if (!(property.objectReferenceValue != null)) + { + DrawProperty(property); + } + else + { + var cc = (T) property.objectReferenceValue; + + var allPossibleCcList = cc.GetComponents(cc.GetType()); + + if (allPossibleCcList.Length < 2) + { + DrawProperty(property); + } + else + { + var buttonContent = new GUIContent(BGEditorUtility.Trim(cc.CcName, 16), "Object has multiple components attached. Click to chose."); + + var buttonWidth = GUI.skin.button.CalcSize(buttonContent).x; + + Rect.width -= buttonWidth; + EditorGUI.PropertyField(Rect, property); + + + if (GUI.Button(new Rect(Rect) {width = buttonWidth, x = Rect.xMax}, buttonContent)) + { + BGCcChoseWindow.Open(cc, allPossibleCcList, newCc => + { + Undo.RecordObject(property.serializedObject.targetObject, "Cc changed"); + property.objectReferenceValue = newCc; + property.serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(property.serializedObject.targetObject); + }); + } + } + } + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs.meta new file mode 100644 index 0000000..16c5a51 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 58d3f7af09907cf429f8934b2cb7eb35 +timeCreated: 1473062560 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs new file mode 100644 index 0000000..f850246 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs @@ -0,0 +1,60 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCcChoseWindow : EditorWindow + { + private static readonly Vector2 WindowSize = new Vector2(400, 200); + + private static Action action; + private static BGCcChoseWindow instance; + private static BGCc current; + private static Component[] availableList; + private static GUIStyle boxStyle; + + + private Vector2 scrollPos; + + + internal static void Open(BGCc current, Component[] availableList, Action action) + { + BGCcChoseWindow.action = action; + BGCcChoseWindow.current = current; + BGCcChoseWindow.availableList = availableList; + + instance = BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + + ShowButtons(); + + EditorGUILayout.EndScrollView(); + } + + private static void ShowButtons() + { + BGEditorUtility.Vertical(BGEditorUtility.Assign(ref boxStyle, () => new GUIStyle("Box") {padding = new RectOffset(8, 8, 8, 8)}), () => + { + for (var i = 0; i < availableList.Length; i++) + { + var cc = (BGCc) availableList[i]; + + BGEditorUtility.DisableGui(() => + { + if (!GUILayout.Button(cc.CcName)) return; + + + action(cc); + instance.Close(); + }, cc == current); + } + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs.meta new file mode 100644 index 0000000..d56fa59 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCcChoseWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3afdd426232a2c34f8f50115b9d5c751 +timeCreated: 1473060319 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs new file mode 100644 index 0000000..4edfc0f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs @@ -0,0 +1,54 @@ +using System; +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + // idea.. partially copy/pasted from BGCcChoseWindow + public class BGChoseComponentWindow : EditorWindow + { + private static readonly Vector2 WindowSize = new Vector2(400, 400); + + private static Action action; + private static BGChoseComponentWindow instance; + private static Component current; + private static GUIStyle boxStyle; + + + private Vector2 scrollPos; + + + internal static void Open(Component current, Action action) + { + BGChoseComponentWindow.action = action; + BGChoseComponentWindow.current = current; + + instance = BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + + BGEditorUtility.VerticalBox(() => + { + var allComponents = current.GetComponents(typeof (Component)); + foreach (var component in allComponents) + { + var comp = component; + BGEditorUtility.DisableGui(() => + { + if (GUILayout.Button(comp.ToString(), GUILayout.Width(380))) + { + action(comp); + instance.Close(); + } + }, current == component); + } + }); + + EditorGUILayout.EndScrollView(); + + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs.meta new file mode 100644 index 0000000..595189b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGChoseComponentWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3164790b79db83d40a1b9a2746cf9b6a +timeCreated: 1475286949 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs new file mode 100644 index 0000000..7d1d7a8 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs @@ -0,0 +1,43 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + // idea.. partially copy/pasted from BGCcChoseWindow + public class BGCurveChosePointWindow : EditorWindow + { + private static readonly Vector2 WindowSize = new Vector2(400, 40); + + private static Action action; + private static BGCurveChosePointWindow instance; + private static BGCurve curve; + private static int current; + + internal static void Open(int current, BGCurve curve, Action action) + { + BGCurveChosePointWindow.action = action; + BGCurveChosePointWindow.current = current; + BGCurveChosePointWindow.curve = curve; + + instance = BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + BGEditorUtility.HorizontalBox(() => + { + EditorGUILayout.LabelField("Point index", GUILayout.Width(100)); + var newValue = EditorGUILayout.IntSlider(current, 0, curve.PointsCount - 1, GUILayout.Width(200)); + if (current != newValue) + { + current = newValue; + action((BGCurvePointComponent) curve[newValue]); + } + + if (GUILayout.Button("Close", GUILayout.Width(50))) instance.Close(); + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs.meta new file mode 100644 index 0000000..0466a3b --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurveChosePointWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 47003328321ae5a4d8ceaf8ab44b555e +timeCreated: 1475061925 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs new file mode 100644 index 0000000..24b00ce --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs @@ -0,0 +1,82 @@ +using BansheeGz.BGSpline.Curve; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + //draws a curve in editor + public class BGCurvePainterGizmo + { + public BGCurveBaseMath Math { get; private set; } + + private readonly BGTransformMonitor transformMonitor; + + public BGCurvePainterGizmo(BGCurveBaseMath math, bool monitorTransform = false) + { + Math = math; + if (monitorTransform) transformMonitor = BGTransformMonitor.GetMonitor(math.Curve); + } + + public virtual void DrawCurve() + { + if (transformMonitor != null) transformMonitor.CheckForChange(); + + var settings = BGPrivateField.GetSettings(Math.Curve); + + BGEditorUtility.SwapGizmosColor(settings.LineColor, () => + { + //======================================== Draw section + for (var i = 0; i < Math.SectionsCount; i++) DrawSection(Math[i]); + }); + + + //======================================== Draw spheres + if (settings.ShowSpheres) + { + BGEditorUtility.SwapGizmosColor(settings.SphereColor, () => + { + BeforeDrawingSpheres(settings); + for (var i = 0; i < Math.Curve.PointsCount; i++) DrawSphere(settings, Math.GetPosition(i), settings.SphereRadius); + AfterDrawingSpheres(); + }); + } + } + + public void Dispose() + { + if (Math != null) Math.Dispose(); + if (transformMonitor != null) transformMonitor.Release(); + } + + protected virtual void BeforeDrawingSpheres(BGCurveSettings settings) + { + } + + protected virtual void AfterDrawingSpheres() + { + } + + public virtual void DrawSphere(BGCurveSettings settings, Vector3 pos, float sphereRadius) + { + Gizmos.DrawSphere(pos, sphereRadius); + } + + protected void DrawSection(BGCurveBaseMath.SectionInfo section) + { + if (section.PointsCount < 2) return; + + var points = section.Points; + var prevPoint = points[0]; + for (var i = 1; i < points.Count; i++) + { + var nexPoint = points[i]; + DrawLine(prevPoint.Position, nexPoint.Position); + prevPoint = nexPoint; + } + } + + protected virtual void DrawLine(Vector3 from, Vector3 to) + { + Gizmos.DrawLine(from, to); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs.meta new file mode 100644 index 0000000..42988a0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterGizmo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 61f851c212ea4794cb98000e86717feb +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs new file mode 100644 index 0000000..f3d18fd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs @@ -0,0 +1,42 @@ +using BansheeGz.BGSpline.Curve; +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCurvePainterHandles : BGCurvePainterGizmo + { + private Color tempColorBeforeSpheresDraw; + + public BGCurvePainterHandles(BGCurveBaseMath math) + : base(math) + { + } + + public override void DrawCurve() + { + BGEditorUtility.SwapHandlesColor(BGPrivateField.GetSettings(Math.Curve).LineColor, () => base.DrawCurve()); + } + + protected override void BeforeDrawingSpheres(BGCurveSettings settings) + { + tempColorBeforeSpheresDraw = Handles.color; + Handles.color = settings.SphereColor; + } + + protected override void AfterDrawingSpheres() + { + Handles.color = tempColorBeforeSpheresDraw; + } + + public override void DrawSphere(BGCurveSettings settings, Vector3 pos, float sphereRadius) + { + Handles.SphereCap(0, pos, Quaternion.identity, sphereRadius*2); + } + + protected override void DrawLine(Vector3 @from, Vector3 to) + { + Handles.DrawLine(from, to); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs.meta new file mode 100644 index 0000000..1fac635 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGCurvePainterHandles.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aee191ffbacf6ee47aab2ecea5833778 +timeCreated: 1458655215 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs new file mode 100644 index 0000000..0101c04 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs @@ -0,0 +1,70 @@ +using BansheeGz.BGSpline.Curve; +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + // Currently this file is not used + // custom drawer for handles settings + // idea.. code is still messy after refactoring + [CustomPropertyDrawer(typeof (BGCurveSettings.SettingsForHandles))] + public class BGHandlesSettingsDrawer : BGPropertyDrawer + { + //do not remove. It indicates 5 lines are used + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return base.GetPropertyHeight(property, label)*5; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // this is required startup call + SetUp(position, property, label, () => + { + //occupy 2 lines + SetHeight(Height*2); + + //this call will set controlRect=space for control itself (without label) + PrefixLabel("Remove"); + + //set cursor to the start of just allocated space for control + SetCursor(ControlRect.x, ControlRect.y); + + //this block will draw checkboxes for Remove options + Indent(0, () => + { + //------------------------------------------- first line + LineWithRemoveControls(property, Height, 15, new[] {"X", "Y", "Z"}, new[] {"RemoveX", "RemoveY", "RemoveZ"}); + + //------------------------------------------- second line + SetCursor(ControlRect.x, CursorY + Height); + LineWithRemoveControls(property, Height, 20, new[] {"XZ", "XY", "YZ"}, new[] {"RemoveXZ", "RemoveXY", "RemoveYZ"}); + }); + + //------------------------------------------- third line (Scale Axis) + //reset height to standard 1 line + SetHeight(Height); + //skip 2 lines, used for checkboxes + NextLine(2); + DrawRelativeProperty(property, "Scale Axis", "AxisScale"); + + //------------------------------------------- forth line (Scale Planes) + NextLine(); + DrawRelativeProperty(property, "Scale Planes", "PlanesScale"); + + //------------------------------------------- fifth line (Alpha) + NextLine(); + DrawRelativeProperty(property, "Alpha", "Alpha"); + }); + } + + private void LineWithRemoveControls(SerializedProperty property, float height, int labelWidth, string[] labels, string[] fields) + { + for (var i = 0; i < labels.Length; i++) + { + RelativePropertyByCursor(10, height, property, fields[i]); + LabelByCursor(labelWidth, height, labels[i]); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs.meta new file mode 100644 index 0000000..4cb9c81 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGHandlesSettingsDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 595f24c0eb8112744bbf9d8d45b91e06 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs new file mode 100644 index 0000000..ce34edd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs @@ -0,0 +1,102 @@ +using System; +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //idea.. code is very messy even after refactoring + //there are currently 2 strategies to draw- 1) by using labelRect + controlRect. 2) By using cursors. This is a total mess. + public class BGPropertyDrawer : PropertyDrawer + { + private const int Space = 5; + + //one line height + protected float Height; + + //space to use for property GUI + protected Rect Rect; + //space used for show Control calls + protected Rect ControlRect; + + //additional cursors for *ByCursor calls. + protected float CursorX; + protected float CursorY; + + // startUp (Required!) + protected void SetUp(Rect position, SerializedProperty property, GUIContent label, Action action) + { + Rect = position; + //do not remove base ref + Height = base.GetPropertyHeight(property, label); + EditorGUI.BeginProperty(position, label, property); + action(); + EditorGUI.EndProperty(); + } + + //helper with indents + protected void Indent(int indent, Action action) + { + var oldIndent = EditorGUI.indentLevel; + EditorGUI.indentLevel = indent; + action(); + EditorGUI.indentLevel = oldIndent; + } + + + //======================================================= By labelRect + controlRect + + protected void PrefixLabel(string message, string tooltip = null) + { + ControlRect = EditorGUI.PrefixLabel(Rect, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(message, tooltip)); + } + + protected void DrawProperty(SerializedProperty property) + { +// PrefixLabel(property.displayName, property.tooltip); + EditorGUI.PropertyField(Rect, property); + } + + + protected bool RelativeProperty(SerializedProperty property, string name) + { + return EditorGUI.PropertyField(ControlRect, property.FindPropertyRelative(name), GUIContent.none); + } + + protected void DrawRelativeProperty(SerializedProperty property, string label, string propertyName, string tooltip = null) + { + PrefixLabel(label, tooltip); + Indent(0, () => RelativeProperty(property, propertyName)); + } + + + protected void SetHeight(float height) + { + Rect.height = height; + } + + protected void NextLine(int linesToSkip = 1) + { + Rect.y += Height*linesToSkip; + } + + + //======================================================= By Cursor + protected void RelativePropertyByCursor(int width, float height, SerializedProperty property, string name) + { + EditorGUI.PropertyField(new Rect(CursorX, CursorY, width, height), property.FindPropertyRelative(name), GUIContent.none); + CursorX += width + Space; + } + + protected void LabelByCursor(int width, float height, string label) + { + EditorGUI.LabelField(new Rect(CursorX, CursorY, width, height), label); + CursorX += width + Space; + } + + protected void SetCursor(float x, float y) + { + CursorX = x; + CursorY = y; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs.meta new file mode 100644 index 0000000..fc663ef --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGPropertyDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5b27947e37c1b494cbcf1ac8331c96a9 +timeCreated: 1471778173 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs new file mode 100644 index 0000000..6a652a3 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGTransformMonitor + { + private static readonly Queue Pool = new Queue(); + + private Vector3 position; + private Quaternion rotation; + private Vector3 scale; + + private Transform transform; + private Action changed; + + private BGTransformMonitor(Transform transform, Action changed) + { + Update(transform, changed); + } + + public static BGTransformMonitor GetMonitor(Transform transform, Action changed) + { + if (Pool.Count == 0) return new BGTransformMonitor(transform, changed); + + var monitor = Pool.Dequeue(); + monitor.transform = transform; + monitor.changed = changed; + + return monitor; + } + + public static BGTransformMonitor GetMonitor(BGCurve curve) + { + return GetMonitor(curve.transform, transform1 => { curve.FireChange(null); }); + } + + + public bool CheckForChange(bool skipAction = false) + { + if (Application.isPlaying || changed == null || transform == null) return false; + + if (position == transform.position && rotation == transform.rotation && scale == transform.lossyScale) return false; + + Update(); + + if (!skipAction) changed(transform); + + return true; + } + + public void Release() + { + transform = null; + changed = null; + + Pool.Enqueue(this); + } + + + private void Update(Transform transform, Action changed) + { + this.transform = transform; + this.changed = changed; + Update(); + } + + private void Update() + { + position = transform.position; + rotation = transform.rotation; + scale = transform.lossyScale; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs.meta new file mode 100644 index 0000000..0356d94 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Infra/BGTransformMonitor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 82b8689fcf20fad4dac3b2732079ad96 +timeCreated: 1474230021 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay.meta new file mode 100644 index 0000000..fd0c658 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2e55235c43bc9794398e45f589fe1c1a +folderAsset: yes +timeCreated: 1472482844 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs new file mode 100644 index 0000000..a260e04 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs @@ -0,0 +1,52 @@ +using UnityEditor; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGOverlayMessage + { + private const float ShowTime = 1.5f; + + private string message; + private double started; + private bool showing; + + private GUIStyle style; + private readonly Rect rect = new Rect(10, 10, 400, 60); + + + //indicates the message should be shown + public void Display(string message) + { + this.message = message; + started = EditorApplication.timeSinceStartup; + showing = true; + } + + // call this every frame to find out if the message expired + public void Check() + { + if (showing && EditorApplication.timeSinceStartup - started > ShowTime) SceneView.RepaintAll(); + } + + // shows a message in the scene view + public void OnSceneGui() + { + if (!showing) return; + + if (EditorApplication.timeSinceStartup - started > ShowTime) showing = false; + + BGEditorUtility.Assign(ref style, () => new GUIStyle("Label") + { + alignment = TextAnchor.MiddleCenter, + richText = true, + normal = {textColor = Color.white, background = BGEditorUtility.Texture1X1(new Color32(0, 0, 0, 100))} + }); + + + Handles.BeginGUI(); + GUI.Label(rect, message, style); + Handles.EndGUI(); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs.meta new file mode 100644 index 0000000..8bf5800 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGOverlayMessage.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3fe7d907a5ebe0b4e8b4d4ed3a46608e +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs new file mode 100644 index 0000000..27ce19a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs @@ -0,0 +1,226 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //popup menu in SceneView + public class BGPopupMenu + { + private const int HeaderHeight = 16; + + + private readonly Texture2D menuItemBackgroundTexture; + private readonly Texture2D backTexture; + private readonly Texture2D selectedTexture; + private readonly Texture2D currentTexture; + + private readonly string title; + + + public Vector2 Point2DPosition; + public Vector3 Point3DPosition; + public bool Active; + public MenuItem ActiveItem; + + private float height; + private float width; + private Rect targetRect; + private BGTransition.SimpleTransition onTransition; + + private readonly List items = new List(); + private GUIStyle titleStyle; + + public BGPopupMenu(string title) + { + this.title = title; + menuItemBackgroundTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGMenuItemBackground123); + backTexture = BGEditorUtility.Texture1X1(new Color32(46, 144, 168, 80)); + selectedTexture = BGEditorUtility.Texture1X1(new Color32(0, 255, 0, 100)); + currentTexture = BGEditorUtility.Texture1X1(new Color32(200, 200, 200, 200)); + } + + public void Add(MenuItem item) + { + items.Add(item); + } + + public MenuItem Get(int index) + { + return items[index]; + } + + public virtual void On(Vector3 position) + { + if (Active) return; + + Active = true; + + onTransition = new BGTransition.SimpleTransition(.2, false); + Point3DPosition = position; + Point2DPosition = BGEditorUtility.GetSceneViewPosition(Point3DPosition); + + //target size (go first) + height = width = 0; + foreach (var size in items.Where(item => !item.Disabled).Select(item => item.Size)) + { + if (height < size.y*2) height = size.y*2; + width += size.x; + } + targetRect.size = new Vector2(width, height + HeaderHeight); + + + //target position (go second) + targetRect.x = Point2DPosition.x - targetRect.size.x*.5f; + targetRect.y = Point2DPosition.y - targetRect.size.y*.75f; + } + + public void OnGui(Event currentEvent) + { + if (!Active) return; + + var mousePosition = currentEvent.mousePosition; + + if (onTransition == null && !targetRect.Contains(mousePosition)) + { + Active = false; + SceneView.RepaintAll(); + return; + } + + BGEditorUtility.Assign(ref titleStyle, () => new GUIStyle("Label") + { + fontStyle = FontStyle.Bold, + alignment = TextAnchor.MiddleCenter, + normal = + { + textColor = Color.white, + background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123) + }, + }); + + Handles.BeginGUI(); + + if (onTransition != null && !onTransition.Tick()) + { + //animating transition + GUI.DrawTexture(new Rect(Vector2.Lerp(Point2DPosition, targetRect.position, onTransition.Ratio), targetRect.size*onTransition.Ratio), backTexture, ScaleMode.StretchToFill); + } + else + { + //ready + onTransition = null; + + GUI.DrawTexture(targetRect, backTexture, ScaleMode.StretchToFill); + GUI.Label(new Rect(targetRect) {height = HeaderHeight}, title, titleStyle); + + ActiveItem = null; + var cursor = targetRect.x; + + foreach (var item in items.Where(item => !item.Disabled)) + { + var itemRect = new Rect(cursor, targetRect.y + HeaderHeight, item.Size.x, item.Size.y); + var selected = itemRect.Contains(mousePosition); + + //if not separator + if (selected && item.Description != null) + { + ActiveItem = item; + + if (!currentEvent.control && item is MenuItemButton) ((MenuItemButton) item).Action(); + } + + //icon + if (item.Icon != null) + { + GUI.DrawTexture(itemRect, menuItemBackgroundTexture, ScaleMode.StretchToFill); + + if (selected) GUI.DrawTexture(itemRect, selectedTexture, ScaleMode.StretchToFill); + + GUI.DrawTexture(itemRect, item.Icon, ScaleMode.StretchToFill); + } + + if (item.Current) + { + GUI.DrawTexture(itemRect, currentTexture, ScaleMode.StretchToFill); + } + + cursor += itemRect.width; + } + } + + Handles.EndGUI(); + + if (!currentEvent.control) Active = false; + } + + //=================================================================================== menu items + //---------------------- abstract + public abstract class MenuItem + { + public abstract string Description { get; } + public abstract Texture2D Icon { get; } + public abstract Vector2 Size { get; } + + public bool Disabled; + + public bool Current; + } + + //---------------------- separator + public class MenuSeparator : MenuItem + { + private readonly Vector2 size = new Vector2(16, 32); + + public override string Description + { + get { return null; } + } + + public override Texture2D Icon + { + get { return null; } + } + + public override Vector2 Size + { + get { return size; } + } + } + + //---------------------- menu item + public class MenuItemButton : MenuItem + { + public readonly Action Action; + + private readonly Texture2D iconTexture; + private readonly string description; + private readonly Vector2 size = new Vector2(32, 32); + + + public override string Description + { + get { return description; } + } + + public override Texture2D Icon + { + get { return iconTexture; } + } + + public override Vector2 Size + { + get { return size; } + } + + public MenuItemButton(Texture2D iconTexture, string description, Action action) + { + this.iconTexture = iconTexture; + this.description = description; + Action = action; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs.meta new file mode 100644 index 0000000..da7e8b4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGPopupMenu.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5da84aced639ead46b938408b8bc6a0c +timeCreated: 1472295379 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs new file mode 100644 index 0000000..e448905 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs @@ -0,0 +1,143 @@ +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //scene view context actions (Ctrl pressed) + //idea.. whole BGSceneViewOverlay thing needs to be refactored + public sealed class BGSceneViewOverlay + { + private static readonly string HeaderColor = BGEditorUtility.ToHex(new Color32(255, 255, 255, 255)); +// private static readonly string ErrorColor = ToHex(new Color32(122, 0, 0, 255)); + private static readonly string ErrorColor = BGEditorUtility.ToHex(new Color32(250, 207, 207, 255)); +// private static readonly string OkColor = ToHex(new Color32(0, 122, 0, 255)); + private static readonly string OkColor = BGEditorUtility.ToHex(new Color32(207, 250, 209, 255)); +// private static readonly string ActionColor = ToHex(new Color32(46, 143, 168, 255)); + private static readonly string ActionColor = BGEditorUtility.ToHex(Color.white); + + internal readonly BGCurveEditorPoints Editor; + private GUIStyle style; + + private readonly SceneAction[] actions; + + //some kind of standard trick + public BGEditorUtility.EventCanceller EventCanceller; + + public BGSceneViewOverlay(BGCurveEditorPoints editor, BGCurveEditorPointsSelection editorSelection) + { + Editor = editor; + + actions = new SceneAction[] + { + new BGSceneViewOverlayMenuSelection(this, editorSelection), + new BGSceneViewOverlayMenuPoint(this, editorSelection), + new BGSceneViewOverlayPointAddAtDistance(this), + new BGSceneViewOverlayPointAddSnap3D(this), + new BGSceneViewOverlayPointAddSnap2D(this) + }; + } + + private void Message(SceneAction action, Vector3 position, string message) + { + BGEditorUtility.SwapHandlesColor(new Color32(46, 143, 168, 255), () => + { + // idea.. some hacker's work that needs to be redone + var error = message.IndexOf(ErrorColor) != -1; + + Handles.Label(position, " " + + "" + + BGEditorUtility.ColorIt("Action[", HeaderColor) + + BGEditorUtility.ColorIt(action.Name, ActionColor) + + BGEditorUtility.ColorIt("] ", HeaderColor) + + (error ? ToError("Error") : ToOk("Ok")) + + "\r\n" + + message, style); + }); + } + + + public void Process(Event currentEvent) + { + if (currentEvent.type == EventType.mouseUp) BGEditorUtility.Release(ref EventCanceller); + + if (currentEvent.shift && !currentEvent.control) return; + + Vector3 mousePosition = Event.current.mousePosition; + + var pixelHeight = SceneView.currentDrawingSceneView.camera.pixelHeight; + var pixelWidth = SceneView.currentDrawingSceneView.camera.pixelWidth; + mousePosition.y = pixelHeight - mousePosition.y; + if (mousePosition.x < 0 || mousePosition.y < 0 || mousePosition.x > pixelWidth || mousePosition.y > pixelHeight) return; + + + BGEditorUtility.Assign(ref style, () => new GUIStyle("Label") + { + padding = new RectOffset(4, 4, 4, 4), + border = new RectOffset(4, 4, 4, 4), + fontStyle = FontStyle.Bold, + richText = true, + normal = new GUIStyleState + { + textColor = Color.white, + background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123) + } + }); + + + foreach (var action in actions) + { + var position = Vector3.zero; + string message = null; + + var seized = action.Seize(currentEvent, ref position, ref message); + if (!seized) continue; + + if (message != null) Message(action, position, message); + break; + } + + if (currentEvent.control && currentEvent.type != EventType.Repaint) SceneView.RepaintAll(); + } + + public static string ToError(string error) + { + return BGEditorUtility.ColorIt(error, ErrorColor); + } + + public static string ToOk(string okMessage) + { + return BGEditorUtility.ColorIt(okMessage, OkColor); + } + + //identify particular action + public abstract class SceneAction + { + protected readonly BGSceneViewOverlay overlay; + + public abstract string Name { get; } + + protected SceneAction(BGSceneViewOverlay overlay) + { + this.overlay = overlay; + } + + //return true if event is seized by this action. if seized, Position and message should also be set in this case + internal abstract bool Seize(Event currentEvent, ref Vector3 position, ref string message); + } + + public static void DrawHandlesGuiTexture(Vector2 screenPoint, BGTransition.SwayTransition pointIndicatorTransition, Texture2D pointSelectedTexture) + { + pointIndicatorTransition.Tick(); + + var shift = pointIndicatorTransition.Value*.5f; + + Handles.BeginGUI(); + + GUI.DrawTexture( + new Rect(screenPoint - new Vector2(shift, shift), new Vector2(pointIndicatorTransition.Value, pointIndicatorTransition.Value)), + pointSelectedTexture, ScaleMode.StretchToFill); + + Handles.EndGUI(); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs.meta new file mode 100644 index 0000000..5907bdd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlay.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 91d24c95cb2b3554fa3ab77739c350f2 +timeCreated: 1472269855 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs new file mode 100644 index 0000000..0283a1a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs @@ -0,0 +1,131 @@ +using System; +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public abstract class BGSceneViewOverlayMenu : BGSceneViewOverlay.SceneAction where T : BGSceneViewOverlayMenu.AbstractMenu + { + protected const float DistanceTolerance = 100; + + private readonly Texture2D pointSelectedTexture; + + protected T menu; + protected BGCurveEditorPointsSelection editorSelection; + + private BGTransition.SwayTransition pointIndicatorTransition; + + protected BGSceneViewOverlayMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) + : base(overlay) + { + this.editorSelection = editorSelection; + pointSelectedTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointSelected123); + } + + internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message) + { + if (menu.Active) + { + menu.OnGui(currentEvent); + + BGEditorUtility.Assign(ref pointIndicatorTransition, () => new BGTransition.SwayTransition(20, 30, .4f)); + BGSceneViewOverlay.DrawHandlesGuiTexture(menu.Point2DPosition, pointIndicatorTransition, pointSelectedTexture); + + var okMessage = menu.ActiveItem != null && menu.ActiveItem.Description != null + ? "Release Ctrl to " + menu.ActiveItem.Description + : "Hover over an option and release Ctrl."; + + //out params + position = menu.Point3DPosition; + message = BGSceneViewOverlay.ToOk(okMessage) + "\r\n" + menu.Details; + //============== Ok + return true; + } + + if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control)) return false; + + if (Process(currentEvent, overlay.Editor.Editor.Math, BGEditorUtility.GetSceneViewHeight(), ref position, ref message)) return true; + + pointIndicatorTransition = null; + + //============== No luck + return false; + } + + protected abstract bool Process(Event @event, BGCurveBaseMath math, float sceneViewHeight, ref Vector3 position, ref string message); + + + + protected static string SuccessMessage(string message) + { + return BGSceneViewOverlay.ToOk("Hover over an option and release Ctrl.\r\n") + message; + } + + + //========================================================== Abstract menu + public abstract class AbstractMenu : BGPopupMenu + { + public readonly BGCurveEditorPointsSelection EditorSelection; + public readonly BGSceneViewOverlay Overlay; + + public abstract string Details { get; } + + protected AbstractMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection, string title) + : base(title) + { + EditorSelection = editorSelection; + Overlay = overlay; + + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlAbsent123), "Convert point control to Absent", + () => { SetControl(BGCurvePoint.ControlTypeEnum.Absent); })); + + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierSymmetrical123), "Convert point control to Bezier Symmetrical", + () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierSymmetrical); })); + + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierIndependent123), "Convert point control to Bezier Independent", + () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierIndependant); })); + + + AdditionalMenuItems(); + + + Add(new LockMenuItem(() => + { + BGCurveSettingsForEditor.LockView = !BGCurveSettingsForEditor.LockView; + EditorUtility.SetDirty(overlay.Editor.Curve); + })); + + Add(new MenuSeparator()); + + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointDelete123), "Delete a point", Delete)); + } + + protected virtual void AdditionalMenuItems() + { + } + + protected abstract void SetControl(BGCurvePoint.ControlTypeEnum controlType); + protected abstract void Delete(); + } + + //========================================================== Lock menu + private sealed class LockMenuItem : BGPopupMenu.MenuItemButton + { + public LockMenuItem(Action action) + : base(null, null, action) + { + } + + public override string Description + { + get { return BGCurveSettingsForEditor.LockView ? "Switch 'Lock View' mode off" : "Switch 'Lock View' mode on"; } + } + + public override Texture2D Icon + { + get { return BGEditorUtility.LoadTexture2D(BGCurveSettingsForEditor.LockView ? BGEditorUtility.Image.BGLockOn123 : BGEditorUtility.Image.BGLockOff123); } + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs.meta new file mode 100644 index 0000000..f6f8347 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenu.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 25d2d1299235bef4fbddaea4c0a46414 +timeCreated: 1472984624 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs new file mode 100644 index 0000000..73b1df5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs @@ -0,0 +1,146 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //point's menu + public class BGSceneViewOverlayMenuPoint : BGSceneViewOverlayMenu + { + public override string Name + { + get { return "Point menu"; } + } + + public BGSceneViewOverlayMenuPoint(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) : base(overlay, editorSelection) + { + menu = new PointMenu(overlay, editorSelection); + } + + + protected override bool Process(Event @event, BGCurveBaseMath math, float sceneViewHeight, ref Vector3 position, ref string message) + { + if (BGCurveSettingsForEditor.DisableSceneViewPointMenu) return false; + + var minDistanceToCamera = float.MaxValue; + var mousePosition = @event.mousePosition; + var cameraPos = SceneView.currentDrawingSceneView.camera.transform.position; + + var index = -1; + var pointsCount = math.Curve.PointsCount; + + for (var i = 0; i < pointsCount; i++) + { + var pointPos = math.GetPosition(i); + + var sqrMagnitude = (mousePosition - BGEditorUtility.GetSceneViewPosition(pointPos, sceneViewHeight)).sqrMagnitude; + if (sqrMagnitude > DistanceTolerance) continue; + + var sqrtMagnitude = Vector3.SqrMagnitude(cameraPos - pointPos); + + if (minDistanceToCamera < sqrtMagnitude) continue; + + //found a target + minDistanceToCamera = sqrMagnitude; + index = i; + } + + if (index < 0) return false; + + + //menu active + var point = math.Curve[index]; + position = math.GetPosition(index); + message = SuccessMessage("Point " + index); + menu.On(point, index); + + //============== Ok + return true; + } + + + //========================================================== Point menu + public sealed class PointMenu : AbstractMenu + { + public int PointIndex; + private BGCurvePointI point; + private MenuItemButton addToSelectionItem; + private MenuItemButton removeFromSelectionItem; + + public PointMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) + : base(overlay, editorSelection, "Point menu") + { + } + + public override string Details + { + get { return "Point " + PointIndex; } + } + + protected override void AdditionalMenuItems() + { + Add(new MenuSeparator()); + + //add before + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointInsertBefore123), "Insert a point before this point", + () => + { + var curve = point.Curve; + var settings = BGPrivateField.GetSettings(curve); + var index = curve.IndexOf(point); + + BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index); + })); + + //add after + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointInsertAfter123), "Insert a point after this point", + () => + { + var curve = point.Curve; + var settings = BGPrivateField.GetSettings(curve); + var index = curve.IndexOf(point); + BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.InsertAfter(curve, index, settings.ControlType, settings.Sections), index + 1); + })); + + + //add remove to selection + addToSelectionItem = new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectionAdd123), "Add this point to selection", + () => EditorSelection.Add(point)); + + removeFromSelectionItem = new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectionRemove123), "Remove this point from selection", + () => EditorSelection.Remove(point)); + + Add(addToSelectionItem); + Add(removeFromSelectionItem); + } + + protected override void SetControl(BGCurvePoint.ControlTypeEnum type) + { + point.ControlType = type; + } + + public void On(BGCurvePointI point, int index) + { + PointIndex = index; + this.point = point; + On(point.PositionWorld); + + Get(0).Current = point.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + Get(1).Current = point.ControlType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical; + Get(2).Current = point.ControlType == BGCurvePoint.ControlTypeEnum.BezierIndependant; + } + + protected override void Delete() + { + BGCurveEditor.DeletePoint(point.Curve, point.Curve.IndexOf(point)); + } + + public override void On(Vector3 position) + { + addToSelectionItem.Disabled = EditorSelection.Contains(point); + removeFromSelectionItem.Disabled = !addToSelectionItem.Disabled; + base.On(position); + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs.meta new file mode 100644 index 0000000..3614bd9 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f64ca4438c929b04e8da2bfe20525440 +timeCreated: 1472274459 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs new file mode 100644 index 0000000..0fc132a --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs @@ -0,0 +1,105 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGSceneViewOverlayMenuSelection : BGSceneViewOverlayMenu + { + public override string Name + { + get { return "Selection menu"; } + } + + public BGSceneViewOverlayMenuSelection(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) + : base(overlay, editorSelection) + { + menu = new SelectionMenu(overlay, editorSelection); + } + + protected override bool Process(Event @event, BGCurveBaseMath math, float sceneViewHeight, ref Vector3 position, ref string message) + { + if (BGCurveSettingsForEditor.DisableSceneViewSelectionMenu || !menu.EditorSelection.HasSelected()) return false; + + + var selectedPos = menu.EditorSelection.GetAveragePosition(); + if (!(DistanceTolerance > (@event.mousePosition - BGEditorUtility.GetSceneViewPosition(selectedPos, sceneViewHeight)).sqrMagnitude)) return false; + + + //out params + position = selectedPos; + message = SuccessMessage("Selected " + menu.EditorSelection.CountSelected + " point(s)."); + + //turn on the menu + menu.On(position); + + //check if all points share the same control type + BGCurvePoint.ControlTypeEnum singleType = BGCurvePoint.ControlTypeEnum.Absent; + bool first = true, single=true; + menu.EditorSelection.ForEach(point => + { + if (first) + { + first = false; + singleType = point.ControlType; + } + else if (singleType != point.ControlType) + { + single = false; + return true; + } + + return false; + }); + + if (single) + { + menu.Get(0).Current = singleType == BGCurvePoint.ControlTypeEnum.Absent; + menu.Get(1).Current = singleType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical; + menu.Get(2).Current = singleType == BGCurvePoint.ControlTypeEnum.BezierIndependant; + } + else menu.Get(0).Current = menu.Get(1).Current = menu.Get(2).Current = false; + + + return true; + } + + //========================================================== Selection menu + public sealed class SelectionMenu : AbstractMenu + { + public SelectionMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) + : base(overlay, editorSelection, "Selection menu") + { + } + + protected override void SetControl(BGCurvePoint.ControlTypeEnum type) + { + EditorSelection.SetControlTypeForSelected(type); + } + + protected override void Delete() + { + EditorSelection.DeleteSelected(); + } + + public override string Details + { + get { return "Selected " + EditorSelection.CountSelected + " point(s)."; } + } + + protected override void AdditionalMenuItems() + { + Add(new MenuSeparator()); + Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectionRemove123), "Remove this point from selection", + () => + { + EditorSelection.Clear(); + EditorUtility.SetDirty(Overlay.Editor.Curve); + })); + } + + + } + + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs.meta new file mode 100644 index 0000000..8712ccd --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayMenuSelection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a24e39d345905a74eb25e8f16f456c30 +timeCreated: 1472984950 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs new file mode 100644 index 0000000..f5260ec --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs @@ -0,0 +1,166 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public abstract class BGSceneViewOverlayPointAdd : BGSceneViewOverlay.SceneAction + { + protected const float ScalePreviewPoint = .18f; + + + private static readonly BGTransition.SwayTransition swayTransition = new BGTransition.SwayTransition(.8f, 1.2f, .6); + + + protected BGSceneViewOverlayPointAdd(BGSceneViewOverlay overlay) : base(overlay) + { + } + + protected static void PreviewControls(BGCurveSettings settings, Vector3 position, Vector3 control1World, Vector3 control2World) + { + BGEditorUtility.SwapHandlesColor(settings.ControlHandlesColor, () => + { + PreviewControl(settings, position, control1World); + PreviewControl(settings, position, control2World); + }); + } + + protected static void PreviewControl(BGCurveSettings settings, Vector3 position, Vector3 controlWorld) + { + var size = BGEditorUtility.GetHandleSize(position, ScalePreviewPoint*.8f); + + Handles.SphereCap(0, controlWorld, Quaternion.identity, size); + Handles.DrawLine(position, controlWorld); + } + + protected static void DrawSection(BGCurvePointI from, BGCurvePointI to, int parts) + { + BGEditorUtility.Split(@from, to, parts, (fromPos, toPos) => Handles.DrawDottedLine(fromPos, toPos, 2)); + } + + + // preview + protected void Preview(Vector3 position, BGCurve curve, ref float toLast, ref float toFirst) + { + var settings = overlay.Editor.Settings; + + //show point + BGEditorUtility.SwapHandlesColor(settings.SphereColor, () => Handles.SphereCap(0, position, Quaternion.identity, BGEditorUtility.GetHandleSize(position, ScalePreviewPoint))); + + //create a point + var newPoint = BGNewPointPositionManager.CreatePoint(position, curve, settings.ControlType, settings.Sections, out toLast, out toFirst, false); + + //show controls + if (newPoint.ControlType != BGCurvePoint.ControlTypeEnum.Absent) PreviewControls(settings, position, newPoint.ControlFirstWorld, newPoint.ControlSecondWorld); + + if (curve.PointsCount == 0) return; + + BGEditorUtility.SwapHandlesColor(BGCurveSettingsForEditor.ColorForNewSectionPreview, () => + { + // last To new + DrawSection(curve[curve.PointsCount - 1], newPoint, settings.Sections); + + AdditionalPreview(newPoint); + + // new To zero + if (curve.Closed) DrawSection(newPoint, curve[0], settings.Sections); + }); + } + + protected virtual void AdditionalPreview(BGCurvePoint newPoint) + { + } + + + //see base class for description + internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message) + { + if (!Comply(currentEvent)) return false; + + + Vector3 intersectionPosition; + Plane plane; + + + if (currentEvent.type == EventType.mouseDown && currentEvent.control && currentEvent.button == 0) + { + //Mouse down for some action + var curve = overlay.Editor.Curve; + var settings = overlay.Editor.Settings; + + Cast(currentEvent, HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition), out intersectionPosition, out message, out plane); + + if (message != null) BGCurveEditor.OverlayMessage.Display(message); + else + { + position = intersectionPosition; + BGCurveEditor.AddPoint(curve, + BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true), + curve.PointsCount); + } + overlay.EventCanceller = new BGEditorUtility.EventCanceller(); + return true; + } + + + if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control)) return false; + + var ray = HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition); + Cast(currentEvent, ray, out intersectionPosition, out message, out plane); + + position = intersectionPosition; + + if (message != null) return true; + + Animation(plane, ray, swayTransition); + + //preview + float toLast = -1, toFirst = -1; + Preview(intersectionPosition, overlay.Editor.Curve, ref toLast, ref toFirst); + + //distance + message = BGSceneViewOverlay.ToOk("MouseClick to add a point\r\n") + + //to last + (toLast < 0 ? "First point is ready to go!" : "Distance to last=" + toLast) + + //to first + (toFirst < 0 ? "" : ", to first=" + toFirst); + return true; + } + + protected virtual void Animation(Plane plane, Ray ray, BGTransition.SwayTransition transition) + { + float enter; + if (plane.Raycast(ray, out enter)) + { + swayTransition.Tick(); + + Animate(transition, ray.GetPoint(enter), enter, plane); + } + } + + + protected virtual bool Comply(Event currentEvent) + { + return true; + } + + protected static Vector3[] GetVertsByPlaneAndDistance(Vector3 scale, Vector3 point, float distanceToCamera, Plane plane) + { + var m = Matrix4x4.TRS(point, Quaternion.LookRotation(plane.normal), scale); + var verts = new[] + {GetRectVector(-1, -1, distanceToCamera, m), GetRectVector(-1, 1, distanceToCamera, m), GetRectVector(1, 1, distanceToCamera, m), GetRectVector(1, -1, distanceToCamera, m)}; + return verts; + } + + private static Vector3 GetRectVector(float x, float y, float distance, Matrix4x4 matrix) + { + return matrix.MultiplyPoint(new Vector3(x, y)*distance/18); + } + + + //abstract + protected abstract void Animate(BGTransition.SwayTransition swayTransition, Vector3 point, float distanceToCamera, Plane plane); + + protected abstract void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane); + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs.meta new file mode 100644 index 0000000..7d27621 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAdd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4bcec5eb8d6d6af48bacbcf49bee822e +timeCreated: 1472345427 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs new file mode 100644 index 0000000..50c768f --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs @@ -0,0 +1,74 @@ +using BansheeGz.BGSpline.Curve; +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGSceneViewOverlayPointAddAtDistance : BGSceneViewOverlayPointAdd + { + private static readonly Color32 PointersColor = Color.white; + private Vector3 lastPosition; + + public BGSceneViewOverlayPointAddAtDistance(BGSceneViewOverlay overlay) : base(overlay) + { + } + + public override string Name + { + get { return "Add point at Distance"; } + } + + + protected override bool Comply(Event currentEvent) + { + return currentEvent.shift; + } + + protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) + { + var settings = overlay.Editor.Settings; + + lastPosition = position = ray.GetPoint(settings.NewPointDistance); + + var curve = overlay.Editor.Curve; + if (curve.Mode2DOn) + { + BGSceneViewOverlayPointAddSnap2D.Get2DPlane(out plane, curve); + position = position - Vector3.Project(position, plane.normal.normalized); + } + else plane = new Plane(ray.direction.normalized, lastPosition); + + error = null; + } + + protected override void AdditionalPreview(BGCurvePoint newPoint) + { + var curve = overlay.Editor.Curve; + if (!curve.Mode2DOn) return; + + Handles.DrawLine(lastPosition, newPoint.PositionWorld); + } + + protected override void Animation(Plane plane, Ray ray, BGTransition.SwayTransition transition) + { + var curve = overlay.Editor.Curve; + + if (!curve.Mode2DOn) base.Animation(plane, ray, transition); + else + { + var settings = overlay.Editor.Settings; + transition.Tick(); + Animate(transition, lastPosition, settings.NewPointDistance, plane); + } + } + + protected override void Animate(BGTransition.SwayTransition swayTransition, Vector3 point, float distanceToCamera, Plane plane) + { + var verts = GetVertsByPlaneAndDistance(new Vector3(swayTransition.Value, swayTransition.Value, swayTransition.Value), point, distanceToCamera, plane); + + var size = swayTransition.Value*ScalePreviewPoint*distanceToCamera/5; + + BGEditorUtility.SwapHandlesColor(PointersColor, () => { foreach (var position in verts) Handles.ConeCap(0, position, Quaternion.LookRotation(point - position), size); }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs.meta new file mode 100644 index 0000000..c1eb169 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddAtDistance.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 13e1047830cfadc46929d3f713cdca63 +timeCreated: 1472280829 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs new file mode 100644 index 0000000..c9d1754 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs @@ -0,0 +1,75 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGSceneViewOverlayPointAddSnap2D : BGSceneViewOverlayPointAdd + { + private static readonly BGTransition.SwayTransition rectTransition = new BGTransition.SwayTransition(1.1f, 1.3f, 2); + + public BGSceneViewOverlayPointAddSnap2D(BGSceneViewOverlay overlay) : base(overlay) + { + } + + public override string Name + { + get { return "Add point and Snap to Curve's 2D Plane"; } + } + + protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) + { + var curve = overlay.Editor.Curve; + + Get2DPlane(out plane, curve); + + float distance; + if (!plane.Raycast(ray, out distance)) + { + error = BGSceneViewOverlay.ToError("Curve is in 2D mode! \r\n Curve's plane does not intersect with the current point.") + + "\r\nUse Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; + + position = ray.GetPoint(10); + } + else + { + error = null; + position = ray.GetPoint(distance); + } + } + + public static void Get2DPlane(out Plane plane, BGCurve curve) + { + switch (curve.Mode2D) + { + case BGCurve.Mode2DEnum.XY: + plane = new Plane(curve.ToWorldDirection(Vector3.forward), curve.transform.position); + break; + case BGCurve.Mode2DEnum.XZ: + plane = new Plane(curve.ToWorldDirection(Vector3.up), curve.transform.position); + break; + default: +// case BGCurve.Mode2DEnum.YZ: + plane = new Plane(curve.ToWorldDirection(Vector3.right), curve.transform.position); + break; + } + } + + protected override bool Comply(Event currentEvent) + { + return overlay.Editor.Curve.Mode2D != BGCurve.Mode2DEnum.Off; + } + + protected override void Animate(BGTransition.SwayTransition swayTransition, Vector3 point, float distanceToCamera, Plane plane) + { + rectTransition.Tick(); + + var verts = GetVertsByPlaneAndDistance(new Vector3(rectTransition.Value, rectTransition.Value, rectTransition.Value), point, distanceToCamera, plane); + + + var color = BGCurveSettingsForEditor.HandleColorForAddAndSnap2D; + Handles.DrawSolidRectangleWithOutline(verts, color, new Color32(color.r, color.g, color.b, 255)); + Handles.DrawWireDisc(point, Vector3.Cross(verts[1] - verts[0], verts[2] - verts[0]), swayTransition.Value*distanceToCamera/24); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs.meta new file mode 100644 index 0000000..48c8bab --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap2D.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cd91011407f1abc41ae27e638529e479 +timeCreated: 1472950363 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs new file mode 100644 index 0000000..a9cf2f2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs @@ -0,0 +1,51 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + //add point and snap to the mesh (or curve's 2D plane) + public class BGSceneViewOverlayPointAddSnap3D : BGSceneViewOverlayPointAdd + { + public BGSceneViewOverlayPointAddSnap3D(BGSceneViewOverlay overlay) + : base(overlay) + { + } + + public override string Name + { + get { return "Add point and Snap to a Mesh"; } + } + + protected override void Animate(BGTransition.SwayTransition swayTransition, Vector3 point, float distanceToCamera, Plane plane) + { + //show rect + var verts = GetVertsByPlaneAndDistance(new Vector3(swayTransition.Value, swayTransition.Value, swayTransition.Value), point, distanceToCamera, plane); + var color = BGCurveSettingsForEditor.HandleColorForAddAndSnap3D; + Handles.DrawSolidRectangleWithOutline(verts, color, new Color32(color.r, color.g, color.b, 255)); + } + + + protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) + { + RaycastHit hit; + if (Physics.Raycast(ray, out hit)) + { + position = hit.point; + plane = new Plane(hit.normal, hit.point); + error = null; + } + else + { + error = BGSceneViewOverlay.ToError("No mesh (or collider) to snap a point to!") + " \r\n Use Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; + position = ray.GetPoint(10); + plane = new Plane(); + } + } + + protected override bool Comply(Event currentEvent) + { + return overlay.Editor.Curve.Mode2D == BGCurve.Mode2DEnum.Off; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs.meta new file mode 100644 index 0000000..c7e50d5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Overlay/BGSceneViewOverlayPointAddSnap3D.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ef3acc6fea76e7b449cac399c8e0f891 +timeCreated: 1472273229 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings.meta new file mode 100644 index 0000000..85c7dd4 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1fa6dd41561b2464fbeac539fb6cbf34 +folderAsset: yes +timeCreated: 1472482812 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs new file mode 100644 index 0000000..638e6eb --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs @@ -0,0 +1,248 @@ +using System; +using UnityEngine; +using System.Linq; +using System.Reflection; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public static class BGCurveSettingsForEditor + { + public enum CoordinateSpaceEnum + { + Local = 0, + LocalTransformed = 1, + World = 2, + } + + + //Keys + private const string InspectorPointsCoordinatesKey = "BansheeGZ.BGCurve.inspectorPointsCoordinates"; + private const string InspectorControlsCoordinatesKey = "BansheeGZ.BGCurve.inspectorControlsCoordinates"; + + private const string DisableRectangularSelectionKey = "BansheeGZ.BGCurve.disableRectangularSelection"; + private const string DisableSceneViewPointMenuKey = "BansheeGZ.BGCurve.disableSceneViewPointMenu"; + private const string DisableSceneViewSelectionMenuKey = "BansheeGZ.BGCurve.disableSceneViewSelectionMenu"; + private const string DisableInspectorPointMenuKey = "BansheeGZ.BGCurve.disableInspectorPointMenu"; + private const string CcInspectorHandlesOffKey = "BansheeGZ.BGCurve.inspectorHandlesOff"; + + private const string LockViewKey = "BansheeGZ.BGCurve.lockView"; + private const string CurrentTabKey = "BansheeGZ.BGCurve.currentTab"; + + //colors + private const string HandleColorForAddAndSnap3DKey = "BansheeGZ.BGCurve.handleColorForAddAndSnap3D"; + private const string HandleColorForAddAndSnap2DKey = "BansheeGZ.BGCurve.handleColorForAddAndSnap2D"; + private const string ColorForRectangularSelectionKey = "BansheeGZ.BGCurve.colorForRectangularSelection"; + private const string ColorForLabelBackgroundKey = "BansheeGZ.BGCurve.colorForLabelBackground"; + private const string ColorForNewSectionPreviewKey = "BansheeGZ.BGCurve.colorForNewSectionPreview"; + + //Default values + private static readonly Color32 HandleColorForAddAndSnap3DDefault = new Color32(46, 143, 168, 20); + private static readonly Color32 HandleColorForAddAndSnap2DDefault = new Color32(255, 255, 255, 10); + private static readonly Color32 ColorForRectangularSelectionDefault = new Color32(46, 143, 168, 25); + private static readonly Color32 ColorForLabelBackgroundDefault = new Color32(255, 255, 255, 25); + private static readonly Color32 ColorForNewSectionPreviewDefault = new Color32(255, 0, 0, 255); + + private static CoordinateSpaceEnum inspectorPointCoordinateSpace; + private static CoordinateSpaceEnum inspectorControlCoordinateSpace; + + private static bool disableRectangularSelection; + private static bool disableSceneViewPointMenu; + private static bool disableSceneViewSelectionMenu; + private static bool disableInspectorPointMenu; + private static bool lockView; + private static bool ccInspectorHandlesOff; + + private static Color32 handleColorForAddAndSnap3D; + private static Color32 handleColorForAddAndSnap2D; + private static Color32 colorForRectangularSelection; + private static Color32 colorForLabelBackground; + private static Color32 colorForNewSectionPreview; + + private static int currentTab; + + public static int CurrentTab + { + get { return currentTab; } + set { SaveInt(ref currentTab, value, CurrentTabKey); } + } + + public static CoordinateSpaceEnum InspectorPointCoordinateSpace + { + get { return inspectorPointCoordinateSpace; } + set + { + if (value == inspectorPointCoordinateSpace) return; + + var val = (int) inspectorPointCoordinateSpace; + SaveInt(ref val, (int) value, InspectorPointsCoordinatesKey); + inspectorPointCoordinateSpace = value; + } + } + + public static CoordinateSpaceEnum InspectorControlCoordinateSpace + { + get { return inspectorControlCoordinateSpace; } + set + { + if (value == inspectorControlCoordinateSpace) return; + + var val = (int) inspectorControlCoordinateSpace; + SaveInt(ref val, (int) value, InspectorControlsCoordinatesKey); + inspectorControlCoordinateSpace = value; + } + } + + public static bool CcInspectorHandlesOff + { + get { return ccInspectorHandlesOff; } + set { SaveBool(ref ccInspectorHandlesOff, value, CcInspectorHandlesOffKey); } + } + + public static bool LockView + { + get { return lockView; } + set { SaveBool(ref lockView, value, LockViewKey); } + } + + + public static bool DisableRectangularSelection + { + get { return disableRectangularSelection; } + set { SaveBool(ref disableRectangularSelection, value, DisableRectangularSelectionKey); } + } + + public static bool DisableSceneViewPointMenu + { + get { return disableSceneViewPointMenu; } + set { SaveBool(ref disableSceneViewPointMenu, value, DisableSceneViewPointMenuKey); } + } + + public static bool DisableSceneViewSelectionMenu + { + get { return disableSceneViewSelectionMenu; } + set { SaveBool(ref disableSceneViewSelectionMenu, value, DisableSceneViewSelectionMenuKey); } + } + + public static bool DisableInspectorPointMenu + { + get { return disableInspectorPointMenu; } + set { SaveBool(ref disableInspectorPointMenu, value, DisableInspectorPointMenuKey); } + } + + + public static Color32 HandleColorForAddAndSnap3D + { + get { return handleColorForAddAndSnap3D; } + set { SaveColor(ref handleColorForAddAndSnap3D, value, HandleColorForAddAndSnap3DKey); } + } + + public static Color32 HandleColorForAddAndSnap2D + { + get { return handleColorForAddAndSnap2D; } + set { SaveColor(ref handleColorForAddAndSnap2D, value, HandleColorForAddAndSnap2DKey); } + } + + public static Color32 ColorForRectangularSelection + { + get { return colorForRectangularSelection; } + set { SaveColor(ref colorForRectangularSelection, value, ColorForRectangularSelectionKey); } + } + + public static Color32 ColorForLabelBackground + { + get { return colorForLabelBackground; } + set { SaveColor(ref colorForLabelBackground, value, ColorForLabelBackgroundKey); } + } + + public static Color32 ColorForNewSectionPreview + { + get { return colorForNewSectionPreview; } + set { SaveColor(ref colorForNewSectionPreview, value, ColorForNewSectionPreviewKey); } + } + + static BGCurveSettingsForEditor() + { + Init(); + } + + private static void SaveBool(ref bool oldValue, bool newValue, string key) + { + CheckAndSave(ref oldValue, newValue, () => EditorPrefs.SetBool(key, newValue)); + } + + private static void SaveInt(ref int oldValue, int newValue, string key) + { + CheckAndSave(ref oldValue, newValue, () => EditorPrefs.SetInt(key, newValue)); + } + + private static void SaveColor(ref Color32 oldValue, Color32 newValue, string key) + { + CheckAndSave(ref oldValue, newValue, () => EditorPrefs.SetString(key, ColorToString(newValue))); + } + + private static void CheckAndSave(ref T oldValue, T newValue, Action notEqualAction) + { + if (oldValue.Equals(newValue)) return; + oldValue = newValue; + notEqualAction(); + } + + private static void Init() + { + inspectorPointCoordinateSpace = (CoordinateSpaceEnum) EditorPrefs.GetInt(InspectorPointsCoordinatesKey, (int) CoordinateSpaceEnum.World); + inspectorControlCoordinateSpace = (CoordinateSpaceEnum) EditorPrefs.GetInt(InspectorControlsCoordinatesKey); + + disableRectangularSelection = EditorPrefs.GetBool(DisableRectangularSelectionKey); + disableSceneViewPointMenu = EditorPrefs.GetBool(DisableSceneViewPointMenuKey); + disableSceneViewSelectionMenu = EditorPrefs.GetBool(DisableSceneViewSelectionMenuKey); + disableInspectorPointMenu = EditorPrefs.GetBool(DisableInspectorPointMenuKey); + + lockView = EditorPrefs.GetBool(LockViewKey); + currentTab = EditorPrefs.GetInt(CurrentTabKey); + + + handleColorForAddAndSnap3D = StringToColor(EditorPrefs.GetString(HandleColorForAddAndSnap3DKey), HandleColorForAddAndSnap3DDefault); + handleColorForAddAndSnap2D = StringToColor(EditorPrefs.GetString(HandleColorForAddAndSnap2DKey), HandleColorForAddAndSnap2DDefault); + colorForRectangularSelection = StringToColor(EditorPrefs.GetString(ColorForRectangularSelectionKey), ColorForRectangularSelectionDefault); + colorForLabelBackground = StringToColor(EditorPrefs.GetString(ColorForLabelBackgroundKey), ColorForLabelBackgroundDefault); + colorForNewSectionPreview = StringToColor(EditorPrefs.GetString(ColorForNewSectionPreviewKey), ColorForNewSectionPreviewDefault); + } + + //resets to default + public static void Reset() + { + var constants = typeof(BGCurveSettingsForEditor).GetFields( + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(c => c.IsLiteral && !c.IsInitOnly && c.Name.EndsWith("Key")).ToList(); + + foreach (var constant in constants) EditorPrefs.DeleteKey((string) constant.GetValue(null)); + + Init(); + } + + private static string ColorToString(Color32 color) + { + return color.r + "," + color.g + "," + color.b + "," + color.a; + } + + private static Color32 StringToColor(string colorString, Color32 defaultColor) + { + if (string.IsNullOrEmpty(colorString)) return defaultColor; + + var parts = colorString.Split(','); + if (parts.Length != 4) return defaultColor; + + + try + { + return new Color32(byte.Parse(parts[0]), byte.Parse(parts[1]), byte.Parse(parts[2]), byte.Parse(parts[3])); + } + catch (Exception e) + { + Debug.LogException(e); + return defaultColor; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs.meta new file mode 100644 index 0000000..e306f9c --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9d802b133f80b6349ad532e4d415d660 +timeCreated: 1472973279 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs new file mode 100644 index 0000000..b5d8831 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs @@ -0,0 +1,117 @@ +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGCurveSettingsForEditorWindow : EditorWindow + { + private const int Padding = 20; + private static readonly Vector2 WindowSize = new Vector2(600, 400); + + private Vector2 scrollPos; + + + internal static void Open() + { + BGEditorUtility.ShowPopupWindow(WindowSize); + } + + private void OnGUI() + { + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + ShowSettings(); + EditorGUILayout.EndScrollView(); + } + + private static void ShowSettings() + { + BGEditorUtility.SwapLabelWidth(300, () => + { + BGEditorUtility.Vertical(new GUIStyle("Box") {padding = new RectOffset(Padding, Padding, Padding, Padding)}, () => + { + EditorGUILayout.LabelField("BG Curve Editor Settings", new GUIStyle("Box") {fontSize = 22}); + + if (GUILayout.Button(new GUIContent("Reset to defaults", "Reset all editor settings to their defaults.")) + && BGEditorUtility.Confirm("Reset settings", "Reset All Editor settings to defaults? It does not affect curve's settings.", "Reset")) + { + BGCurveSettingsForEditor.Reset(); + } + + //coordinates for points and controls + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.PopupField(BGCurveSettingsForEditor.InspectorPointCoordinateSpace, "Point Coordinates", + b => BGCurveSettingsForEditor.InspectorPointCoordinateSpace = (BGCurveSettingsForEditor.CoordinateSpaceEnum) b); + EditorGUILayout.HelpBox("Coordinate Space for points (for Inspector's fields inder Points tab.)", MessageType.Info); + }); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.PopupField(BGCurveSettingsForEditor.InspectorControlCoordinateSpace, "Point Controls Coordinates", + b => BGCurveSettingsForEditor.InspectorControlCoordinateSpace = (BGCurveSettingsForEditor.CoordinateSpaceEnum)b); + EditorGUILayout.HelpBox("Coordinate Space for points controls (for Inspector's fields inder Points tab.)", MessageType.Info); + }); + + + // disable fields + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ToggleField(BGCurveSettingsForEditor.DisableSceneViewPointMenu, "Disable SV Point Menu", b => BGCurveSettingsForEditor.DisableSceneViewPointMenu = b); + EditorGUILayout.HelpBox("Disable point's menu, which is activated in Scene View by holding Ctrl over a point.", MessageType.Info); + }); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ToggleField(BGCurveSettingsForEditor.DisableSceneViewSelectionMenu, "Disable SV Selection Menu", b => BGCurveSettingsForEditor.DisableSceneViewSelectionMenu = b); + EditorGUILayout.HelpBox("Disable selection's menu, which is activated in Scene View by holding Ctrl over a selection handles.", MessageType.Info); + }); + +/* + BGEUtil.VerticalBox(() => + { + BGEUtil.ToggleField(BGCurveEditorSettings.DisableInspectorPointMenu, "Disable Inspector Points Menu", b => BGCurveEditorSettings.DisableInspectorPointMenu = b); + EditorGUILayout.HelpBox("Disable points menu, which is located under Points tab in Inspector.", MessageType.Info); + }); + */ + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ToggleField(BGCurveSettingsForEditor.DisableRectangularSelection, "Disable Rectangular Selection", b => BGCurveSettingsForEditor.DisableRectangularSelection = b); + EditorGUILayout.HelpBox("Disable rectangular selection in Scene View, which is activated by holding shift and mouse dragging.", MessageType.Info); + }); + + + // colors + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ColorField("Rectangular Selection Color", BGCurveSettingsForEditor.ColorForRectangularSelection, b => BGCurveSettingsForEditor.ColorForRectangularSelection = b); + EditorGUILayout.HelpBox("Color for Rectangular Selection background", MessageType.Info); + }); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ColorField("Add and Snap 3D Handles Color", BGCurveSettingsForEditor.HandleColorForAddAndSnap3D, b => BGCurveSettingsForEditor.HandleColorForAddAndSnap3D = b); + EditorGUILayout.HelpBox("Color for handles, shown for 3D curve in Scene View when new point is previewed.", MessageType.Info); + }); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ColorField("Add and Snap 2D Handles Color", BGCurveSettingsForEditor.HandleColorForAddAndSnap2D, b => BGCurveSettingsForEditor.HandleColorForAddAndSnap2D = b); + EditorGUILayout.HelpBox("Color for handles, shown for 2D curve in Scene View when new point is previewed.", MessageType.Info); + }); + + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ColorField("Points labels back color", BGCurveSettingsForEditor.ColorForLabelBackground, b => BGCurveSettingsForEditor.ColorForLabelBackground = b); + EditorGUILayout.HelpBox("Background color for points labels in Scene View.", MessageType.Info); + }); + BGEditorUtility.VerticalBox(() => + { + BGEditorUtility.ColorField("New section preview color", BGCurveSettingsForEditor.ColorForNewSectionPreview, b => BGCurveSettingsForEditor.ColorForNewSectionPreview = b); + EditorGUILayout.HelpBox("Color for new section preview in Scene View.", MessageType.Info); + }); + }); + }); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs.meta new file mode 100644 index 0000000..864abd2 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsForEditorWindow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cd56b8c2c4cb03b41a910f6f1281b6bc +timeCreated: 1472981091 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs new file mode 100644 index 0000000..0ae8a3e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs @@ -0,0 +1,144 @@ +using System.Collections.Generic; +using System.IO; +using BansheeGz.BGSpline.Curve; +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public static class BGCurveSettingsOperations + { + private const string DefaultFileName = "BGDefaultSettings123"; + + private const string EditorKey = "BansheeGZ.BGCurve.settingsDir"; + + private static string[] allSettings; + private static bool dirty; + + public static BGCurveSettings LoadDefault() + { + return Load(DefaultFileName); + } + + public static BGCurveSettings Load(string asset) + { + var dir = GetPath(); + if (dir == null || !IsValid(dir)) return null; + + var loaded = AssetDatabase.LoadAssetAtPath(GetFullPath(dir, asset)); + return loaded == null ? null : Object.Instantiate(loaded).Settings; + } + + + public static bool SaveDefault(BGCurveSettings settings) + { + return Save(settings, DefaultFileName); + } + + public static bool Save(BGCurveSettings settings, string name) + { + var dir = GetPath(); + if (!IsValid(dir)) dir = null; + + if (dir == null) dir = ChoseFolder(); + + if (dir == null) return false; + + var settingsSo = ScriptableObject.CreateInstance(); + settingsSo.Settings = settings; + + var fullPath = GetFullPath(dir, name); + AssetDatabase.CreateAsset(settingsSo, fullPath); + AssetDatabase.SaveAssets(); + dirty = true; + return true; + } + + private static string GetFullPath(string dir, string asset) + { + return dir + Path.DirectorySeparatorChar + asset + ".asset"; + } + + private static string ChoseFolder() + { + var dir = EditorUtility.OpenFolderPanel("Chose a folder to store default settings", Application.dataPath, ""); + + if (dir == null || dir.Equals("")) return null; + + + if (!dir.StartsWith(Application.dataPath)) + { + Debug.Log("Failed. Path should be relative to project folder"); + dir = null; + } + else + { + //this was a stupid idea to include "Assets" to the path + dir = "Assets" + dir.Substring(Application.dataPath.Length); + EditorPrefs.SetString(EditorKey, dir); + dirty = true; + } + return dir; + } + + public static void ChoseDir() + { + ChoseFolder(); + } + + public static string GetPath() + { + var path = EditorPrefs.GetString(EditorKey); + return path == null || path.Equals("") ? null : path; + } + + public static bool IsValid(string dir) + { + //this was a stupid idea to include "Assets" to the path + return dir != null && !dir.Equals("") && Directory.Exists(Application.dataPath.Substring(0, Application.dataPath.Length - "Assets".Length) + dir); + } + + public static string[] GetAll() + { + var path = GetPath(); + if (!IsValid(path)) return new string[0]; + + if (allSettings == null || dirty) + { + dirty = false; + Reload(path); + } + + return allSettings; + } + + public static void Reload(string path) + { + var guids = AssetDatabase.FindAssets("t:BGCurveSettingsSO", new[] {path}); + if (guids != null && guids.Length > 0) + { + var pathes = new List(); + foreach (var guid in guids) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var separatorIndex = assetPath.LastIndexOf(Path.DirectorySeparatorChar); + + if (separatorIndex > 0) assetPath = assetPath.Substring(separatorIndex + 1); + + separatorIndex = assetPath.LastIndexOf(Path.AltDirectorySeparatorChar); + + if (separatorIndex > 0) assetPath = assetPath.Substring(separatorIndex + 1); + + if (assetPath.EndsWith(".asset")) assetPath = assetPath.Substring(0, assetPath.Length - 6); + + pathes.Add(assetPath); + } + allSettings = pathes.ToArray(); + } + else + { + allSettings = new string[0]; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs.meta new file mode 100644 index 0000000..ce2f47e --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsOperations.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3961a72ccd7952343b4cee470a7c51cb +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs new file mode 100644 index 0000000..a4e7c98 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs @@ -0,0 +1,12 @@ +using System; +using BansheeGz.BGSpline.Curve; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + [Serializable] + public class BGCurveSettingsSO : ScriptableObject + { + public BGCurveSettings Settings; + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs.meta new file mode 100644 index 0000000..53a14f5 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Settings/BGCurveSettingsSO.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 363780417ece4f1439ee477913bf05e3 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils.meta new file mode 100644 index 0000000..ef4fac6 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5d766538e07f6b44595f6f99251584c2 +folderAsset: yes +timeCreated: 1472482870 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs new file mode 100644 index 0000000..55c2d90 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs @@ -0,0 +1,1207 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BansheeGz.BGSpline.Curve; +using UnityEngine; +using UnityEditor; +using UnityEditor.AnimatedValues; + +namespace BansheeGz.BGSpline.Editor +{ + public static class BGEditorUtility + { + private const string DefaultIconPath = "Assets/BansheeGz/BGCurve/Icons/"; + + //exact names for icons + public enum Image + { + BGCurveLogo123, + BGDelete123, + BGAdd123, + BGMoveUp123, + BGMoveDown123, + BGPoints123, + BGConvertAll123, + BGTickNo123, + BGTickYes123, + BGSelectAll123, + BGDeSelectAll123, + BGSettings123, + BGComponents123, + BGFields123, + BGTableHeader123, + BGTableCell123, + BGTableTitle123, + BGBoxWithBorder123, + BGPointSelected123, + BGPointMenu123, + BGControlAbsent123, + BGControlBezierSymmetrical123, + BGControlBezierIndependent123, + BGPointDelete123, + BGLockOff123, + BGLockOn123, + BGCcNoImage123, + BGCurveComponents123, + BGHelp123, + BGBoxRed123, + BGBoxWhite123, + BGCollapseAll123, + BGExpandAll123, + BGHierarchyIcon123, + BGHierarchySelectedIcon123, + BGHierarchyErrorIcon123, + BGHierarchyErrorSelectedIcon123, + BGOn123, + BGOff123, + BGHierarchyWarningSelectedIcon123, + BGHierarchyWarningIcon123, + BGMenuItemBackground123, + BGPointInsertAfter123, + BGPointInsertBefore123, + BGSelectionAdd123, + BGSelectionRemove123, + BGExpanded123, + BGCollapsed123, + BGSettingsIcon123, + BGCcEditName123, + BGHandlesOn123, + BGHandlesOff123, + BGCopy123, + BGPaste123 + } + + private static readonly DragSession dragSession = new DragSession(); + private static Texture2D whiteTexture1x1; + + private static float xSnap = EditorPrefs.GetFloat("MoveSnapX", 1f); + private static float ySnap = EditorPrefs.GetFloat("MoveSnapY", 1f); + private static float zSnap = EditorPrefs.GetFloat("MoveSnapZ", 1f); + + private static string currentIconPath = DefaultIconPath; + private static string additionalCcIconPath; + + private static readonly List layers = new List(); + private static readonly List layerNumbers = new List(); + private static readonly List optionsList = new List(); + private static readonly List fieldsList = new List(); + private static bool vertexSnappingOn; + + static BGEditorUtility() + { + ReloadSnapSettings(); + } + + public static void ReloadSnapSettings() + { + xSnap = EditorPrefs.GetFloat("MoveSnapX", 1f); + ySnap = EditorPrefs.GetFloat("MoveSnapY", 1f); + zSnap = EditorPrefs.GetFloat("MoveSnapZ", 1f); + } + + // ============================================== OnSceneGui utils + + public static void SwapHandlesColor(Color color, Action action) + { + var oldColor = Handles.color; + Handles.color = color; + action(); + Handles.color = oldColor; + } + + public static void SwapGizmosColor(Color color, Action action) + { + var oldColor = Gizmos.color; + Gizmos.color = color; + action(); + Gizmos.color = oldColor; + } + + public static Vector2 GetSceneViewPosition(Vector3 position, float sceneViewHeight) + { + var screenPoint = SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(position); + return new Vector2(screenPoint.x, sceneViewHeight - screenPoint.y); + } + + public static Vector2 GetSceneViewPosition(Vector3 position) + { + var screenPoint = SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(position); + return new Vector2(screenPoint.x, GetSceneViewHeight() - screenPoint.y); + } + + public static float GetSceneViewHeight() + { + return SceneView.currentDrawingSceneView.camera.pixelHeight; + } + + public static float GetHandleSize(Vector3 position, float scale = 1) + { + return HandleUtility.GetHandleSize(position)*scale; + } + + // ============================================== OnInspectorGui utils + public static void SwapGuiBackgroundColor(Color color, Action action) + { + var oldColor = GUI.backgroundColor; + GUI.backgroundColor = color; + + Assign(ref whiteTexture1x1, () => Texture1X1(Color.white)); + + try + { + var temp = whiteTexture1x1.width; + temp.Equals(1); + } + catch (MissingReferenceException) + { + //have no darn idea about any other way to reload the texture + whiteTexture1x1 = Texture1X1(Color.white); + } + + Horizontal(new GUIStyle(GUIStyle.none) {normal = {background = whiteTexture1x1}}, action); + GUI.backgroundColor = oldColor; + } + + public static void FadeGroup(BoolAnimatedProperty boolProperty, Action callback) + { + VerticalBox(() => + { + boolProperty.Property.boolValue = boolProperty.AnimBool.target = EditorGUILayout.ToggleLeft(boolProperty.Property.displayName, boolProperty.Property.boolValue); + if (EditorGUILayout.BeginFadeGroup(boolProperty.AnimBool.faded)) Indent(1, callback); + EditorGUILayout.EndFadeGroup(); + }); + } + + public static void Indent(int steps, Action action) + { + StartIndent(steps); + action(); + EndIndent(steps); + } + + public static void EndIndent(int steps = 2) + { + EditorGUI.indentLevel -= steps; + } + + public static void StartIndent(int steps = 2) + { + EditorGUI.indentLevel += steps; + } + + public static bool ButtonOnOff(ref bool value, string name, string tooltip, Color onColor, GUIContent onContent, GUIContent offContent, Action additionalAction = null) + { + var myValue = value; + Action action = () => + { + EditorGUILayout.PrefixLabel(new GUIContent(name, tooltip)); + if (GUILayout.Button(myValue ? onContent : offContent)) myValue = !myValue; + + if (additionalAction != null) additionalAction(); + }; + + if (myValue) SwapGuiBackgroundColor(onColor, action); + else HorizontalBox(action); + + value = myValue; + return myValue; + } + + + // ============================================== Layout + public static void Vertical(Action callback) + { + Vertical(GUIStyle.none, callback); + } + + public static void Vertical(GUIStyle style, Action callback) + { + EditorGUILayout.BeginVertical(style); + callback(); + EditorGUILayout.EndVertical(); + } + + public static void VerticalBox(Action callback) + { + Vertical("Box", callback); + } + + public static void Horizontal(Action callback) + { + Horizontal(GUIStyle.none, callback); + } + + public static void Horizontal(GUIStyle style, Action callback) + { + EditorGUILayout.BeginHorizontal(style); + callback(); + EditorGUILayout.EndHorizontal(); + } + + public static void HorizontalBox(Action callback) + { + Horizontal("Box", callback); + } + + + // ============================================== Fields + public static void TextField(Rect rect, string value, Action action, bool isDelayed) + { + var newValue = !isDelayed ? EditorGUI.TextField(rect, value) : EditorGUI.DelayedTextField(rect, value); + if (!String.Equals(newValue, value)) action(newValue); + } + + public static void TextField(string value, Action action, bool isDelayed) + { + var newValue = !isDelayed ? EditorGUILayout.TextField(value) : EditorGUILayout.DelayedTextField(value); + if (!String.Equals(newValue, value)) action(newValue); + } + + public static void TextField(string label, string value, Action action, bool isDelayed) + { + var newValue = !isDelayed ? EditorGUILayout.TextField(label, value) : EditorGUILayout.DelayedTextField(label, value); + if (!String.Equals(newValue, value)) action(newValue); + } + + public static void BoolField(Rect rect, bool value, Action action) + { + var newValue = EditorGUI.Toggle(rect, value); + if (value != newValue) action(newValue); + } + + public static void BoolField(string label, bool value, Action action) + { + var newValue = EditorGUILayout.Toggle(label, value); + if (value != newValue) action(newValue); + } + + public static void Vector3Field(string name, string tooltip, Vector3 value, Action action) + { + var newValue = EditorGUILayout.Vector3Field(new GUIContent(name, tooltip), value); + if (AnyChange(newValue, value)) action(newValue); + } + + public static void Vector2Field(string name, string tooltip, Vector2 value, Action action) + { + var newValue = EditorGUILayout.Vector2Field(new GUIContent(name, tooltip), value); + if (AnyChange(newValue, value)) action(newValue); + } + + public static void ToggleField(bool value, string label, Action action) + { + var newValue = EditorGUILayout.Toggle(label, value); + if (value != newValue) action(newValue); + } + + public static void ToggleField(Rect rect, bool value, Action action) + { + var newValue = EditorGUI.Toggle(rect, value); + if (value ^ newValue && action != null) action(newValue); + } + + public static void IntField(string label, int value, Action action) + { + var newValue = EditorGUILayout.IntField(label, value); + if (value != newValue) action(newValue); + } + + public static void FloatField(string label, float value, Action action) + { + var newValue = EditorGUILayout.FloatField(label, value); + if (Math.Abs(value - newValue) > BGCurve.Epsilon) action(newValue); + } + + public static void BoundsField(string label, Bounds value, Action action) + { + var newValue = EditorGUILayout.BoundsField(label, value); + if (value != newValue) action(newValue); + } + + public static void AnimationCurveField(string label, AnimationCurve value, Action action) + { + if (value == null) value = new AnimationCurve(); + var newValue = EditorGUILayout.CurveField(label, value); + if (value != newValue) action(newValue); + } + + public static void QuaternionField(string label, Quaternion value, Action action) + { + var oldValue = new Vector4(value.x, value.y, value.z, value.w); + var newValue = EditorGUILayout.Vector4Field(label, oldValue); + if (oldValue != newValue) action(new Quaternion(newValue.x, newValue.y, newValue.z, newValue.w)); + } + + public static void GameObjectField(string label, GameObject value, Action action) + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(GameObject), true); + if (value != newValue) action((GameObject) newValue); + } + + public static void ComponentField(string label, T value, Action action) where T : Component + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(T), true); + if (value != newValue) action((T) newValue); + } + + + public static void ComponentChoosableField(string label, Component value, Action action) + { + Horizontal(() => + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(Component), true); + if (value != newValue) action((Component) newValue); + + if (newValue != null && GUILayout.Button("...", GUILayout.Width(40))) BGChoseComponentWindow.Open((Component) newValue, action); + }); + } + + public static void BGCurveField(string label, BGCurve value, Action action) + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(BGCurve), true); + if (value != newValue) action((BGCurve) newValue); + } + + public static void BGCurvePointComponentField(string label, BGCurvePointComponent value, Action action) + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(BGCurvePointComponent), true); + if (value != newValue) action((BGCurvePointComponent) newValue); + } + + public static void BGCurvePointGOField(string label, BGCurvePointGO value, Action action) + { + var newValue = EditorGUILayout.ObjectField(label, value, typeof(BGCurvePointGO), true); + if (value != newValue) action((BGCurvePointGO) newValue); + } + + + public static void ColorField(Rect rect, Color color, Action action) + { + var newValue = EditorGUI.ColorField(rect, color); + if (AnyChange(color, newValue)) action(newValue); + } + + public static void ColorField(string label, Color32 color, Action action) + { + var newValue = EditorGUILayout.ColorField(label, color); + if (AnyChange(color, newValue)) action(newValue); + } + + public static void SliderField(Rect rect, float value, float min, float max, Action action) + { + var newValue = GUI.HorizontalSlider(rect, value, min, max); + if (AnyChange(value, newValue)) action(newValue); + } + + public static void SliderField(int value, int min, int max, Action action) + { + var newValue = EditorGUILayout.IntSlider(value, min, max); + if (AnyChange(value, newValue)) action(newValue); + } + + public static void SliderField(float value, float min, float max, Action action) + { + var newValue = GUILayout.HorizontalSlider(value, min, max); + if (AnyChange(value, newValue)) action(newValue); + } + + + public static void PopupField(Rect rect, Enum value, Enum[] allOptions, Action action) + { + var options = new string[allOptions.Length]; + var selected = 0; + for (var i = 0; i < allOptions.Length; i++) + { + var val = allOptions.GetValue(i); + + options[i] = val.ToString(); + if (Equals(value, val)) selected = i; + } + var newIndex = EditorGUI.Popup(rect, selected, options); + + if (newIndex != selected) action((Enum) allOptions.GetValue(newIndex)); + } + + public static void PopupField(Rect rect, Enum value, Action action) + { + PopupField(rect, value, Enum.GetValues(value.GetType()).Cast().ToArray(), action); + } + + public static void PopupField(Enum value, string label, Enum[] allOptions, Action action) + { + var options = new string[allOptions.Length]; + var selected = 0; + for (var i = 0; i < allOptions.Length; i++) + { + var val = allOptions.GetValue(i); + + options[i] = val.ToString(); + if (Equals(value, val)) selected = i; + } + var newIndex = EditorGUILayout.Popup(label, selected, options); + + if (newIndex != selected) action((Enum) allOptions.GetValue(newIndex)); + } + + public static void PopupField(Enum value, string label, Action action) + { + PopupField(value, label, Enum.GetValues(value.GetType()).Cast().ToArray(), action); + } + + + public static void LayerMaskField(string label, LayerMask layer, Action action) + { +/* + var newValue = EditorGUILayout.LayerField(label, layer.value); + if (newValue != layer.value) action(newValue); + */ + //thanks to FlyingOstriche + //I have no time to figure out what's going on here + layers.Clear(); + layerNumbers.Clear(); + + for (var i = 0; i < 32; i++) + { + var layerName = LayerMask.LayerToName(i); + if (String.IsNullOrEmpty(layerName)) continue; + + layers.Add(layerName); + layerNumbers.Add(i); + } + + var mask = 0; + for (var i = 0; i < layerNumbers.Count; i++) + if (((1 << layerNumbers[i]) & layer.value) > 0) + { + mask |= (1 << i); + } + + var newValue = EditorGUILayout.MaskField(label, mask, layers.ToArray()); + + //do not convert to LINQ + var newMask = 0; + var newMaskCheck = 0; + for (var i = 0; i < layerNumbers.Count; i++) + if ((newValue & (1 << i)) > 0) + { + newMask |= (1 << layerNumbers[i]); + newMaskCheck |= (1 << i); + } + + if (newMaskCheck == mask) return; + + + action(newMask); + } + + public static void CustomField(GUIContent label, BGCurve curve, BGCurvePointField value, BGCurvePointField.TypeEnum type, Action action) + { + //idea.. this is a nasty hack to get rid of weak reference object.. not sure how to get rid of it properly + if (value == null) action(null); + + optionsList.Clear(); + fieldsList.Clear(); + + optionsList.Add(new GUIContent("None")); + + var fields = curve.Fields; + var selectedIndex = 0; + if (fields != null && fields.Length > 0) + { + var cursor = 1; + foreach (var field in fields) + { + if (field.Type != type) continue; + + var b = value != null; + var @equals = b && String.Equals(value.FieldName, field.FieldName); + if (b && @equals) selectedIndex = cursor; + + optionsList.Add(new GUIContent(field.FieldName)); + fieldsList.Add(field); + cursor++; + } + } + var newIndex = EditorGUILayout.Popup(label, selectedIndex, optionsList.ToArray()); + if (newIndex != selectedIndex) action(newIndex == 0 ? null : fieldsList[newIndex - 1]); + } + + + // ============================================== Textures + //loads a texture2d + public static Texture2D LoadTexture2D(Image image, string path = DefaultIconPath, string ext = ".png", bool critical = true) + { + if (String.Equals(path, DefaultIconPath)) path = currentIconPath; + + var icon = LoadTexture(path + image + ext); + if (icon != null) return icon; + + //try to find in assets + var newPath = FindByName(Image.BGDelete123.ToString()); + if (newPath == null) + { + if (critical) + { + // no luck + Debug.LogException(new UnityException( + "Can not find BGCurve Editors icons folder. The icons folder, located by default at '" + DefaultIconPath + + "', should be included in your assets, otherwise the package will not work correctly in Editor.")); + } + return null; + } + + currentIconPath = FolderFromFullPath(newPath); + return LoadTexture(currentIconPath + image + ext); + } + + public static Texture2D LoadCcTexture2D(string path) + { + if (String.IsNullOrEmpty(path)) return null; + + var icon = LoadTexture(path); + + if (icon == null) + { + string fileName; + string fileNameNoExtension; + try + { + fileName = FileFromFullPath(path); + fileNameNoExtension = StripExtension(fileName); + } + catch (Exception) + { + return null; + } + + if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileNameNoExtension)) return null; + + //try to find in another place + if (additionalCcIconPath != null) icon = LoadTexture(additionalCcIconPath + fileName); + + if (icon == null) + { + var newPath = FindByName(fileNameNoExtension); + if (newPath != null) + { + var newFolder = FolderFromFullPath(newPath); + if (additionalCcIconPath == null) additionalCcIconPath = newFolder; + icon = LoadTexture(newFolder + fileName); + } + } + } + return icon; + } + + public static Texture2D LoadTexture(string path) + { + //we do hope LoadAssetAtPath is optimized by Unity + return AssetDatabase.LoadAssetAtPath(path); + } + + private static string FindByName(string fileName) + { + var files = AssetDatabase.FindAssets(fileName); + return files == null || files.Length == 0 ? null : AssetDatabase.GUIDToAssetPath(files[0]); + } + + private static string FolderFromFullPath(string path) + { + try + { + var maxSlashIndex = Mathf.Max(path.LastIndexOf('/'), path.LastIndexOf('\\')); + return maxSlashIndex >= 0 ? path.Substring(0, maxSlashIndex + 1) : path; + } + catch (Exception) + { + return null; + } + } + + private static string FileFromFullPath(string path) + { + try + { + var maxSlashIndex = Mathf.Max(path.LastIndexOf('/'), path.LastIndexOf('\\')); + return maxSlashIndex >= 0 ? path.Substring(maxSlashIndex + 1, path.Length - maxSlashIndex - 1) : path; + } + catch (Exception) + { + return null; + } + } + + private static string StripExtension(string fileName) + { + try + { + var dotIndex = Mathf.Max(fileName.LastIndexOf('.')); + return dotIndex >= 0 ? fileName.Substring(0, dotIndex) : fileName; + } + catch (Exception) + { + return null; + } + } + + + // texture is not getting scaled! + public static bool ButtonWithIcon(Texture2D icon, string tooltip, int width = 16, int height = 16) + { + return GUI.Button( + GUILayoutUtility.GetRect(width, width, height, height, + new GUIStyle {fixedWidth = width, fixedHeight = height, stretchWidth = false, stretchHeight = false}), + new GUIContent(icon, tooltip), GUIStyle.none); + } + + public static Texture2D Texture1X1(Color color) + { + var texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); + texture.SetPixel(0, 0, color); + texture.Apply(false); + return texture; + } + + public static Texture2D TextureWithBorder(int size, int borderSize, Color color, Color borderColor) + { + if (size < 4) size = 4; + else if (size > 1024) size = 1024; + if (!Mathf.IsPowerOfTwo(size)) size = Mathf.ClosestPowerOfTwo(size); + + if (borderSize < 1) borderSize = 1; + else if (borderSize > size/2) borderSize = Mathf.CeilToInt(size/2f); + + var texture = new Texture2D(size, size, TextureFormat.ARGB32, false); + + //idea... setPixels works faster + //left + for (var i = 0; i < borderSize; i++) for (var j = 0; j < size; j++) texture.SetPixel(i, j, borderColor); + //right + for (var i = size - borderSize; i < size; i++) for (var j = 0; j < size; j++) texture.SetPixel(i, j, borderColor); + for (var i = borderSize; i < size - borderSize; i++) + { + //top + for (var j = 0; j < borderSize; j++) texture.SetPixel(i, j, borderColor); + //bottom + for (var j = size - borderSize; j < size; j++) texture.SetPixel(i, j, borderColor); + } + + //back + for (var i = borderSize; i < size - borderSize; i++) for (var j = borderSize; j < size - borderSize; j++) texture.SetPixel(i, j, color); + + texture.Apply(false); + return texture; + } + + // ============================================== Dialogs + public static void Inform(string title, string message) + { + EditorUtility.DisplayDialog(title, message, "Ok"); + } + + public static bool Confirm(string title, string message, string ok) + { + return EditorUtility.DisplayDialog(title, message, ok, "Cancel"); + } + + public static void HelpBox(string message, MessageType messageType, bool condition = true, Action elseAction = null) + { + if (condition) EditorGUILayout.HelpBox(message, messageType); + else if (elseAction != null) elseAction(); + } + + + // ============================================== Custom handles + + public static Vector3 ControlHandleCustom(int number, Vector3 position, Quaternion rotation, BGCurveSettings.SettingsForHandles handlesSettings) + { + var handleSize = GetHandleSize(position); + + if (vertexSnappingOn) + { + Handles.color = Handles.centerColor; + GUI.SetNextControlName("FreeMoveAxis"); + return Handles.FreeMoveHandle(position, rotation, handleSize*0.15f, new Vector3(xSnap, ySnap, zSnap), Handles.RectangleCap); + } + + var axisSize = handleSize*handlesSettings.AxisScale; + + var color = Handles.color; + + if (!handlesSettings.RemoveX) position = AxisHandle(position, rotation, axisSize, Handles.xAxisColor, "xAxis", Vector3.right, xSnap, handlesSettings.Alpha); + + if (!handlesSettings.RemoveY) position = AxisHandle(position, rotation, axisSize, Handles.yAxisColor, "yAxis", Vector3.up, ySnap, handlesSettings.Alpha); + + if (!handlesSettings.RemoveZ) position = AxisHandle(position, rotation, axisSize, Handles.zAxisColor, "zAxis", Vector3.forward, zSnap, handlesSettings.Alpha); + + if (!handlesSettings.RemoveXZ) position = PlanarHandle("xz" + number, position, rotation, handleSize*.3f*handlesSettings.PlanesScale, Vector3.right, Vector3.forward, Handles.yAxisColor); + + if (!handlesSettings.RemoveYZ) position = PlanarHandle("yz" + number, position, rotation, handleSize*.3f*handlesSettings.PlanesScale, Vector3.up, Vector3.forward, Handles.xAxisColor); + + if (!handlesSettings.RemoveXY) position = PlanarHandle("xy" + number, position, rotation, handleSize*.3f*handlesSettings.PlanesScale, Vector3.up, Vector3.right, Handles.zAxisColor); + + Handles.color = color; + return position; + } + + private static Vector3 AxisHandle(Vector3 position, Quaternion rotation, float handleSize, Color color, string controlName, Vector3 direction, float snap, float alpha) + { + Handles.color = new Color(color.r, color.g, color.b, alpha); + GUI.SetNextControlName(controlName); + return Handles.Slider(position, rotation*direction, handleSize, Handles.ArrowCap, snap); + } + + // ======================================================================================= + // This is a hell lot of a hackery & bad code & probably bugs. + // idea.. to rewrite + // ======================================================================================= + private static Vector3 PlanarHandle(string name, Vector3 position, Quaternion rotation, float size, Vector3 direction1, Vector3 direction2, Color color) + { + var c = Handles.color; + Handles.color = color; + var v1 = rotation*(direction1*size); + var v2 = rotation*(direction2*size); + var verts = new[] {position + v1 + v2, position + v1 - v2, position - v1 - v2, position - v1 + v2}; + + //adjustments + var cameraPos = Camera.current.transform.position; + var min = Single.MaxValue; + + + var minIndex = -1; + var dragCheck = dragSession.Active(name); + + if (dragCheck > 0) minIndex = dragCheck; + else + { + for (var i = 0; i < verts.Length; i++) + { + var magnitude = (cameraPos - verts[i]).sqrMagnitude; + if ((min < magnitude)) continue; + + minIndex = i; + min = magnitude; + } + + dragSession.NextMin(minIndex, name); + } + + for (var i = 0; i < verts.Length; i++) if (i != minIndex) verts[i] = Vector3.Lerp(verts[i], verts[minIndex], .5f); + + var center = (verts[0] + verts[1] + verts[2] + verts[3])*.25f; + + Handles.DrawSolidRectangleWithOutline(verts, new Color(color.r, color.g, color.r, .1f), new Color(0.0f, 0.0f, 0.0f, 0.0f)); + + GUI.SetNextControlName(name); + + var newCenter = Handles.Slider2D(center, rotation*Vector3.Cross(direction1, direction2), rotation*direction1, rotation*direction2, size*.5f, Handles.RectangleCap, 0); + + if (AnyChange(center, newCenter)) position = position + (newCenter - center); + + Handles.color = c; + return position; + } + + + // ============================================= Misc functions + + public static string ToHex(Color c) + { + return String.Format("#{0:X2}{1:X2}{2:X2}", ToByte(c.r), ToByte(c.g), ToByte(c.b)); + } + + private static byte ToByte(float f) + { + f = Mathf.Clamp01(f); + return (byte) (f*255); + } + + public static string ColorIt(string message, string color) + { + return "" + message + ""; + } + + public static bool AnyChange(Vector3 vector1, Vector3 vector2) + { + return !Mathf.Approximately(vector1.x, vector2.x) || !Mathf.Approximately(vector1.y, vector2.y) || !Mathf.Approximately(vector1.z, vector2.z); + } + + public static bool AnyChange(float value1, float value2) + { + return !Mathf.Approximately(value1, value2); + } + + private static bool AnyChange(Color32 color1, Color32 color2) + { + return color1.r != color2.r || color1.g != color2.g || color1.b != color2.b || color1.a != color2.a; + } + + public static T Assign(ref T nullable, Func valueProvider) where T : class + { + return nullable ?? (nullable = valueProvider()); + } + + public static void Iterate(T[] array, Action action) + { + if (array == null || array.Length == 0) return; + for (var i = 0; i < array.Length; i++) action(i, array[i]); + } + + public static bool IterateInterruptable(T[] array, Func action) + { + if (array == null || array.Length == 0) return false; + if (array.Where((t, i) => action(i, t)).Any()) return true; + return false; + } + + public static TV Ensure(Dictionary key2Value, TK key, Func valueProvider) + { + if (key2Value.ContainsKey(key)) return key2Value[key]; + + var newValue = valueProvider(); + key2Value[key] = newValue; + return newValue; + } + + public static List Ensure(Dictionary> key2Value, TK key) + { + if (key2Value.ContainsKey(key)) return key2Value[key]; + + var newValue = new List(); + key2Value[key] = newValue; + return newValue; + } + + public static bool ChangeCheck(Action action, Action changeCallback = null) + { + EditorGUI.BeginChangeCheck(); + action(); + var changed = EditorGUI.EndChangeCheck(); + if (changed && changeCallback != null) changeCallback(); + return changed; + } + + + public static void SwapGuiColor(Color color, Action action) + { + var oldColor = GUI.color; + GUI.color = color; + action(); + GUI.color = oldColor; + } + + public static void SwapLabelWidth(int width, Action action) + { + var oldValue = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = width; + action(); + EditorGUIUtility.labelWidth = oldValue; + } + + public static void DisableGui(Action action, bool condition = true) + { + var oldValue = false; + if (condition) + { + oldValue = GUI.enabled; + GUI.enabled = false; + } + action(); + if (condition) GUI.enabled = oldValue; + } + + public static bool Empty(T[] array) + { + return array == null || array.Length == 0; + } + + public static bool Empty(List list) + { + return list == null || list.Count == 0; + } + + public static string Trim(string value, int maxWidth) + { + if (value == null) return null; + + string result; + + if (value.Length < maxWidth) + { + result = value.Substring(0, value.Length); + } + else + { + result = value.Substring(0, maxWidth - "..".Length) + ".."; + } + return result; + } + + public static T ShowPopupWindow(Vector2 size) where T : EditorWindow + { + // var window = EditorWindow.GetWindow(); + var window = ScriptableObject.CreateInstance(); + + var screenPoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); + window.ShowAsDropDown(new Rect(screenPoint.x, screenPoint.y, 16, 16), size); + return window; + } + + public static void DrawBound(Bounds bounds, Color color, Color borderColor) + { + var min = bounds.min; + var max = bounds.max; + + var xMin = min.x; + var xMax = max.x; + var yMin = min.y; + var yMax = max.y; + var zMin = min.z; + var zMax = max.z; + + var p1 = new Vector3(xMin, yMin, zMin); + var p2 = new Vector3(xMin, yMax, zMin); + var p3 = new Vector3(xMax, yMax, zMin); + var p4 = new Vector3(xMax, yMin, zMin); + var p5 = new Vector3(xMin, yMin, zMax); + var p6 = new Vector3(xMin, yMax, zMax); + var p7 = new Vector3(xMax, yMax, zMax); + var p8 = new Vector3(xMax, yMin, zMax); + + DrawRect(p1, p2, p3, p4, color, borderColor); + DrawRect(p1, p5, p6, p2, color, borderColor); + DrawRect(p2, p6, p7, p3, color, borderColor); + DrawRect(p3, p7, p8, p4, color, borderColor); + DrawRect(p4, p8, p5, p1, color, borderColor); + DrawRect(p5, p6, p7, p8, color, borderColor); + } + + + public static void DrawRect(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, Color color, Color bColor) + { + var verts = new[] {v1, v2, v3, v4}; + Handles.DrawSolidRectangleWithOutline(verts, color, bColor); + } + + // ============================================= Curve related + //this is very slow + public static void Split(BGCurvePointI @from, BGCurvePointI to, int parts, Action action) + { + var noControls = @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent; + if (noControls) + { + action(@from.PositionWorld, to.PositionWorld); + } + else + { + var fromPos = @from.PositionWorld; + var toPos = to.PositionWorld; + var control1 = @from.ControlSecondWorld; + var control2 = to.ControlFirstWorld; + var bothControls = @from.ControlType != BGCurvePoint.ControlTypeEnum.Absent && to.ControlType != BGCurvePoint.ControlTypeEnum.Absent; + if (!bothControls && @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent) control1 = control2; + + + var prev = fromPos; + for (var i = 1; i < parts + 1; i++) + { + var ratio = i/(float) parts; + + var currentPosition = bothControls + ? BGCurveFormulas.BezierCubic(ratio, fromPos, control1, control2, toPos) + : BGCurveFormulas.BezierQuadratic(ratio, fromPos, control1, toPos); + action(prev, currentPosition); + prev = currentPosition; + } + } + } + + //copy paste from math, not sure how to refactor it + public static Vector3 CalculatePosition(BGCurvePointI @from, BGCurvePointI to, float t) + { + if (@from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent) + { + return Vector3.Lerp(@from.PositionWorld, to.PositionWorld, t); + } + if (@from.ControlType != BGCurvePoint.ControlTypeEnum.Absent && to.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + { + return BGCurveFormulas.BezierCubic(t, @from.PositionWorld, @from.ControlSecondWorld, to.ControlFirstWorld, to.PositionWorld); + } + + return BGCurveFormulas.BezierQuadratic(t, @from.PositionWorld, @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent ? to.ControlFirstWorld : @from.ControlSecondWorld, + to.PositionWorld); + } + + /// Tangent in World coordinates + public static Vector3 CalculateTangent(BGCurvePointI @from, BGCurvePointI to, float t) + { + if (@from.ControlType == BGCurvePoint.ControlTypeEnum.Absent && to.ControlType == BGCurvePoint.ControlTypeEnum.Absent) + { + return (to.PositionWorld - @from.PositionWorld).normalized; + } + if (@from.ControlType != BGCurvePoint.ControlTypeEnum.Absent && to.ControlType != BGCurvePoint.ControlTypeEnum.Absent) + { + return BGCurveFormulas.BezierCubicDerivative(t, @from.PositionWorld, @from.ControlSecondWorld, to.ControlFirstWorld, to.PositionWorld).normalized; + } + + return BGCurveFormulas.BezierQuadraticDerivative(t, @from.PositionWorld, @from.ControlType == BGCurvePoint.ControlTypeEnum.Absent ? to.ControlFirstWorld : @from.ControlSecondWorld, + to.PositionWorld).normalized; + } + + /// Tangent in World coordinates + public static Vector3 CalculateTangent(BGCurvePointI point, BGCurvePointI previous, BGCurvePointI next, float precision) + { + var prevTangent = previous != null ? CalculateTangent(previous, point, 1 - precision) : Vector3.zero; + var nextTangent = next != null ? CalculateTangent(point, next, precision) : Vector3.zero; + + var tangent = (previous != null && next != null) + ? Vector3.Lerp(prevTangent, nextTangent, .5f) + : next == null ? prevTangent : nextTangent; + + return tangent.normalized; + } + +/* + public static Vector3 CalculateTangent(BGCurvePoint point, float precision) + { + var curve = point.Curve; + + //not enough points + if (curve.PointsCount < 2) return Vector3.zero; + + var myIndex = curve.IndexOf(point); + + //have no idea why it can happen + if (myIndex < 0) return Vector3.zero; + + //prev point + BGCurvePoint prev = null; + if (myIndex != 0 || curve.Closed) + { + prev = myIndex == 0 ? curve[curve.PointsCount - 1] : curve[myIndex - 1]; + } + + //next point + BGCurvePoint next = null; + if (myIndex != curve.PointsCount - 1 || curve.Closed) + { + next = myIndex == curve.PointsCount - 1 ? curve[0] : curve[myIndex + 1]; + } + return CalculateTangent(point, prev, next, precision); + } + */ + + public static float CalculateDistance(BGCurvePointI from, BGCurvePointI to, int parts) + { + var distance = 0f; + Split(@from, to, parts, (fromPos, toPos) => distance += Vector3.Distance(fromPos, toPos)); + return distance; + } + + // ============================================= Helper classes + public class BoolAnimatedProperty + { + public readonly SerializedProperty Property; + public readonly AnimBool AnimBool = new AnimBool(); + + public BoolAnimatedProperty(UnityEditor.Editor editor, SerializedProperty obj, string name) + { + Property = obj.FindPropertyRelative(name); + AnimBool.target = Property.boolValue; + AnimBool.valueChanged.AddListener(editor.Repaint); + } + } + + private sealed class DragSession + { + private int minIndex; + private bool needtoRecalculate; + private string lastActiveName; + + + public int Active(string name) + { + var currentEvent = Event.current; + + if (currentEvent.type == EventType.MouseUp || currentEvent.type == EventType.MouseDown) needtoRecalculate = true; + + if (needtoRecalculate || GUIUtility.hotControl == 0 || !String.Equals(lastActiveName, name) || !String.Equals(GUI.GetNameOfFocusedControl(), name)) return -1; + + return minIndex; + } + + public void NextMin(int minIndex, string name) + { + if (GUIUtility.hotControl == 0 || !String.Equals(GUI.GetNameOfFocusedControl(), name)) return; + + lastActiveName = name; + needtoRecalculate = false; + this.minIndex = minIndex; + } + } + + public static void Release(ref EventCanceller eventCanceller) + { + if (eventCanceller != null) + { + eventCanceller.Release(); + //bye + eventCanceller = null; + } + } + + public class EventCanceller + { + public EventCanceller() + { + Event.current.Use(); + GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive); + } + + internal void Release() + { + GUIUtility.hotControl = 0; + } + } + + public class ExitException : Exception + { + //get me outta of here + } + + //handles + public static Vector3 Handle(int number, BGCurveSettings.HandlesTypeEnum type, Vector3 position, Quaternion rotation, BGCurveSettings.SettingsForHandles handlesSettings) + { + switch (type) + { + case BGCurveSettings.HandlesTypeEnum.FreeMove: + position = Handles.FreeMoveHandle(position, rotation, GetHandleSize(position, .2f), Vector3.zero, Handles.CircleCap); + break; + case BGCurveSettings.HandlesTypeEnum.Standard: + position = Handles.PositionHandle(position, rotation); + break; + case BGCurveSettings.HandlesTypeEnum.Configurable: + + var dragging = GUIUtility.hotControl != 0; + var current = Event.current; + switch (current.type) + { + case EventType.KeyDown: + if (current.keyCode == KeyCode.V && !dragging) vertexSnappingOn = true; + break; + case EventType.KeyUp: + if (current.keyCode == KeyCode.V && !current.shift && !dragging) vertexSnappingOn = false; + break; + case EventType.Layout: + var vertexDragging = BGPrivateField.Get(typeof(Tools), "vertexDragging"); + if (!dragging && !vertexDragging) vertexSnappingOn = current.shift; + break; + } + + + position = ControlHandleCustom(number, position, rotation, handlesSettings); + break; + } + return position; + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs.meta new file mode 100644 index 0000000..9d9a69d --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGEditorUtility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2e1efa288be0969499190391b84444b4 +timeCreated: 1458400607 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs new file mode 100644 index 0000000..469c247 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs @@ -0,0 +1,113 @@ +using System; +using System.Reflection; +using BansheeGz.BGSpline.Curve; +using UnityEngine; + +namespace BansheeGz.BGSpline.Editor +{ + // access private members + public static class BGPrivateField + { + //--------------------------------------- Settings + public static void SetSettings(BGCurve curve, BGCurveSettings settings) + { + Set(curve, "settings", settings); + } + + public static BGCurveSettings GetSettings(BGCurve curve) + { + return Get(curve, "settings"); + } + + //--------------------------------------- Fields + public static bool GetShowHandles(BGCurvePointField field) + { + return Get(field, "showHandles"); + } + + public static int GetHandlesType(BGCurvePointField field) + { + return Get(field, "handlesType"); + } + + public static Color GetHandlesColor(BGCurvePointField field) + { + return Get(field, "handlesColor"); + } + + public static bool GetShowInPointsMenu(BGCurvePointField field) + { + return Get(field, "showInPointsMenu"); + } + + public static void SetShowHandles(BGCurvePointField field, bool value) + { + Set(field, "showHandles", value); + } + + public static void SetHandlesType(BGCurvePointField field, int value) + { + Set(field, "handlesType", value); + } + + public static void SetHandlesColor(BGCurvePointField field, Color value) + { + Set(field, "handlesColor", value); + } + + public static void SetShowInPointsMenu(BGCurvePointField field, bool value) + { + Set(field, "showInPointsMenu", value); + } + + //--------------------------------------- Cc + public static bool GetShowHandles(BGCc cc) + { + return Get(cc, "showHandles"); + } + + // == utility + public static T Get(object obj, string name) + { + return (T) GetField(obj, name).GetValue(obj); + } + + public static void Set(object obj, string name, T value) + { + GetField(obj, name).SetValue(obj, value); + } + + private static FieldInfo GetField(object obj, string name) + { + var isStatic = obj is Type; + var type = isStatic ? (Type) obj : obj.GetType(); + + var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + + if (isStatic) bindingFlags |= BindingFlags.Static; + + var targetField = type.GetField(name, bindingFlags); + + if (targetField != null) return targetField; + + + var basetype = type.BaseType; + while (targetField == null && basetype != null && basetype != typeof(object)) + { + targetField = basetype.GetField(name, bindingFlags); + basetype = basetype.BaseType; + } + return targetField; + } + + public static object Invoke(object obj, string methodName, params object[] parameters) + { + return obj.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj, parameters); + } + + public static object Invoke(object obj, string methodName, Type[] types, params object[] parameters) + { + return obj.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance, null, types, null).Invoke(obj, parameters); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs.meta new file mode 100644 index 0000000..dc29f49 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGPrivateField.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ad83a743d133b9043a076f918496f4a0 +timeCreated: 1458403127 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs new file mode 100644 index 0000000..61c39a0 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using BansheeGz.BGSpline.Curve; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + [InitializeOnLoad] + public static class BGStartUp + { + private const int IconSize = 20; + + // Not selected + private static readonly Texture2D CurveIcon; + private static readonly Texture2D CurveWarningIcon; + private static readonly Texture2D CurveErrorIcon; + + // Selected + private static readonly Texture2D CurveSelectedIcon; + private static readonly Texture2D CurveWarningSelectedIcon; + private static readonly Texture2D CurveErrorSelectedIcon; + + + static BGStartUp() + { + CurveIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchyIcon123, critical:false); + if (CurveIcon!=null) + { + CurveWarningIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchyWarningIcon123); + CurveErrorIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchyErrorIcon123); + + CurveSelectedIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchySelectedIcon123); + CurveWarningSelectedIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchyWarningSelectedIcon123); + CurveErrorSelectedIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHierarchyErrorSelectedIcon123); + EditorApplication.hierarchyWindowItemOnGUI += ShowIcon; + } + } + + //thanks to laurentlavigne + private static void ShowIcon(int instanceId, Rect selectionRect) + { + var go = EditorUtility.InstanceIDToObject(instanceId) as GameObject; + + if (go == null) return; + var curve = go.GetComponent(); + if (curve == null) return; + + var selected = Selection.Contains(instanceId); + bool hasError = false, hasWarning = false; + BGCurveEditorComponents.ComponentsStatus(curve, ref hasError, ref hasWarning); + + var icon = selected + //selected + ? hasError + ? CurveErrorSelectedIcon + : hasWarning + ? CurveWarningSelectedIcon + : CurveSelectedIcon + + // Not selected + : hasError + ? CurveErrorIcon + : hasWarning + ? CurveWarningIcon + : CurveIcon; + + GUI.Label(new Rect(selectionRect) {x = selectionRect.width - IconSize, width = IconSize}, icon); + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs.meta new file mode 100644 index 0000000..6db4b16 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGStartUp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bfc6ad0229c788e4eba29701126bfed0 +timeCreated: 1472626247 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs new file mode 100644 index 0000000..29a3972 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs @@ -0,0 +1,84 @@ +using UnityEngine; +using UnityEditor; + +namespace BansheeGz.BGSpline.Editor +{ + public abstract class BGTransition + { + private readonly bool cycle; +// private readonly double startTime; + private readonly double period; + + private double cycleStartTime; + private float ratio; + + private bool completed; + + public float Ratio + { + get { return ratio; } + } + + + protected BGTransition(double period, bool cycle) + { + this.period = period; + this.cycle = cycle; +// startTime = cycleStartTime = EditorApplication.timeSinceStartup; + } + + public virtual bool Tick() + { + if (completed) return true; + + var elapsed = (float) (EditorApplication.timeSinceStartup - cycleStartTime); + var cycleEnded = elapsed > period; + + if (cycleEnded) + { + elapsed = 0; + cycleStartTime = EditorApplication.timeSinceStartup; + + if (!cycle) completed = true; + } + ratio = (float) (elapsed/period); + + return cycleEnded; + } + + public class SimpleTransition : BGTransition + { + public SimpleTransition(double period, bool cycle) + : base(period, cycle) + { + } + } + + public class SwayTransition : BGTransition + { + private readonly float from; + private readonly float to; + + private bool up = true; + + public float Value { get; set; } + + public SwayTransition(float @from, float to, double period) + : base(period, true) + { + this.from = from; + this.to = to; + Value = from; + } + + public override bool Tick() + { + if (base.Tick()) up = !up; + + Value = up ? Mathf.Lerp(from, to, Ratio) : Mathf.Lerp(to, from, Ratio); + + return true; + } + } + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs.meta new file mode 100644 index 0000000..46acd06 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTransition.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c5d7571d642b2ea499ebf45bd0227fc5 +timeCreated: 1472289579 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs new file mode 100644 index 0000000..6cae669 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs @@ -0,0 +1,275 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using BansheeGz.BGSpline.Curve; + +namespace BansheeGz.BGSpline.Editor +{ + public class BGTreeView where T : BGTreeNode + { + public readonly List Roots = new List(); + + public Config Configuration { get; private set; } + + private Texture2D linkTexture; + private Texture2D expandedIconTexture; + private Texture2D collapsedIconTexture; + + public Texture2D ExpandedIconTexture + { + get { return expandedIconTexture ?? (expandedIconTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGExpanded123)); } + } + + public Texture2D CollapsedIconTexture + { + get { return collapsedIconTexture ?? (collapsedIconTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCollapsed123)); } + } + + public BGTreeView(Config config) + { + Configuration = config; + } + + public virtual void OnInspectorGui() + { + IterateRoots((i, root) => + { + if (i != 0) GUILayout.Space(Configuration.VerticalSpace*2); + root.OnInspectorGui(); + }); + } + + public void ExpandCollapseAll(bool collapsed) + { + IterateRoots((i, root) => root.ExpandCollapsed(collapsed, true)); + } + + protected void IterateRoots(Action action) + { + for (var i = 0; i < Roots.Count; i++) action(i, Roots[i]); + } + + public virtual Texture2D GetLinkTexture(int level) + { + BGEditorUtility.Assign(ref linkTexture, () => BGEditorUtility.Texture1X1(Color.black)); + return linkTexture; + } + + //========================================================= Config + public class Config + { + public int VerticalSpace { get; private set; } + public int HorizontalLinkOffset { get; private set; } + public int HorizontalSpace { get; private set; } + public int LinkLineSize { get; private set; } + + public int ExpandCollapseIconSize { get; private set; } + + public Config(int verticalSpace, int horizontalSpace, int horizontalLinkOffset, int linkLineSize, int expandCollapseIconSize) + { + VerticalSpace = verticalSpace; + HorizontalLinkOffset = horizontalLinkOffset; + HorizontalSpace = horizontalSpace; + LinkLineSize = linkLineSize; + ExpandCollapseIconSize = expandCollapseIconSize; + } + } + } + + + //========================================================= Node + //curiously recurring template pattern (something wrong here) + public abstract class BGTreeNode where T : BGTreeNode + { + private readonly BGTreeView tree; + private T parent; + private List children; + + private GUIStyle buttonStyle; + + public virtual bool Collapsed { get; set; } + + public Rect Rect { get; set; } + + public bool HasChildren + { + get { return !BGEditorUtility.Empty(children); } + } + + private List postActions; + + public T Parent + { + get { return parent; } + set + { + if (parent == value) return; + + //remove from old parent + if (parent != null && parent.children != null) parent.children.Remove((T) this); + + parent = value; + if (parent == null) return; + + //recursion check + var currentParent = parent; + var nestingLevel = 0; + while (currentParent != null) + { + if (currentParent == this) throw new BGCc.CcException("Recursion check fail!"); + if (nestingLevel > 10) throw new BGCc.CcException("Recursion check fail! Unacceptable Nesting Level " + nestingLevel); + + currentParent = currentParent.Parent; + nestingLevel++; + } + + //add to parent + parent.children = parent.children ?? new List(); + if (!parent.children.Contains((T) this)) parent.children.Add((T) this); + } + } + + public int Level + { + get + { + if (Parent == null) return 0; + + var parentLevel = Parent.Level; + //just in case (recursion check) + if (parentLevel > 10) throw new BGCc.CcException("Recursion check fail! Unacceptable Nesting Level " + parentLevel); + return parentLevel + 1; + } + } + + public BGTreeView Tree + { + get { return tree; } + } + + + protected BGTreeNode(BGTreeView tree) + { + if (tree == null) throw new BGCc.CcException("tree can not be null!"); + this.tree = tree; + } + + public void ExpandCollapsed(bool collapsed, bool recursive) + { + Collapsed = collapsed; + if (recursive) IterateChildren(child => child.ExpandCollapsed(collapsed, true)); + } + + protected void IterateChildren(Action action) + { + if (BGEditorUtility.Empty(children)) return; + + foreach (var child in children) action(child); + } + + + public virtual Rect OnInspectorGui() + { + var level = Level; + + var myRect = new Rect(); + BGEditorUtility.Vertical(() => + { + BGEditorUtility.Horizontal(() => + { + if (level > 0 && tree.Configuration.HorizontalSpace > 0) GUILayout.Space(tree.Configuration.HorizontalSpace*level); + + BGEditorUtility.Vertical(() => { OnInspectorGuiInternal(level); }); + + myRect = GUILayoutUtility.GetLastRect(); + }); + }); + + if (Event.current.type == EventType.Repaint) Rect = myRect; + + if (children == null || children.Count == 0 || Collapsed) return myRect; + + + //Children + var texture = tree.GetLinkTexture(level); + + var linkStartX = myRect.x + tree.Configuration.HorizontalLinkOffset; + + var childRect = new Rect(); + + var linkSize = tree.Configuration.LinkLineSize; + + if (postActions != null) postActions.Clear(); + foreach (var child in children) + { + if (tree.Configuration.VerticalSpace > 0) GUILayout.Space(tree.Configuration.VerticalSpace); + + childRect = child.OnInspectorGui(); + + //horizontal link + var linkWidth = childRect.x - linkStartX; + + if (!(linkWidth > 0)) continue; + + //child Y Center + var childCenterY = childRect.y + childRect.size.y*.5f; + + //link + var horizontalLink = new Rect( + linkStartX, + childCenterY - linkSize*.5f, + linkWidth, + linkSize); + + GUI.DrawTexture(horizontalLink, texture, ScaleMode.StretchToFill); + + //icon + var iconSize = tree.Configuration.ExpandCollapseIconSize; + if (iconSize > 0 && child.HasChildren) + { + BGEditorUtility.Assign(ref buttonStyle, () => new GUIStyle("Button") + { + margin = new RectOffset(), + padding = new RectOffset(), + border = new RectOffset() + }); + + postActions = postActions ?? new List(); + var childRef = child; + postActions.Add(() => + { + var iconSizeHalf = iconSize*.5f; + if (GUI.Button(new Rect( + linkStartX - iconSizeHalf + linkSize*.5f, + childCenterY - iconSizeHalf + linkSize*.5f, + iconSize, + iconSize), + childRef.Collapsed ? tree.CollapsedIconTexture : tree.ExpandedIconTexture, buttonStyle)) + { + childRef.Collapsed = !childRef.Collapsed; + } + }); + } + } + + if (linkStartX < childRect.x) + { + //vertical link + GUI.DrawTexture(new Rect( + linkStartX, + myRect.yMax, + linkSize, + childRect.center.y - myRect.yMax + ), texture, ScaleMode.StretchToFill); + } + + + if (postActions != null && postActions.Count > 0) foreach (var postAction in postActions) postAction(); + + return myRect; + } + + public abstract void OnInspectorGuiInternal(int level); + public abstract void ProcessStructure(); + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs.meta new file mode 100644 index 0000000..19beb63 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/Scripts/Editor/Utils/BGTreeView.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4fecf1343b9858f4a8c2a2f8c22e15d2 +timeCreated: 1472892209 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt new file mode 100644 index 0000000..edd35b7 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt @@ -0,0 +1,62 @@ +BG Curve v.1.2.2 by BancheeGz (12/2016) +Bezier spline editor for Unity +License: MIT License + +www.bansheegz.com/BGCurve +support email: banshee.gzzz@gmail.com + +===================================================== + +----------------------------------------------------- +Package structure: +----------------------------------------------------- +Curve - basic curve's classes + math (distance, positions, tangents, position by closest point). +Components - components are meant to add some functions to curve without any scripting. +Examples - examples and tests for different use-cases. + +----------------------------------------------------- +Quick tips: +----------------------------------------------------- +1) To create a curve chose GameObjecty->Create Other->BG Curve or AddComponent and search "BGCurve". +2) You can learn a lot by looking at fields tooltips and contextual tips in the editor. Example scene could also be helpfull. +3) You can save & load curve settings on/from disk. +4) You can select several points and perform group operations. Hold shift to use rectangular selection. +5) Use components- they are meant to work without any additional scripting. +5) BGCurve class does not contain any Math operations- to use Math- add BGCcMath component +6) Use 2D mode if needed, it helps with 2d curves. +7) Use Lock view to disable selecting of any object except curve's points. +8) Use point's and selection menus in Scene View (hold Ctrl and hover over a point or selection's center). +9) Use standard Unity's AnimationView to animate splines +10) View demo video. + + + +===================================================== +Versions History: +----------------------------------------------------- +Version 1.2 changes: +----------------------------------------------------- +Animation support +Custom fields for points +Snapping (to terrain etc.) +New components (Scale and Triangulate) +New approximation type (Adaptive) +Base math switched to fastest algorithm available for approximation (25% faster) +Components (ChangeCursor and Rotate) are upgraded to support custom points fields +Points store options (inlined, component, gameobjects) + +----------------------------------------------------- +Version 1.1 changes: +----------------------------------------------------- +Components are added (for using without scripting) +Rectangular selection for points. +Context menu for points and selections in SceneView. +BGCurveBaseMath optimization. +New points now has preview in Scene View before adding. +Point creation now respect tangents, controls are scaled properly, in 2D mode Ctrl+Click now respects curve's 2D plane, rather than some mesh. +Show tangents option in SceneView +Examples are reworked. +Minor bugs fixing. +code cleanup and refactoring. +Unity 5.4 compatibility + diff --git a/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt.meta b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt.meta new file mode 100644 index 0000000..5860c96 --- /dev/null +++ b/IronToad_UnityProject/Assets/BansheeGz/BGCurve/readme.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 291a61797e7bab64195fb6be8d006b4d +timeCreated: 1458544744 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Fonts.meta b/IronToad_UnityProject/Assets/Fonts.meta new file mode 100644 index 0000000..79d6b53 --- /dev/null +++ b/IronToad_UnityProject/Assets/Fonts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e993c1c70630f4e33ad8dc005f5d4acc +folderAsset: yes +timeCreated: 1484957599 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf b/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf new file mode 100755 index 0000000..23d266d Binary files /dev/null and b/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf differ diff --git a/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf.meta b/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf.meta new file mode 100644 index 0000000..e06cfdc --- /dev/null +++ b/IronToad_UnityProject/Assets/Fonts/Gang of Three.ttf.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: ee2d72575bd6d453283d60eb13fa8d91 +timeCreated: 1484957639 +licenseType: Free +TrueTypeFontImporter: + serializedVersion: 4 + fontSize: 16 + forceTextureCase: -2 + characterSpacing: 0 + characterPadding: 1 + includeFontData: 1 + fontName: Gang of Three + fontNames: + - Gang of Three + fallbackFontReferences: [] + customCharacters: + fontRenderingMode: 0 + ascentCalculationMode: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween.meta b/IronToad_UnityProject/Assets/LeanTween.meta new file mode 100644 index 0000000..0bc313d --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5e6a0fa47acf54892bbdae89028eaec3 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation.meta new file mode 100644 index 0000000..69aee15 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6737b2aaab0f546e39693df5f551dfc8 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets.meta new file mode 100644 index 0000000..ed25ad6 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: cb26df1b849af495bbce0f91bac5a3f7 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css.meta new file mode 100644 index 0000000..03b114e --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1f4f05e2c3c7b4c5eb028eb9c0c93886 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css new file mode 100644 index 0000000..621cf57 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css @@ -0,0 +1,836 @@ +/* +Font sizes for all selectors other than the body are given in percentages, +with 100% equal to 13px. To calculate a font size percentage, multiply the +desired size in pixels by 7.6923076923. + +Here's a quick lookup table: + +10px - 76.923% +11px - 84.615% +12px - 92.308% +13px - 100% +14px - 107.692% +15px - 115.385% +16px - 123.077% +17px - 130.769% +18px - 138.462% +19px - 146.154% +20px - 153.846% +*/ + + +html { + background: #fff; + color: #333; + overflow-y: scroll; +} + +body { + font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif; + margin: 0; + padding: 0; +} + +/* -- Links ----------------------------------------------------------------- */ +a { + color: #356de4; + text-decoration: none; +} + +.hidden { + display: none; +} + +a:hover { text-decoration: underline; } + +/* "Jump to Table of Contents" link is shown to assistive tools, but hidden from + sight until it's focused. */ +.jump { + position: absolute; + padding: 3px 6px; + left: -99999px; + top: 0; +} + +.jump:focus { left: 40%; } + +/* -- Paragraphs ------------------------------------------------------------ */ +p { margin: 1.3em 0; } +dd p, td p { margin-bottom: 0; } +dd p:first-child, td p:first-child { margin-top: 0; } + +/* -- Headings -------------------------------------------------------------- */ +h1, h2, h3, h4, h5, h6 { + color: #D98527;/*was #f80*/ + font-family: 'Trebuchet MS', sans-serif; + font-weight: bold; + line-height: 1.1; + margin: 1.1em 0 0.5em; +} + +h1 { + font-size: 184.6%; + color: #30418C; + margin: 0.75em 0 0.5em; +} + +h2 { + font-size: 153.846%; + color: #E48A2B; +} + +h3 { font-size: 138.462%; } + +h4 { + border-bottom: 1px solid #DBDFEA; + color: #E48A2B; + font-size: 115.385%; + font-weight: normal; + padding-bottom: 2px; +} + +h5, h6 { font-size: 107.692%; } + +/* -- Code and examples ----------------------------------------------------- */ +code, kbd, pre, samp { + font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; + font-size: 92.308%; + line-height: 1.35; +} + +p code, p kbd, p samp { + background: #FCFBFA; + border: 1px solid #EFEEED; + padding: 0 3px; +} + +a code, a kbd, a samp, +pre code, pre kbd, pre samp, +table code, table kbd, table samp, +.intro code, .intro kbd, .intro samp, +.toc code, .toc kbd, .toc samp { + background: none; + border: none; + padding: 0; +} + +pre.code, pre.terminal, pre.cmd { + overflow-x: auto; + *overflow-x: scroll; + padding: 0.3em 0.6em; +} + +pre.code { + background: #FCFBFA; + border: 1px solid #EFEEED; + border-left-width: 5px; +} + +pre.terminal, pre.cmd { + background: #F0EFFC; + border: 1px solid #D0CBFB; + border-left: 5px solid #D0CBFB; +} + +/* Don't reduce the font size of // elements inside
+   blocks. */
+pre code, pre kbd, pre samp { font-size: 100%; }
+
+/* Used to denote text that shouldn't be selectable, such as line numbers or
+   shell prompts. Guess which browser this doesn't work in. */
+.noselect {
+    -moz-user-select: -moz-none;
+    -khtml-user-select: none;
+    -webkit-user-select: none;
+    -o-user-select: none;
+    user-select: none;
+}
+
+/* -- Lists ----------------------------------------------------------------- */
+dd { margin: 0.2em 0 0.7em 1em; }
+dl { margin: 1em 0; }
+dt { font-weight: bold; }
+
+/* -- Tables ---------------------------------------------------------------- */
+caption, th { text-align: left; }
+
+table {
+    border-collapse: collapse;
+    width: 100%;
+}
+
+td, th {
+    border: 1px solid #fff;
+    padding: 5px 12px;
+    vertical-align: top;
+}
+
+td { background: #E6E9F5; }
+td dl { margin: 0; }
+td dl dl { margin: 1em 0; }
+td pre:first-child { margin-top: 0; }
+
+th {
+    background: #D2D7E6;/*#97A0BF*/
+    border-bottom: none;
+    border-top: none;
+    color: #000;/*#FFF1D5*/
+    font-family: 'Trebuchet MS', sans-serif;
+    font-weight: bold;
+    line-height: 1.3;
+    white-space: nowrap;
+}
+
+
+/* -- Layout and Content ---------------------------------------------------- */
+#doc {
+    margin: auto;
+    min-width: 1024px;
+}
+
+.content { padding: 0 20px 0 25px; }
+
+.sidebar {
+    padding: 0 15px 0 10px;
+}
+#bd {
+    padding: 7px 0 130px;
+    position: relative;
+    width: 99%;
+}
+
+/* -- Table of Contents ----------------------------------------------------- */
+
+/* The #toc id refers to the single global table of contents, while the .toc
+   class refers to generic TOC lists that could be used throughout the page. */
+
+.toc code, .toc kbd, .toc samp { font-size: 100%; }
+.toc li { font-weight: bold; }
+.toc li li { font-weight: normal; }
+
+/* -- Intro and Example Boxes ----------------------------------------------- */
+
+.intro, .example { margin-bottom: 2em; }
+.example {
+    -moz-border-radius: 4px;
+    -webkit-border-radius: 4px;
+    border-radius: 4px;
+    -moz-box-shadow: 0 0 5px #bfbfbf;
+    -webkit-box-shadow: 0 0 5px #bfbfbf;
+    box-shadow: 0 0 5px #bfbfbf;
+    padding: 0.5em 0.5em 0.5em 0.5em;
+    background-color: #EFF2FA;
+}
+.intro {
+    background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
+}
+
+.example h4{
+    margin:0.0em 0 0.0em;
+}
+
+.example p {
+    margin:0.3em 0;
+}
+
+
+/* -- Other Styles ---------------------------------------------------------- */
+
+/* These are probably YUI-specific, and should be moved out of Selleck's default
+   theme. */
+
+.button {
+    border: 1px solid #dadada;
+    -moz-border-radius: 3px;
+    -webkit-border-radius: 3px;
+    border-radius: 3px;
+    color: #444;
+    display: inline-block;
+    font-family: Helvetica, Arial, sans-serif;
+    font-size: 92.308%;
+    font-weight: bold;
+    padding: 4px 13px 3px;
+    -moz-text-shadow: 1px 1px 0 #fff;
+    -webkit-text-shadow: 1px 1px 0 #fff;
+    text-shadow: 1px 1px 0 #fff;
+    white-space: nowrap;
+
+    background: #EFEFEF; /* old browsers */
+    background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
+}
+
+.button:hover {
+    border-color: #466899;
+    color: #fff;
+    text-decoration: none;
+    -moz-text-shadow: 1px 1px 0 #222;
+    -webkit-text-shadow: 1px 1px 0 #222;
+    text-shadow: 1px 1px 0 #222;
+
+    background: #6396D8; /* old browsers */
+    background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
+}
+
+.newwindow { text-align: center; }
+
+.header .version em {
+    display: block;
+    text-align: right;
+}
+
+.header .version form {
+    display: block;
+    text-align: right;
+}
+
+
+#classdocs .item {
+    border-bottom: 1px solid #466899;
+    margin: 1em 0;
+    padding: 1.5em;
+}
+
+.params, .returns{
+    font-size:11px;
+}
+
+.returns-description p{
+    margin:0 0 0.6em 0;
+}
+
+#classdocs .item .params p,
+    #classdocs .item .returns p,{
+    display: inline;
+}
+
+#classdocs .item em code, #classdocs .item em.comment {
+    color: green;
+}
+
+#classdocs .item em.comment a {
+    color: green;
+    text-decoration: underline;
+}
+
+#classdocs .foundat {
+    font-size: 11px;
+    font-style: normal;
+}
+
+.attrs .emits {
+    margin-left: 2em;
+    padding: .5em;
+    border-left: 1px dashed #ccc;
+}
+
+abbr {
+    border-bottom: 1px dashed #ccc;
+    font-size: 80%;
+    cursor: help;
+}
+
+.prettyprint li.L0, 
+.prettyprint li.L1, 
+.prettyprint li.L2, 
+.prettyprint li.L3, 
+.prettyprint li.L5, 
+.prettyprint li.L6, 
+.prettyprint li.L7, 
+.prettyprint li.L8 {
+    list-style: decimal;
+}
+
+ul li p {
+    margin-top: 0;
+}
+
+.method .name {
+    font-size: 110%;
+}
+
+.apidocs .methods .extends .method,
+.apidocs .properties .extends .property,
+.apidocs .attrs .extends .attr,
+.apidocs .events .extends .event {
+    font-weight: bold;
+}
+
+.apidocs .methods .extends .inherited,
+.apidocs .properties .extends .inherited,
+.apidocs .attrs .extends .inherited,
+.apidocs .events .extends .inherited {
+    font-weight: normal;
+}
+
+#hd {
+    background: whiteSmoke;
+    background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
+    background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
+    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dcdbd9',endColorstr='#F6F5F3',GradientType=0);
+    border-bottom: 1px solid #DFDFDF;
+    padding: 0 15px 1px 20px;
+    margin-bottom: 15px;
+}
+
+#hd img {
+    margin-right: 10px;
+    vertical-align: middle;
+}
+
+
+/* -- API Docs CSS ---------------------------------------------------------- */
+
+/*
+This file is organized so that more generic styles are nearer the top, and more
+specific styles are nearer the bottom of the file. This allows us to take full
+advantage of the cascade to avoid redundant style rules. Please respect this
+convention when making changes.
+*/
+
+/* -- Generic TabView styles ------------------------------------------------ */
+
+/*
+These styles apply to all API doc tabviews. To change styles only for a
+specific tabview, see the other sections below.
+*/
+
+.yui3-js-enabled .apidocs .tabview {
+    visibility: visible; /* Hide until the TabView finishes rendering. */
+    _visibility: visible;
+}
+
+.apidocs .tabview.yui3-tabview-content { visibility: visible; }
+.apidocs .tabview .yui3-tabview-panel { background: #fff; }
+
+/* -- Generic Content Styles ------------------------------------------------ */
+
+/* Headings */
+h2, h3, h4, h5, h6 {
+    border: none;
+    color: #30418C;
+    font-weight: bold;
+    text-decoration: none;
+}
+
+.link-docs {
+    float: right;
+    font-size: 15px;
+    margin: 4px 4px 6px;
+    padding: 6px 30px 5px;
+}
+
+.apidocs { zoom: 1; }
+
+/* Generic box styles. */
+.apidocs .box {
+    border: 1px solid;
+    border-radius: 3px;
+    margin: 1em 0;
+    padding: 0 1em;
+}
+
+/* A flag is a compact, capsule-like indicator of some kind. It's used to
+   indicate private and protected items, item return types, etc. in an
+   attractive and unobtrusive way. */
+.apidocs .flag {
+    background: #bababa;
+    border-radius: 3px;
+    color: #fff;
+    font-size: 11px;
+    margin: 0 0.5em;
+    padding: 2px 4px 1px;
+}
+
+/* Class/module metadata such as "Uses", "Extends", "Defined in", etc. */
+.apidocs .meta {
+    background: #f9f9f9;
+    border-color: #efefef;
+    color: #555;
+    font-size: 11px;
+    padding: 3px 6px;
+}
+
+.apidocs .meta p { margin: 0; }
+
+/* Deprecation warning. */
+.apidocs .box.deprecated,
+.apidocs .flag.deprecated {
+    background: #fdac9f;
+    border: 1px solid #fd7775;
+}
+
+.apidocs .box.deprecated p { margin: 0.5em 0; }
+.apidocs .flag.deprecated { color: #333; }
+
+/* Module/Class intro description. */
+.apidocs .intro {
+    background: #f0f1f8;
+    border-color: #d4d8eb;
+}
+
+/* Loading spinners. */
+#bd.loading .apidocs,
+#api-list.loading .yui3-tabview-panel {
+    background: #fff url(../img/spinner.gif) no-repeat center 70px;
+    min-height: 150px;
+}
+
+#bd.loading .apidocs .content,
+#api-list.loading .yui3-tabview-panel .apis {
+    display: none;
+}
+
+.apidocs .no-visible-items { color: #666; }
+
+/* Generic inline list. */
+.apidocs ul.inline {
+    display: inline;
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+
+.apidocs ul.inline li { display: inline; }
+
+/* Comma-separated list. */
+.apidocs ul.commas li:after { content: ','; }
+.apidocs ul.commas li:last-child:after { content: ''; }
+
+/* Keyboard shortcuts. */
+kbd .cmd { font-family: Monaco, Helvetica; }
+
+/* -- Generic Access Level styles ------------------------------------------- */
+.apidocs .item.protected,
+.apidocs .item.private,
+.apidocs .index-item.protected,
+.apidocs .index-item.deprecated,
+.apidocs .index-item.private {
+    display: none;
+}
+
+.show-deprecated .item.deprecated,
+.show-deprecated .index-item.deprecated,
+.show-protected .item.protected,
+.show-protected .index-item.protected,
+.show-private .item.private,
+.show-private .index-item.private {
+    display: block;
+}
+
+.hide-inherited .item.inherited,
+.hide-inherited .index-item.inherited {
+    display: none;
+}
+
+/* -- Generic Item Index styles --------------------------------------------- */
+.apidocs .index { margin: 1.5em 0 3em; }
+
+.apidocs .index h3 {
+    border-bottom: 1px solid #efefef;
+    color: #333;
+    font-size: 13px;
+    margin: 2em 0 0.6em;
+    padding-bottom: 2px;
+}
+
+.apidocs .index .no-visible-items { margin-top: 2em; }
+
+.apidocs .index-list {
+    border-color: #efefef;
+    font-size: 12px;
+    list-style: none;
+    margin: 0;
+    padding: 0;
+    -moz-column-count: 4;
+    -moz-column-gap: 10px;
+    -moz-column-width: 170px;
+    -ms-column-count: 4;
+    -ms-column-gap: 10px;
+    -ms-column-width: 170px;
+    -o-column-count: 4;
+    -o-column-gap: 10px;
+    -o-column-width: 170px;
+    -webkit-column-count: 4;
+    -webkit-column-gap: 10px;
+    -webkit-column-width: 170px;
+    column-count: 4;
+    column-gap: 10px;
+    column-width: 170px;
+}
+
+.apidocs .no-columns .index-list {
+    -moz-column-count: 1;
+    -ms-column-count: 1;
+    -o-column-count: 1;
+    -webkit-column-count: 1;
+    column-count: 1;
+}
+
+.apidocs .index-item { white-space: nowrap; }
+
+.apidocs .index-item .flag {
+    background: none;
+    border: none;
+    color: #afafaf;
+    display: inline;
+    margin: 0 0 0 0.2em;
+    padding: 0;
+}
+
+/* -- Generic API item styles ----------------------------------------------- */
+.apidocs .args {
+    display: inline;
+    margin: 0 0.5em;
+}
+
+.apidocs .flag.chainable { background: #46ca3b; }
+.apidocs .flag.protected { background: #9b86fc; }
+.apidocs .flag.private { background: #fd6b1b; }
+.apidocs .flag.async { background: #356de4; }
+.apidocs .flag.required { background: #e60923; }
+
+.apidocs .item {
+    border-bottom: 1px solid #efefef;
+    margin: 1.5em 0 2em;
+    padding-bottom: 2em;
+}
+
+.apidocs .item h4,
+.apidocs .item h5,
+.apidocs .item h6 {
+    color: #333;
+    font-family: inherit;
+    font-size: 100%;
+}
+
+.apidocs .item .description p,
+.apidocs .item pre.code {
+    margin: 1em 0 0;
+}
+
+.apidocs .item .meta {
+    background: none;
+    border: none;
+    padding: 0;
+}
+
+.apidocs .item .name {
+    display: inline;
+    font-size: 14px;
+}
+
+.apidocs .item .type,
+.apidocs .item .type a,
+.apidocs .returns-inline {
+    color: #555;
+}
+
+.apidocs .item .type,
+.apidocs .returns-inline {
+    font-size: 11px;
+    margin: 0 0 0 0;
+}
+
+.apidocs .item .type a { border-bottom: 1px dotted #afafaf; }
+.apidocs .item .type a:hover { border: none; }
+
+/* -- Item Parameter List --------------------------------------------------- */
+.apidocs .params-list {
+    list-style: square;
+    margin: 0 0 0 2em;
+    padding: 0;
+}
+
+.apidocs .param { margin-bottom: 0em; }
+
+.apidocs .param .type,
+.apidocs .param .type a {
+    color: #666;
+}
+
+.apidocs .param .type {
+    margin: 0 0 0 0.5em;
+    *margin-left: 0.5em;
+}
+
+.apidocs .param-name { font-weight: bold; }
+
+/* -- Item "Emits" block ---------------------------------------------------- */
+.apidocs .item .emits {
+    background: #f9f9f9;
+    border-color: #eaeaea;
+}
+
+/* -- Item "Returns" block -------------------------------------------------- */
+.apidocs .item .returns .type,
+.apidocs .item .returns .type a {
+    font-size: 100%;
+    margin: 0;
+}
+
+/* -- Class Constructor block ----------------------------------------------- */
+.apidocs .constructor .item {
+    border: none;
+    padding-bottom: 0;
+}
+
+/* -- File Source View ------------------------------------------------------ */
+.apidocs .file pre.code,
+#doc .apidocs .file pre.prettyprint {
+    background: inherit;
+    border: none;
+    overflow: visible;
+    padding: 0;
+}
+
+.apidocs .L0,
+.apidocs .L1,
+.apidocs .L2,
+.apidocs .L3,
+.apidocs .L4,
+.apidocs .L5,
+.apidocs .L6,
+.apidocs .L7,
+.apidocs .L8,
+.apidocs .L9 {
+    background: inherit;
+}
+
+/* -- Submodule List -------------------------------------------------------- */
+.apidocs .module-submodule-description {
+    font-size: 12px;
+    margin: 0.3em 0 1em;
+}
+
+.apidocs .module-submodule-description p:first-child { margin-top: 0; }
+
+/* -- Sidebar TabView ------------------------------------------------------- */
+#api-tabview { margin-top: 0.6em; }
+
+#api-tabview-filter,
+#api-tabview-panel {
+    border: 1px solid #dfdfdf;
+}
+
+#api-tabview-filter {
+    border-bottom: none;
+    border-top: none;
+    padding: 0.6em 10px 0 10px;
+}
+
+#api-tabview-panel { border-top: none; }
+#api-filter { width: 97%; }
+
+.yui3-u-1-4{
+    width:21%;
+}
+
+/* -- Content TabView ------------------------------------------------------- */
+#classdocs .yui3-tabview-panel { border: none; }
+
+/* -- Source File Contents -------------------------------------------------- */
+.prettyprint li.L0,
+.prettyprint li.L1,
+.prettyprint li.L2,
+.prettyprint li.L3,
+.prettyprint li.L5,
+.prettyprint li.L6,
+.prettyprint li.L7,
+.prettyprint li.L8 {
+    list-style: decimal;
+}
+
+/* -- API options ----------------------------------------------------------- */
+#api-options {
+    font-size: 11px;
+    margin-top: 2.2em;
+    position: absolute;
+    right: 1.5em;
+}
+
+/*#api-options label { margin-right: 0.6em; }*/
+
+/* -- API list -------------------------------------------------------------- */
+#api-list {
+    margin-top: 1.5em;
+    *zoom: 1;
+}
+
+.apis {
+    font-size: 12px;
+    line-height: 1.4;
+    list-style: none;
+    margin: 0;
+    padding: 0.5em 0 0.5em 0.4em;
+}
+
+.apis a {
+    border: 1px solid transparent;
+    display: block;
+    margin: 0 0 0 -4px;
+    padding: 1px 4px 0;
+    text-decoration: none;
+    _border: none;
+    _display: inline;
+}
+
+.apis a:hover,
+.apis a:focus {
+    background: #E8EDFC;
+    background: -moz-linear-gradient(top, #e8edfc 0%, #becef7 100%);
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#E8EDFC), color-stop(100%,#BECEF7));
+    border-color: #AAC0FA;
+    border-radius: 3px;
+    color: #333;
+    outline: none;
+}
+
+.api-list-item a:hover,
+.api-list-item a:focus {
+    font-weight: bold;
+    text-shadow: 1px 1px 1px #fff;
+}
+
+.apis .message { color: #888; }
+.apis .result a { padding: 3px 5px 2px; }
+
+.apis .result .type {
+    right: 4px;
+    top: 7px;
+}
+
+.api-list-item .yui3-highlight {
+    font-weight: bold;
+}
+
+#advertising{
+    text-align: center;
+    background-color: #e4e9f6;
+    padding: 5px 0 5px 0;
+}
+
+#advertising img{
+    border:1px solid black;
+}
+
+#advertising *{
+    line-height:1.0;
+    display: block;
+    margin: 5px auto 5px auto;
+    margin-right: auto;
+}
+
+#support{
+    margin-top:8px;
+}
+
+#support td{
+    background:none;
+    border:none;
+    padding:0px;
+}
+
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css.meta
new file mode 100644
index 0000000..850eeeb
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/css/main.css.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: f2e6f2786cebb4eb8945b46000f02d18
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico
new file mode 100644
index 0000000..414ac4f
Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico differ
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico.meta
new file mode 100644
index 0000000..c1be27b
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/favicon.ico.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 751c9ec47ccc246ae9845f7503545585
+timeCreated: 1479470953
+licenseType: Store
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html
new file mode 100644
index 0000000..487fe15
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html
@@ -0,0 +1,10 @@
+
+
+    
+        Redirector
+        
+    
+    
+        Click here to redirect
+    
+
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html.meta
new file mode 100644
index 0000000..b08ed0a
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/assets/index.html.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 395ceea41819e494b8fe14c2e7b05a00
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes.meta
new file mode 100644
index 0000000..c3e4637
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: d4bb1e3d3bec8431a82cb033f38b4ceb
diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html
new file mode 100644
index 0000000..fb6446a
--- /dev/null
+++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html
@@ -0,0 +1,720 @@
+
+
+
+    
+    LTBezierPath
+    
+    
+    
+    
+    
+    
+    
+    
+
+
+
+
+
+
+

- Developed by Dented Pixel
+
+
+ API Docs for: LeanTween 2.42
+ + + + + +
+

Support LeanTween!

+ +
+
+ + + + + + + +
+
+
+ +

Maintaining and adding new features takes time, your support is appreciated.

+
+
+ + +
+
+ Show: + + + + + + + +
+ +
+
+
+

LTBezierPath Class

+
+ + +
+ Defined in: LeanTween.cs:2462 +
+ + +
+ + +
+

Manually animate along a bezier path with this class

+ +
+ +
+

Constructor

+
+

LTBezierPath

+ +
+ (
    +
  • + pts +
  • +
) +
+ + + + + + + + +
+

+ Defined in + LeanTween.cs:2462 +

+ + + +
+ +
+ +
+ +
+

Parameters:

+ +
    +
  • + pts + Vector3 Array + + +
    +

    A set of points that define one or many bezier paths (the paths should be passed in multiples of 4, which correspond to each individual bezier curve)
    + It goes in the order: startPoint,endControl,startControl,endPoint - Note: the control for the end and start are reversed! This is just a quirk of the API.
    +

    + +
    + +
  • +
+
+ + +
+

Example:

+ +
+

LTBezierPath ltPath = new LTBezierPath( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(1f,0f,0f), new Vector3(1f,0f,0f), new Vector3(1f,1f,0f)} );

+ LeanTween.move(lt, ltPath.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
+ Vector3 pt = ltPath.point( 0.6f ); // retrieve a point along the path

+ +
+
+
+
+ +
+ + +
+
+

Item Index

+ +
+

Methods

+ + +
+ +
+

Properties

+ + +
+ + +
+ +
+

Methods

+ +
+

place

+ +
+ (
    +
  • + transform:Transform +
  • +
  • + ratio:float +
  • +
) +
+ + + + + + + + +
+

+ Defined in + LeanTween.cs:2561 +

+ + + +
+ +
+

Place an object along a certain point on the path (facing the direction perpendicular to the path)

+ +
+ +
+

Parameters:

+ +
    +
  • + transform:Transform + Transform + + +
    +

    the transform of the object you wish to place along the path

    + +
    + +
  • +
  • + ratio:float + Float + + +
    +

    ratio of the point along the path you wish to receive (0-1)

    + +
    + +
  • +
+
+ + +
+

Example:

+ +
+

ltPath.place( transform, 0.6f );

+ +
+
+
+
+

place

+ +
+ (
    +
  • + transform:Transform +
  • +
  • + ratio:float +
  • +
  • + rotation:Vector3 +
  • +
) +
+ + + + + + + + +
+

+ Defined in + LeanTween.cs:2575 +

+ + + +
+ +
+

Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path

+ +
+ +
+

Parameters:

+ +
    +
  • + transform:Transform + Transform + + +
    +

    the transform of the object you wish to place along the path

    + +
    + +
  • +
  • + ratio:float + Float + + +
    +

    ratio of the point along the path you wish to receive (0-1)

    + +
    + +
  • +
  • + rotation:Vector3 + Vector3 + + +
    +

    the direction in which to place the transform ex: Vector3.up

    + +
    + +
  • +
+
+ + +
+

Example:

+ +
+

ltPath.place( transform, 0.6f, Vector3.left );

+ +
+
+
+
+

placeLocal

+ +
+ (
    +
  • + transform:Transform +
  • +
  • + ratio:float +
  • +
) +
+ + + + + + + + +
+

+ Defined in + LeanTween.cs:2593 +

+ + + +
+ +
+

Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space

+ +
+ +
+

Parameters:

+ +
    +
  • + transform:Transform + Transform + + +
    +

    the transform of the object you wish to place along the path

    + +
    + +
  • +
  • + ratio:float + Float + + +
    +

    ratio of the point along the path you wish to receive (0-1)

    + +
    + +
  • +
+
+ + +
+

Example:

+ +
+

ltPath.placeLocal( transform, 0.6f );

+ +
+
+
+
+

placeLocal

+ +
+ (
    +
  • + transform:Transform +
  • +
  • + ratio:float +
  • +
  • + rotation:Vector3 +
  • +
) +
+ + + + + + + + +
+

+ Defined in + LeanTween.cs:2606 +

+ + + +
+ +
+

Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space

+ +
+ +
+

Parameters:

+ +
    +
  • + transform:Transform + Transform + + +
    +

    the transform of the object you wish to place along the path

    + +
    + +
  • +
  • + ratio:float + Float + + +
    +

    ratio of the point along the path you wish to receive (0-1)

    + +
    + +
  • +
  • + rotation:Vector3 + Vector3 + + +
    +

    the direction in which to place the transform ex: Vector3.up

    + +
    + +
  • +
+
+ + +
+

Example:

+ +
+

ltPath.placeLocal( transform, 0.6f, Vector3.left );

+ +
+
+
+
+

point

+ +
+ (
    +
  • + ratio:float +
  • +
) +
+ + + Vector3 + + + + + + + + +
+

+ Defined in + LeanTween.cs:2522 +

+ + + +
+ +
+

Retrieve a point along a path

+ +
+ +
+

Parameters:

+ +
    +
  • + ratio:float + Float + + +
    +

    ratio of the point along the path you wish to receive (0-1)

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ Vector3: +

Vector3 position of the point along the path

+ +
+
+ +
+

Example:

+ +
+

transform.position = ltPath.point( 0.6f );

+ +
+
+
+
+ +
+

Properties

+ +
+

distance distance of the path (in unity units)

+ Float + + + + + +
+

+ Defined in + LeanTween.cs:2513 +

+ + +
+ +
+ +
+ + + +
+
+ + +
+
+
+
+
+
+
+
+ + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html.meta new file mode 100644 index 0000000..98d07aa --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTBezierPath.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f7b721e4275c14b53a73241b9d0b256f diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html new file mode 100644 index 0000000..9dc07be --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html @@ -0,0 +1,2705 @@ + + + + + LTDescr + + + + + + + + + + + +
+
+
+

- Developed by Dented Pixel
+
+
+ API Docs for: LeanTween 2.42
+ + + + + +
+

Support LeanTween!

+ +
+
+ + + + + + + +
+
+
+ +

Maintaining and adding new features takes time, your support is appreciated.

+
+
+ + +
+
+ Show: + + + + + + + +
+ +
+
+
+

LTDescr Class

+
+ + +
+ Defined in: LTDescr.cs:4 +
+ + +
+ + +
+

Internal Representation of a Tween
+
+ This class represents all of the optional parameters you can pass to a method (it also represents the internal representation of the tween).

+ Optional Parameters are passed at the end of every method:
+
+   Example:
+   LeanTween.moveX( gameObject, 1f, 1f).setEase( LeanTweenType.easeInQuad ).setDelay(1f);
+
+ You can pass the optional parameters in any order, and chain on as many as you wish.
+ You can also pass parameters at a later time by saving a reference to what is returned.
+
+ Retrieve a unique id for the tween by using the "id" property. You can pass this to LeanTween.pause, LeanTween.resume, LeanTween.cancel, LeanTween.isTweening methods
+
+   

Example:

+   int id = LeanTween.moveX(gameObject, 1f, 3f).id;

+
  // pause a specific tween
+   LeanTween.pause(id);
+
  // resume later
+   LeanTween.resume(id);
+
  // check if it is tweening before kicking of a new tween
+   if( LeanTween.isTweening( id ) ){
+       LeanTween.cancel( id );
+       LeanTween.moveZ(gameObject, 10f, 3f);
+   }
+
+ +
+

Constructor

+
+

LTDescr

+ + () + + + + + + + + +
+

+ Defined in + LTDescr.cs:4 +

+ + + +
+ +
+ +
+ + + +
+
+ +
+ + +
+
+

Item Index

+ +
+

Methods

+ + +
+ + + +
+ +
+

Methods

+ +
+

pause

+ + () + + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1113 +

+ + + +
+ +
+

Pause a tween

+ +
+ + +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+
+

resume

+ + () + + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1128 +

+ + + +
+ +
+

Resume a paused tween

+ +
+ + +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+
+

setDelay

+ +
+ (
    +
  • + float +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1145 +

+ + + +
+ +
+

Delay the start of a tween

+ +
+ +
+

Parameters:

+ +
    +
  • + float + Float + + +
    +

    time The time to complete the tween in

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setDelay( 1.5f );

+ +
+
+
+
+

setDirection

+ +
+ (
    +
  • + direction:float +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:2157 +

+ + + +
+ +
+

Set the direction of a tween -1f for backwards 1f for forwards (currently only bezier and spline paths are supported)

+ +
+ +
+

Parameters:

+ +
    +
  • + direction:float + Float + + +
    +

    the direction that the tween should run, -1f for backwards 1f for forwards

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setDirection(-1f);

+ +
+
+
+
+

setEase

+ +
+ (
    +
  • + easeType:LeanTweenType +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1164 +

+ + + +
+ +
+

Set the type of easing used for the tween.

+ +
+ +
+

Parameters:

+ +
    +
  • + easeType:LeanTweenType + LeanTweenType + + +
    +

    the easing type to use

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce );

+ +
+
+
+
+

setEase (AnimationCurve)

+ +
+ (
    +
  • + easeDefinition:AnimationCurve +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1616 +

+ + + +
+ +
+

Set the type of easing used for the tween with a custom curve.

+ +
+ +
+

Parameters:

+ +
    +
  • + easeDefinition:AnimationCurve + AnimationCurve + + +
    +

    an AnimationCure that describes the type of easing you want, this is great for when you want a unique type of movement

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce );

+ +
+
+
+
+

setIgnoreTimeScale

+ +
+ (
    +
  • + useUnScaledTime:bool +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1750 +

+ + + +
+ +
+

Set ignore time scale when tweening an object when you want the animation to be time-scale independent (ignores the Time.timeScale value). Great for pause screens, when you want all other action to be stopped (or slowed down)

+ +
+ +
+

Parameters:

+ +
    +
  • + useUnScaledTime:bool + Bool + + +
    +

    whether to use the unscaled time or not

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setIgnoreTimeScale( true );

+ +
+
+
+
+

setLoopClamp

+ +
+ (
    +
  • + loops:int +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1796 +

+ + + +
+ +
+

When the animation gets to the end it starts back at where it began

+ +
+ +
+

Parameters:

+ +
    +
  • + loops:int + Int + + +
    +

    (defaults to -1) how many times you want the loop to happen (-1 for an infinite number of times)

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopClamp( 2 );

+ +
+
+
+
+

setLoopOnce

+ + () + + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1787 +

+ + + +
+ +
+

No looping involved, just run once (the default)

+ +
+ + +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce();

+ +
+
+
+
+

setLoopPingPong

+ +
+ (
    +
  • + loops:int +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1815 +

+ + + +
+ +
+

When the animation gets to the end it then tweens back to where it started (and on, and on)

+ +
+ +
+

Parameters:

+ +
    +
  • + loops:int + Int + + +
    +

    (defaults to -1) how many times you want the loop to happen in both directions (-1 for an infinite number of times). Passing a value of 1 will cause the object to go towards and back from it's destination once.

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopPingPong( 2 );

+ +
+
+
+
+

setOnComplete

+ +
+ (
    +
  • + onComplete:Action +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1835 +

+ + + +
+ +
+

Have a method called when the tween finishes

+ +
+ +
+

Parameters:

+ +
    +
  • + onComplete:Action + Action + + +
    +

    the method that should be called when the tween is finished ex: tweenFinished(){ }

    + +
    + +
  • +
+
+ +
+

Returns:

+ +
+ LTDescr: +

LTDescr an object that distinguishes the tween

+ +
+
+ +
+

Example:

+ +
+

LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished );

+ +
+
+
+
+

setOnComplete (object)

+ +
+ (
    +
  • + onComplete:Action<object> +
  • +
) +
+ + + LTDescr + + + + + + + + +
+

+ Defined in + LTDescr.cs:1849 +

+ + + +
+ +
+

Have a method called when the tween finishes

+ +
+ +
+

Parameters:

+ +
    +
  • + onComplete:Action<object> + Action + + +
    +

    the method that should be called when the tween is finished ex: tweenFinished( object myObj ){ }

    + +
    + + + + + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished );

    + +
    +
    + +
    +

    setOnCompleteOnRepeat

    + +
    + (
      +
    • + isOn:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2095 +

    + + + +
    + +
    +

    Set the onComplete method to be called at the end of every loop cycle (also applies to the delayedCall method)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + isOn:bool + Bool + + +
      +

      does call onComplete on every loop cycle

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true);

    + +
    +
    +
    +
    +

    setOnCompleteOnStart

    + +
    + (
      +
    • + isOn:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2108 +

    + + + +
    + +
    +

    Set the onComplete method to be called at the beginning of the tween (it will still be called when it is completed as well)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + isOn:bool + Bool + + +
      +

      does call onComplete at the start of the tween

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.delayedCall(gameObject, 2f, ()=>{
    // Flash an object 5 times +  LeanTween.alpha(gameObject, 0f, 1f);
    +  LeanTween.alpha(gameObject, 1f, 0f).setDelay(1f);
    + }).setOnCompleteOnStart(true).setRepeat(5);

    + +
    +
    +
    +
    +

    setOnCompleteParam

    + +
    + (
      +
    • + onComplete:object +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1870 +

    + + + +
    + +
    +

    Pass an object to along with the onComplete Function

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onComplete:object + Object + + +
      +

      an object that

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.delayedCall(1.5f, enterMiniGameStart).setOnCompleteParam( new object[]{""+5} );

    + void enterMiniGameStart( object val ){
    +  object[] arr = (object [])val;
    +  int lvl = int.Parse((string)arr[0]);
    + }

    + +
    +
    +
    +
    +

    setOnStart

    + +
    + (
      +
    • + onStart:Action<> +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2141 +

    + + + +
    + +
    +

    Have a method called when the tween starts

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onStart:Action<> + Action<> + + +
      +

      the method that should be called when the tween is starting ex: tweenStarted( ){ }

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    C#:
    + LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( ()=>{ Debug.Log("I started!"); }); + Javascript:
    + LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( function(){ Debug.Log("I started!"); } );

    + +
    +
    +
    +
    +

    setOnUpdate

    + +
    + (
      +
    • + onUpdate:Action<float> +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1889 +

    + + + +
    + +
    +

    Have a method called on each frame that the tween is being animated (passes a float value)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onUpdate:Action<float> + Action + + +
      +

      a method that will be called on every frame with the float value of the tweened object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
    +
    + void tweenMoved( float val ){ }

    + +
    +
    +
    +
    +

    setOnUpdate (object)

    + +
    + (
      +
    • + onUpdate:Action<float,object> +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1951 +

    + + + +
    + +
    +

    Have a method called on each frame that the tween is being animated (passes a float value and a object)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onUpdate:Action<float,object> + Action + + +
      +

      a method that will be called on every frame with the float value of the tweened object, and an object of the person's choosing

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );
    +
    + void tweenMoved( float val, object obj ){ }

    + +
    +
    +
    +
    +

    setOnUpdate (Vector3)

    + +
    + (
      +
    • + onUpdate:Action<Vector3> +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1985 +

    + + + +
    + +
    +

    Have a method called on each frame that the tween is being animated (passes a float value)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onUpdate:Action<Vector3> + Action + + +
      +

      a method that will be called on every frame with the float value of the tweened object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
    +
    + void tweenMoved( Vector3 val ){ }

    + +
    +
    +
    +
    +

    setOnUpdateParam

    + +
    + (
      +
    • + onUpdateParam:object +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2005 +

    + + + +
    + +
    +

    Have an object passed along with the onUpdate method

    + +
    + +
    +

    Parameters:

    + +
      +
    • + onUpdateParam:object + Object + + +
      +

      an object that will be passed along with the onUpdate method

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );
    +
    + void tweenMoved( float val, object obj ){ }

    + +
    +
    +
    +
    +

    setOrientToPath

    + +
    + (
      +
    • + doesOrient:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2020 +

    + + + +
    + +
    +

    While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon

    + +
    + +
    +

    Parameters:

    + +
      +
    • + doesOrient:bool + Bool + + +
      +

      whether the gameobject will orient to the path it is animating along

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);

    + +
    +
    +
    +
    +

    setOrientToPath2d

    + +
    + (
      +
    • + doesOrient:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2039 +

    + + + +
    + +
    +

    While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon

    + +
    + +
    +

    Parameters:

    + +
      +
    • + doesOrient:bool + Bool + + +
      +

      whether the gameobject will orient to the path it is animating along

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath2d(true).setAxis(Vector3.forward);

    + +
    +
    +
    +
    +

    setOvershoot

    + +
    + (
      +
    • + overshoot:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1577 +

    + + + +
    + +
    +

    Set how far past a tween will overshoot for certain ease types (compatible: easeInBack, easeInOutBack, easeOutBack, easeOutElastic, easeInElastic, easeInOutElastic).

    + +
    + +
    +

    Parameters:

    + +
      +
    • + overshoot:float + Float + + +
      +

      how far past the destination it will go before settling in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutBack ).setOvershoot(2f);

    + +
    +
    +
    +
    +

    setPeriod

    + +
    + (
      +
    • + period:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1590 +

    + + + +
    + +
    +

    Set how short the iterations are for certain ease types (compatible: easeOutElastic, easeInElastic, easeInOutElastic).

    + +
    + +
    +

    Parameters:

    + +
      +
    • + period:float + Float + + +
      +

      how short the iterations are that the tween will animate at (default 0.3f)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutElastic ).setPeriod(0.3f);

    + +
    +
    +
    +
    +

    setPoint

    + +
    + (
      +
    • + point:Vector3 +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2072 +

    + + + +
    + +
    +

    Set the point at which the GameObject will be rotated around

    + +
    + +
    +

    Parameters:

    + +
      +
    • + point:Vector3 + Vector3 + + +
      +

      point at which you want the object to rotate around (local space)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.rotateAround( cube, Vector3.up, 360.0f, 1.0f ) .setPoint( new Vector3(1f,0f,0f) ) .setEase( LeanTweenType.easeInOutBounce );

    + +
    +
    +
    +
    +

    setRecursive

    + +
    + (
      +
    • + useRecursion:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:2189 +

    + + + +
    + +
    +

    Set whether or not the tween will recursively effect an objects children in the hierarchy

    + +
    + +
    +

    Parameters:

    + +
      +
    • + useRecursion:bool + Bool + + +
      +

      whether the tween will recursively effect an objects children in the hierarchy

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alpha(gameObject, 0f, 1f).setRecursive(true);

    + +
    +
    +
    +
    +

    setRepeat

    + +
    + (
      +
    • + repeatNum:int +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1721 +

    + + + +
    + +
    +

    Set the tween to repeat a number of times.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + repeatNum:int + Int + + +
      +

      the number of times to repeat the tween. -1 to repeat infinite times

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong();

    + +
    +
    +
    +
    +

    setScale

    + +
    + (
      +
    • + scale:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1603 +

    + + + +
    + +
    +

    Set how large the effect is for certain ease types (compatible: punch, shake, animation curves).

    + +
    + +
    +

    Parameters:

    + +
      +
    • + scale:float + Float + + +
      +

      how much the ease will be multiplied by (default 1f)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.punch ).setScale(2f);

    + +
    +
    +
    +
    +

    setSpeed

    + +
    + (
      +
    • + speed:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1706 +

    + + + +
    + +
    +

    Set the finish time of the tween

    + +
    + +
    +

    Parameters:

    + +
      +
    • + speed:float + Float + + +
      +

      the speed in unity units per second you wish the object to travel (overrides the given time)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveLocalZ( gameObject, 10f, 1f).setSpeed(0.2f) // the given time is ignored when speed is set

    + +
    +
    +
    +
    +

    setTime

    + +
    + (
      +
    • + finishTime:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1688 +

    + + + +
    + +
    +

    Set the finish time of the tween

    + +
    + +
    +

    Parameters:

    + +
      +
    • + finishTime:float + Float + + +
      +

      the length of time in seconds you wish the tween to complete in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    int tweenId = LeanTween.moveX(gameObject, 5f, 2.0f ).id;
    + // Later
    + LTDescr descr = description( tweenId );
    + descr.setTime( 1f );

    + +
    +
    +
    +
    +

    setTo

    + +
    + (
      +
    • + to:Vector3 +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1631 +

    + + + +
    + +
    +

    Set the end that the GameObject is tweening towards

    + +
    + +
    +

    Parameters:

    + +
      +
    • + to:Vector3 + Vector3 + + +
      +

      point at which you want the tween to reach

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LTDescr descr = LeanTween.move( cube, Vector3.up, new Vector3(1f,3f,0f), 1.0f ).setEase( LeanTweenType.easeInOutBounce );
    + // Later your want to change your destination or your destiation is constantly moving
    + descr.setTo( new Vector3(5f,10f,3f); );

    + +
    +
    +
    +
    +

    setUseFrames

    + +
    + (
      +
    • + useFrames:bool +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:1763 +

    + + + +
    + +
    +

    Use frames when tweening an object, when you don't want the animation to be time-frame independent...

    + +
    + +
    +

    Parameters:

    + +
      +
    • + useFrames:bool + Bool + + +
      +

      whether to use estimated time or not

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setUseFrames( true );

    + +
    +
    +
    +
    +

    updateNow

    + + () + + + LTDescr + + + + + + + + +
    +

    + Defined in + LTDescr.cs:904 +

    + + + +
    + +
    +

    If you need a tween to happen immediately instead of waiting for the next Update call, you can force it with this method

    + +
    + + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject, 5f, 0f ).updateNow();

    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html.meta new file mode 100644 index 0000000..bbd5916 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTDescr.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 728d9c45462a9409f8b8be1447f59e94 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html new file mode 100644 index 0000000..c22a64f --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html @@ -0,0 +1,237 @@ + + + + + LTEvent + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LTEvent Class

    +
    + + +
    + Defined in: LeanTween.cs:3325 +
    + + +
    + + +
    +

    Object that describes the event to an event listener

    + +
    + +
    +

    Constructor

    +
    +

    LTEvent

    + +
    + (
      +
    • + data:object +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:3325 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + data:object + Object + + +
      +

      Data that has been passed from the dispatchEvent method

      + +
      + +
    • +
    +
    + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + + + + +
    + + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html.meta new file mode 100644 index 0000000..7dd3032 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTEvent.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 2b8203605b4454b009a6fc1e269a8d50 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html new file mode 100644 index 0000000..1145d5c --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html @@ -0,0 +1,359 @@ + + + + + LTRect + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LTRect Class

    +
    + + +
    + Defined in: LeanTween.cs:3083 +
    + + +
    + + +
    +

    Animate GUI Elements by creating this object and passing the *.rect variable to the GUI method

    + Example Javascript:
    var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
    + LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 );
    + function OnGUI(){
    +   if(GUI.Button(bRect.rect, "Scale")){ }
    + }
    +
    + Example C#:
    + LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
    + LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f );
    + void OnGUI(){
    +   if(GUI.Button(bRect.rect, "Scale")){ }
    + }

    + +
    + +
    +

    Constructor

    +
    +

    LTRect

    + +
    + (
      +
    • + x:float +
    • +
    • + y:float +
    • +
    • + width:float +
    • +
    • + height:float +
    • +
    • + alpha:float +
    • +
    • + rotation:float +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:3083 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + x:float + Float + + +
      +

      X location

      + +
      + +
    • +
    • + y:float + Float + + +
      +

      Y location

      + +
      + +
    • +
    • + width:float + Float + + +
      +

      Width

      + +
      + +
    • +
    • + height:float + Float + + +
      +

      Height

      + +
      + +
    • +
    • + alpha:float + Float + + +
      +

      (Optional) initial alpha amount (0-1)

      + +
      + +
    • +
    • + rotation:float + Float + + +
      +

      (Optional) initial rotation in degrees (0-360)

      + +
      + +
    • +
    +
    + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + + +
    +

    Properties

    + + +
    + + +
    + + +
    +

    Properties

    + +
    +

    rect

    + Rect rect:Rect Rect object that controls the positioning and size + + + + + +
    +

    + Defined in + LeanTween.cs:3110 +

    + + +
    + +
    +

    Pass this value to the GUI Methods

    + +
    + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html.meta new file mode 100644 index 0000000..feec8d2 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTRect.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b7ee5979c5f5f428d9c8735d84e09421 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html new file mode 100644 index 0000000..e150251 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html @@ -0,0 +1,796 @@ + + + + + LTSpline + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LTSpline Class

    +
    + + +
    + Defined in: LeanTween.cs:2651 +
    + + +
    + + +
    +

    Animate along a set of points that need to be in the format: controlPoint, point1, point2.... pointLast, endControlPoint

    + +
    + +
    +

    Constructor

    +
    +

    LTSpline

    + +
    + (
      +
    • + pts +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2651 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + pts + Vector3 Array + + +
      +

      A set of points that define the points the path will pass through (starting with starting control point, and ending with a control point)
      + Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value.

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LTSpline ltSpline = new LTSpline( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(0f,0f,0f), new Vector3(0f,0.5f,0f), new Vector3(1f,1f,0f), new Vector3(1f,1f,0f)} );

    + LeanTween.moveSpline(lt, ltSpline.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
    + Vector3 pt = ltSpline.point( 0.6f ); // retrieve a point along the path

    + +
    +
    +
    +
    + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + + + + +
    + +
    +

    Methods

    + +
    +

    place

    + +
    + (
      +
    • + transform:Transform +
    • +
    • + ratio:float +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2863 +

    + + + +
    + +
    +

    Place an object along a certain point on the path (facing the direction perpendicular to the path)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + transform:Transform + Transform + + +
      +

      the transform of the object you wish to place along the path

      + +
      + +
    • +
    • + ratio:float + Float + + +
      +

      ratio of the point along the path you wish to receive (0-1)

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    ltPath.place( transform, 0.6f );

    + +
    +
    +
    +
    +

    place

    + +
    + (
      +
    • + transform:Transform +
    • +
    • + ratio:float +
    • +
    • + rotation:Vector3 +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2876 +

    + + + +
    + +
    +

    Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path

    + +
    + +
    +

    Parameters:

    + +
      +
    • + transform:Transform + Transform + + +
      +

      the transform of the object you wish to place along the path

      + +
      + +
    • +
    • + ratio:float + Float + + +
      +

      ratio of the point along the path you wish to receive (0-1)

      + +
      + +
    • +
    • + rotation:Vector3 + Vector3 + + +
      +

      the direction in which to place the transform ex: Vector3.up

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    ltPath.place( transform, 0.6f, Vector3.left );

    + +
    +
    +
    +
    +

    placeLocal

    + +
    + (
      +
    • + transform:Transform +
    • +
    • + ratio:float +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2895 +

    + + + +
    + +
    +

    Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space

    + +
    + +
    +

    Parameters:

    + +
      +
    • + transform:Transform + Transform + + +
      +

      the transform of the object you wish to place along the path

      + +
      + +
    • +
    • + ratio:float + Float + + +
      +

      ratio of the point along the path you wish to receive (0-1)

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    ltPath.placeLocal( transform, 0.6f );

    + +
    +
    +
    +
    +

    placeLocal

    + +
    + (
      +
    • + transform:Transform +
    • +
    • + ratio:float +
    • +
    • + rotation:Vector3 +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2908 +

    + + + +
    + +
    +

    Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space

    + +
    + +
    +

    Parameters:

    + +
      +
    • + transform:Transform + Transform + + +
      +

      the transform of the object you wish to place along the path

      + +
      + +
    • +
    • + ratio:float + Float + + +
      +

      ratio of the point along the path you wish to receive (0-1)

      + +
      + +
    • +
    • + rotation:Vector3 + Vector3 + + +
      +

      the direction in which to place the transform ex: Vector3.up

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    ltPath.placeLocal( transform, 0.6f, Vector3.left );

    + +
    +
    +
    +
    +

    point

    + +
    + (
      +
    • + ratio:float +
    • +
    ) +
    + + + Vector3 + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2828 +

    + + + +
    + +
    +

    Retrieve a point along a path

    + +
    + +
    +

    Parameters:

    + +
      +
    • + ratio:float + Float + + +
      +

      ratio of the point along the path you wish to receive (0-1)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Vector3: +

    Vector3 position of the point along the path

    + +
    +
    + +
    +

    Example:

    + +
    +

    transform.position = ltSpline.point( 0.6f );

    + +
    +
    +
    +
    +

    ratioAtPoint

    + +
    + (
      +
    • + point:Vector3 +
    • +
    ) +
    + + + Float + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2804 +

    + + + +
    + +
    +

    Retrieve a point along a path

    + +
    + +
    +

    Parameters:

    + +
      +
    • + point:Vector3 + Vector3 + + +
      +

      given a current location it makes the best approximiation of where it is along the path ratio-wise (0-1)

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Float: +

    float of ratio along the path

    + +
    +
    + +
    +

    Example:

    + +
    +

    ratioIter = ltSpline.ratioAtPoint( transform.position );

    + +
    +
    +
    +
    + +
    +

    Properties

    + +
    +

    distance distance of the spline (in unity units)

    + Float + + + + + +
    +

    + Defined in + LeanTween.cs:2667 +

    + + +
    + +
    + +
    + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html.meta new file mode 100644 index 0000000..49235af --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LTSpline.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1adcbb4b77b884a4fb75bde98799d037 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html new file mode 100644 index 0000000..af6fb60 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html @@ -0,0 +1,332 @@ + + + + + LeanAudio + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LeanAudio Class

    +
    + + +
    + Defined in: LeanAudio.cs:30 +
    + + +
    + + +
    +

    Create Audio dynamically and easily playback

    + +
    + +
    +

    Constructor

    +
    +

    LeanAudio

    + + () + + + + + + + + +
    +

    + Defined in + LeanAudio.cs:30 +

    + + + +
    + +
    + +
    + + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + + + +
    + +
    +

    Methods

    + +
    +

    createAudio

    + +
    + (
      +
    • + volumeCurve:AnimationCurve +
    • +
    • + frequencyCurve:AnimationCurve +
    • +
    • + options:LeanAudioOptions +
    • +
    ) +
    + + + AudioClip + + + + + + + + +
    +

    + Defined in + LeanAudio.cs:65 +

    + + + +
    + +
    +

    Create dynamic audio from a set of Animation Curves and other options.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + volumeCurve:AnimationCurve + AnimationCurve + + +
      +

      describing the shape of the audios volume (from 0-1). The length of the audio is dicated by the end value here.

      + +
      + +
    • +
    • + frequencyCurve:AnimationCurve + AnimationCurve + + +
      +

      describing the width of the oscillations between the sound waves in seconds. Large numbers mean a lower note, while higher numbers mean a tighter frequency and therefor a higher note. Values are usually between 0.01 and 0.000001 (or smaller)

      + +
      + +
    • +
    • + options:LeanAudioOptions + LeanAudioOptions + + +
      +

      You can pass any other values in here like vibrato or the frequency you would like the sound to be encoded at. See LeanAudioOptions for more details.

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + AudioClip: +

    AudioClip of the procedurally generated audio

    + +
    +
    + +
    +

    Example:

    + +
    +

    AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ));

    + +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html.meta new file mode 100644 index 0000000..c466510 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudio.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ddb683830b7524ebb8b302202c645c65 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html new file mode 100644 index 0000000..3e4a5b0 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html @@ -0,0 +1,383 @@ + + + + + LeanAudioOptions + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LeanAudioOptions Class

    +
    + + +
    + Defined in: LeanAudio.cs:316 +
    + + +
    + + +
    +

    Pass in options to LeanAudio

    + +
    + +
    +

    Constructor

    +
    +

    LeanAudioOptions

    + + () + + + + + + + + +
    +

    + Defined in + LeanAudio.cs:316 +

    + + + +
    + +
    + +
    + + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + + + +
    + +
    +

    Methods

    + +
    +

    setFrequency

    + +
    + (
      +
    • + frequencyRate:int +
    • +
    ) +
    + + + LeanAudioOptions + + + + + + + + +
    +

    + Defined in + LeanAudio.cs:343 +

    + + + +
    + +
    +

    Set the frequency for the audio is encoded. 44100 is CD quality, but you can usually get away with much lower (or use a lower amount to get a more 8-bit sound).

    + +
    + +
    +

    Parameters:

    + +
      +
    • + frequencyRate:int + Int + + +
      +

      of the frequency you wish to encode the AudioClip at

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LeanAudioOptions: +

    LeanAudioOptions describing optional values

    + +
    +
    + +
    +

    Example:

    + +
    +

    AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ).setFrequency(12100) );

    + +
    +
    +
    +
    +

    setVibrato

    + +
    + (
      +
    • + vibratoArray:Vector3[] +
    • +
    ) +
    + + + LeanAudioOptions + + + + + + + + +
    +

    + Defined in + LeanAudio.cs:359 +

    + + + +
    + +
    +

    Set details about the shape of the curve by adding vibrato modulations through it (alters the peak values giving it a wah-wah effect). You can add as many as you want to sculpt out more detail in the sound wave.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + vibratoArray:Vector3[] + Vector3 + + +
      +

      The first value is the period in seconds that you wish to have the vibrato wave fluctuate at. The second value is the minimum height you wish the vibrato wave to dip down to (default is zero). The third is reserved for future effects.

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LeanAudioOptions: +

    LeanAudioOptions describing optional values

    + +
    +
    + +
    +

    Example:

    + +
    +

    AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0.3f,0f)} ).setFrequency(12100) );

    + +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html.meta new file mode 100644 index 0000000..fcb8d15 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanAudioOptions.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ff952359765254c20b97874f5949c0d7 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html new file mode 100644 index 0000000..8115c36 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html @@ -0,0 +1,7474 @@ + + + + + LeanTween + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LeanTween Class

    +
    + + +
    + Defined in: LeanTween.cs:204 +
    + + +
    + + +
    +

    LeanTween is an efficient tweening engine for Unity3d

    + Index of All Methods | Optional Paramaters that can be passed

    + Optional Parameters are passed at the end of every method
    +
    + Example:
    + LeanTween.moveX( gameObject, 1f, 1f).setEase( LeanTweenType.easeInQuad ).setDelay(1f);
    +
    + You can pass the optional parameters in any order, and chain on as many as you wish!

    + You can also modify this tween later, just save the unique id of the tween.
    +

    Example:

    + int id = LeanTween.moveX(gameObject, 1f, 1f).id;
    + LTDescr d = LeanTween.descr( id );

    + if(d!=null){ // if the tween has already finished it will return null
    +    // change some parameters
    +    d.setOnComplete( onCompleteFunc ).setEase( LeanTweenType.easeInOutBack );
    + }

    + +
    + + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + + + +
    + +
    +

    Methods

    + +
    +

    LeanTween.addListener

    + +
    + (
      +
    • + caller:GameObject +
    • +
    • + eventId:int +
    • +
    • + callback:System.Action<LTEvent> +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2269 +

    + + + +
    + +
    +

    Add a listener method to be called when the appropriate LeanTween.dispatchEvent is called

    + +
    + +
    +

    Parameters:

    + +
      +
    • + caller:GameObject + GameObject + + +
      +

      the gameObject the listener is attached to

      + +
      + +
    • +
    • + eventId:int + Int + + +
      +

      a unique int that describes the event (best to use an enum)

      + +
      + +
    • +
    • + callback:System.Action<LTEvent> + System.Action + + +
      +

      the method to call when the event has been dispatched

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.addListener(gameObject, (int)MyEvents.JUMP, jumpUp);
    +
    + void jumpUp( LTEvent e ){ Debug.Log("jump!"); }

    + +
    +
    +
    +
    +

    LeanTween.alpha

    + +
    + (
      +
    • + ltRect:LTRect +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:908 +

    + + + +
    + +
    +

    Fade a GUI Object

    + +
    + +
    +

    Parameters:

    + +
      +
    • + ltRect:LTRect + LTRect + + +
      +

      LTRect that you wish to fade

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      the final alpha value (0-1)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alpha(ltRect, 1f, 1f) .setEase(LeanTweenType.easeInCirc);

    + +
    +
    +
    +
    +

    LeanTween.alpha

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:887 +

    + + + +
    + +
    +

    Fade a gameobject's material to a certain alpha value. The material's shader needs to support alpha. Owl labs has some excellent efficient shaders.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to fade

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      the final alpha value (0-1)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alpha(gameObject, 1f, 1f) .setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.alpha (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1886 +

    + + + +
    + +
    +

    Alpha an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final Vector3 with which to tween to (localScale)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alpha(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.alpha (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1900 +

    + + + +
    + +
    +

    Change the Color of an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final Vector3 with which to tween to (localScale)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.color(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.alphaCanvas

    + +
    + (
      +
    • + rectTransform:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:944 +

    + + + +
    + +
    +

    Fade a Unity UI Canvas Group

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTransform:RectTransform + RectTransform + + +
      +

      RectTransform that the CanvasGroup is attached to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      the final alpha value (0-1)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alphaCanvas(gameObject.GetComponent<RectTransform>(), 0f, 1f) .setLoopPingPong();

    + +
    +
    +
    +
    +

    LeanTween.alphaText

    + +
    + (
      +
    • + rectTransform:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:926 +

    + + + +
    + +
    +

    Fade a Unity UI Object

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTransform:RectTransform + RectTransform + + +
      +

      RectTransform associated with the Text Component you wish to fade

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      the final alpha value (0-1)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.alphaText(gameObject.GetComponent<RectTransform>(), 1f, 1f) .setEase(LeanTweenType.easeInCirc);

    + +
    +
    +
    +
    +

    LeanTween.alphaVertex

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:960 +

    + + + +
    + +
    +

    This works by tweening the vertex colors directly.
    +
    + Vertex-based coloring is useful because you avoid making a copy of your + object's material for each instance that needs a different color.
    +
    + A shader that supports vertex colors is required for it to work + (for example the shaders in Mobile/Particles/)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to alpha

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The alpha value you wish to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to delay before calling the function

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.cancel

    + +
    + (
      +
    • + id:int +
    • +
    • + callOnComplete:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:524 +

    + + + +
    + +
    +

    Cancel a specific tween with the provided id

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:int + Int + + +
      +

      unique id that represents that tween

      + +
      + +
    • +
    • + callOnComplete:int + Bool + + +
      +

      (optional) whether to call the onComplete method before canceling

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).id;
    + LeanTween.cancel( id );

    + +
    +
    +
    +
    +

    LeanTween.cancel

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + callOnComplete:bool +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:478 +

    + + + +
    + +
    +

    Cancel all tweens that are currently targeting the gameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      gameObject whose tweens you wish to cancel

      + +
      + +
    • +
    • + callOnComplete:bool + Bool + + +
      +

      (optional) whether to call the onComplete method before canceling

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f);
    + LeanTween.cancel( gameObject );

    + +
    +
    +
    +
    +

    LeanTween.cancelAll

    + +
    + (
      +
    • + callComplete:bool +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:456 +

    + + + +
    + +
    +

    Cancels all tweens

    + +
    + +
    +

    Parameters:

    + +
      +
    • + callComplete:bool + Bool + + +
      +

      (optional) if true, then the all onCompletes will run before canceling

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.cancelAll(true);

    + +
    +
    +
    +
    +

    LeanTween.color

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + to:Color +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:979 +

    + + + +
    + +
    +

    Change a gameobject's material to a certain color value. The material's shader needs to support color tinting. Owl labs has some excellent efficient shaders.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to change the color

      + +
      + +
    • +
    • + to:Color + Color + + +
      +

      the final color value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.color(gameObject, Color.yellow, 1f) .setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.colorText

    + +
    + (
      +
    • + rectTransform:RectTransform +
    • +
    • + to:Color +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1000 +

    + + + +
    + +
    +

    Change the color a Unity UI Object

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTransform:RectTransform + RectTransform + + +
      +

      RectTransform attached to the Text Component whose color you want to change

      + +
      + +
    • +
    • + to:Color + Color + + +
      +

      the final alpha value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time with which to fade the object

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.colorText(gameObject.GetComponent<RectTransform>(), Color.yellow, 1f) .setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.delayedCall

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1019 +

    + + + +
    + +
    +

    Call a method after a specified amount of time

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to associate with this delayed call

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      delay The time you wish to pass before the method is called

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.delayedCall(gameObject, 1f, ()=>{
    Debug.Log("I am called one second later!");
    }));

    + +
    +
    +
    +
    +

    LeanTween.descr

    + +
    + (
      +
    • + id:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:550 +

    + + + +
    + +
    +

    Retrieve a tweens LTDescr object to modify

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:int + Int + + +
      +

      unique id that represents that tween

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod ).id;

    +
    // later I want decide I want to change onComplete method
    + LTDescr descr = LeanTween.descr( id );
    + if(descr!=null) // if the tween has already finished it will come back null
    +   descr.setOnComplete( newMethod );
    +
    +
    +
    +
    +

    LeanTween.descriptions

    + +
    + (
      +
    • + id:GameObject +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:578 +

    + + + +
    + +
    +

    Retrieve a tweens LTDescr object(s) to modify

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:GameObject + GameObject + + +
      +

      object whose tween descriptions you want to retrieve

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod );

    +
    // later I want decide I want to change onComplete method
    + LTDescr[] descr = LeanTween.descriptions( gameObject );
    + if(descr.Length>0) // make sure there is a valid description for this target
    +   descr[0].setOnComplete( newMethod );// in this case we only ever expect there to be one tween on this object
    +
    +
    +
    +
    +

    LeanTween.dispatchEvent

    + +
    + (
      +
    • + eventId:int +
    • +
    • + data:object +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2356 +

    + + + +
    + +
    +

    Tell the added listeners that you are dispatching the event

    + +
    + +
    +

    Parameters:

    + +
      +
    • + eventId:int + Int + + +
      +

      a unique int that describes the event (best to use an enum)

      + +
      + +
    • +
    • + data:object + Object + + +
      +

      Pass data to the listener, access it from the listener with *.data on the LTEvent object

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.dispatchEvent( (int)MyEvents.JUMP, transform );
    +
    + void jumpUp( LTEvent e ){
    +   Transform tran = (Transform)e.data;
    + }

    + +
    +
    +
    +
    +

    LeanTween.dispatchEvent

    + +
    + (
      +
    • + eventId:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2345 +

    + + + +
    + +
    +

    Tell the added listeners that you are dispatching the event

    + +
    + +
    +

    Parameters:

    + +
      +
    • + eventId:int + Int + + +
      +

      a unique int that describes the event (best to use an enum)

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.dispatchEvent( (int)MyEvents.JUMP );

    + +
    +
    +
    +
    +

    LeanTween.init

    + +
    + (
      +
    • + maxSimultaneousTweens:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:285 +

    + + + +
    + +
    +

    This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + maxSimultaneousTweens:int + Integer + + +
      +

      The maximum number of tweens you will use, make sure you don't go over this limit, otherwise the code will throw an error

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.init( 800 );

    + +
    +
    +
    +
    +

    LeanTween.isTweening

    + +
    + (
      +
    • + id:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:724 +

    + + + +
    + +
    +

    Test whether or not a tween is active or not

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:int + GameObject + + +
      +

      id of the tween that you want to test if it is tweening

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    int id = LeanTween.moveX(gameObject, 1f, 3f).id;
    + if(LeanTween.isTweening( id ))
    +      Debug.Log("I am tweening!");

    + +
    +
    +
    +
    +

    LeanTween.isTweening

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:702 +

    + + + +
    + +
    +

    Test whether or not a tween is active on a GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      GameObject that you want to test if it is tweening

      + +
      + +
    • +
    +
    + + +
    +
    +

    LeanTween.move

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + destination:Transform +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1290 +

    + + + +
    + +
    +

    Move a GameObject to another transform

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + destination:Transform + Transform + + +
      +

      Transform whose position the tween will finally end on

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.move(gameObject, anotherTransform, 2.0f) .setEase( LeanTweenType.easeOutQuad );

    + +
    +
    +
    +
    +

    LeanTween.move

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + vec:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1052 +

    + + + +
    + +
    +

    Move a GameObject to a certain location

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + vec:Vector3 + Vector3 + + +
      +

      to The final positin with which to move to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.move(gameObject, new Vector3(0f,-3f,5f), 2.0f) .setEase( LeanTweenType.easeOutQuad );

    + +
    +
    +
    +
    +

    LeanTween.move

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + path:Vector3[] +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1070 +

    + + + +
    + +
    +

    Move a GameObject along a set of bezier curves

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + path:Vector3[] + Vector3 + + +
      +

      A set of points that define the curve(s) ex: Point1,Handle2,Handle1,Point2,...

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Javascript:
    + LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + C#:
    + LeanTween.move(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);;

    + +
    +
    +
    +
    +

    LeanTween.move (GUI)

    + +
    + (
      +
    • + ltRect:LTRect +
    • +
    • + vec:Vector2 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1171 +

    + + + +
    + +
    +

    Move a GUI Element to a certain location

    + +
    + +
    +

    Parameters:

    + +
      +
    • + ltRect:LTRect + LTRect + + +
      +

      ltRect LTRect object that you wish to move

      + +
      + +
    • +
    • + vec:Vector2 + Vector2 + + +
      +

      to The final position with which to move to (pixel coordinates)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.move (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1754 +

    + + + +
    + +
    +

    Move a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:Vector3 + Vector3 + + +
      +

      The final Vector3 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.move(gameObject.GetComponent<RectTransform>(), new Vector3(200f,-100f,0f), 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.moveLocal

    + +
    + (
      +
    • + GameObject +
    • +
    • + Vector3 +
    • +
    • + float +
    • +
    • + Hashtable +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1227 +

    + + + +
    + +
    +

    Move a GameObject to a certain location relative to the parent transform.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to rotate

      + +
      + +
    • +
    • + Vector3 + Vector3 + + +
      +

      to The final positin with which to move to

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    • + Hashtable + Hashtable + + +
      +

      optional Hashtable where you can pass optional items.

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.moveLocal

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + path:Vector3[] +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1241 +

    + + + +
    + +
    +

    Move a GameObject along a set of bezier curves, in local space

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + path:Vector3[] + Vector3 + + +
      +

      A set of points that define the curve(s) ex: Point1,Handle1,Handle2,Point2,...

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Javascript:
    + LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + C#:
    + LeanTween.move(gameObject, new Vector3[]{Vector3(0f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,1f)}).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + +
    +
    +
    +
    +

    LeanTween.moveSpline

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + spline:LTSpline +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1129 +

    + + + +
    + +
    +

    Move a GameObject through a set of points

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + spline:LTSpline + LTSpline + + +
      +

      pass a pre-existing LTSpline for the object to move along

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Javascript:
    + LeanTween.moveSpline(gameObject, ltSpline, 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + C#:
    + LeanTween.moveSpline(gameObject, ltSpline, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + +
    +
    +
    +
    +

    LeanTween.moveSpline

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + path:Vector3[] +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1108 +

    + + + +
    + +
    +

    Move a GameObject through a set of points

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + path:Vector3[] + Vector3 + + +
      +

      A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd
      Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value.

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Javascript:
    + LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + C#:
    + LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + +
    +
    +
    +
    +

    LeanTween.moveSplineLocal

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + path:Vector3[] +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1150 +

    + + + +
    + +
    +

    Move a GameObject through a set of points, in local space

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to move

      + +
      + +
    • +
    • + path:Vector3[] + Vector3 + + +
      +

      A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Javascript:
    + LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + C#:
    + LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + +
    +
    +
    +
    +

    LeanTween.moveX

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1188 +

    + + + +
    + +
    +

    Move a GameObject along the x-axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to move

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      to The final position with which to move to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the move in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.moveX (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1768 +

    + + + +
    + +
    +

    Move a RectTransform object affecting x-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final x location with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveX(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.moveY

    + +
    + (
      +
    • + GameObject +
    • +
    • + float +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1201 +

    + + + +
    + +
    +

    Move a GameObject along the y-axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to move

      + +
      + +
    • +
    • + float + Float + + +
      +

      to The final position with which to move to

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the move in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.moveY (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1782 +

    + + + +
    + +
    +

    Move a RectTransform object affecting y-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final y location with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveY(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.moveZ

    + +
    + (
      +
    • + GameObject +
    • +
    • + float +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1214 +

    + + + +
    + +
    +

    Move a GameObject along the z-axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to move

      + +
      + +
    • +
    • + float + Float + + +
      +

      to The final position with which to move to

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the move in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.moveZ (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1796 +

    + + + +
    + +
    +

    Move a RectTransform object affecting z-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final x location with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.moveZ(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.pause

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:625 +

    + + + +
    + +
    +

    Pause all tweens for a GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      GameObject whose tweens you want to pause

      + +
      + +
    • +
    +
    + + +
    +
    +

    LeanTween.pause

    + +
    + (
      +
    • + id:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:606 +

    + + + +
    + +
    +

    Pause all tweens for a GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:int + Int + + +
      +

      Id of the tween you want to pause

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    int id = LeanTween.moveX(gameObject, 5, 1.0).id
    + LeanTween.pause( id );
    + // Later....
    + LeanTween.resume( id );

    + +
    +
    +
    +
    +

    LeanTween.pauseAll

    + + () + + + + + + + + +
    +

    + Defined in + LeanTween.cs:640 +

    + + + +
    + +
    +

    Pause all active tweens

    + +
    + + + +
    +
    +

    LeanTween.play

    + +
    + (
      +
    • + rectTransform:RectTransform +
    • +
    • + sprites:Sprite[] +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:870 +

    + + + +
    + +
    +

    Play a sequence of images on a Unity UI Object

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTransform:RectTransform + RectTransform + + +
      +

      RectTransform that you want to play the sequence of sprites on

      + +
      + +
    • +
    • + sprites:Sprite[] + Sprite + + +
      +

      Sequence of sprites to be played

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.play(gameObject.GetComponent(), sprites).setLoopPingPong();

    + +
    +
    +
    +
    +

    LeanTween.removeListener

    + +
    + (
      +
    • + caller:GameObject +
    • +
    • + eventId:int +
    • +
    • + callback:System.Action<LTEvent> +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:2318 +

    + + + +
    + +
    +

    Remove an event listener you have added

    + +
    + +
    +

    Parameters:

    + +
      +
    • + caller:GameObject + GameObject + + +
      +

      the gameObject the listener is attached to

      + +
      + +
    • +
    • + eventId:int + Int + + +
      +

      a unique int that describes the event (best to use an enum)

      + +
      + +
    • +
    • + callback:System.Action<LTEvent> + System.Action + + +
      +

      the method that was specified to call when the event has been dispatched

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    LeanTween.removeListener(gameObject, (int)MyEvents.JUMP, jumpUp);
    +
    + void jumpUp( LTEvent e ){ }

    + +
    +
    +
    +
    +

    LeanTween.resume

    + +
    + (
      +
    • + id:int +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:669 +

    + + + +
    + +
    +

    Resume a specific tween

    + +
    + +
    +

    Parameters:

    + +
      +
    • + id:int + Int + + +
      +

      Id of the tween you want to resume

      + +
      + +
    • +
    +
    + + +
    +

    Example:

    + +
    +

    int id = LeanTween.moveX(gameObject, 5, 1.0).id
    + LeanTween.pause( id );
    + // Later....
    + LeanTween.resume( id );

    + +
    +
    +
    +
    +

    LeanTween.resume

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + LeanTween.cs:688 +

    + + + +
    + +
    +

    Resume all the tweens on a GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      GameObject whose tweens you want to resume

      + +
      + +
    • +
    +
    + + +
    +
    +

    LeanTween.resumeAll

    + + () + + + + + + + + +
    +

    + Defined in + LeanTween.cs:652 +

    + + + +
    + +
    +

    Resume all active tweens

    + +
    + + + +
    +
    +

    LeanTween.rotate

    + +
    + (
      +
    • + ltRect:LTRect +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    • + optional:Array +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1319 +

    + + + +
    + +
    +

    Rotate a GUI element (using an LTRect object), to a value that is in degrees

    + +
    + +
    +

    Parameters:

    + +
      +
    • + ltRect:LTRect + LTRect + + +
      +

      LTRect that you wish to rotate

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final rotation with which to rotate to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    • + optional:Array + Array + + +
      +

      Object Array where you can pass optional items.

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    if(GUI.Button(buttonRect.rect, "Rotate"))
    + LeanTween.rotate( buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);
    + GUI.matrix = Matrix4x4.identity;

    + +
    +
    +
    +
    +

    LeanTween.rotate

    + +
    + (
      +
    • + GameObject +
    • +
    • + Vector3 +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1304 +

    + + + +
    + +
    +

    Rotate a GameObject, to values are in passed in degrees

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to rotate

      + +
      + +
    • +
    • + Vector3 + Vector3 + + +
      +

      to The final rotation with which to rotate to

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.rotate(cube, new Vector3(180f,30f,0f), 1.5f);

    + +
    +
    +
    +
    +

    LeanTween.rotate (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1810 +

    + + + +
    + +
    +

    Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The degree with which to rotate the RectTransform

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.rotate(gameObject.GetComponent<RectTransform>(), 90f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.rotateAround

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + vec:Vector3 +
    • +
    • + degrees:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1389 +

    + + + +
    + +
    +

    Rotate a GameObject around a certain Axis (the best method to use when you want to rotate beyond 180 degrees)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + vec:Vector3 + Vector3 + + +
      +

      axis in which to rotate around ex: Vector3.up

      + +
      + +
    • +
    • + degrees:float + Float + + +
      +

      the degrees in which to rotate

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example:
    + LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f );

    + +
    +
    +
    +
    +

    LeanTween.rotateAround (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + axis:Vector3 +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1828 +

    + + + +
    + +
    +

    Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + axis:Vector3 + Vector3 + + +
      +

      The axis in which to rotate the RectTransform (Vector3.forward is most commonly used)

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The degree with which to rotate the RectTransform

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.rotateAround(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.rotateAroundLocal

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + vec:Vector3 +
    • +
    • + degrees:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1406 +

    + + + +
    + +
    +

    Rotate a GameObject around a certain Axis in Local Space (the best method to use when you want to rotate beyond 180 degrees)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + vec:Vector3 + Vector3 + + +
      +

      axis in which to rotate around ex: Vector3.up

      + +
      + +
    • +
    • + degrees:float + Float + + +
      +

      the degrees in which to rotate

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example:
    + LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f );

    + +
    +
    +
    +
    +

    LeanTween.rotateAroundLocal (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + axis:Vector3 +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1843 +

    + + + +
    + +
    +

    Rotate a RectTransform object around it's local axis (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + axis:Vector3 + Vector3 + + +
      +

      The local axis in which to rotate the RectTransform (Vector3.forward is most commonly used)

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The degree with which to rotate the RectTransform

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.rotateAroundLocal(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.rotateLocal

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + to:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1337 +

    + + + +
    + +
    +

    Rotate a GameObject in the objects local space (on the transforms localEulerAngles object)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + to:Vector3 + Vector3 + + +
      +

      The final rotation with which to rotate to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.rotateX

    + +
    + (
      +
    • + GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1350 +

    + + + +
    + +
    +

    Rotate a GameObject only on the X axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final x-axis rotation with which to rotate

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.rotateY

    + +
    + (
      +
    • + GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1363 +

    + + + +
    + +
    +

    Rotate a GameObject only on the Y axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final y-axis rotation with which to rotate

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.rotateZ

    + +
    + (
      +
    • + GameObject +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1376 +

    + + + +
    + +
    +

    Rotate a GameObject only on the Z axis

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      Gameobject that you wish to rotate

      + +
      + +
    • +
    • + to:float + Float + + +
      +

      The final z-axis rotation with which to rotate

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the rotation in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.scale

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + vec:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1423 +

    + + + +
    + +
    +

    Scale a GameObject to a certain size

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      gameObject Gameobject that you wish to scale

      + +
      + +
    • +
    • + vec:Vector3 + Vector3 + + +
      +

      to The size with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.scale (GUI)

    + +
    + (
      +
    • + LTRect +
    • +
    • + Vector2 +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1436 +

    + + + +
    + +
    +

    Scale a GUI Element to a certain width and height

    + +
    + +
    +

    Parameters:

    + +
      +
    • + LTRect + LTRect + + +
      +

      ltRect LTRect object that you wish to move

      + +
      + +
    • +
    • + Vector2 + Vector2 + + +
      +

      to The final width and height to scale to (pixel based)

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
    + LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 ).setEase(LeanTweenType.easeOutBounce);
    + function OnGUI(){
    +   if(GUI.Button(bRect.rect, "Scale")){ }
    + }
    +
    + Example C#:
    + LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
    + LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f ).setEase(LeanTweenType.easeOutBounce);
    + void OnGUI(){
    +   if(GUI.Button(bRect.rect, "Scale")){ }
    + }

    + +
    +
    +
    +
    +

    LeanTween.scale (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1858 +

    + + + +
    + +
    +

    Scale a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:Vector3 + Vector3 + + +
      +

      The final Vector3 with which to tween to (localScale)

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.scale(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().localScale*2f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.scaleX

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + scaleTo:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1463 +

    + + + +
    + +
    +

    Scale a GameObject to a certain size along the x-axis only

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to scale

      + +
      + +
    • +
    • + scaleTo:float + Float + + +
      +

      the size with which to scale to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      the time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.scaleY

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + scaleTo:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1476 +

    + + + +
    + +
    +

    Scale a GameObject to a certain size along the y-axis only

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to scale

      + +
      + +
    • +
    • + scaleTo:float + Float + + +
      +

      the size with which to scale to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      the time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.scaleZ

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + scaleTo:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1489 +

    + + + +
    + +
    +

    Scale a GameObject to a certain size along the z-axis only

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to scale

      + +
      + +
    • +
    • + scaleTo:float + Float + + +
      +

      the size with which to scale to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      the time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.size (RectTransform)

    + +
    + (
      +
    • + rectTrans:RectTransform +
    • +
    • + to:Vector2 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1872 +

    + + + +
    + +
    +

    Change the sizeDelta of a RectTransform object (used in Unity Canvas, for Buttons, Panel, Scrollbar, etc...)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + rectTrans:RectTransform + RectTransform + + +
      +

      RectTransform that you wish to attach the tween to

      + +
      + +
    • +
    • + to:Vector2 + Vector2 + + +
      +

      The final Vector2 the tween will end at for sizeDelta property

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    LeanTween.size(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().sizeDelta*2f, 1f).setDelay(1f);

    + +
    +
    +
    +
    +

    LeanTween.tweensRunning

    + + () + + + + + + + + +
    +

    + Defined in + LeanTween.cs:266 +

    + + + +
    + +
    +

    Find out how many tweens you have animating at a given time

    + +
    + + + +
    +

    Example:

    + +
    +

    Debug.Log("I have "+LeanTween.tweensRunning+" animating!");

    + +
    +
    +
    +
    +

    LeanTween.value (Color)

    + +
    + (
      +
    • + GameObject +
    • +
    • + callOnUpdate:Action<Color> +
    • +
    • + Color +
    • +
    • + Color +
    • +
    • + Color +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1664 +

    + + + +
    + +
    +

    Tween from one color to another

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject

      + +
      + +
    • +
    • + callOnUpdate:Action<Color> + Action + + +
      +

      The function that is called on every Update frame, this function needs to accept a color value ex: function updateValue( Color val ){ }

      + +
      + +
    • +
    • + Color + Color + + +
      +

      from The original value to start the tween from

      + +
      + +
    • +
    • + Color + Color + + +
      +

      to The value to end the tween on

      + +
      + +
    • +
    • + Color + Color + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
    + function updateValueExampleCallback( val:Color ){
    +   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
    + }
    +
    + Example C#:
    + LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
    + void updateValueExampleCallback( Color val ){
    +   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
    + }

    + +
    +
    +
    +
    +

    LeanTween.value (Color)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + from:Color +
    • +
    • + to:Color +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1577 +

    + + + +
    + +
    +

    Tween any particular value (Color)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + from:Color + Color + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:Color + Color + + +
      +

      The final Color with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( function( val:Color ){
    +  Debug.Log("tweened val:"+val);
    + } );
    +
    + Example C#:
    + LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( (Color val)=>{
    +  Debug.Log("tweened val:"+val);
    + } );

    + +
    +
    +
    +
    +

    LeanTween.value (float)

    + +
    + (
      +
    • + GameObject +
    • +
    • + callOnUpdateRatio:Action<float,float> +
    • +
    • + float +
    • +
    • + float +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1636 +

    + + + +
    + +
    +

    Tweens any float value, it does not need to be tied to any particular type or GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject

      + +
      + +
    • +
    • + callOnUpdateRatio:Action<float,float> + Action + + +
      +

      Function that's called every Update frame. It must accept two float values ex: function updateValue( float val, float ratio){ }

      + +
      + +
    • +
    • + float + Float + + +
      +

      from The original value to start the tween from

      + +
      + +
    • +
    • + float + Float + + +
      +

      to The value to end the tween on

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + function updateValueExampleCallback( val:float, ratio:float ){
    +   Debug.Log("tweened value:"+val+" percent complete:"+ratio100);
    + }
    +
    + Example C#:
    + LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + void updateValueExampleCallback( float val, float ratio ){
    +   Debug.Log("tweened value:"+val+" percent complete:"+ratio
    100);
    + }

    + +
    +
    +
    +
    +

    LeanTween.value (float)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + from:float +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1502 +

    + + + +
    + +
    +

    Tween any particular value (float)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + from:float + Float + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:float + Vector3 + + +
      +

      The final float with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( function( val:float ){
    +  Debug.Log("tweened val:"+val);
    + } );
    +
    + Example C#:
    + LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( (float val)=>{
    +  Debug.Log("tweened val:"+val);
    + } );

    + +
    +
    +
    +
    +

    LeanTween.value (float)

    + +
    + (
      +
    • + GameObject +
    • +
    • + callOnUpdate:Action<float> +
    • +
    • + float +
    • +
    • + float +
    • +
    • + float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1608 +

    + + + +
    + +
    +

    Tween any particular value, it does not need to be tied to any particular type or GameObject

    + +
    + +
    +

    Parameters:

    + +
      +
    • + GameObject + GameObject + + +
      +

      gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject

      + +
      + +
    • +
    • + callOnUpdate:Action<float> + Action + + +
      +

      The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( float val ){ }

      + +
      + +
    • +
    • + float + Float + + +
      +

      from The original value to start the tween from

      + +
      + +
    • +
    • + float + Float + + +
      +

      to The value to end the tween on

      + +
      + +
    • +
    • + float + Float + + +
      +

      time The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + function updateValueExampleCallback( val:float ){
    +   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
    + }
    +
    + Example C#:
    + LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + void updateValueExampleCallback( float val ){
    +   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
    + }

    + +
    +
    +
    +
    +

    LeanTween.value (float,object)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + callOnUpdate:Action<float,object> +
    • +
    • + from:float +
    • +
    • + to:float +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1727 +

    + + + +
    + +
    +

    Tween any particular value (float)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + callOnUpdate:Action<float,object> + Action + + +
      +

      The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val, object obj ){ }

      + +
      + +
    • +
    • + from:float + Float + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:float + Vector3 + + +
      +

      The final Vector3 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.value (Vector2)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + callOnUpdate:Action<Vector2> +
    • +
    • + from:Vector2 +
    • +
    • + to:Vector2 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1697 +

    + + + +
    + +
    +

    Tween any particular value (Vector2), this could be used to tween an arbitrary value like offset property

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + callOnUpdate:Action<Vector2> + Action + + +
      +

      The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ }

      + +
      + +
    • +
    • + from:Vector2 + Float + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:Vector2 + Vector2 + + +
      +

      The final Vector3 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    +

    LeanTween.value (Vector2)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + from:Vector2 +
    • +
    • + to:Vector2 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1529 +

    + + + +
    + +
    +

    Tween any particular value (Vector2)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + from:Vector2 + Vector2 + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:Vector2 + Vector3 + + +
      +

      The final Vector2 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, new Vector2(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( function( val:Vector2 ){
    +  Debug.Log("tweened val:"+val);
    + } );
    +
    + Example C#:
    + LeanTween.value( gameObject, new Vector3(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( (Vector2 val)=>{
    +  Debug.Log("tweened val:"+val);
    + } );

    + +
    +
    +
    +
    +

    LeanTween.value (Vector3)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + from:Vector3 +
    • +
    • + to:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1553 +

    + + + +
    + +
    +

    Tween any particular value (Vector3)

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + from:Vector3 + Vector3 + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:Vector3 + Vector3 + + +
      +

      The final Vector3 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +

    Example:

    + +
    +

    Example Javascript:
    + LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( function( val:Vector3 ){
    +  Debug.Log("tweened val:"+val);
    + } );
    +
    + Example C#:
    + LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( (Vector3 val)=>{
    +  Debug.Log("tweened val:"+val);
    + } );

    + +
    +
    +
    +
    +

    LeanTween.value (Vector3)

    + +
    + (
      +
    • + gameObject:GameObject +
    • +
    • + callOnUpdate:Action<Vector3> +
    • +
    • + from:Vector3 +
    • +
    • + to:Vector3 +
    • +
    • + time:float +
    • +
    ) +
    + + + LTDescr + + + + + + + + +
    +

    + Defined in + LeanTween.cs:1712 +

    + + + +
    + +
    +

    Tween any particular value (Vector3), this could be used to tween an arbitrary property that uses a Vector

    + +
    + +
    +

    Parameters:

    + +
      +
    • + gameObject:GameObject + GameObject + + +
      +

      Gameobject that you wish to attach the tween to

      + +
      + +
    • +
    • + callOnUpdate:Action<Vector3> + Action + + +
      +

      The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ }

      + +
      + +
    • +
    • + from:Vector3 + Float + + +
      +

      The original value to start the tween from

      + +
      + +
    • +
    • + to:Vector3 + Vector3 + + +
      +

      The final Vector3 with which to tween to

      + +
      + +
    • +
    • + time:float + Float + + +
      +

      The time to complete the tween in

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + LTDescr: +

    LTDescr an object that distinguishes the tween

    + +
    +
    + +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html.meta new file mode 100644 index 0000000..7a17654 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTween.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: beea01b16f84c4f18a168afa5800b612 diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html new file mode 100644 index 0000000..a1de3f3 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html @@ -0,0 +1,1090 @@ + + + + + LeanTweenType + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    LeanTweenType Class

    +
    + + +
    + Defined in: LeanTween.cs:38 +
    + + +
    + + +
    +

    Pass this to the "ease" parameter, to get a different easing behavior

    + Example:
    LeanTween.rotateX(gameObject, 270.0f, 1.5f).setEase(LeanTweenType.easeInBack);

    + +
    + + +
    + + +
    +
    +

    Item Index

    + + +
    +

    Properties

    + + +
    + + +
    + + +
    +

    Properties

    + +
    +

    easeInBack

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:120 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInBounce

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:111 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInCirc

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:102 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInCubic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:57 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInElastic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:129 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInExpo

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:93 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutBack

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:126 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutBounce

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:117 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutCirc

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:108 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutCubic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:63 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutElastic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:135 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutExpo

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:99 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutQuad

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:54 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutQuart

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:72 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutQuint

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:81 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInOutSine

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:90 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInQuad

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:51 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInQuart

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:66 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInQuint

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:75 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeInSine

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:84 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutBack

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:123 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutBounce

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:114 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutCirc

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:105 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutCubic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:60 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutElastic

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:132 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutExpo

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:96 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutQuad

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:48 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutQuart

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:69 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutQuint

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:78 +

    + + +
    + +
    + +
    + + + +
    +
    +

    easeOutSine

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:87 +

    + + +
    + +
    + +
    + + + +
    +
    +

    linear

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:45 +

    + + +
    + +
    + +
    + + + +
    +
    +

    punch

    + Integer + + + + + +
    +

    + Defined in + LeanTween.cs:138 +

    + + +
    + +
    + +
    + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html.meta new file mode 100644 index 0000000..57a6283 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/LeanTweenType.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 85c97d3850f59444cb0751b3bc40b06d diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html new file mode 100644 index 0000000..487fe15 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html @@ -0,0 +1,10 @@ + + + + Redirector + + + + Click here to redirect + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html.meta new file mode 100644 index 0000000..891c717 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/classes/index.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a23cc63a765c44c9c82fb33b1ecb455f diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/elements.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements.meta new file mode 100644 index 0000000..6c785fc --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 932507f3c60bb4fcea847cba753363b8 +folderAsset: yes +timeCreated: 1479470944 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html new file mode 100644 index 0000000..487fe15 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html @@ -0,0 +1,10 @@ + + + + Redirector + + + + Click here to redirect + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html.meta new file mode 100644 index 0000000..b9d37f7 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/elements/index.html.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6a53cd107c1f4d5498ea9c736e3a650 +timeCreated: 1479471015 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html b/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html new file mode 100644 index 0000000..6fbeeb7 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + +
    +
    +
    +

    - Developed by Dented Pixel
    +
    +
    + API Docs for: LeanTween 2.42
    + + + + + +
    +

    Support LeanTween!

    + +
    +
    + + + + + + + +
    +
    +
    + +

    Maintaining and adding new features takes time, your support is appreciated.

    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +
    +
    +

    + Browse to a module or class using the sidebar to view its API documentation. +

    + +

    Keyboard Shortcuts

    + +
      +
    • Press s to focus the API search box.

    • + +
    • Use Up and Down to select classes, modules, and search results.

    • + +
    • With the API search box or sidebar focused, use -Left or -Right to switch sidebar tabs.

    • + +
    • With the API search box or sidebar focused, use Ctrl+Left and Ctrl+Right to switch sidebar tabs.

    • +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html.meta b/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html.meta new file mode 100644 index 0000000..7a0b59d --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Documentation/index.html.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 78eeb9616e21d4178b574871040d7fa0 diff --git a/IronToad_UnityProject/Assets/LeanTween/Editor.meta b/IronToad_UnityProject/Assets/LeanTween/Editor.meta new file mode 100644 index 0000000..0d4266c --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 19bfca9f9a913415ea58580f6667f922 +folderAsset: yes +timeCreated: 1454272449 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs b/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs new file mode 100644 index 0000000..a854d7c --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using System.Collections; +#if UNITY_EDITOR +using UnityEditor; + +public class LeanTweenDocumentationEditor : Editor { + + [MenuItem ("Help/LeanTween Documentation")] + static void openDocumentation() + { + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 + // Loops through all items in case the user has moved the default installation directory + string[] guids = AssetDatabase.FindAssets ("LeanTween", null); + string documentationPath = ""; + foreach (string guid in guids){ + string path = AssetDatabase.GUIDToAssetPath(guid); + if(path.IndexOf("classes/LeanTween.html")>=0){ + documentationPath = path; + break; + } + } + documentationPath = documentationPath.Substring(documentationPath.IndexOf("/")); + string browserPath = "file://" + Application.dataPath + documentationPath + "#index"; + Application.OpenURL(browserPath); + + #else + // assumes the default installation directory + string documentationPath = "file://"+Application.dataPath + "/LeanTween/Documentation/classes/LeanTween.html#index"; + Application.OpenURL(documentationPath); + + #endif + } + + [MenuItem ("Help/LeanTween Forum (ask questions)")] + static void openForum() + { + Application.OpenURL("http://forum.unity3d.com/threads/leantween-a-tweening-engine-that-is-up-to-5x-faster-than-competing-engines.161113/"); + } + + [MenuItem ("Help/LeanTween GitHub (contribute code)")] + static void openGit() + { + Application.OpenURL("https://github.com/dentedpixel/LeanTween"); + } + + [MenuItem ("Help/LeanTween Support (donate)")] + static void openLTDonate() + { + Application.OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YJPUT3RAK5VL8"); + } + + [MenuItem ("Help/Dented Pixel News")] + static void openDPNews() + { + Application.OpenURL("http://dentedpixel.com/category/developer-diary/"); + } +} + +#endif \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs.meta new file mode 100644 index 0000000..1bcb938 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Editor/LeanTweenDocumentationEditor.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 52fea17a2d56d46afa0d6cb52e2a4335 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples.meta b/IronToad_UnityProject/Assets/LeanTween/Examples.meta new file mode 100644 index 0000000..b6b1d02 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 486852d399aed440aa95693d95263c16 diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived.meta new file mode 100644 index 0000000..312cf73 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8d71b219a4562400b9fabb60eb51396d +folderAsset: yes +timeCreated: 1460027769 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader new file mode 100644 index 0000000..0115e68 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader @@ -0,0 +1,30 @@ +Shader "Custom/2dUnlitWithFade" { + Properties + { + _Color ("Color Tint", Color) = (1,1,1,1) + _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" + } + + Category + { + Lighting Off + ZWrite Off + //ZWrite On // uncomment if you have problems like the sprite disappear in some rotations. + Cull back + Blend SrcAlpha OneMinusSrcAlpha + //AlphaTest Greater 0.001 // uncomment if you have problems like the sprites or 3d text have white quads instead of alpha pixels. + Tags {Queue=Transparent} + + SubShader + { + Pass + { + SetTexture [_MainTex] + { + ConstantColor [_Color] + Combine Texture * constant + } + } + } + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader.meta new file mode 100644 index 0000000..83969be --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/2dUnlitWithFade.shader.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8bce9282b1bfd475284fd2e72b37403c diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg new file mode 100644 index 0000000..c725862 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg.meta new file mode 100644 index 0000000..c7e10a0 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/GrumpyCat.jpeg.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 6a9d1d221a3c94d83b614d921df0402e +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + textureType: 5 + buildTargetSettings: [] diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs new file mode 100644 index 0000000..64d4a0e --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs @@ -0,0 +1,84 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class OldGUIExamplesCS : MonoBehaviour { + public Texture2D grumpy; + public Texture2D beauty; + + private float w; + private float h; + + private LTRect buttonRect1; + private LTRect buttonRect2; + private LTRect buttonRect3; + private LTRect buttonRect4; + private LTRect grumpyRect; + private LTRect beautyTileRect; + + + // Use this for initialization + void Start () { + w = Screen.width; + h = Screen.height; + buttonRect1 = new LTRect(0.10f*w, 0.8f*h, 0.2f*w, 0.14f*h ); + buttonRect2 = new LTRect(1.2f*w, 0.8f*h, 0.2f*w, 0.14f*h ); + buttonRect3 = new LTRect(0.35f*w, 0.0f*h, 0.3f*w, 0.2f*h, 0f ); + buttonRect4 = new LTRect(0.0f*w, 0.4f*h, 0.3f*w, 0.2f*h, 1.0f, 15.0f ); + + grumpyRect = new LTRect(0.5f*w - grumpy.width*0.5f, 0.5f*h - grumpy.height*0.5f, grumpy.width, grumpy.height ); + beautyTileRect = new LTRect(0.0f,0.0f,1.0f,1.0f ); + + LeanTween.move( buttonRect2, new Vector2(0.55f*w, buttonRect2.rect.y), 0.7f ).setEase(LeanTweenType.easeOutQuad); + } + + public void catMoved(){ + Debug.Log("cat moved..."); + } + + // Update is called once per frame + void OnGUI () { + GUI.DrawTexture( grumpyRect.rect, grumpy); + + Rect staticRect = new Rect(0.0f*w, 0.0f*h, 0.2f*w, 0.14f*h); + if(GUI.Button( staticRect, "Move Cat")){ + if(LeanTween.isTweening(grumpyRect)==false){ // Check to see if the cat is already tweening, so it doesn't freak out + Vector2 orig = new Vector2( grumpyRect.rect.x, grumpyRect.rect.y ); + LeanTween.move( grumpyRect, new Vector2( 1.0f*Screen.width - grumpy.width, 0.0f*Screen.height ), 1.0f).setEase(LeanTweenType.easeOutBounce).setOnComplete(catMoved); + LeanTween.move( grumpyRect, orig, 1.0f ).setDelay(1.0f).setEase( LeanTweenType.easeOutBounce); + } + } + + if(GUI.Button(buttonRect1.rect, "Scale Centered")){ + LeanTween.scale( buttonRect1, new Vector2(buttonRect1.rect.width, buttonRect1.rect.height) * 1.2f, 0.25f ).setEase( LeanTweenType.easeOutQuad ); + LeanTween.move( buttonRect1, new Vector2(buttonRect1.rect.x-buttonRect1.rect.width*0.1f, buttonRect1.rect.y-buttonRect1.rect.height*0.1f), 0.25f ).setEase(LeanTweenType.easeOutQuad); + } + + if(GUI.Button(buttonRect2.rect, "Scale")){ + LeanTween.scale( buttonRect2, new Vector2(buttonRect2.rect.width, buttonRect2.rect.height) * 1.2f, 0.25f ).setEase(LeanTweenType.easeOutBounce); + } + + staticRect = new Rect(0.76f*w, 0.53f*h, 0.2f*w, 0.14f*h); + if(GUI.Button( staticRect, "Flip Tile")){ + LeanTween.move( beautyTileRect, new Vector2( 0f, beautyTileRect.rect.y + 1.0f ), 1.0f ).setEase(LeanTweenType.easeOutBounce); + } + + GUI.DrawTextureWithTexCoords( new Rect(0.8f*w, 0.5f*h - beauty.height*0.5f, beauty.width*0.5f, beauty.height*0.5f), beauty, beautyTileRect.rect); + + + if(GUI.Button(buttonRect3.rect, "Alpha")){ + LeanTween.alpha( buttonRect3, 0.0f, 1.0f).setEase(LeanTweenType.easeOutQuad); + LeanTween.alpha( buttonRect3, 1.0f, 1.0f).setDelay(1.0f).setEase( LeanTweenType.easeInQuad); + + LeanTween.alpha( grumpyRect, 0.0f, 1.0f).setEase(LeanTweenType.easeOutQuad); + LeanTween.alpha( grumpyRect, 1.0f, 1.0f).setDelay(1.0f).setEase(LeanTweenType.easeInQuad); + } + GUI.color = new Color(1.0f,1.0f,1.0f,1.0f); // Reset to normal alpha, otherwise other gui elements will be effected + + if(GUI.Button(buttonRect4.rect, "Rotate")){ + LeanTween.rotate( buttonRect4, 150.0f, 1.0f ).setEase(LeanTweenType.easeOutElastic); + LeanTween.rotate( buttonRect4, 0.0f, 1.0f ).setDelay(1.0f).setEase(LeanTweenType.easeOutElastic); + } + GUI.matrix = Matrix4x4.identity; + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs.meta new file mode 100644 index 0000000..353172a --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 876bfcaf53a664f29a628faa9fa332fc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity new file mode 100644 index 0000000..b714b14 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity.meta new file mode 100644 index 0000000..65e6186 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesCS.unity.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ec27881ee9cf54018ac9bd5706c2fdab diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js new file mode 100644 index 0000000..ed13ce6 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js @@ -0,0 +1,71 @@ +import DentedPixel; + +public var grumpy:Texture2D; +public var beauty:Texture2D; + +private var w:float = Screen.width; +private var h:float = Screen.height; + +private var buttonRect1:LTRect; +private var buttonRect2:LTRect; +private var buttonRect3:LTRect; +private var buttonRect4:LTRect; +private var grumpyRect:LTRect; +private var beautyTileRect:LTRect; + +function Start () { + w = Screen.width; + h = Screen.height; + buttonRect1 = new LTRect(0.10*w, 0.8*h, 0.25*w, 0.14*h ); + buttonRect2 = new LTRect(1.2*w, 0.8*h, 0.2*w, 0.14*h ); + buttonRect3 = new LTRect(0.35*w, 0.0*h, 0.3*w, 0.2*h ); + buttonRect4 = new LTRect(0.0*w, 0.4*h, 0.3*w, 0.2*h, 1.0, 15.0 ); + + grumpyRect = new LTRect(0.5*w - grumpy.width/2.0, 0.5*h - grumpy.height/2.0, grumpy.width, grumpy.height ); + beautyTileRect = new LTRect(0,0,1,1 ); + + LeanTween.move( buttonRect2, Vector2(0.55*w, buttonRect2.rect.y), 0.7f ).setEase(LeanTweenType.easeOutQuad); +} + +function OnGUI(){ + var staticRect:Rect = Rect(0.0*w, 0.0*h, 0.2*w, 0.14*h); + if(GUI.Button( staticRect, "Move Cat")){ + if(LeanTween.isTweening(grumpyRect)==false){ // Check to see if the cat is already tweening, so it doesn't freak out + var orig:Vector2 = Vector2( grumpyRect.rect.x, grumpyRect.rect.y ); + LeanTween.move( grumpyRect, Vector2( 1.0*w - grumpy.width, 0.0*h ), 1.0).setEase(LeanTweenType.easeOutBounce) ; + LeanTween.move( grumpyRect, orig, 1.0 ).setEase(LeanTweenType.easeOutBounce).setDelay(1.0); + } + } + GUI.DrawTexture( grumpyRect.rect, grumpy); + + if(GUI.Button(buttonRect1.rect, "Scale Centered")){ + LeanTween.scale( buttonRect1, Vector2(buttonRect1.rect.width, buttonRect1.rect.height) * 1.2, 0.25 ).setEase(LeanTweenType.easeOutQuad); + LeanTween.move( buttonRect1, Vector2(buttonRect1.rect.x-buttonRect1.rect.width*0.1, buttonRect1.rect.y-buttonRect1.rect.height*0.1), 0.25).setEase(LeanTweenType.easeOutQuad) ; + } + + if(GUI.Button(buttonRect2.rect, "Scale")){ + LeanTween.scale( buttonRect2, Vector2(buttonRect2.rect.width, buttonRect2.rect.height) * 1.2, 0.25 ).setEase(LeanTweenType.easeOutBounce); + } + + staticRect = Rect(0.76*w, 0.53*h, 0.2*w, 0.14*h); + if(GUI.Button( staticRect, "Flip Tile")){ + LeanTween.move( beautyTileRect, Vector2( 0, beautyTileRect.rect.y + 1 ), 1.0 ).setEase(LeanTweenType.easeOutBounce); + } + + GUI.DrawTextureWithTexCoords( Rect(0.8*w, 0.5*h - beauty.height/2.0, beauty.width*0.5, beauty.height*0.5 ), beauty, beautyTileRect.rect); + + + if(GUI.Button(buttonRect3.rect, "Alpha")){ + LeanTween.alpha( buttonRect3, 0.0, 1.0 ).setEase(LeanTweenType.easeOutQuad); + LeanTween.alpha( buttonRect3, 1.0, 1.0 ).setEase(LeanTweenType.easeOutQuad).setDelay(1.0); + } + GUI.color.a = 1.0; // Reset to normal alpha, otherwise other gui elements will be effected + + + if(GUI.Button(buttonRect4.rect, "Rotate")){ + LeanTween.rotate( buttonRect4, 150.0, 1.0 ).setEase(LeanTweenType.easeOutElastic); + LeanTween.rotate( buttonRect4, 0.0, 1.0 ).setEase(LeanTweenType.easeOutElastic).setDelay(1.0); + } + GUI.matrix = Matrix4x4.identity; // Reset to normal rotation, otherwise other gui elements will be effected + +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js.meta new file mode 100644 index 0000000..3d293ab --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d0e7350ec07764a7aa1352edb0fb9134 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity new file mode 100644 index 0000000..d06c04b Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity.meta new file mode 100644 index 0000000..615e1a9 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUIExamplesJS.unity.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 808c431ee916c4aa39e00cd736e24fca diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js new file mode 100644 index 0000000..14086d9 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js @@ -0,0 +1,16 @@ +#pragma strict + +public var grumpy:Texture2D; + +private var grumpyRect:LTRect; + +function Start () { + grumpyRect = new LTRect( -grumpy.width, 0.5*Screen.height - grumpy.height/2.0, grumpy.width, grumpy.height ); + + // Slide in + LeanTween.move(grumpyRect, new Vector2(0.5*Screen.width - grumpy.width/2.0, grumpyRect.rect.y ), 1.0).setEase(LeanTweenType.easeOutQuad); +} + +function OnGUI(){ + GUI.DrawTexture( grumpyRect.rect, grumpy); +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js.meta new file mode 100644 index 0000000..fc388c6 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c62e83ce84a23432498632ff043c1aa4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity new file mode 100644 index 0000000..39423b7 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity.meta new file mode 100644 index 0000000..cb72165 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/OldGUISlideImageIn.unity.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9dfd2f0f7af014addb94a1e09a3e81dd diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif new file mode 100644 index 0000000..64170b1 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif.meta new file mode 100644 index 0000000..ebf9780 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/SoBeautiful.gif.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 78e9e608c3c9d47a3b312c2908d10f46 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + textureType: -1 + buildTargetSettings: [] diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/TestingPunch.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/TestingPunch.cs new file mode 100644 index 0000000..683d44a --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Archived/TestingPunch.cs @@ -0,0 +1,182 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class TestingPunch : MonoBehaviour { + + public AnimationCurve exportCurve; + public float overShootValue = 1f; + + private LTDescr descr; + + void Start () { + //LeanTween.rotateAround(gameObject, gameObject.transform.rotation.eulerAngles, 360f, 5f).setDelay(1f).setEase(LeanTweenType.easeOutBounce); + Debug.Log( "exported curve:" + curveToString(exportCurve) ); + } + + void Update () + { + LeanTween.dtManual = Time.deltaTime; + if (Input.GetKeyDown(KeyCode.Q)) + { + //LeanTween.scale(this.gameObject, Vector3.one*3f, 1.0f).setEase(LeanTweenType.easeSpring).setUseManualTime(true); + //print("scale punch time independent!"); + + LeanTween.moveLocalX(gameObject, 5, 1).setOnComplete( () => { + Debug.Log("on complete move local X"); + }).setOnCompleteOnStart(true); + + GameObject light = GameObject.Find("DirectionalLight"); + Light lt = light.GetComponent(); + + LeanTween.value(lt.gameObject, lt.intensity, 0.0f, 1.5f) + .setEase(LeanTweenType.linear) + .setLoopPingPong() + .setRepeat(-1) + .setOnUpdate((float val)=>{ + + lt.intensity = val; + }); + } + if (Input.GetKeyDown(KeyCode.S)) + { + print("scale punch!"); + + tweenStatically( this.gameObject ); + + LeanTween.scale(this.gameObject, new Vector3(1.15f, 1.15f, 1.15f), 0.6f); + + LeanTween.rotateAround(this.gameObject, Vector3.forward, -360f, 0.3f).setOnComplete(() => + { + LeanTween.rotateAround(this.gameObject, Vector3.forward, -360f, 0.4f).setOnComplete(() => + { + LeanTween.scale(this.gameObject, new Vector3(1f, 1f, 1f), 0.1f); + + LeanTween.value(this.gameObject, (v) => + { + + }, 0, 1, 0.3f).setDelay(1); + + }); + + }); + + + } + + if (Input.GetKeyDown(KeyCode.T)) + { + Vector3[] pts = new Vector3[] {new Vector3(-1f,0f,0f), new Vector3(0f,0f,0f), new Vector3(4f,0f,0f), new Vector3(20f,0f,0f)}; + descr = LeanTween.move(gameObject, pts, 15f).setOrientToPath(true).setDirection(1f).setOnComplete( ()=>{ + Debug.Log("move path finished"); + }); + } + + if (Input.GetKeyDown(KeyCode.Y)) // Reverse the move path + { + descr.setDirection(-descr.direction); + } + + if (Input.GetKeyDown(KeyCode.R)) + { + // LeanTween.rotate(this.gameObject, Vector3.one, 1.0f).setEase(LeanTweenType.punch); + LeanTween.rotateAroundLocal(this.gameObject, this.transform.forward, -80f, 5.0f).setPoint(new Vector3(1.25f, 0f, 0f)); + print("rotate punch!"); + } + + if (Input.GetKeyDown(KeyCode.M)) + { + // LeanTween.move(this.gameObject, new Vector3(0f,0f,1f), 1.0f).setEase(LeanTweenType.punch); + print("move punch!"); + Time.timeScale = 0.25f; + float start = Time.realtimeSinceStartup; + LeanTween.moveX( this.gameObject, 1f, 1f).setOnComplete( destroyOnComp ).setOnCompleteParam( this.gameObject ).setOnComplete( ()=>{ + float end = Time.realtimeSinceStartup; + float diff = end - start; + Debug.Log("start:"+start+" end:"+end+" diff:"+diff+" x:"+this.gameObject.transform.position.x); + }).setEase(LeanTweenType.easeInBack).setOvershoot( overShootValue ).setPeriod(0.3f); + } + + if (Input.GetKeyDown(KeyCode.C)) + { + LeanTween.color( this.gameObject, new Color(1f, 0f, 0f, 0.5f), 1f); + + Color to = new Color(Random.Range(0f,1f),0f,Random.Range(0f,1f),0.0f); + GameObject l = GameObject.Find("LCharacter"); + LeanTween.color( l, to, 4.0f ).setLoopPingPong(1).setEase(LeanTweenType.easeOutBounce); + } + + if (Input.GetKeyDown(KeyCode.E)) + { + LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true).setOnCompleteParam( "hi" ); + } + + if (Input.GetKeyDown(KeyCode.V)) + { + LeanTween.value( gameObject, updateColor, new Color(1.0f,0.0f,0.0f,1.0f), Color.blue, 4.0f );//.setRepeat(2).setLoopPingPong().setEase(LeanTweenType.easeOutBounce); + } + + if (Input.GetKeyDown(KeyCode.P)) + { + LeanTween.delayedCall(0.05f, enterMiniGameStart).setOnCompleteParam( new object[]{""+5} ); + } + + if(Input.GetKeyDown(KeyCode.U)){ + #if !UNITY_FLASH + LeanTween.value(gameObject, (Vector2 val)=>{ + // Debug.Log("tweening vec2 val:"+val); + transform.position = new Vector3(val.x, transform.position.y, transform.position.z); + }, new Vector2(0f,0f), new Vector2(5f,100f), 1f ).setEase(LeanTweenType.easeOutBounce); + + GameObject l = GameObject.Find("LCharacter"); + Debug.Log("x:"+l.transform.position.x+" y:"+l.transform.position.y); + LeanTween.value(l, new Vector2( l.transform.position.x, l.transform.position.y), new Vector2( l.transform.position.x, l.transform.position.y+5), 1f ).setOnUpdate( + (Vector2 val)=>{ + Debug.Log("tweening vec2 val:"+val); + l.transform.position = new Vector3(val.x, val.y, transform.position.z); + } + + ); + #endif + } + } + + static void tweenStatically( GameObject gameObject ){ + Debug.Log("Starting to tween..."); + LeanTween.value(gameObject, (val)=>{ + Debug.Log("tweening val:"+val); + }, 0f, 1f, 1f); + } + + void enterMiniGameStart( object val ){ + object[] arr = (object [])val; + int lvl = int.Parse((string)arr[0]); + Debug.Log("level:"+lvl); + } + + void updateColor( Color c ){ + GameObject l = GameObject.Find("LCharacter"); + // Debug.Log("new col:"+c); + l.GetComponent().material.color = c; + } + + void delayedMethod( object myVal ){ + string castBack = myVal as string; + Debug.Log("delayed call:"+Time.time +" myVal:"+castBack); + } + + void destroyOnComp( object p ){ + GameObject g = (GameObject)p; + Destroy( g ); + } + + string curveToString( AnimationCurve curve) { + string str = ""; + for(int i = 0; i < curve.length; i++){ + str += "new Keyframe("+curve[i].time+"f, "+curve[i].value+"f)"; + if(i{ + int first = (int)Mathf.Floor(val); + int next = first < movePts.Length-1 ? first + 1 : first; + float diff = val - (float)first; + // Debug.Log("val:"+val+" first:"+first+" next:"+next); + Vector3 diffPos = (movePts[next].position-movePts[first].position); + avatarMove.transform.position = movePts[first].position + diffPos*diff; + }).setEase(LeanTweenType.easeInOutExpo).setLoopPingPong(); + + // move the pts + for(int i = 0; i < movePts.Length; i++) + LeanTween.moveY( movePts[i].gameObject, movePts[i].position.y + 1.5f, 1f).setDelay(((float)i)*0.2f).setLoopPingPong(); + + + // move objects at a constant speed + for(int i = 0; i < avatarSpeed.Length; i++) + LeanTween.moveLocalZ( avatarSpeed[i], (i+1)*5f, 1f).setSpeed(6f).setEase(LeanTweenType.easeInOutExpo).setLoopPingPong(); // any time you set the speed it overrides the time value + + // move around a circle at a constant speed + for(int i = 0; i < avatarSpeed2.Length; i++){ + LeanTween.moveLocal( avatarSpeed2[i], i == 0 ? circleSm : circleLrg, 1f).setSpeed(20f).setRepeat(-1); + } + + } + +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralAdvancedTechniques.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralAdvancedTechniques.cs.meta new file mode 100644 index 0000000..73041c0 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralAdvancedTechniques.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4fce1b486cc240c4825b3bfd794e9e0 +timeCreated: 1461150844 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs new file mode 100644 index 0000000..6fae245 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs @@ -0,0 +1,82 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralBasicCS : MonoBehaviour { + + public GameObject prefabAvatar; + + void Start () { + // Setup + GameObject avatarRotate = GameObject.Find("AvatarRotate"); + GameObject avatarScale = GameObject.Find("AvatarScale"); + GameObject avatarMove = GameObject.Find("AvatarMove"); + + // Rotate Example + LeanTween.rotateAround( avatarRotate, Vector3.forward, 360f, 5f); + + // Scale Example + LeanTween.scale( avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce); + LeanTween.moveX( avatarScale, avatarScale.transform.position.x + 5f, 5f).setEase(LeanTweenType.easeOutBounce); // Simultaneously target many different tweens on the same object + + // Move Example + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-9f, 0f, 1f), 2f).setEase(LeanTweenType.easeInQuad); + + // Delay + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-6f, 0f, 1f), 2f).setDelay(3f); + + // Chain properties (delay, easing with a set repeating of type ping pong) + LeanTween.scale( avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setLoopPingPong( 3 ); + + // Call methods after a certain time period + LeanTween.delayedCall(gameObject, 0.2f, advancedExamples); + } + + // Advanced Examples + // It might be best to master the basics first, but this is included to tease the many possibilies LeanTween provides. + + void advancedExamples(){ + LeanTween.delayedCall(gameObject, 14f, ()=>{ + for(int i=0; i < 10; i++){ + // Instantiate Container + GameObject rotator = new GameObject("rotator"+i); + rotator.transform.position = new Vector3(10.2f,2.85f,0f); + + // Instantiate Avatar + GameObject dude = (GameObject)GameObject.Instantiate(prefabAvatar, Vector3.zero, prefabAvatar.transform.rotation ); + dude.transform.parent = rotator.transform; + dude.transform.localPosition = new Vector3(0f,1.5f,2.5f*i); + + // Scale, pop-in + dude.transform.localScale = new Vector3(0f,0f,0f); + LeanTween.scale(dude, new Vector3(0.65f,0.65f,0.65f), 1f).setDelay(i*0.2f).setEase(LeanTweenType.easeOutBack); + + // Color like the rainbow + float period = LeanTween.tau/10*i; + float red = Mathf.Sin(period + LeanTween.tau*0f/3f) * 0.5f + 0.5f; + float green = Mathf.Sin(period + LeanTween.tau*1f/3f) * 0.5f + 0.5f; + float blue = Mathf.Sin(period + LeanTween.tau*2f/3f) * 0.5f + 0.5f; + Color rainbowColor = new Color(red, green, blue); + LeanTween.color(dude, rainbowColor, 0.3f).setDelay(1.2f + i*0.4f); + + // Push into the wheel + LeanTween.moveZ(dude, 0f, 0.3f).setDelay(1.2f + i*0.4f).setEase(LeanTweenType.easeSpring).setOnComplete( + ()=>{ + LeanTween.rotateAround(rotator, Vector3.forward, -1080f, 12f); + } + ); + + // Jump Up and back down + LeanTween.moveLocalY(dude,4f,1.2f).setDelay(5f + i*0.2f).setLoopPingPong(1).setEase(LeanTweenType.easeInOutQuad); + + // Alpha Out, and destroy + LeanTween.alpha(dude, 0f, 0.6f).setDelay(9.2f + i*0.4f).setDestroyOnComplete(true).setOnComplete( + ()=>{ + Destroy( rotator ); // destroying parent as well + } + ); + } + + }).setOnCompleteOnStart(true).setRepeat(-1); // Have the OnComplete play in the beginning and have the whole group repeat endlessly + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs.meta new file mode 100644 index 0000000..87e42bb --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicCS.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a2605544ab2e14c93a780ca20c108cfe +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js new file mode 100644 index 0000000..287f3c6 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js @@ -0,0 +1,78 @@ +#pragma strict +import DentedPixel; + +public var prefabAvatar:GameObject; + +function Start () { + // Setup + var avatarRotate:GameObject = GameObject.Find("AvatarRotate"); + var avatarScale:GameObject = GameObject.Find("AvatarScale"); + var avatarMove:GameObject = GameObject.Find("AvatarMove"); + + // Rotate Example + LeanTween.rotateAround( avatarRotate, Vector3.forward, 360f, 5f); + + // Scale Example + LeanTween.scale( avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce); + LeanTween.moveX( avatarScale, avatarScale.transform.position.x + 5f, 5f).setEase(LeanTweenType.easeOutBounce); // Simultaneously target many different tweens on the same object + + // Move Example + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-9f, 0f, 1f), 2f).setEase(LeanTweenType.easeInQuad); + + // Delay + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-6f, 0f, 1f), 2f).setDelay(3f); + + // Chain properties (delay, easing with a set repeating of type ping pong) + LeanTween.scale( avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setRepeat(5).setLoopPingPong(); + + // Call methods after a certain time period + LeanTween.delayedCall(gameObject, 0.2f, advancedExamples); +} + +// Advanced Examples +// It might be best to master the basics first, but this is included to tease the many possibilies LeanTween provides. + +function advancedExamples(){ + LeanTween.delayedCall(gameObject, 14f, function(){ + for(var i:int=0; i < 10; i++){ + // Instantiate Container + var rotator:GameObject = new GameObject("rotator"+i); + rotator.transform.position = new Vector3(10.2f,2.85f,0f); + + // Instantiate Avatar + var dude:GameObject = GameObject.Instantiate(prefabAvatar, Vector3.zero, prefabAvatar.transform.rotation ) as GameObject; + dude.transform.parent = rotator.transform; + dude.transform.localPosition = new Vector3(0f,1.5f,2.5f*i); + + // Scale, pop-in + dude.transform.localScale = new Vector3(0f,0f,0f); + LeanTween.scale(dude, new Vector3(0.65f,0.65f,0.65f), 1f).setDelay(i*0.2f).setEase(LeanTweenType.easeOutBack); + + // Color like the rainbow + var period:float = LeanTween.tau/10*i; + var red:float = Mathf.Sin(period + LeanTween.tau*0f/3f) * 0.5f + 0.5f; + var green:float = Mathf.Sin(period + LeanTween.tau*1f/3f) * 0.5f + 0.5f; + var blue:float = Mathf.Sin(period + LeanTween.tau*2f/3f) * 0.5f + 0.5f; + var rainbowColor:Color = new Color(red, green, blue); + LeanTween.color(dude, rainbowColor, 0.3f).setDelay(1.2f + i*0.4f); + + // Push into the wheel + LeanTween.moveZ(dude, 0f, 0.3f).setDelay(1.2f + i*0.4f).setEase(LeanTweenType.easeSpring).setOnComplete( + function( rot:GameObject ){ + LeanTween.rotateAround(rot, Vector3.forward, -1080f, 12f); + } + ).setOnCompleteParam( rotator ); + + // Jump Up and back down + LeanTween.moveLocalY(dude,4f,1.2f).setDelay(5f + i*0.2f).setLoopPingPong().setRepeat(2).setEase(LeanTweenType.easeInOutQuad); + + // Alpha Out, and destroy + LeanTween.alpha(dude, 0f, 0.6f).setDelay(9.2f + i*0.4f).setDestroyOnComplete(true).setOnComplete( + function(rot:GameObject){ + Destroy( rot ); // destroying parent as well + } + ).setOnCompleteParam( rotator ); + } + + }).setOnCompleteOnStart(true).setRepeat(-1); // Have the OnComplete play in the beginning and have the whole group repeat endlessly +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js.meta new file mode 100644 index 0000000..625ec88 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 344fd7cd6efc54e5c80a30429269c2de +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs new file mode 100644 index 0000000..2ea1c05 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs @@ -0,0 +1,102 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralBasics2dCS : MonoBehaviour { + + public Texture2D dudeTexture; + public GameObject prefabParticles; + + #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) + + void Start () { + // Setup + GameObject avatarRotate = createSpriteDude( "avatarRotate", new Vector3(-2.51208f,10.7119f,-14.37754f)); + GameObject avatarScale = createSpriteDude( "avatarScale", new Vector3(2.51208f,10.2119f,-14.37754f)); + GameObject avatarMove = createSpriteDude( "avatarMove", new Vector3(-3.1208f,7.100643f,-14.37754f)); + + // Rotate Example + LeanTween.rotateAround( avatarRotate, Vector3.forward, -360f, 5f); + + // Scale Example + LeanTween.scale( avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce); + LeanTween.moveX( avatarScale, avatarScale.transform.position.x + 1f, 5f).setEase(LeanTweenType.easeOutBounce); // Simultaneously target many different tweens on the same object + + // Move Example + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(1.7f, 0f, 0f), 2f).setEase(LeanTweenType.easeInQuad); + + // Delay + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(2f, -1f, 0f), 2f).setDelay(3f); + + // Chain properties (delay, easing with a set repeating of type ping pong) + LeanTween.scale( avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setLoopPingPong(3); + + // Call methods after a certain time period + LeanTween.delayedCall(gameObject, 0.2f, advancedExamples); + } + + GameObject createSpriteDude( string name, Vector3 pos, bool hasParticles = true ){ + GameObject go = new GameObject(name); + SpriteRenderer ren = go.AddComponent(); + go.GetComponent().color = new Color(0f,181f/255f,1f); + ren.sprite = Sprite.Create( dudeTexture, new Rect(0.0f,0.0f,256.0f,256.0f), new Vector2(0.5f,0f), 256f); + go.transform.position = pos; + + if(hasParticles){ + GameObject particles = (GameObject)GameObject.Instantiate(prefabParticles, Vector3.zero, prefabParticles.transform.rotation ); + particles.transform.parent = go.transform; + particles.transform.localPosition = prefabParticles.transform.position; + } + return go; + } + + // Advanced Examples + // It might be best to master the basics first, but this is included to tease the many possibilies LeanTween provides. + + void advancedExamples(){ + LeanTween.delayedCall(gameObject, 14f, ()=>{ + for(int i=0; i < 10; i++){ + // Instantiate Container + GameObject rotator = new GameObject("rotator"+i); + rotator.transform.position = new Vector3(2.71208f,7.100643f,-12.37754f); + + // Instantiate Avatar + GameObject dude = createSpriteDude( "dude"+i, new Vector3(-2.51208f,7.100643f,-14.37754f), false);//(GameObject)GameObject.Instantiate(prefabAvatar, Vector3.zero, prefabAvatar.transform.rotation ); + dude.transform.parent = rotator.transform; + dude.transform.localPosition = new Vector3(0f,0.5f,0.5f*i); + + // Scale, pop-in + dude.transform.localScale = new Vector3(0f,0f,0f); + LeanTween.scale(dude, new Vector3(0.65f,0.65f,0.65f), 1f).setDelay(i*0.2f).setEase(LeanTweenType.easeOutBack); + + // Color like the rainbow + float period = LeanTween.tau/10*i; + float red = Mathf.Sin(period + LeanTween.tau*0f/3f) * 0.5f + 0.5f; + float green = Mathf.Sin(period + LeanTween.tau*1f/3f) * 0.5f + 0.5f; + float blue = Mathf.Sin(period + LeanTween.tau*2f/3f) * 0.5f + 0.5f; + Color rainbowColor = new Color(red, green, blue); + LeanTween.color(dude, rainbowColor, 0.3f).setDelay(1.2f + i*0.4f); + + // Push into the wheel + LeanTween.moveLocalZ(dude, -2f, 0.3f).setDelay(1.2f + i*0.4f).setEase(LeanTweenType.easeSpring).setOnComplete( + ()=>{ + LeanTween.rotateAround(rotator, Vector3.forward, -1080f, 12f); + } + ); + + // Jump Up and back down + LeanTween.moveLocalY(dude,1.17f,1.2f).setDelay(5f + i*0.2f).setLoopPingPong(1).setEase(LeanTweenType.easeInOutQuad); + + // Alpha Out, and destroy + LeanTween.alpha(dude, 0f, 0.6f).setDelay(9.2f + i*0.4f).setDestroyOnComplete(true).setOnComplete( + ()=>{ + Destroy( rotator ); // destroying parent as well + } + ); + } + + }).setOnCompleteOnStart(true).setRepeat(-1); // Have the OnComplete play in the beginning and have the whole group repeat endlessly + } + + #endif +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs.meta new file mode 100644 index 0000000..d8c9463 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dCS.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9b39dd70d168b4cbea9a7b8561d9accc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js new file mode 100644 index 0000000..7f62fde --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js @@ -0,0 +1,98 @@ +#pragma strict +import DentedPixel; + +public var dudeTexture:Texture2D; +public var prefabParticles:GameObject; + +#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + +function Start () { + // Setup + var avatarRotate:GameObject = createSpriteDude( "avatarRotate", new Vector3(-2.51208f,10.7119f,-14.37754f), true); + var avatarScale:GameObject = createSpriteDude( "avatarScale", new Vector3(2.51208f,10.2119f,-14.37754f), true); + var avatarMove:GameObject = createSpriteDude( "avatarMove", new Vector3(-3.1208f,7.100643f,-14.37754f), true); + + // Rotate Example + LeanTween.rotateAround( avatarRotate, Vector3.forward, -360f, 5f); + + // Scale Example + LeanTween.scale( avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce); + LeanTween.moveX( avatarScale, avatarScale.transform.position.x + 1f, 5f).setEase(LeanTweenType.easeOutBounce); // Simultaneously target many different tweens on the same object + + // Move Example + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(1.7f, 0f, 0f), 2f).setEase(LeanTweenType.easeInQuad); + + // Delay + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(2f, -1f, 0f), 2f).setDelay(3f); + + // Chain properties (delay, easing with a set repeating of type ping pong) + LeanTween.scale( avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setRepeat(5).setLoopPingPong(); + + // Call methods after a certain time period + LeanTween.delayedCall(gameObject, 0.2f, advancedExamples); +} + +function createSpriteDude( name:String, pos:Vector3, hasParticles:boolean ):GameObject{ + var go:GameObject = new GameObject(name); + var ren:SpriteRenderer = go.AddComponent(SpriteRenderer); + go.GetComponent.().material.color = new Color(0f,181f/255f,1f); + ren.sprite = Sprite.Create( dudeTexture, new Rect(0.0f,0.0f,256.0f,256.0f), new Vector2(0.5f,0f), 256f); + go.transform.position = pos; + + if(hasParticles){ + var particles:GameObject = GameObject.Instantiate(prefabParticles, Vector3.zero, prefabParticles.transform.rotation ) as GameObject; + particles.transform.parent = go.transform; + particles.transform.localPosition = prefabParticles.transform.position; + } + return go; +} + +// Advanced Examples +// It might be best to master the basics first, but this is included to tease the many possibilies LeanTween provides. + +function advancedExamples(){ + LeanTween.delayedCall(gameObject, 14f, function(){ + for(var i:int=0; i < 10; i++){ + // Instantiate Container + var rotator:GameObject = new GameObject("rotator"+i); + rotator.transform.position = new Vector3(2.71208f,7.100643f,-12.37754f); + + // Instantiate Avatar + var dude:GameObject = createSpriteDude( "dude"+i, new Vector3(-2.51208f,7.100643f,-14.37754f), false);//(GameObject)GameObject.Instantiate(prefabAvatar, Vector3.zero, prefabAvatar.transform.rotation ); + dude.transform.parent = rotator.transform; + dude.transform.localPosition = new Vector3(0f,0.5f,0.5f*i); + + // Scale, pop-in + dude.transform.localScale = new Vector3(0f,0f,0f); + LeanTween.scale(dude, new Vector3(0.65f,0.65f,0.65f), 1f).setDelay(i*0.2f).setEase(LeanTweenType.easeOutBack); + + // Color like the rainbow + var period:float = LeanTween.tau/10*i; + var red:float = Mathf.Sin(period + LeanTween.tau*0f/3f) * 0.5f + 0.5f; + var green:float = Mathf.Sin(period + LeanTween.tau*1f/3f) * 0.5f + 0.5f; + var blue:float = Mathf.Sin(period + LeanTween.tau*2f/3f) * 0.5f + 0.5f; + var rainbowColor:Color = new Color(red, green, blue); + LeanTween.color(dude, rainbowColor, 0.3f).setDelay(1.2f + i*0.4f); + + // Push into the wheel + LeanTween.moveLocalZ(dude, -2f, 0.3f).setDelay(1.2f + i*0.4f).setEase(LeanTweenType.easeSpring).setOnComplete( + function( rot:GameObject ){ + LeanTween.rotateAround(rot, Vector3.forward, -1080f, 12f); + } + ).setOnCompleteParam( rotator ); + + // Jump Up and back down + LeanTween.moveLocalY(dude,1.17f,1.2f).setDelay(5f + i*0.2f).setLoopPingPong(1).setEase(LeanTweenType.easeInOutQuad); + + // Alpha Out, and destroy + LeanTween.alpha(dude, 0f, 0.6f).setDelay(9.2f + i*0.4f).setDestroyOnComplete(true).setOnComplete( + function(rot:GameObject){ + Destroy( rot ); // destroying parent as well + } + ).setOnCompleteParam( rotator );; + } + + }).setOnCompleteOnStart(true).setRepeat(-1); // Have the OnComplete play in the beginning and have the whole group repeat endlessly +} + +#endif \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js.meta new file mode 100644 index 0000000..7a1152b --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasics2dJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 282a362514d90477796b0badacbebf8a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js new file mode 100644 index 0000000..287f3c6 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js @@ -0,0 +1,78 @@ +#pragma strict +import DentedPixel; + +public var prefabAvatar:GameObject; + +function Start () { + // Setup + var avatarRotate:GameObject = GameObject.Find("AvatarRotate"); + var avatarScale:GameObject = GameObject.Find("AvatarScale"); + var avatarMove:GameObject = GameObject.Find("AvatarMove"); + + // Rotate Example + LeanTween.rotateAround( avatarRotate, Vector3.forward, 360f, 5f); + + // Scale Example + LeanTween.scale( avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce); + LeanTween.moveX( avatarScale, avatarScale.transform.position.x + 5f, 5f).setEase(LeanTweenType.easeOutBounce); // Simultaneously target many different tweens on the same object + + // Move Example + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-9f, 0f, 1f), 2f).setEase(LeanTweenType.easeInQuad); + + // Delay + LeanTween.move( avatarMove, avatarMove.transform.position + new Vector3(-6f, 0f, 1f), 2f).setDelay(3f); + + // Chain properties (delay, easing with a set repeating of type ping pong) + LeanTween.scale( avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setRepeat(5).setLoopPingPong(); + + // Call methods after a certain time period + LeanTween.delayedCall(gameObject, 0.2f, advancedExamples); +} + +// Advanced Examples +// It might be best to master the basics first, but this is included to tease the many possibilies LeanTween provides. + +function advancedExamples(){ + LeanTween.delayedCall(gameObject, 14f, function(){ + for(var i:int=0; i < 10; i++){ + // Instantiate Container + var rotator:GameObject = new GameObject("rotator"+i); + rotator.transform.position = new Vector3(10.2f,2.85f,0f); + + // Instantiate Avatar + var dude:GameObject = GameObject.Instantiate(prefabAvatar, Vector3.zero, prefabAvatar.transform.rotation ) as GameObject; + dude.transform.parent = rotator.transform; + dude.transform.localPosition = new Vector3(0f,1.5f,2.5f*i); + + // Scale, pop-in + dude.transform.localScale = new Vector3(0f,0f,0f); + LeanTween.scale(dude, new Vector3(0.65f,0.65f,0.65f), 1f).setDelay(i*0.2f).setEase(LeanTweenType.easeOutBack); + + // Color like the rainbow + var period:float = LeanTween.tau/10*i; + var red:float = Mathf.Sin(period + LeanTween.tau*0f/3f) * 0.5f + 0.5f; + var green:float = Mathf.Sin(period + LeanTween.tau*1f/3f) * 0.5f + 0.5f; + var blue:float = Mathf.Sin(period + LeanTween.tau*2f/3f) * 0.5f + 0.5f; + var rainbowColor:Color = new Color(red, green, blue); + LeanTween.color(dude, rainbowColor, 0.3f).setDelay(1.2f + i*0.4f); + + // Push into the wheel + LeanTween.moveZ(dude, 0f, 0.3f).setDelay(1.2f + i*0.4f).setEase(LeanTweenType.easeSpring).setOnComplete( + function( rot:GameObject ){ + LeanTween.rotateAround(rot, Vector3.forward, -1080f, 12f); + } + ).setOnCompleteParam( rotator ); + + // Jump Up and back down + LeanTween.moveLocalY(dude,4f,1.2f).setDelay(5f + i*0.2f).setLoopPingPong().setRepeat(2).setEase(LeanTweenType.easeInOutQuad); + + // Alpha Out, and destroy + LeanTween.alpha(dude, 0f, 0.6f).setDelay(9.2f + i*0.4f).setDestroyOnComplete(true).setOnComplete( + function(rot:GameObject){ + Destroy( rot ); // destroying parent as well + } + ).setOnCompleteParam( rotator ); + } + + }).setOnCompleteOnStart(true).setRepeat(-1); // Have the OnComplete play in the beginning and have the whole group repeat endlessly +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js.meta new file mode 100644 index 0000000..e5c11b5 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralBasicsJS.js.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5834eb1aca810405cb0a0a6585d407bf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs new file mode 100644 index 0000000..36c19d2 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs @@ -0,0 +1,82 @@ +#if !UNITY_FLASH +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralCameraShake : MonoBehaviour { + + private GameObject avatarBig; + private float jumpIter = 9.5f; + private AudioClip boomAudioClip; + + // Use this for initialization + void Start () { + avatarBig = GameObject.Find("AvatarBig"); + + AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(8.130963E-06f, 0.06526042f, 0f, -1f), new Keyframe(0.0007692695f, 2.449077f, 9.078861f, 9.078861f), new Keyframe(0.01541314f, 0.9343268f, -40f, -40f), new Keyframe(0.05169491f, 0.03835937f, -0.08621139f, -0.08621139f)); + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003005181f, 0f, 0f), new Keyframe(0.01507768f, 0.002227979f, 0f, 0f)); + boomAudioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.1f,0f,0f)} )); + + + bigGuyJump(); + } + + void bigGuyJump(){ + float height = Mathf.PerlinNoise(jumpIter, 0f)*10f; + height = height*height * 0.3f; + // Debug.Log("height:"+height+" jumpIter:"+jumpIter); + + LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete( ()=>{ + LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete( ()=>{ + LeanTween.cancel(gameObject); + + /************** + * Camera Shake + **************/ + + float shakeAmt = height*0.2f; // the degrees to shake the camera + float shakePeriodTime = 0.42f; // The period of each shake + float dropOffTime = 1.6f; // How long it takes the shaking to settle down to nothing + LTDescr shakeTween = LeanTween.rotateAroundLocal( gameObject, Vector3.right, shakeAmt, shakePeriodTime) + .setEase( LeanTweenType.easeShake ) // this is a special ease that is good for shaking + .setLoopClamp() + .setRepeat(-1); + + // Slow the camera shake down to zero + LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( + (float val)=>{ + shakeTween.setTo(Vector3.right*val); + } + ).setEase(LeanTweenType.easeOutQuad); + + + /******************** + * Shake scene objects + ********************/ + + // Make the boxes jump from the big stomping + GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn"); // I just arbitrarily tagged the boxes with this since it was available in the scene + foreach (GameObject box in boxes) { + box.GetComponent().AddForce(Vector3.up * 100 * height); + } + + // Make the lamps spin from the big stomping + GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController"); // I just arbitrarily tagged the lamps with this since it was available in the scene + foreach (GameObject lamp in lamps) { + float z = lamp.transform.eulerAngles.z; + z = z > 0.0f && z < 180f ? 1 : -1; // push the lamps in whatever direction they are currently swinging + lamp.GetComponent().AddForce(new Vector3(z, 0f, 0f ) * 15 * height); + } + + // Play BOOM! + LeanAudio.play(boomAudioClip, transform.position, height*0.2f); // Like this sound? : http://leanaudioplay.dentedpixel.com/?d=a:fvb:8,0,0.003005181,0,0,0.01507768,0.002227979,0,0,8~8,8.130963E-06,0.06526042,0,-1,0.0007692695,2.449077,9.078861,9.078861,0.01541314,0.9343268,-40,-40,0.05169491,0.03835937,-0.08621139,-0.08621139,8~0.1,0,0,~44100 + + // Have the jump happen again 2 seconds from now + LeanTween.delayedCall(2f, bigGuyJump); + }); + }); + jumpIter += 5.2f; + } + +} +#endif \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs.meta new file mode 100644 index 0000000..3fb02ea --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralCameraShake.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8a650682fa3d54a57a2521dbf9f6eac2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs new file mode 100644 index 0000000..24c2b64 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using System.Collections; +using System.Reflection; +using DentedPixel; + +public class GeneralEasingTypes : MonoBehaviour { + + public float lineDrawScale = 10f; + public AnimationCurve animationCurve; + + private string[] easeTypes = new string[]{ + "EaseLinear","EaseAnimationCurve","EaseSpring", + "EaseInQuad","EaseOutQuad","EaseInOutQuad", + "EaseInCubic","EaseOutCubic","EaseInOutCubic", + "EaseInQuart","EaseOutQuart","EaseInOutQuart", + "EaseInQuint","EaseOutQuint","EaseInOutQuint", + "EaseInSine","EaseOutSine","EaseInOutSine", + "EaseInExpo","EaseOutExpo","EaseInOutExpo", + "EaseInCirc","EaseOutCirc","EaseInOutCirc", + "EaseInBounce","EaseOutBounce","EaseInOutBounce", + "EaseInBack","EaseOutBack","EaseInOutBack", + "EaseInElastic","EaseOutElastic","EaseInOutElastic", + "EasePunch","EaseShake", + }; + + void Start () { + + demoEaseTypes(); + } + + private void demoEaseTypes(){ + for(int i = 0; i < easeTypes.Length; i++){ + string easeName = easeTypes[i]; + Transform obj1 = GameObject.Find(easeName).transform.FindChild("Line"); + float obj1val = 0f; + LTDescr lt = LeanTween.value( obj1.gameObject, 0f, 1f, 5f).setOnUpdate( (float val)=>{ + Vector3 vec = obj1.localPosition; + vec.x = obj1val*lineDrawScale; + vec.y = val*lineDrawScale; + + obj1.localPosition = vec; + + obj1val += Time.deltaTime/5f; + if(obj1val>1f) + obj1val = 0f; + }); + if(easeName.IndexOf("AnimationCurve")>=0){ + lt.setEase(animationCurve); + }else{ + MethodInfo theMethod = lt.GetType().GetMethod("set"+easeName); + theMethod.Invoke(lt, null); + } + + if(easeName.IndexOf("EasePunch")>=0){ + lt.setScale(1f); + } + } + + LeanTween.delayedCall(gameObject, 10f, resetLines); + LeanTween.delayedCall(gameObject, 10.1f, demoEaseTypes); + } + + private void resetLines(){ + for(int i = 0; i < easeTypes.Length; i++){ + Transform obj1 = GameObject.Find(easeTypes[i]).transform.FindChild("Line"); + obj1.localPosition = new Vector3(0f,0f,0f); + } + } + +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs.meta new file mode 100644 index 0000000..c16432f --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEasingTypes.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 94e9a883a33cd40b9be1a63f002c4db2 +timeCreated: 1471950328 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs new file mode 100644 index 0000000..3e04305 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs @@ -0,0 +1,83 @@ +#if !UNITY_FLASH +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralEventsListenersCS : MonoBehaviour { + + Vector3 towardsRotation; + float turnForLength = 0.5f; + float turnForIter = 0f; + Color fromColor; + + // It's best to make this a public enum that you use throughout your project, so every class can have access to it + public enum MyEvents{ + CHANGE_COLOR, + JUMP, + LENGTH + } + + void Awake(){ + LeanTween.LISTENERS_MAX = 100; // This is the maximum of event listeners you will have added as listeners + LeanTween.EVENTS_MAX = (int)MyEvents.LENGTH; // The maximum amount of events you will be dispatching + + fromColor = GetComponent().material.color; + } + + void Start () { + // Adding Listeners, it's best to use an enum so your listeners are more descriptive but you could use an int like 0,1,2,... + LeanTween.addListener(gameObject, (int)MyEvents.CHANGE_COLOR, changeColor); + LeanTween.addListener(gameObject, (int)MyEvents.JUMP, jumpUp); + } + + // ****** Event Listening Methods + + void jumpUp( LTEvent e ){ + GetComponent().AddRelativeForce(Vector3.forward * 300f); + } + + void changeColor( LTEvent e ){ + Transform tran = (Transform)e.data; + float distance = Vector3.Distance( tran.position, transform.position); + Color to = new Color(Random.Range(0f,1f),0f,Random.Range(0f,1f)); + LeanTween.value( gameObject, fromColor, to, 0.8f ).setLoopPingPong(1).setDelay(distance*0.05f).setOnUpdate( + (Color col)=>{ + GetComponent().material.color = col; + } + ); + } + + // ****** Physics / AI Stuff + + void OnCollisionEnter(Collision collision) { + if(collision.gameObject.layer!=2) + towardsRotation = new Vector3(0f, Random.Range(-180, 180), 0f); + } + + void OnCollisionStay(Collision collision) { + if(collision.gameObject.layer!=2){ + turnForIter = 0f; + turnForLength = Random.Range(0.5f, 1.5f); + } + } + + void FixedUpdate(){ + if(turnForIter < turnForLength){ + GetComponent().MoveRotation( GetComponent().rotation * Quaternion.Euler(towardsRotation * Time.deltaTime ) ); + turnForIter += Time.deltaTime; + } + + GetComponent().AddRelativeForce(Vector3.forward * 4.5f); + } + + // ****** Key and clicking detection + + void OnMouseDown(){ + if(Input.GetKey( KeyCode.J )){ // Are you also pressing the "j" key while clicking + LeanTween.dispatchEvent((int)MyEvents.JUMP); + }else{ + LeanTween.dispatchEvent((int)MyEvents.CHANGE_COLOR, transform); // with every dispatched event, you can include an object (retrieve this object with the *.data var in LTEvent) + } + } +} +#endif diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs.meta new file mode 100644 index 0000000..82d5acb --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersCS.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cd679d4fbbd8d475ba7187561370c3aa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js new file mode 100644 index 0000000..71c19d0 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js @@ -0,0 +1,77 @@ +#pragma strict +import DentedPixel; + +private var towardsRotation:Vector3; +private var turnForLength:float = 0.5f; +private var turnForIter:float = 0f; +private var fromColor:Vector3; + +// It's best to make this a public enum that you use throughout your project, so every class can have access to it +public enum MyEvents{ + CHANGE_COLOR, + JUMP, + LENGTH +} + +function Awake(){ + LeanTween.LISTENERS_MAX = 100; // This is the maximum of event listeners you will have added as listeners + LeanTween.EVENTS_MAX = MyEvents.LENGTH; // The maximum amount of events you will be dispatching + + fromColor = new Vector3(GetComponent.().material.color.r, GetComponent.().material.color.g, GetComponent.().material.color.b); +} + +function Start () { + // Adding Listeners, it's best to use an enum so your listeners are more descriptive but you could use an int like 0,1,2,... + LeanTween.addListener(gameObject, MyEvents.CHANGE_COLOR, changeColor); + LeanTween.addListener(gameObject, MyEvents.JUMP, jumpUp); +} + +// ****** Event Listening Methods + +function jumpUp( e:LTEvent ){ + GetComponent.().AddRelativeForce(Vector3.forward * 300f); +} + +function changeColor( e:LTEvent ){ + var tran:Transform = e.data as Transform; + var distance:float = Vector3.Distance( tran.position, transform.position); + var to:Vector3 = new Vector3(Random.Range(0f,1f),0f,Random.Range(0f,1f)); + LeanTween.value( gameObject, updateColor, fromColor, to, 0.8f ).setLoopPingPong(1).setDelay(distance*0.05f); +} + +function updateColor( v:Vector3 ){ + GetComponent.().material.color = new Color( v.x, v.y, v.z ); +} + +// ****** Physics / AI Stuff + +function OnCollisionEnter(collision:Collision) { + if(collision.gameObject.layer!=2) + towardsRotation = new Vector3(0f, Random.Range(-180, 180), 0f); +} + + function OnCollisionStay( collision:Collision ) { + if(collision.gameObject.layer!=2){ + turnForIter = 0f; + turnForLength = Random.Range(0.5f, 1.5f); + } + } + +function FixedUpdate(){ + if(turnForIter < turnForLength){ + GetComponent.().MoveRotation( GetComponent.().rotation * Quaternion.Euler(towardsRotation * Time.deltaTime ) ); + turnForIter += Time.deltaTime; + } + + GetComponent.().AddRelativeForce(Vector3.forward * 4.5f); +} + +// ****** Key and clicking detection + +function OnMouseDown(){ + if(Input.GetKey( KeyCode.J )){ // Are you also pressing the "j" key while clicking + LeanTween.dispatchEvent(MyEvents.JUMP); + }else{ + LeanTween.dispatchEvent(MyEvents.CHANGE_COLOR, transform); // with every dispatched event, you can include an object (retrieve this object with the *.data var in LTEvent) + } +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js.meta new file mode 100644 index 0000000..eee5811 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralEventsListenersJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8c4802b493d38443e9ac0c4d122334c9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs new file mode 100644 index 0000000..4af3a39 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs @@ -0,0 +1,56 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralSimpleUiCS : MonoBehaviour { + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + public RectTransform button; + + void Start () { + Debug.Log("For better examples see the 4.6_Examples folder!"); + if(button==null){ + Debug.LogError("Button not assigned! Create a new button via Hierarchy->Create->UI->Button. Then assign it to the button variable"); + return; + } + + // Tweening various values in a block callback style + LeanTween.value(button.gameObject, button.anchoredPosition, new Vector2(200f,100f), 1f ).setOnUpdate( + (Vector2 val)=>{ + button.anchoredPosition = val; + } + ); + + LeanTween.value(gameObject, 1f, 0.5f, 1f ).setOnUpdate( + (float volume)=>{ + Debug.Log("volume:"+volume); + } + ); + + LeanTween.value(gameObject, gameObject.transform.position, gameObject.transform.position + new Vector3(0,1f,0), 1f ).setOnUpdate( + (Vector3 val)=>{ + gameObject.transform.position = val; + } + ); + + LeanTween.value(gameObject, Color.red, Color.green, 1f ).setOnUpdate( + (Color val)=>{ + UnityEngine.UI.Image image = (UnityEngine.UI.Image)button.gameObject.GetComponent( typeof(UnityEngine.UI.Image) ); + image.color = val; + } + ); + + // Tweening Using Unity's new Canvas GUI System + LeanTween.move(button, new Vector3(200f,-100f,0f), 1f).setDelay(1f); + LeanTween.rotateAround(button, Vector3.forward, 90f, 1f).setDelay(2f); + LeanTween.scale(button, button.localScale*2f, 1f).setDelay(3f); + LeanTween.rotateAround(button, Vector3.forward, -90f, 1f).setDelay(4f).setEase(LeanTweenType.easeInOutElastic); + } + + #else + void Start(){ + Debug.LogError("Unity 4.6+ is required to use the new UI"); + } + + #endif +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs.meta new file mode 100644 index 0000000..f9b578b --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiCS.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 19c352f230e8b46f08abbbd7cc11edb8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js new file mode 100644 index 0000000..0d39a10 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js @@ -0,0 +1,48 @@ +#pragma strict +import DentedPixel; + +#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + public var button:RectTransform; + + function Start () { + Debug.Log("For better examples see the 4.6_Examples folder!"); + if(button==null){ + Debug.LogError("Button not assigned! Create a new button via Hierarchy->Create->UI->Button. Then assign it to the button variable"); + return; + } + + // Tweening various values in a block callback style + LeanTween.value(button.gameObject, button.anchoredPosition, new Vector2(200f,100f), 1f ).setOnUpdateVector3( + function(val:Vector3){ + button.anchoredPosition = new Vector2(val.x, val.y); + } + ); + + LeanTween.value(gameObject, 1f, 0.5f, 1f ).setOnUpdate( + function(volume:float){ + Debug.Log("volume:"+volume); + } + ); + + LeanTween.value(gameObject, gameObject.transform.position, gameObject.transform.position + new Vector3(0,1f,0), 1f ).setOnUpdateVector3( + function(val:Vector3){ + gameObject.transform.position = val; + } + ); + + LeanTween.value(gameObject, Color.red, Color.green, 1f ).setOnUpdateColor( + function(val:Color){ + var image:UnityEngine.UI.Image = button.gameObject.GetComponent( UnityEngine.UI.Image ); + image.color = val; + } + ); + + // Tweening Using Unity's new Canvas GUI System + LeanTween.move(button, new Vector3(200f,-100f,0f), 1f).setDelay(1f); + LeanTween.rotateAround(button, Vector3.forward, 90f, 1f).setDelay(2f); + LeanTween.scale(button, button.localScale*2f, 1f).setDelay(3f); + LeanTween.rotateAround(button, Vector3.forward, -90f, 1f).setDelay(4f).setEase(LeanTweenType.easeInOutElastic); + } + + #endif \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js.meta new file mode 100644 index 0000000..4beac02 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralSimpleUiJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8011e3187b0a148ee865b364c5cc4173 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs new file mode 100644 index 0000000..d964428 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs @@ -0,0 +1,89 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class GeneralUISpaceCS : MonoBehaviour { + + public RectTransform mainWindow; + public RectTransform mainParagraphText; + public RectTransform mainTitleText; + public RectTransform mainButton1; + public RectTransform mainButton2; + + public RectTransform pauseRing1; + public RectTransform pauseRing2; + public RectTransform pauseWindow; + + public RectTransform chatWindow; + public RectTransform chatRect; + public Sprite[] chatSprites; + public RectTransform chatBar1; + public RectTransform chatBar2; + public UnityEngine.UI.Text chatText; + + public RectTransform rawImageRect; + + void Start () { + // Time.timeScale = 1f/4f; + + // *********** Main Window ********** + // Scale the whole window in + mainWindow.localScale = Vector3.zero; + LeanTween.scale( mainWindow, new Vector3(1f,1f,1f), 0.6f).setEase(LeanTweenType.easeOutBack); + LeanTween.alphaCanvas( mainWindow.GetComponent(), 0f, 1f).setDelay(2f).setLoopPingPong().setRepeat(2); + + // Fade the main paragraph in while moving upwards + mainParagraphText.anchoredPosition3D += new Vector3(0f,-10f,0f); + LeanTween.textAlpha( mainParagraphText, 0f, 0.6f).setFrom(0f).setDelay(0f); + LeanTween.textAlpha( mainParagraphText, 1f, 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f); + LeanTween.move( mainParagraphText, mainParagraphText.anchoredPosition3D + new Vector3(0f,10f,0f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f); + + // Flash text to purple and back + LeanTween.textColor( mainTitleText, new Color(133f/255f,145f/255f,223f/255f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f).setLoopPingPong().setRepeat(-1); + + // Fade button in + LeanTween.textAlpha(mainButton2, 1f, 2f ).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad); + LeanTween.alpha(mainButton2, 1f, 2f ).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad); + + // Pop size of button + LeanTween.size(mainButton1, mainButton1.sizeDelta * 1.1f, 0.5f).setDelay(3f).setEaseInOutCirc().setRepeat(6).setLoopPingPong(); + + + // *********** Pause Button ********** + // Drop pause button in + pauseWindow.anchoredPosition3D += new Vector3(0f,200f,0f); + LeanTween.moveY( pauseWindow, pauseWindow.anchoredPosition3D.y + -200f, 0.6f).setEase(LeanTweenType.easeOutSine).setDelay(0.6f); + + // Punch Pause Symbol + RectTransform pauseText = pauseWindow.Find("PauseText").GetComponent(); + LeanTween.moveZ( pauseText, pauseText.anchoredPosition3D.z - 80f, 1.5f).setEase(LeanTweenType.punch).setDelay(2.0f); + + // Rotate rings around in opposite directions + LeanTween.rotateAroundLocal(pauseRing1, Vector3.forward, 360f, 12f).setRepeat(-1); + LeanTween.rotateAroundLocal(pauseRing2, Vector3.forward, -360f, 22f).setRepeat(-1); + + + // *********** Chat Window ********** + // Flip the chat window in + chatWindow.RotateAround(chatWindow.position, Vector3.up, -180f); + LeanTween.rotateAround(chatWindow, Vector3.up, 180f, 2f).setEase(LeanTweenType.easeOutElastic).setDelay(1.2f); + + // Play a series of sprites on the window on repeat endlessly + LeanTween.play(chatRect, chatSprites).setLoopPingPong(); + + // Animate the bar up and down while changing the color to red-ish + LeanTween.color( chatBar2, new Color(248f/255f,67f/255f,108f/255f, 0.5f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong().setDelay(1.2f); + LeanTween.scale( chatBar2, new Vector2(1f,0.7f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong(); + + // Write in paragraph text + string origText = chatText.text; + chatText.text = ""; + LeanTween.value(gameObject, 0, (float)origText.Length, 6f).setEase(LeanTweenType.easeOutQuad).setOnUpdate( (float val)=>{ + chatText.text = origText.Substring( 0, Mathf.RoundToInt( val ) ); + }).setLoopClamp().setDelay(2.0f); + + // Raw Image + LeanTween.alpha(rawImageRect,0f,1f).setLoopPingPong(); + } + +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs.meta new file mode 100644 index 0000000..5f46eea --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/GeneralUISpaceCS.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc2ddccee016148b189d987f564ee08e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs new file mode 100644 index 0000000..4692af8 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using DentedPixel; + +public class LogoCinematic : MonoBehaviour { + + public GameObject lean; + + public GameObject tween; + + void Awake(){ + + } + + + void Start () { + //Time.timeScale = 0.2f; + + // Slide in + tween.transform.localPosition += -Vector3.right * 15f; + LeanTween.moveLocalX(tween, tween.transform.localPosition.x+15f, 0.4f).setEase(LeanTweenType.linear).setDelay(0f).setOnComplete( playBoom ); + + // Drop Down tween down + tween.transform.RotateAround(tween.transform.position, Vector3.forward, -30f); + LeanTween.rotateAround(tween, Vector3.forward, 30f, 0.4f).setEase(LeanTweenType.easeInQuad).setDelay(0.4f).setOnComplete( playBoom ); + + // Drop Lean In + lean.transform.position += Vector3.up * 5.1f; + LeanTween.moveY(lean, lean.transform.position.y-5.1f, 0.6f).setEase(LeanTweenType.easeInQuad).setDelay(0.6f).setOnComplete( playBoom ); + } + + void playBoom(){ + // Make your own Dynamic Audio at http://leanaudioplay.dentedpixel.com + + AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1.163155f, 0f, -1f), new Keyframe(0.3098361f, 0f, 0f, 0f), new Keyframe(0.5f, 0.003524712f, 0f, 0f)); + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0.000819672f, 0.007666667f, 0f, 0f), new Keyframe(0.01065573f, 0.002424242f, 0f, 0f), new Keyframe(0.02704918f, 0.007454545f, 0f, 0f), new Keyframe(0.03770492f, 0.002575758f, 0f, 0f), new Keyframe(0.052459f, 0.007090909f, 0f, 0f), new Keyframe(0.06885245f, 0.002939394f, 0f, 0f), new Keyframe(0.0819672f, 0.006727273f, 0f, 0f), new Keyframe(0.1040983f, 0.003181818f, 0f, 0f), new Keyframe(0.1188525f, 0.006212121f, 0f, 0f), new Keyframe(0.145082f, 0.004151515f, 0f, 0f), new Keyframe(0.1893443f, 0.005636364f, 0f, 0f)); + + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.1f,0f,0f)} ).setFrequency(11025)); + + LeanAudio.play( audioClip ); //a:fvb:8,.000819672,.007666667,,,.01065573,.002424242,,,.02704918,.007454545,,,.03770492,.002575758,,,.052459,.007090909,,,.06885245,.002939394,,,.0819672,.006727273,,,.1040983,.003181818,,,.1188525,.006212121,,,.145082,.004151515,,,.1893443,.005636364,,,8~8,,1.163155,,-,.3098361,,,,.5,.003524712,,,8~.1,,,~11025~0~~ + } + +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs.meta new file mode 100644 index 0000000..3bc70a2 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/LogoCinematic.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 674f3c10d8880408e875a9e6c3ee83bb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs new file mode 100644 index 0000000..2b8317d --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +namespace DentedPixel.LTExamples{ + +public class PathBezier : MonoBehaviour { + + public Transform[] trans; + + LTBezierPath cr; + private GameObject avatar1; + + void OnEnable(){ + // create the path + cr = new LTBezierPath( new Vector3[] {trans[0].position, trans[2].position, trans[1].position, trans[3].position, trans[3].position, trans[5].position, trans[4].position, trans[6].position} ); + } + + void Start () { + avatar1 = GameObject.Find("Avatar1"); + + // Tween automatically + LTDescr descr = LeanTween.move(avatar1, cr.pts, 6.5f).setOrientToPath(true).setRepeat(-1); + Debug.Log("length of path 1:"+cr.length); + Debug.Log("length of path 2:"+descr.optional.path.length); + } + + private float iter; + void Update () { + // Or Update Manually + //cr.place2d( sprite1.transform, iter ); + + iter += Time.deltaTime*0.07f; + if(iter>1.0f) + iter = 0.0f; + } + + void OnDrawGizmos(){ + // Debug.Log("drwaing"); + if(cr!=null) + OnEnable(); + Gizmos.color = Color.red; + if(cr!=null) + cr.gizmoDraw(); // To Visualize the path, use this method + } +} + +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs.meta new file mode 100644 index 0000000..56435b7 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathBezier.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ac2038ba3961049ed889ae71039982cd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js new file mode 100644 index 0000000..0e9c834 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js @@ -0,0 +1,32 @@ +#pragma strict +import DentedPixel; + +public var customAnimationCurve:AnimationCurve; + +public var pt1:Transform; +public var pt2:Transform; +public var pt3:Transform; +public var pt4:Transform; + +private var containingSphere:Transform; +private var spline:LTSpline; +private var ltLogo:GameObject; + +function Start () { + ltLogo = GameObject.Find("LeanTweenLogo"); + containingSphere = GameObject.Find("ContaingCube").transform; + + var path:Vector3[] = [pt1.position,pt1.position,pt2.position,pt3.position,pt4.position,pt4.position]; + spline = new LTSpline( path ); + LeanTween.moveSplineLocal( ltLogo, path, 3.0 ).setEase(LeanTweenType.easeInQuad).setOrientToPath(true).setRepeat(-1); +} + +function Update(){ + containingSphere.transform.eulerAngles.y += Time.deltaTime*3.0; +} + +function OnDrawGizmos(){ + if(spline!=null) + spline.gizmoDraw(1.0f); // debug aid to be able to see the path in the scene inspector +} + diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js.meta new file mode 100644 index 0000000..80088da --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathLocalCurveJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 89833bacbefcb4e899edf31253b2e23f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs new file mode 100644 index 0000000..a928a58 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs @@ -0,0 +1,38 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class ExampleSpline : MonoBehaviour { + + public Transform[] trans; + + LTSpline spline; + private GameObject ltLogo; + private GameObject ltLogo2; + + void Start () { + spline = new LTSpline( new Vector3[] {trans[0].position, trans[1].position, trans[2].position, trans[3].position, trans[4].position} ); + ltLogo = GameObject.Find("LeanTweenLogo1"); + ltLogo2 = GameObject.Find("LeanTweenLogo2"); + + LeanTween.moveSpline( ltLogo2, spline.pts, 1f).setEase(LeanTweenType.easeInOutQuad).setLoopPingPong().setOrientToPath(true); + + LTDescr zoomInPath_LT = LeanTween.moveSpline(ltLogo2, new Vector3[]{Vector3.zero, Vector3.zero, new Vector3(1,1,1), new Vector3(2,1,1), new Vector3(2,1,1)}, 1.5f); + zoomInPath_LT.setUseEstimatedTime(true); + } + + private float iter; + void Update () { + // Iterating over path + ltLogo.transform.position = spline.point( iter /*(Time.time*1000)%1000 * 1.0 / 1000.0 */); + + iter += Time.deltaTime*0.1f; + if(iter>1.0f) + iter = 0.0f; + } + + void OnDrawGizmos(){ + if(spline!=null) + spline.gizmoDraw(); // debug aid to be able to see the path in the scene inspector + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs.meta new file mode 100644 index 0000000..fd4e012 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ef4235237d8d8413c9d5807cf0a1f77b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs new file mode 100644 index 0000000..58718fb --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class PathSpline2d : MonoBehaviour { + + public Transform[] trans; + public Texture2D spriteTexture; + + LTSpline cr; + private GameObject sprite1; + private GameObject sprite2; + + void Start () { + cr = new LTSpline( new Vector3[] {trans[0].position, trans[1].position, trans[2].position, trans[3].position, trans[4].position} ); + sprite1 = GameObject.Find("sprite1"); + sprite2 = GameObject.Find("sprite2"); + #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) + sprite1.AddComponent(); + sprite1.GetComponent().sprite = Sprite.Create( spriteTexture, new Rect(0.0f,0.0f,100.0f,100.0f), new Vector2(50.0f,50.0f), 10.0f); + sprite2.AddComponent(); + sprite2.GetComponent().sprite = Sprite.Create( spriteTexture, new Rect(0.0f,0.0f,100.0f,100.0f), new Vector2(0.0f,0.0f), 10.0f); + #endif + // LeanTween.moveSpline( ltLogo2, new Vector3[] {trans[0].position, trans[1].position, trans[2].position, trans[3].position, trans[4].position}, 1f).setEase(LeanTweenType.easeInOutQuad).setLoopPingPong().setOrientToPath(true); + + LTDescr zoomInPath_LT = LeanTween.moveSpline(sprite2, new Vector3[]{Vector3.zero, Vector3.zero, new Vector3(1,1,1), new Vector3(2,1,1), new Vector3(2,1,1)}, 1.5f).setOrientToPath2d(true); + zoomInPath_LT.setUseEstimatedTime(true); + } + + private float iter; + void Update () { + cr.place2d( sprite1.transform, iter ); + + iter += Time.deltaTime*0.1f; + if(iter>1.0f) + iter = 0.0f; + } + + void OnDrawGizmos(){ + if(cr!=null) + cr.gizmoDraw(); + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs.meta new file mode 100644 index 0000000..e23a2f0 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSpline2d.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 15c036b11e3ff486ea685da06fa305f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs new file mode 100644 index 0000000..f8336b9 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs @@ -0,0 +1,125 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using DentedPixel; + +public class PathSplineEndlessCS : MonoBehaviour { + public GameObject trackTrailRenderers; + public GameObject car; + public GameObject carInternal; + + public GameObject[] cubes; + private int cubesIter; + public GameObject[] trees; + private int treesIter; + + public float randomIterWidth = 0.1f; + + private LTSpline track; + private List trackPts = new List(); + private int zIter = 0; + private float carIter = 0f; + private float carAdd; + private int trackMaxItems = 15; + private int trackIter = 1; + private float pushTrackAhead = 0f; + private float randomIter = 0f; + + void Start () { + + // Setup initial track points + for(int i = 0; i < 4; i++){ + addRandomTrackPoint(); + } + refreshSpline(); + + // Animate in track ahead of the car + LeanTween.value(gameObject, 0, 0.3f, 2f).setOnUpdate( ( float val )=>{ + pushTrackAhead = val; + }); + } + + void Update () { + + float zLastDist = (trackPts[ trackPts.Count - 1].z - transform.position.z); + if(zLastDist < 200f){ // if the last node is too close we'll add in a new point and refresh the spline + addRandomTrackPoint(); + refreshSpline(); + } + + // Update avatar's position on correct track + track.place( car.transform, carIter ); + carIter += carAdd * Time.deltaTime; + + // we'll place the trail renders always a bit in front of the car + track.place( trackTrailRenderers.transform, carIter + pushTrackAhead ); + + + // Switch tracks on keyboard input + float turn = Input.GetAxis("Horizontal"); + if(Input.anyKeyDown){ + if(turn<0f && trackIter>0){ + trackIter--; + playSwish(); + }else if(turn>0f && trackIter < 2){ // We have three track "rails" so stopping it from going above 3 + trackIter++; + playSwish(); + } + // Move the internal local x of the car to simulate changing tracks + LeanTween.moveLocalX(carInternal, (trackIter-1)*6f, 0.3f).setEase(LeanTweenType.easeOutBack); + } + } + + // Simple object queuing system + GameObject objectQueue( GameObject[] arr, ref int lastIter ){ + lastIter = lastIter>=arr.Length-1 ? 0 : lastIter+1; + + // Reset scale and rotation for a new animation + arr[ lastIter ].transform.localScale = Vector3.one; + arr[ lastIter ].transform.rotation = Quaternion.identity; + return arr[ lastIter ]; + } + + void addRandomTrackPoint(){ + float randX = Mathf.PerlinNoise(0f, randomIter); + randomIter += randomIterWidth; + + Vector3 randomInFrontPosition = new Vector3( (randX-0.5f)*20f, 0f, zIter*40f); + + // placing the box is just to visualize how the paths get created + GameObject box = objectQueue( cubes, ref cubesIter ); + box.transform.position = randomInFrontPosition; + + // Line the roads with trees + GameObject tree = objectQueue( trees, ref treesIter ); + float treeX = zIter%2==0 ? -15f : 15f; + tree.transform.position = new Vector3( randomInFrontPosition.x + treeX, 0f, zIter*40f); + + // Animate in new tree (just for fun) + LeanTween.rotateAround( tree, Vector3.forward, 0f, 1f).setFrom( zIter%2==0 ? 180f : -180f).setEase(LeanTweenType.easeOutBack); + + trackPts.Add( randomInFrontPosition ); // Add a future spline node + if(trackPts.Count > trackMaxItems) + trackPts.RemoveAt(0); // Remove the trailing spline node + + zIter++; + } + + void refreshSpline(){ + track = new LTSpline( trackPts.ToArray() ); + carIter = track.ratioAtPoint( car.transform.position ); // we created a new spline so we need to update the cars iteration point on this new spline + // Debug.Log("distance:"+track.distance+" carIter:"+carIter); + carAdd = 40f / track.distance; // we want to make sure the speed is based on the distance of the spline for a more constant speed + } + + // Make your own LeanAudio sounds at http://leanaudioplay.dentedpixel.com + void playSwish(){ + AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 0.005464481f, 1.83897f, 0f), new Keyframe(0.1114856f, 2.281785f, 0f, 0f), new Keyframe(0.2482903f, 2.271654f, 0f, 0f), new Keyframe(0.3f, 0.01670286f, 0f, 0f)); + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.00136725f, 0f, 0f), new Keyframe(0.1482391f, 0.005405405f, 0f, 0f), new Keyframe(0.2650336f, 0.002480127f, 0f, 0f)); + + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.2f,0.5f,0f)} ).setWaveNoise().setWaveNoiseScale(1000)); + + LeanAudio.play( audioClip ); //a:fvb:8,,.00136725,,,.1482391,.005405405,,,.2650336,.002480127,,,8~8,,.005464481,1.83897,,.1114856,2.281785,,,.2482903,2.271654,,,.3,.01670286,,,8~.2,.5,,~~0~~3,1000,1 + } + +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs.meta new file mode 100644 index 0000000..15fe013 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineEndlessCS.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 784f0e347ee4d4c3b83ca56d6f33f01a +timeCreated: 1460315101 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs new file mode 100644 index 0000000..cad5453 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs @@ -0,0 +1,93 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using DentedPixel; +// This class is to test the upper limits of a complex spline + +public class PathSplinePerformanceCS : MonoBehaviour { + + public GameObject trackTrailRenderers; + public GameObject car; + public GameObject carInternal; + + + public float circleLength = 10f; + public float randomRange = 1f; + public int trackNodes = 30; + public float carSpeed = 30f; + public float tracerSpeed = 2f; + + private LTSpline track; + private int trackIter = 1; + private float carAdd; + private float trackPosition; // ratio 0,1 of the avatars position on the track + + void Start () { + Application.targetFrameRate = 240; + + // Make the track from the provided transforms + List randList = new List(); + float degree = 0f; + int nodeLength = trackNodes + 1;// We need to add some extra because the first and last nodes just act as *guides* to the first and last curvature + for(int i = 0; i < nodeLength; i++){ + float x = Mathf.Cos( degree * Mathf.Deg2Rad ) * circleLength + Random.Range(0f, randomRange); + float z = Mathf.Sin( degree * Mathf.Deg2Rad ) * circleLength + Random.Range(0f, randomRange); + randList.Add( new Vector3(x,1f,z ) ); + + degree += 360f/(float)trackNodes; + } + randList[0] = randList[ randList.Count-1 ]; // set the zero-ith one as the last position so it will flow smoothly into the first curve + randList.Add( randList[1] ); // Add the first and second one in, so the circle connects to itself + randList.Add( randList[2] ); + + track = new LTSpline( randList.ToArray() ); + + carAdd = carSpeed / track.distance; + + tracerSpeed = track.distance / (carSpeed*1.2f); + + // Optional technique to show the trails in game + LeanTween.moveSpline( trackTrailRenderers, track, tracerSpeed ).setOrientToPath(true).setRepeat(-1); + } + + void Update () { + // Switch tracks on keyboard input + float turn = Input.GetAxis("Horizontal"); + if(Input.anyKeyDown){ + if(turn<0f && trackIter>0){ + trackIter--; + playSwish(); + }else if(turn>0f && trackIter < 2){ // We have three track "rails" so stopping it from going above 3 + trackIter++; + playSwish(); + } + // Move the internal local x of the car to simulate changing tracks + LeanTween.moveLocalX(carInternal, (trackIter-1)*6f, 0.3f).setEase(LeanTweenType.easeOutBack); + + } + + // Update avatar's position on correct track + track.place( car.transform, trackPosition ); + + trackPosition += Time.deltaTime * carAdd; + + if(trackPosition>1f) + trackPosition = 0f; // We need to keep the ratio between 0-1 so after one we will loop back to the beginning of the track + } + + // Use this for visualizing what the track looks like in the editor (for a full suite of spline tools check out the LeanTween Editor) + void OnDrawGizmos(){ + if(track!=null) + track.drawGizmo( Color.red ); + } + + // Make your own LeanAudio sounds at http://leanaudioplay.dentedpixel.com + void playSwish(){ + AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 0.005464481f, 1.83897f, 0f), new Keyframe(0.1114856f, 2.281785f, 0f, 0f), new Keyframe(0.2482903f, 2.271654f, 0f, 0f), new Keyframe(0.3f, 0.01670286f, 0f, 0f)); + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.00136725f, 0f, 0f), new Keyframe(0.1482391f, 0.005405405f, 0f, 0f), new Keyframe(0.2650336f, 0.002480127f, 0f, 0f)); + + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.2f,0.5f,0f)} ).setWaveNoise().setWaveNoiseScale(1000)); + + LeanAudio.play( audioClip ); //a:fvb:8,,.00136725,,,.1482391,.005405405,,,.2650336,.002480127,,,8~8,,.005464481,1.83897,,.1114856,2.281785,,,.2482903,2.271654,,,.3,.01670286,,,8~.2,.5,,~~0~~3,1000,1 + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs.meta new file mode 100644 index 0000000..bbef093 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplinePerformanceCS.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5de62495c8a5d49e6b3ca111f8c7e944 +timeCreated: 1460894008 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs new file mode 100644 index 0000000..357431b --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs @@ -0,0 +1,68 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +// This project demonstrates how you can use the spline behaviour for a multi-track game (like an endless runner style) + +public class PathSplineTrackCS : MonoBehaviour { + + public GameObject car; + public GameObject carInternal; + public GameObject trackTrailRenderers; + + public Transform[] trackOnePoints; + + private LTSpline track; + private int trackIter = 1; + private float trackPosition; // ratio 0,1 of the avatars position on the track + + void Start () { + // Make the track from the provided transforms + track = new LTSpline( new Vector3[] {trackOnePoints[0].position, trackOnePoints[1].position, trackOnePoints[2].position, trackOnePoints[3].position, trackOnePoints[4].position, trackOnePoints[5].position, trackOnePoints[6].position} ); + + // Optional technique to show the trails in game + LeanTween.moveSpline( trackTrailRenderers, track, 2f ).setOrientToPath(true).setRepeat(-1); + } + + void Update () { + // Switch tracks on keyboard input + float turn = Input.GetAxis("Horizontal"); + if(Input.anyKeyDown){ + if(turn<0f && trackIter>0){ + trackIter--; + playSwish(); + }else if(turn>0f && trackIter < 2){ // We have three track "rails" so stopping it from going above 3 + trackIter++; + playSwish(); + } + // Move the internal local x of the car to simulate changing tracks + LeanTween.moveLocalX(carInternal, (trackIter-1)*6f, 0.3f).setEase(LeanTweenType.easeOutBack); + + } + + // Update avatar's position on correct track + track.place( car.transform, trackPosition ); + + trackPosition += Time.deltaTime * 0.03f;// * Input.GetAxis("Vertical"); // Uncomment to have the forward and backwards controlled by the directional arrows + + if (trackPosition < 0f) // We need to keep the ratio between 0-1 so after one we will loop back to the beginning of the track + trackPosition = 1f; + else if(trackPosition>1f) + trackPosition = 0f; + } + + // Use this for visualizing what the track looks like in the editor (for a full suite of spline tools check out the LeanTween Editor) + void OnDrawGizmos(){ + LTSpline.drawGizmo( trackOnePoints, Color.red); + } + + // Make your own LeanAudio sounds at http://leanaudioplay.dentedpixel.com + void playSwish(){ + AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 0.005464481f, 1.83897f, 0f), new Keyframe(0.1114856f, 2.281785f, 0f, 0f), new Keyframe(0.2482903f, 2.271654f, 0f, 0f), new Keyframe(0.3f, 0.01670286f, 0f, 0f)); + AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.00136725f, 0f, 0f), new Keyframe(0.1482391f, 0.005405405f, 0f, 0f), new Keyframe(0.2650336f, 0.002480127f, 0f, 0f)); + + AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.2f,0.5f,0f)} ).setWaveNoise().setWaveNoiseScale(1000)); + + LeanAudio.play( audioClip ); //a:fvb:8,,.00136725,,,.1482391,.005405405,,,.2650336,.002480127,,,8~8,,.005464481,1.83897,,.1114856,2.281785,,,.2482903,2.271654,,,.3,.01670286,,,8~.2,.5,,~~0~~3,1000,1 + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs.meta new file mode 100644 index 0000000..d41a6dd --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplineTrackCS.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 31af73f8be2864eda9a3fbb6d0d2a9c7 +timeCreated: 1460209336 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs new file mode 100644 index 0000000..8df95b9 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using System.Collections; +using DentedPixel; + +public class PathSplines : MonoBehaviour { + + public Transform[] trans; + + LTSpline cr; + private GameObject avatar1; + + void OnEnable(){ + // create the path + cr = new LTSpline( new Vector3[] {trans[0].position, trans[1].position, trans[2].position, trans[3].position, trans[4].position} ); + // cr = new LTSpline( new Vector3[] {new Vector3(-1f,0f,0f), new Vector3(0f,0f,0f), new Vector3(4f,0f,0f), new Vector3(20f,0f,0f), new Vector3(30f,0f,0f)} ); + } + + void Start () { + avatar1 = GameObject.Find("Avatar1"); + + // Tween automatically + LeanTween.move(avatar1, cr, 6.5f).setOrientToPath(true).setRepeat(1).setOnComplete( ()=>{ + Vector3[] next = new Vector3[] {trans[4].position, trans[3].position, trans[2].position, trans[1].position, trans[0].position}; + LeanTween.moveSpline( avatar1, next, 6.5f); // move it back to the start without an LTSpline + }).setEase(LeanTweenType.easeOutQuad); + } + + private float iter; + void Update () { + // Or Update Manually + // cr.place( avatar1.transform, iter ); + + iter += Time.deltaTime*0.07f; + if(iter>1.0f) + iter = 0.0f; + } + + void OnDrawGizmos(){ + // Debug.Log("drwaing"); + if(cr==null) + OnEnable(); + Gizmos.color = Color.red; + if(cr!=null) + cr.gizmoDraw(); // To Visualize the path, use this method + } +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs.meta new file mode 100644 index 0000000..0ccb4fe --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/PathSplines.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: de0396ae3eef541c190f0e6962090454 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js new file mode 100644 index 0000000..05f2de1 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js @@ -0,0 +1,186 @@ + #pragma strict + import DentedPixel; + +public var customAnimationCurve:AnimationCurve; +public var shakeCurve:AnimationCurve; + +public var pt1:Transform; +public var pt2:Transform; +public var pt3:Transform; +public var pt4:Transform; +public var pt5:Transform; + +function Awake(){ + LeanTween.init(400); // This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective. +} + +function Start () { + ltLogo = GameObject.Find("LeanTweenLogo"); + cycleThroughExamples(); + //LeanTween.delayedCall(1.0f, cycleThroughExamples); + // loopTestClamp(); + // loopTestPingPong(); + // LeanTween.delayedCall(2.6, loopPause); + // LeanTween.delayedCall(4.5, loopResume); + // LeanTween.delayedCall(1.5, loopCancel); +} + +function OnGUI(){ + GUI.Label(Rect(0.03*Screen.width,0.03*Screen.height,0.5*Screen.width,0.3*Screen.height), "useEstimatedTime:"+useEstimatedTime); +} + +private var exampleIter:int = 0; +private var exampleFunctions = [updateValue3Example,loopTestPingPong,loopTestClamp,moveOnACurveExample,punchTest, customTweenExample, moveExample, rotateExample, scaleExample, updateValueExample, alphaExample, moveLocalExample, delayedCallExample, rotateAroundExample]; +private var useEstimatedTime:boolean = true; +private var ltLogo:GameObject; +private var cube1:GameObject; +private var cube2:GameObject; + +function cycleThroughExamples(){ + + if(exampleIter==0){ + useEstimatedTime = !useEstimatedTime; + Time.timeScale = useEstimatedTime ? 0 : 1; // pause the Time Scale to show the effectiveness of the useEstimatedTime feature (this is very usefull with Pause Screens) + } + exampleFunctions[ exampleIter ](); + exampleIter = exampleIter+1>=exampleFunctions.length ? 0 : exampleIter + 1; + + LeanTween.delayedCall( 1.05, cycleThroughExamples).setUseEstimatedTime(useEstimatedTime); +} + +function updateValue3Example(){ + Debug.Log("updateValue3Example"); + LeanTween.value( ltLogo, updateValue3ExampleCallback, new Vector3(0.0, 270.0, 0.0), new Vector3(30.0, 270.0, 180), 0.5).setEase(LeanTweenType.easeInBounce).setLoopPingPong().setRepeat(2).setOnUpdateVector3(updateValue3ExampleUpdate).setUseEstimatedTime(useEstimatedTime); +} + +function updateValue3ExampleUpdate( val:Vector3 ){ + Debug.Log("val:"+val); +} + +function updateValue3ExampleCallback( val:Vector3 ){ + ltLogo.transform.eulerAngles = val; +} + +function loopTestClamp(){ + Debug.Log("loopTestClamp"); + cube1 = GameObject.Find("Cube1"); + cube1.transform.localScale.z = 1.0; + moveId = LeanTween.scaleZ( cube1, 4.0, 1.0).setEase(LeanTweenType.easeOutElastic).setLoopClamp().setRepeat(7).setUseEstimatedTime(useEstimatedTime); +} + +function loopTestPingPong(){ + Debug.Log("loopTestPingPong"); + cube2 = GameObject.Find("Cube2"); + cube2.transform.localScale.y = 1.0; + pingPongDescrId = LeanTween.scaleY( cube2, 4.0, 1.0).setEase(LeanTweenType.easeOutQuad).setLoopPingPong(4).setUseEstimatedTime(useEstimatedTime).id; +} + +function moveOnACurveExample(){ + Debug.Log("moveOnACurveExample"); + var path:Vector3[] = [ltLogo.transform.position,pt1.position,pt2.position,pt3.position,pt3.position,pt4.position,pt5.position,ltLogo.transform.position]; + LeanTween.move( ltLogo, path, 1.0).setEase(LeanTweenType.easeInQuad).setOrientToPath(true).setUseEstimatedTime(useEstimatedTime); +} + +function punchTest(){ + LeanTween.moveX( ltLogo, 7, 1.0).setEase(LeanTweenType.punch).setUseEstimatedTime(useEstimatedTime); +} + +function customTweenExample(){ + Debug.Log("customTweenExample"); + + LeanTween.moveX( ltLogo, -10, 0.5).setEase(customAnimationCurve).setUseEstimatedTime(useEstimatedTime); + LeanTween.moveX( ltLogo, 0, 0.5).setDelay(0.5).setEase(customAnimationCurve).setUseEstimatedTime(useEstimatedTime); +} + +function moveExample(){ + Debug.Log("moveExample"); + + LeanTween.move( ltLogo, new Vector3(-2f,-1f,0f), 0.5f).setUseEstimatedTime(useEstimatedTime); + LeanTween.move( ltLogo, ltLogo.transform.position, 0.5f).setDelay(0.5).setUseEstimatedTime(useEstimatedTime); +} + +function rotateExample(){ + Debug.Log("rotateExample"); + + LeanTween.rotate( ltLogo, Vector3(0,360,0), 1.0).setEase(LeanTweenType.easeOutQuad).setUseEstimatedTime(useEstimatedTime); +} + +function scaleExample(){ + Debug.Log("scaleExample"); + + var currentScale:Vector3 = ltLogo.transform.localScale; + LeanTween.scale( ltLogo, new Vector3(currentScale.x+0.2,currentScale.y+0.2,currentScale.z+0.2), 1).setEase(LeanTweenType.easeOutBounce).setUseEstimatedTime(useEstimatedTime); +} + +function updateValueExample(){ + Debug.Log("updateValueExample"); + LeanTween.value( ltLogo, updateValueExampleCallback, ltLogo.transform.eulerAngles.y, 270.0, 1).setEase(LeanTweenType.easeOutElastic).setUseEstimatedTime(useEstimatedTime); +} + +function updateValueExampleCallback( val:float ){ + ltLogo.transform.eulerAngles.y = val; +} + +function delayedCallExample(){ + Debug.Log("delayedCallExample"); + + LeanTween.delayedCall(0.5, delayedCallExampleCallback).setUseEstimatedTime(useEstimatedTime); + // LeanTween.delayedCall(gameObject, 1, delayedCallCallback); // pass an object of type GameObject value in case you want the tween to quit if this gameObject is ever destroyed (this is useful with tweens the might be interrupted when a new level is loaded). +} + +function delayedCallExampleCallback(){ + Debug.Log("Delayed function was called"); + var currentScale:Vector3 = gameObject.transform.localScale; + LeanTween.scale( ltLogo, new Vector3(currentScale.x-0.2,currentScale.y-0.2,currentScale.z-0.2), 0.5).setEase(LeanTweenType.easeInOutCirc).setUseEstimatedTime(useEstimatedTime); +} + +function alphaExample(){ + Debug.Log("alphaExample"); + + var cube:GameObject = GameObject.Find ("LCharacter"); + LeanTween.alpha( cube, 0.0f, 0.5f).setUseEstimatedTime(useEstimatedTime); + LeanTween.alpha( cube, 1.0f, 0.5f).setDelay(0.5f).setUseEstimatedTime(useEstimatedTime); +} + +function moveLocalExample(){ + Debug.Log("moveLocalExample"); + + var cube:GameObject = GameObject.Find ("LCharacter"); + var origPos:Vector3 = cube.transform.localPosition; + LeanTween.moveLocal( cube, new Vector3(0.0f,2.0f,0.0f), 0.5f).setUseEstimatedTime(useEstimatedTime); + LeanTween.moveLocal( cube, origPos, 0.5f).setDelay(0.5f).setUseEstimatedTime(useEstimatedTime); +} + +function rotateAroundExample(){ + Debug.Log("rotateAroundExample"); + + var cube:GameObject = GameObject.Find ("LCharacter"); + LeanTween.rotateAround( cube, Vector3.up, 360.0f, 1.0f ).setUseEstimatedTime(useEstimatedTime); +} + +function moveXExample(){ + LeanTween.moveX( ltLogo, 5, 0.5); +} + +function rotateXExample(){ + +} + +function scaleXExample(){ + +} + +private var moveId:LTDescr; +private var pingPongDescrId:int; + +function loopPause(){ + moveId.pause(); +} + +function loopResume(){ + moveId.resume(); +} + +function loopCancel(){ + LeanTween.cancel( pingPongDescrId ); +} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js.meta new file mode 100644 index 0000000..8ced56f --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingAllJS.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 99269cf0e003f4484a404bac166139ae +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs new file mode 100644 index 0000000..70bfa92 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs @@ -0,0 +1,521 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using DentedPixel; + +namespace DentedPixel.LTExamples{ + + public class TestingUnitTests : MonoBehaviour { + + public GameObject cube1; + public GameObject cube2; + public GameObject cube3; + public GameObject cube4; + public GameObject cubeAlpha1; + public GameObject cubeAlpha2; + + + private bool eventGameObjectWasCalled = false, eventGeneralWasCalled = false; + private int lt1Id; + private LTDescr lt2; + private LTDescr lt3; + private LTDescr lt4; + private LTDescr[] groupTweens; + private GameObject[] groupGOs; + private int groupTweensCnt; + private int rotateRepeat; + private int rotateRepeatAngle; + private GameObject boxNoCollider; + private float timeElapsedNormalTimeScale; + private float timeElapsedIgnoreTimeScale; + + void Awake(){ + boxNoCollider = GameObject.CreatePrimitive(PrimitiveType.Cube); + Destroy( boxNoCollider.GetComponent( typeof(BoxCollider) ) as Component ); + } + + void Start () { +// Time.timeScale = 0.25f; + + LeanTest.timeout = 46f; + LeanTest.expected = 56; + + LeanTween.init(15 + 1200); + + // add a listener + LeanTween.addListener(cube1, 0, eventGameObjectCalled); + + LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING" ); + + LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING" ); + + LeanTween.scaleX( cube4, 2f, 0f).setOnComplete( ()=>{ + LeanTest.expect( cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME" ); + }); + + // dispatch event that is received + LeanTween.dispatchEvent(0); + LeanTest.expect( eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED" ); + + // do not remove listener + LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled)==false, "EVENT GAMEOBJECT NOT REMOVED" ); + // remove listener + LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED" ); + + // add a listener + LeanTween.addListener(1, eventGeneralCalled); + + // dispatch event that is received + LeanTween.dispatchEvent(1); + LeanTest.expect( eventGeneralWasCalled, "EVENT ALL RECEIVED" ); + + // remove listener + LeanTest.expect( LeanTween.removeListener( 1, eventGeneralCalled), "EVENT ALL REMOVED" ); + + lt1Id = LeanTween.move( cube1, new Vector3(3f,2f,0.5f), 1.1f ).id; + LeanTween.move( cube2, new Vector3(-3f,-2f,-0.5f), 1.1f ); + + LeanTween.reset(); + + // Queue up a bunch of tweens, cancel some of them but expect the remainder to finish + GameObject[] cubes = new GameObject[99]; + int[] tweenIds = new int[cubes.Length]; + for (int i = 0; i < cubes.Length; i++) { + GameObject c = cubeNamed("cancel"+i); + tweenIds[i] = LeanTween.moveX (c, 100f, 1f).id; + cubes [i] = c; + } + int onCompleteCount = 0; + LeanTween.delayedCall (cubes[0], 0.2f, () => { + for (int i = 0; i < cubes.Length; i++) { + if(i%3==0){ + LeanTween.cancel( cubes [i] ); + }else if(i%3==1){ + LeanTween.cancel( tweenIds[i] ); + }else if(i%3==2){ + LTDescr descr = LeanTween.descr(tweenIds[i]); +// Debug.Log("descr:"+descr); + descr.setOnComplete( ()=>{ + onCompleteCount++; +// Debug.Log("onCompleteCount:"+onCompleteCount); + if(onCompleteCount>=33){ + LeanTest.expect(true, "CANCELS DO NOT EFFECT FINISHING" ); + } + }); + } + } + }); + + Vector3[] splineArr = new Vector3[] {new Vector3(-1f,0f,0f), new Vector3(0f,0f,0f), new Vector3(4f,0f,0f), new Vector3(20f,0f,0f), new Vector3(30f,0f,0f)}; + LTSpline cr = new LTSpline( splineArr ); + cr.place( cube4.transform, 0.5f ); + LeanTest.expect( (Vector3.Distance( cube4.transform.position, new Vector3(10f,0f,0f) ) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:"+cube4.transform.position+" but should be:(10f,0f,0f)"); + LeanTween.color(cube4, Color.green, 0.01f); + +// Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2])); + + // OnStart Speed Test for ignoreTimeScale vs normal timeScale + + GameObject cubeDest = cubeNamed("cubeDest"); + Vector3 cubeDestEnd = new Vector3(100f,20f,0f); + LeanTween.move( cubeDest, cubeDestEnd, 0.7f); + + GameObject cubeToTrans = cubeNamed("cubeToTrans"); + LeanTween.move( cubeToTrans, cubeDest.transform, 1.2f).setEase( LeanTweenType.easeOutQuad ).setOnComplete( ()=>{ + LeanTest.expect( cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS"); + }); + + GameObject cubeDestroy = cubeNamed("cubeDestroy"); + LeanTween.moveX( cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true); + LeanTween.moveX( cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete( ()=>{ + LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED"); + }); + + GameObject cubeSpline = cubeNamed("cubeSpline"); + LeanTween.moveSpline(cubeSpline, new Vector3[]{new Vector3(0.5f,0f,0.5f),new Vector3(0.75f,0f,0.75f),new Vector3(1f,0f,1f),new Vector3(1f,0f,1f)}, 0.1f).setOnComplete( ()=>{ + LeanTest.expect(Vector3.Distance(new Vector3(1f,0f,1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS"); + }); + + // This test works when it is positioned last in the test queue (probably worth fixing when you have time) + GameObject jumpCube = cubeNamed("jumpTime"); + jumpCube.transform.position = new Vector3(100f,0f,0f); + jumpCube.transform.localScale *= 100f; + int jumpTimeId = LeanTween.moveX( jumpCube, 200f, 1f).id; + + LeanTween.delayedCall(gameObject, 0.2f, ()=>{ + LTDescr d = LeanTween.descr( jumpTimeId ); + float beforeX = jumpCube.transform.position.x; + d.setTime( 0.5f ); + LeanTween.delayedCall( 0.0f, ()=>{ }).setOnStart( ()=>{ + float diffAmt = 1f;// This variable is dependent on a good frame-rate because it evalutes at the next Update + beforeX += Time.deltaTime * 100f * 2f; + LeanTest.expect( Mathf.Abs( jumpCube.transform.position.x - beforeX ) < diffAmt , "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:"+Mathf.Abs( jumpCube.transform.position.x - beforeX ) +" beforeX:"+beforeX+" now:"+jumpCube.transform.position.x+" dt:"+Time.deltaTime); + }); + }); + + // Tween with time of zero is needs to be set to it's final value + GameObject zeroCube = cubeNamed("zeroCube"); + LeanTween.moveX( zeroCube, 10f, 0f).setOnComplete( ()=>{ + LeanTest.expect( zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:"+ zeroCube.transform.position.x); + }); + + // Scale, and OnStart + GameObject cubeScale = cubeNamed("cubeScale"); + LeanTween.scale(cubeScale, new Vector3(5f,5f,5f),0.01f).setOnStart(()=>{ + LeanTest.expect( true, "ON START WAS CALLED"); + }).setOnComplete(()=>{ + LeanTest.expect( cubeScale.transform.localScale.z == 5f, "SCALE","expected scale z:"+5f+" returned:"+cubeScale.transform.localScale.z); + }); + + // Rotate + GameObject cubeRotate = cubeNamed("cubeRotate"); + LeanTween.rotate(cubeRotate, new Vector3(0f,180f,0f),0.02f).setOnComplete(()=>{ + LeanTest.expect( cubeRotate.transform.eulerAngles.y == 180f, "ROTATE","expected rotate y:"+180f+" returned:"+cubeRotate.transform.eulerAngles.y); + }); + + // RotateAround + GameObject cubeRotateA = cubeNamed("cubeRotateA"); + LeanTween.rotateAround(cubeRotateA,Vector3.forward,90f,0.3f).setOnComplete(()=>{ + LeanTest.expect( cubeRotateA.transform.eulerAngles.z==90f, "ROTATE AROUND","expected rotate z:"+90f+" returned:"+cubeRotateA.transform.eulerAngles.z); + }); + + // RotateAround 360 + GameObject cubeRotateB = cubeNamed("cubeRotateB"); + cubeRotateB.transform.position = new Vector3(200f,10f,8f); + LeanTween.rotateAround(cubeRotateB,Vector3.forward,360f,0.3f).setPoint(new Vector3(5f,3f,2f)).setOnComplete(()=>{ + LeanTest.expect( cubeRotateB.transform.position.ToString()==(new Vector3(200f,10f,8f)).ToString(), "ROTATE AROUND 360","expected rotate pos:"+(new Vector3(200f,10f,8f))+" returned:"+cubeRotateB.transform.position); + }); + + // Alpha, onUpdate with passing value, onComplete value + LeanTween.alpha(cubeAlpha1,0.5f,0.1f).setOnUpdate( (float val)=>{ + LeanTest.expect(val!=0f ,"ON UPDATE VAL"); + }).setOnCompleteParam( "Hi!" ).setOnComplete( (object completeObj)=>{ + LeanTest.expect(((string)completeObj)=="Hi!","ONCOMPLETE OBJECT"); + LeanTest.expect(cubeAlpha1.GetComponent().material.color.a == 0.5f,"ALPHA"); + }); + // Color + float onStartTime = -1f; + LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete( ()=>{ + LeanTest.expect(cubeAlpha2.GetComponent().material.color==Color.cyan, "COLOR"); + LeanTest.expect(onStartTime>=0f && onStartTime{ + onStartTime = Time.time; + }); + // moveLocalY (make sure uses y values) + Vector3 beforePos = cubeAlpha1.transform.position; + LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete( ()=>{ + LeanTest.expect(cubeAlpha1.transform.position.x==beforePos.x && cubeAlpha1.transform.position.z==beforePos.z,"MOVE Y"); + }); + + Vector3 beforePos2 = cubeAlpha2.transform.localPosition; + LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete( ()=>{ + LeanTest.expect(cubeAlpha2.transform.localPosition.x==beforePos2.x && cubeAlpha2.transform.localPosition.y==beforePos2.y,"MOVE LOCAL Z","ax:"+cubeAlpha2.transform.localPosition.x+" bx:"+beforePos.x+" ay:"+cubeAlpha2.transform.localPosition.y+" by:"+beforePos2.y); + }); + + AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve( new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options()); + LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f,0f,0f), 0.1f).setDelay(0.2f).setOnComplete( ()=>{ + LeanTest.expect(Time.time>0,"DELAYED SOUND"); + }); + + // value2 + bool value2UpdateCalled = false; + LeanTween.value(gameObject, new Vector2(0, 0), new Vector2(256, 96), 0.1f).setOnUpdate((Vector2 value) => { + value2UpdateCalled = true; + }); + LeanTween.delayedCall(0.2f, ()=>{ + LeanTest.expect( value2UpdateCalled, "VALUE2 UPDATE"); + } ); + + StartCoroutine( timeBasedTesting() ); + } + + private GameObject cubeNamed( string name ){ + GameObject cube = Instantiate( boxNoCollider ) as GameObject; + cube.name = name; + return cube; + } + + IEnumerator timeBasedTesting(){ + yield return new WaitForEndOfFrame(); + + GameObject cubeNormal = cubeNamed("normalTimeScale"); + // float timeElapsedNormal = Time.time; + LeanTween.moveX(cubeNormal, 12f, 1.5f).setIgnoreTimeScale( false ).setOnComplete( ()=>{ + timeElapsedNormalTimeScale = Time.time; + }); + + LTDescr[] descr = LeanTween.descriptions( cubeNormal ); + LeanTest.expect( descr.Length >= 0 && descr[0].to.x == 12f, "WE CAN RETRIEVE A DESCRIPTION"); + + GameObject cubeIgnore = cubeNamed("ignoreTimeScale"); + LeanTween.moveX(cubeIgnore, 5f, 1.5f).setIgnoreTimeScale( true ).setOnComplete( ()=>{ + timeElapsedIgnoreTimeScale = Time.time; + }); + + yield return new WaitForSeconds(1.5f); + LeanTest.expect( Mathf.Abs( timeElapsedNormalTimeScale - timeElapsedIgnoreTimeScale ) < 0.7f, "START IGNORE TIMING", "timeElapsedIgnoreTimeScale:"+timeElapsedIgnoreTimeScale+" timeElapsedNormalTimeScale:"+timeElapsedNormalTimeScale ); + +// yield return new WaitForSeconds(100f); + Time.timeScale = 4f; + + int pauseCount = 0; + LeanTween.value( gameObject, 0f, 1f, 1f).setOnUpdate( ( float val )=>{ + pauseCount++; + }).pause(); + + // Bezier should end at exact end position not just 99% close to it + Vector3[] roundCirc = new Vector3[]{ new Vector3(0f,0f,0f), new Vector3(-9.1f,25.1f,0f), new Vector3(-1.2f,15.9f,0f), new Vector3(-25f,25f,0f), new Vector3(-25f,25f,0f), new Vector3(-50.1f,15.9f,0f), new Vector3(-40.9f,25.1f,0f), new Vector3(-50f,0f,0f), new Vector3(-50f,0f,0f), new Vector3(-40.9f,-25.1f,0f), new Vector3(-50.1f,-15.9f,0f), new Vector3(-25f,-25f,0f), new Vector3(-25f,-25f,0f), new Vector3(0f,-15.9f,0f), new Vector3(-9.1f,-25.1f,0f), new Vector3(0f,0f,0f) }; + GameObject cubeRound = cubeNamed("bRound"); + Vector3 onStartPos = cubeRound.transform.position; + LeanTween.moveLocal(cubeRound, roundCirc, 0.5f).setOnComplete( ()=>{ + LeanTest.expect(cubeRound.transform.position==onStartPos, "BEZIER CLOSED LOOP SHOULD END AT START","onStartPos:"+onStartPos+" onEnd:"+cubeRound.transform.position); + }); + + // Spline should end at exact end position not just 99% close to it + Vector3[] roundSpline = new Vector3[]{ new Vector3(0f,0f,0f), new Vector3(0f,0f,0f), new Vector3(2f,0f,0f), new Vector3(0.9f,2f,0f), new Vector3(0f,0f,0f), new Vector3(0f,0f,0f) }; + GameObject cubeSpline = cubeNamed("bSpline"); + Vector3 onStartPosSpline = cubeSpline.transform.position; + LeanTween.moveSplineLocal(cubeSpline, roundSpline, 0.5f).setOnComplete( ()=>{ + LeanTest.expect(Vector3.Distance(onStartPosSpline, cubeSpline.transform.position) <= 0.01f, "SPLINE CLOSED LOOP SHOULD END AT START","onStartPos:"+onStartPosSpline+" onEnd:"+cubeSpline.transform.position+" dist:"+Vector3.Distance(onStartPosSpline, cubeSpline.transform.position)); + }); + + // Groups of tweens testing + groupTweens = new LTDescr[ 1200 ]; + groupGOs = new GameObject[ groupTweens.Length ]; + groupTweensCnt = 0; + int descriptionMatchCount = 0; + for(int i = 0; i < groupTweens.Length; i++){ + GameObject cube = cubeNamed("c"+i); + cube.transform.position = new Vector3(0,0,i*3); + + groupGOs[i] = cube; + } + + yield return new WaitForEndOfFrame(); + + bool hasGroupTweensCheckStarted = false; + int setOnStartNum = 0; + int setPosNum = 0; + bool setPosOnUpdate = true; + for(int i = 0; i < groupTweens.Length; i++){ + Vector3 finalPos = transform.position + Vector3.one*3f; + Dictionary finalDict = new Dictionary{ {"final",finalPos}, {"go",groupGOs[i]} }; + groupTweens[i] = LeanTween.move(groupGOs[i], finalPos, 3f ).setOnStart( ()=>{ + setOnStartNum++; + }).setOnUpdate( (Vector3 newPosition) => { + if(transform.position.z > newPosition.z){ + setPosOnUpdate = false; + } +// Debug.LogWarning("New Position: " + newPosition.ToString()); + }). + setOnCompleteParam( finalDict ). + setOnComplete( (object param)=>{ + Dictionary finalDictRetr = param as Dictionary; + Vector3 neededPos = (Vector3)finalDictRetr["final"]; + GameObject tweenedGo = finalDictRetr["go"] as GameObject; + if(neededPos.ToString() == tweenedGo.transform.position.ToString()) + setPosNum++; + else{ +// Debug.Log("neededPos:"+neededPos+" tweenedGo.transform.position:"+tweenedGo.transform.position); + } + if(hasGroupTweensCheckStarted==false){ + hasGroupTweensCheckStarted = true; + LeanTween.delayedCall(gameObject, 0.1f, ()=>{ + LeanTest.expect( setOnStartNum == groupTweens.Length, "SETONSTART CALLS", "expected:"+groupTweens.Length+" was:"+setOnStartNum); + LeanTest.expect( groupTweensCnt==groupTweens.Length, "GROUP FINISH", "expected "+groupTweens.Length+" tweens but got "+groupTweensCnt); + LeanTest.expect( setPosNum==groupTweens.Length, "GROUP POSITION FINISH", "expected "+groupTweens.Length+" tweens but got "+setPosNum); + LeanTest.expect( setPosOnUpdate, "GROUP POSITION ON UPDATE"); + }); + } + groupTweensCnt++; + }); + + if(LeanTween.description(groupTweens[i].id).trans==groupTweens[i].trans) + descriptionMatchCount++; + } + + while (LeanTween.tweensRunning{ + LeanTest.expect( cube4!=null && previousXlt4!=cube4.transform.position.x, "RESUME OUT OF ORDER", "cube4:"+cube4+" previousXlt4:"+previousXlt4+" cube4.transform.position.x:"+(cube4!=null ? cube4.transform.position.x : 0)); + }).setDestroyOnComplete( true ); + lt4.resume(); + + rotateRepeat = rotateRepeatAngle = 0; + LeanTween.rotateAround(cube3, Vector3.forward, 360f, 0.1f).setRepeat(3).setOnComplete(rotateRepeatFinished).setOnCompleteOnRepeat(true).setDestroyOnComplete(true); + yield return new WaitForEndOfFrame(); + LeanTween.delayedCall(0.1f*8f+1f, rotateRepeatAllFinished); + + int countBeforeCancel = LeanTween.tweensRunning; + LeanTween.cancel( lt1Id ); + LeanTest.expect( countBeforeCancel==LeanTween.tweensRunning, "CANCEL AFTER RESET SHOULD FAIL", "expected "+countBeforeCancel+" but got "+LeanTween.tweensRunning); + LeanTween.cancel(cube2); + + int tweenCount = 0; + for(int i = 0; i < groupTweens.Length; i++){ + if(LeanTween.isTweening( groupGOs[i] )) + tweenCount++; + if(i%3==0) + LeanTween.pause( groupGOs[i] ); + else if(i%3==1) + groupTweens[i].pause(); + else + LeanTween.pause( groupTweens[i].id ); + } + LeanTest.expect( tweenCount==groupTweens.Length, "GROUP ISTWEENING", "expected "+groupTweens.Length+" tweens but got "+tweenCount ); + + yield return new WaitForEndOfFrame(); + + tweenCount = 0; + for(int i = 0; i < groupTweens.Length; i++){ + if(i%3==0) + LeanTween.resume( groupGOs[i] ); + else if(i%3==1) + groupTweens[i].resume(); + else + LeanTween.resume( groupTweens[i].id ); + + if(i%2==0 ? LeanTween.isTweening( groupTweens[i].id ) : LeanTween.isTweening( groupGOs[i] ) ) + tweenCount++; + } + LeanTest.expect( tweenCount==groupTweens.Length, "GROUP RESUME" ); + + LeanTest.expect( LeanTween.isTweening(cube1)==false, "CANCEL TWEEN LTDESCR" ); + LeanTest.expect( LeanTween.isTweening(cube2)==false, "CANCEL TWEEN LEANTWEEN" ); + + LeanTest.expect( pauseCount==0, "ON UPDATE NOT CALLED DURING PAUSE", "expect pause count of 0, but got "+pauseCount); + + yield return new WaitForEndOfFrame(); + Time.timeScale = 0.25f; + float tweenTime = 0.2f; + float expectedTime = tweenTime * (1f/Time.timeScale); + float start = Time.realtimeSinceStartup; + bool onUpdateWasCalled = false; + LeanTween.moveX(cube1, -5f, tweenTime).setOnUpdate( (float val)=>{ + onUpdateWasCalled = true; + }).setOnComplete( ()=>{ + float end = Time.realtimeSinceStartup; + float diff = end - start; + + LeanTest.expect( Mathf.Abs( expectedTime - diff) < 0.05f, "SCALED TIMING DIFFERENCE", "expected to complete in roughly "+expectedTime+" but completed in "+diff ); + LeanTest.expect( Mathf.Approximately(cube1.transform.position.x, -5f), "SCALED ENDING POSITION", "expected to end at -5f, but it ended at "+cube1.transform.position.x); + LeanTest.expect( onUpdateWasCalled, "ON UPDATE FIRED" ); + }); + + bool didGetCorrectOnUpdate = false; + LeanTween.value(gameObject, new Vector3(1f,1f,1f), new Vector3(10f,10f,10f), 1f).setOnUpdate( ( Vector3 val )=>{ + didGetCorrectOnUpdate = val.x >= 1f && val.y >= 1f && val.z >= 1f; + }).setOnComplete( ()=>{ + LeanTest.expect( didGetCorrectOnUpdate, "VECTOR3 CALLBACK CALLED"); + }); + + yield return new WaitForSeconds( expectedTime ); + Time.timeScale = 1f; + + int ltCount = 0; + GameObject[] allGos = FindObjectsOfType(typeof(GameObject)) as GameObject[]; + foreach (GameObject go in allGos) { + if(go.name == "~LeanTween") + ltCount++; + } + LeanTest.expect( ltCount==1, "RESET CORRECTLY CLEANS UP" ); + + lotsOfCancels(); + } + + IEnumerator lotsOfCancels(){ + yield return new WaitForEndOfFrame(); + + Time.timeScale = 4f; + int cubeCount = 10; + + int[] tweensA = new int[ cubeCount ]; + GameObject[] aGOs = new GameObject[ cubeCount ]; + for(int i = 0; i < aGOs.Length; i++){ + GameObject cube = Instantiate( boxNoCollider ) as GameObject; + cube.transform.position = new Vector3(0,0,i*2f); + cube.name = "a"+i; + aGOs[i] = cube; + tweensA[i] = LeanTween.move(cube, cube.transform.position + new Vector3(10f,0,0), 0.5f + 1f * (1.0f/(float)aGOs.Length) ).id; + LeanTween.color(cube, Color.red, 0.01f); + } + + yield return new WaitForSeconds(1.0f); + + int[] tweensB = new int[ cubeCount ]; + GameObject[] bGOs = new GameObject[ cubeCount ]; + for(int i = 0; i < bGOs.Length; i++){ + GameObject cube = Instantiate( boxNoCollider ) as GameObject; + cube.transform.position = new Vector3(0,0,i*2f); + cube.name = "b"+i; + bGOs[i] = cube; + tweensB[i] = LeanTween.move(cube, cube.transform.position + new Vector3(10f,0,0), 2f).id; + } + + for(int i = 0; i < aGOs.Length; i++){ + LeanTween.cancel( aGOs[i] ); + GameObject cube = aGOs[i]; + tweensA[i] = LeanTween.move(cube, new Vector3(0,0,i*2f), 2f).id; + } + + yield return new WaitForSeconds(0.5f); + + for(int i = 0; i < aGOs.Length; i++){ + LeanTween.cancel( aGOs[i] ); + GameObject cube = aGOs[i]; + tweensA[i] = LeanTween.move(cube, new Vector3(0,0,i*2f) + new Vector3(10f,0,0), 2f ).id; + } + + for(int i = 0; i < bGOs.Length; i++){ + LeanTween.cancel( bGOs[i] ); + GameObject cube = bGOs[i]; + tweensB[i] = LeanTween.move(cube, new Vector3(0,0,i*2f), 2f ).id; + } + + yield return new WaitForSeconds(2.1f); + + bool inFinalPlace = true; + for(int i = 0; i < aGOs.Length; i++){ + if(Vector3.Distance( aGOs[i].transform.position, new Vector3(0,0,i*2f) + new Vector3(10f,0,0) ) > 0.1f) + inFinalPlace = false; + } + + for(int i = 0; i < bGOs.Length; i++){ + if(Vector3.Distance( bGOs[i].transform.position, new Vector3(0,0,i*2f) ) > 0.1f) + inFinalPlace = false; + } + + LeanTest.expect(inFinalPlace,"AFTER LOTS OF CANCELS"); + } + + void rotateRepeatFinished(){ + if( Mathf.Abs(cube3.transform.eulerAngles.z)<0.0001f ) + rotateRepeatAngle++; + rotateRepeat++; + } + + void rotateRepeatAllFinished(){ + LeanTest.expect( rotateRepeatAngle==3, "ROTATE AROUND MULTIPLE", "expected 3 times received "+rotateRepeatAngle+" times" ); + LeanTest.expect( rotateRepeat==3, "ROTATE REPEAT", "expected 3 times received "+rotateRepeat+" times" ); + LeanTest.expect( cube3==null, "DESTROY ON COMPLETE", "cube3:"+cube3 ); + } + + void eventGameObjectCalled( LTEvent e ){ + eventGameObjectWasCalled = true; + } + + void eventGeneralCalled( LTEvent e ){ + eventGeneralWasCalled = true; + } + + } + +} \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs.meta new file mode 100644 index 0000000..d2fc149 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Scripts/TestingUnitTests.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fef58bd01146344429d022b95c6af872 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures.meta new file mode 100644 index 0000000..64ca521 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9e39f8f3dc0404757be9a05da7cc9802 diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg new file mode 100644 index 0000000..6687944 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg.meta new file mode 100644 index 0000000..c8e6b57 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/DefaultParticleReplacement.jpg.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: eabba395643bb4e388d633c8d9a4f1e8 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + textureType: -1 + buildTargetSettings: [] diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png new file mode 100644 index 0000000..d790b85 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png.meta new file mode 100644 index 0000000..a42c891 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/Dude2d.png.meta @@ -0,0 +1,56 @@ +fileFormatVersion: 2 +guid: 5f7fa9a7940a64e79b5a42d9f661d42c +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg new file mode 100644 index 0000000..566e2d2 Binary files /dev/null and b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg differ diff --git a/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg.meta b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg.meta new file mode 100644 index 0000000..860e495 --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/Examples/Textures/HorizontalGradient.jpg.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 547f51a8eea214bd7a5863356fd25619 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + textureType: -1 + buildTargetSettings: [] diff --git a/IronToad_UnityProject/Assets/LeanTween/License.txt b/IronToad_UnityProject/Assets/LeanTween/License.txt new file mode 100644 index 0000000..4f43b9a --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/License.txt @@ -0,0 +1,31 @@ +The MIT License (MIT) + +Copyright (c) 2017 Russell Savage - Dented Pixel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +TERMS OF USE - EASING EQUATIONS +Open source under the BSD License. +Copyright (c)2001 Robert Penner +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/IronToad_UnityProject/Assets/LeanTween/License.txt.meta b/IronToad_UnityProject/Assets/LeanTween/License.txt.meta new file mode 100644 index 0000000..1d0d8ca --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/License.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e389e9bcd4f944c338327697bd209cad +timeCreated: 1469016738 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt b/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt new file mode 100644 index 0000000..49687de --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt @@ -0,0 +1,9 @@ +LeanTween is an efficient tweening engine for Unity3d + +Full Documentation: + http://dentedpixel.com/LeanTweenDocumentation/classes/LeanTween.html + This can also be accessed offline! From the Unity menu Help->LeanTween Documentation + +Getting Started + + There are many examples included! Look in the “LeanTween/LeanTweenExamples" folder to see many of the methods outlined. diff --git a/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt.meta b/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt.meta new file mode 100644 index 0000000..c08c74a --- /dev/null +++ b/IronToad_UnityProject/Assets/LeanTween/ReadMe.txt.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f1e0da947b69648fdb1884d602088d92 diff --git a/IronToad_UnityProject/Assets/M_Lighthouse.FBX b/IronToad_UnityProject/Assets/M_Lighthouse.FBX new file mode 100644 index 0000000..5eac5fd Binary files /dev/null and b/IronToad_UnityProject/Assets/M_Lighthouse.FBX differ diff --git a/IronToad_UnityProject/Assets/M_Lighthouse.FBX.meta b/IronToad_UnityProject/Assets/M_Lighthouse.FBX.meta new file mode 100644 index 0000000..0b763ac --- /dev/null +++ b/IronToad_UnityProject/Assets/M_Lighthouse.FBX.meta @@ -0,0 +1,81 @@ +fileFormatVersion: 2 +guid: 03cd9f33716bc4591b4392a874ba8e30 +timeCreated: 1484952271 +licenseType: Free +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 400000: //RootNode + 2300000: //RootNode + 3300000: //RootNode + 4300000: lightHouse + 9500000: //RootNode + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 2 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Materials/No Name.mat b/IronToad_UnityProject/Assets/Materials/No Name.mat new file mode 100644 index 0000000..e15f536 Binary files /dev/null and b/IronToad_UnityProject/Assets/Materials/No Name.mat differ diff --git a/IronToad_UnityProject/Assets/Materials/No Name.mat.meta b/IronToad_UnityProject/Assets/Materials/No Name.mat.meta new file mode 100644 index 0000000..20a1699 --- /dev/null +++ b/IronToad_UnityProject/Assets/Materials/No Name.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4f1435577f444874a5c76f472e3872b +timeCreated: 1484952271 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins.meta b/IronToad_UnityProject/Assets/Plugins.meta new file mode 100644 index 0000000..d67927c --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1839327a1a81c4d979f53b07027ab4b9 diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween.meta new file mode 100644 index 0000000..e69c1be --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a3f23ec8eb7c24f0bbb1d41bf96c154f +folderAsset: yes +timeCreated: 1469292088 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs new file mode 100644 index 0000000..6cbb74a --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs @@ -0,0 +1,2246 @@ +//namespace DentedPixel{ +using System; +using UnityEngine; + +/** +* Internal Representation of a Tween
    +*
    +* This class represents all of the optional parameters you can pass to a method (it also represents the internal representation of the tween).

    +* Optional Parameters are passed at the end of every method:
    +*
    +*   Example:
    +*   LeanTween.moveX( gameObject, 1f, 1f).setEase( LeanTweenType.easeInQuad ).setDelay(1f);
    +*
    +* You can pass the optional parameters in any order, and chain on as many as you wish.
    +* You can also pass parameters at a later time by saving a reference to what is returned.
    +*
    +* Retrieve a unique id for the tween by using the "id" property. You can pass this to LeanTween.pause, LeanTween.resume, LeanTween.cancel, LeanTween.isTweening methods
    +*
    +*   

    Example:

    +*   int id = LeanTween.moveX(gameObject, 1f, 3f).id;
    +*
      // pause a specific tween
    +*   LeanTween.pause(id);
    +*
      // resume later
    +*   LeanTween.resume(id);
    +*
      // check if it is tweening before kicking of a new tween
    +*   if( LeanTween.isTweening( id ) ){
    +*       LeanTween.cancel( id );
    +*       LeanTween.moveZ(gameObject, 10f, 3f);
    +*   }
    +* @class LTDescr +* @constructor +*/ +public class LTDescr +{ + public bool toggle; + public bool useEstimatedTime; + public bool useFrames; + public bool useManualTime; + public bool usesNormalDt; + public bool hasInitiliazed; + public bool hasExtraOnCompletes; + public bool hasPhysics; + public bool onCompleteOnRepeat; + public bool onCompleteOnStart; + public bool useRecursion; + public float ratioPassed; + public float passed; + public float delay; + public float time; + public float speed; + public float lastVal; + private uint _id; + public int loopCount; + public uint counter; + public float direction; + public float directionLast; + public float overshoot; + public float period; + public float scale; + public bool destroyOnComplete; + public Transform trans; + public LTRect ltRect; + internal Vector3 fromInternal; + public Vector3 from { get { return this.fromInternal; } set { this.fromInternal = value; } } + internal Vector3 toInternal; + public Vector3 to { get { return this.toInternal; } set { this.toInternal = value; } } + internal Vector3 diff; + internal Vector3 diffDiv2; + public TweenAction type; + public LeanTweenType tweenType; + public LeanTweenType loopType; + + public bool hasUpdateCallback; + + public EaseTypeDelegate easeMethod; + public ActionMethodDelegate easeInternal {get; set; } + public ActionMethodDelegate initInternal {get; set; } + public delegate Vector3 EaseTypeDelegate(); + public delegate void ActionMethodDelegate(); + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + public SpriteRenderer spriteRen; + #endif + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public RectTransform rectTransform; + public UnityEngine.UI.Text uiText; + public UnityEngine.UI.Image uiImage; + public UnityEngine.UI.RawImage rawImage; + public UnityEngine.Sprite[] sprites; + #endif + + public LTDescrOptional _optional = new LTDescrOptional(); + + private static uint global_counter = 0; + + public override string ToString(){ + return (trans!=null ? "name:"+trans.gameObject.name : "gameObject:null")+" toggle:"+toggle+" passed:"+passed+" time:"+time+" delay:"+delay+" direction:"+direction+" from:"+from+" to:"+to+" diff:"+diff+" type:"+type+" ease:"+tweenType+" useEstimatedTime:"+useEstimatedTime+" id:"+id+" hasInitiliazed:"+hasInitiliazed; + } + + public LTDescr(){ + + } + + [System.Obsolete("Use 'LeanTween.cancel( id )' instead")] + public LTDescr cancel( GameObject gameObject ){ + // Debug.Log("canceling id:"+this._id+" this.uniqueId:"+this.uniqueId+" go:"+this.trans.gameObject); + if(gameObject==this.trans.gameObject) + LeanTween.removeTween((int)this._id, this.uniqueId); + return this; + } + + public int uniqueId{ + get{ + uint toId = _id | counter << 16; + + /*uint backId = toId & 0xFFFF; + uint backCounter = toId >> 16; + if(_id!=backId || backCounter!=counter){ + Debug.LogError("BAD CONVERSION toId:"+_id); + }*/ + + return (int)toId; + } + } + + public int id{ + get{ + return uniqueId; + } + } + + public LTDescrOptional optional{ + get{ + return _optional; + } + set{ + this._optional = optional; + } + } + + public void reset(){ + this.toggle = this.useRecursion = this.usesNormalDt = true; + this.trans = null; + this.passed = this.delay = this.lastVal = 0.0f; + this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = this.hasExtraOnCompletes = false; + this.tweenType = LeanTweenType.linear; + this.loopType = LeanTweenType.once; + this.loopCount = 0; + this.direction = this.directionLast = this.overshoot = this.scale = 1.0f; + this.period = 0.3f; + this.speed = -1f; + this.easeMethod = this.easeLinear; + this.from = this.to = Vector3.zero; + this._optional.reset(); + + global_counter++; + if(global_counter>0x8000) + global_counter = 0; + } + + // Initialize and Internal Methods + + public LTDescr setMoveX(){ + this.type = TweenAction.MOVE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.x; }; + this.easeInternal = ()=>{ trans.position=new Vector3( easeMethod().x,trans.position.y,trans.position.z); }; + return this; + } + + public LTDescr setMoveY(){ + this.type = TweenAction.MOVE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.y; }; + this.easeInternal = ()=>{ trans.position=new Vector3( trans.position.x,easeMethod().x,trans.position.z); }; + return this; + } + + public LTDescr setMoveZ(){ + this.type = TweenAction.MOVE_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.z; };; + this.easeInternal = ()=>{ trans.position=new Vector3( trans.position.x,trans.position.y,easeMethod().x); }; + return this; + } + + public LTDescr setMoveLocalX(){ + this.type = TweenAction.MOVE_LOCAL_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.x; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( easeMethod().x,trans.localPosition.y,trans.localPosition.z); }; + return this; + } + + public LTDescr setMoveLocalY(){ + this.type = TweenAction.MOVE_LOCAL_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.y; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( trans.localPosition.x,easeMethod().x,trans.localPosition.z); }; + return this; + } + + public LTDescr setMoveLocalZ(){ + this.type = TweenAction.MOVE_LOCAL_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.z; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( trans.localPosition.x,trans.localPosition.y,easeMethod().x); }; + return this; + } + + private void initFromInternal(){ this.fromInternal.x = 0; } + + public LTDescr setMoveCurved(){ + this.type = TweenAction.MOVE_CURVED; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.path.orientToPath){ + if(this._optional.path.orientToPath2d){ + this._optional.path.place2d( trans, val ); + }else{ + this._optional.path.place( trans, val ); + } + }else{ + trans.position = this._optional.path.point( val ); + } + }; + return this; + } + + public LTDescr setMoveCurvedLocal(){ + this.type = TweenAction.MOVE_CURVED_LOCAL; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.path.orientToPath){ + if(this._optional.path.orientToPath2d){ + this._optional.path.placeLocal2d( trans, val ); + }else{ + this._optional.path.placeLocal( trans, val ); + } + }else{ + trans.localPosition = this._optional.path.point( val ); + } + }; + return this; + } + + public LTDescr setMoveSpline(){ + this.type = TweenAction.MOVE_SPLINE; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.spline.orientToPath){ + if(this._optional.spline.orientToPath2d){ + this._optional.spline.place2d( trans, val ); + }else{ + this._optional.spline.place( trans, val ); + } + }else{ + trans.position = this._optional.spline.point( val ); + } + }; + return this; + } + + public LTDescr setMoveSplineLocal(){ + this.type = TweenAction.MOVE_SPLINE_LOCAL; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.spline.orientToPath){ + if(this._optional.spline.orientToPath2d){ + this._optional.spline.placeLocal2d( trans, val ); + }else{ + this._optional.spline.placeLocal( trans, val ); + } + }else{ + trans.localPosition = this._optional.spline.point( val ); + } + }; + return this; + } + + public LTDescr setScaleX(){ + this.type = TweenAction.SCALE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.x; }; + this.easeInternal = ()=>{ trans.localScale = new Vector3( easeMethod().x,trans.localScale.y,trans.localScale.z); }; + return this; + } + + public LTDescr setScaleY(){ + this.type = TweenAction.SCALE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.y; }; + this.easeInternal = ()=>{ trans.localScale=new Vector3( trans.localScale.x,easeMethod().x,trans.localScale.z); }; + return this; + } + + public LTDescr setScaleZ(){ + this.type = TweenAction.SCALE_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.z; }; + this.easeInternal = ()=>{ trans.localScale=new Vector3( trans.localScale.x,trans.localScale.y,easeMethod().x); }; + return this; + } + + public LTDescr setRotateX(){ + this.type = TweenAction.ROTATE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.eulerAngles.x; this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x);}; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(easeMethod().x,trans.eulerAngles.y,trans.eulerAngles.z); }; + return this; + } + + public LTDescr setRotateY(){ + this.type = TweenAction.ROTATE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.eulerAngles.y; this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x);}; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(trans.eulerAngles.x,easeMethod().x,trans.eulerAngles.z); }; + return this; + } + + public LTDescr setRotateZ(){ + this.type = TweenAction.ROTATE_Z; + this.initInternal = ()=>{ + this.fromInternal.x = trans.eulerAngles.z; + this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x); + }; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(trans.eulerAngles.x,trans.eulerAngles.y,easeMethod().x); }; + return this; + } + + public LTDescr setRotateAround(){ + this.type = TweenAction.ROTATE_AROUND; + this.initInternal = ()=>{ + this.fromInternal.x = 0f; + this._optional.origRotation = trans.rotation; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Vector3 origPos = trans.localPosition; + Vector3 rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + // Debug.Log("this._optional.point:"+this._optional.point); + trans.RotateAround(rotateAroundPt, this._optional.axis, -this._optional.lastVal); + Vector3 diff = origPos - trans.localPosition; + + trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + trans.rotation = this._optional.origRotation; + + rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + trans.RotateAround(rotateAroundPt, this._optional.axis, val); + + this._optional.lastVal = val; + }; + return this; + } + + public LTDescr setRotateAroundLocal(){ + this.type = TweenAction.ROTATE_AROUND_LOCAL; + this.initInternal = ()=>{ + this.fromInternal.x = 0f; + this._optional.origRotation = trans.localRotation; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Vector3 origPos = trans.localPosition; + trans.RotateAround((Vector3)trans.TransformPoint( this._optional.point ), trans.TransformDirection(this._optional.axis), -this._optional.lastVal); + Vector3 diff = origPos - trans.localPosition; + + trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + trans.localRotation = this._optional.origRotation; + Vector3 rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + trans.RotateAround(rotateAroundPt, trans.TransformDirection(this._optional.axis), val); + + this._optional.lastVal = val; + }; + return this; + } + + public LTDescr setAlpha(){ + this.type = TweenAction.ALPHA; + this.initInternal = ()=>{ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + if(trans.gameObject.renderer){ this.fromInternal.x = trans.gameObject.renderer.material.color.a; }else if(trans.childCount>0){ foreach (Transform child in trans) { if(child.gameObject.renderer!=null){ Color col = child.gameObject.renderer.material.color; this.fromInternal.x = col.a; break; }}} + this.easeInternal = this.alpha; + break; + #else + SpriteRenderer ren = trans.gameObject.GetComponent(); + if(ren!=null){ + this.fromInternal.x = ren.color.a; + }else{ + if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_Color")){ + this.fromInternal.x = trans.gameObject.GetComponent().material.color.a; + }else if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")){ + Color col = trans.gameObject.GetComponent().material.GetColor("_TintColor"); + this.fromInternal.x = col.a; + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.GetComponent()!=null){ + Color col = child.gameObject.GetComponent().material.color; + this.fromInternal.x = col.a; + break; + } + } + } + } + #endif + + this.easeInternal = ()=>{ + val = easeMethod().x; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + alphaRecursive(this.trans, val, this.useRecursion); + #else + if(this.spriteRen!=null){ + this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val); + alphaRecursiveSprite(this.trans, val); + }else{ + alphaRecursive(this.trans, val, this.useRecursion); + } + #endif + }; + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + alphaRecursive(this.trans, val, this.useRecursion); + #else + if(this.spriteRen!=null){ + this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val); + alphaRecursiveSprite(this.trans, val); + }else{ + alphaRecursive(this.trans, val, this.useRecursion); + } + #endif + }; + return this; + } + + public LTDescr setTextAlpha(){ + this.type = TweenAction.TEXT_ALPHA; + this.initInternal = ()=>{ + this.uiText = trans.gameObject.GetComponent(); + this.fromInternal.x = this.uiText != null ? this.uiText.color.a : 1f; + }; + this.easeInternal = ()=>{ textAlphaRecursive( trans, easeMethod().x, this.useRecursion ); }; + return this; + } + + public LTDescr setAlphaVertex(){ + this.type = TweenAction.ALPHA_VERTEX; + this.initInternal = ()=>{ this.fromInternal.x = trans.GetComponent().mesh.colors32[0].a; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Mesh mesh = trans.GetComponent().mesh; + Vector3[] vertices = mesh.vertices; + Color32[] colors = new Color32[vertices.Length]; + if (colors.Length == 0){ //MaxFW fix: add vertex colors if the mesh doesn't have any + Color32 transparentWhiteColor32 = new Color32(0xff, 0xff, 0xff, 0x00); + colors = new Color32[mesh.vertices.Length]; + for (int k=0; k{ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + if(trans.gameObject.renderer){ + this.setFromColor( trans.gameObject.renderer.material.color ); + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.renderer!=null){ + this.setFromColor( child.gameObject.renderer.material.color ); + break; + } + } + } + #else + SpriteRenderer renColor = trans.gameObject.GetComponent(); + if(renColor!=null){ + this.setFromColor( renColor.color ); + }else{ + if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_Color")){ + Color col = trans.gameObject.GetComponent().material.color; + this.setFromColor( col ); + }else if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")){ + Color col = trans.gameObject.GetComponent().material.GetColor ("_TintColor"); + this.setFromColor( col ); + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.GetComponent()!=null){ + Color col = child.gameObject.GetComponent().material.color; + this.setFromColor( col ); + break; + } + } + } + } + #endif + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + + if(this.spriteRen!=null){ + this.spriteRen.color = toColor; + colorRecursiveSprite( trans, toColor); + }else{ + #endif + // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff); + if(this.type==TweenAction.COLOR) + colorRecursive(trans, toColor, this.useRecursion); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + } + #endif + if(dt!=0f && this._optional.onUpdateColor!=null){ + this._optional.onUpdateColor(toColor); + }else if(dt!=0f && this._optional.onUpdateColorObject!=null){ + this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam); + } + }; + return this; + } + + public LTDescr setCallbackColor(){ + this.type = TweenAction.CALLBACK_COLOR; + this.initInternal = ()=>{ this.diff = new Vector3(1.0f,0.0f,0.0f); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + if(this.spriteRen!=null){ + this.spriteRen.color = toColor; + colorRecursiveSprite( trans, toColor); + }else{ + #endif + // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff); + if(this.type==TweenAction.COLOR) + colorRecursive(trans, toColor, this.useRecursion); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + } + #endif + if(dt!=0f && this._optional.onUpdateColor!=null){ + this._optional.onUpdateColor(toColor); + }else if(dt!=0f && this._optional.onUpdateColorObject!=null){ + this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam); + } + }; + return this; + } + + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + public LTDescr setTextColor(){ + this.type = TweenAction.TEXT_COLOR; + this.initInternal = ()=>{ + this.uiText = trans.gameObject.GetComponent(); + this.setFromColor( this.uiText != null ? this.uiText.color : Color.white ); + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + this.uiText.color = toColor; + if (dt!=0f && this._optional.onUpdateColor != null) + this._optional.onUpdateColor(toColor); + + if(this.useRecursion && trans.childCount>0) + textColorRecursive(this.trans, toColor); + }; + return this; + } + + public LTDescr setCanvasAlpha(){ + this.type = TweenAction.CANVAS_ALPHA; + this.initInternal = ()=>{ + this.uiImage = trans.gameObject.GetComponent(); + if(this.uiImage!=null){ + this.fromInternal.x = this.uiImage.color.a; + }else{ + this.rawImage = trans.gameObject.GetComponent(); + if(this.rawImage != null){ + this.fromInternal.x = this.rawImage.color.a; + }else{ + this.fromInternal.x = 1f; + } + } + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this.uiImage!=null){ + Color c = this.uiImage.color; c.a = val; this.uiImage.color = c; + }else if(this.rawImage!=null){ + Color c = this.rawImage.color; c.a = val; this.rawImage.color = c; + } + if(this.useRecursion){ + alphaRecursive( this.rectTransform, val, 0 ); + textAlphaRecursive( this.rectTransform, val); + } + }; + return this; + } + + public LTDescr setCanvasGroupAlpha(){ + this.type = TweenAction.CANVASGROUP_ALPHA; + this.initInternal = ()=>{this.fromInternal.x = trans.gameObject.GetComponent().alpha;}; + this.easeInternal = ()=>{ this.trans.GetComponent().alpha = easeMethod().x; }; + return this; + } + + public LTDescr setCanvasColor(){ + this.type = TweenAction.CANVAS_COLOR; + this.initInternal = ()=>{ + this.uiImage = trans.gameObject.GetComponent(); + if(this.uiImage==null){ + this.rawImage = trans.gameObject.GetComponent(); + this.setFromColor( this.rawImage!=null ? this.rawImage.color : Color.white ); + }else{ + this.setFromColor( this.uiImage.color ); + } + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + if(this.uiImage!=null){ + this.uiImage.color = toColor; + }else if(this.rawImage!=null){ + this.rawImage.color = toColor; + } + + if (dt!=0f && this._optional.onUpdateColor != null) + this._optional.onUpdateColor(toColor); + + if(this.useRecursion) + colorRecursive(this.rectTransform, toColor); + }; + return this; + } + + public LTDescr setCanvasMoveX(){ + this.type = TweenAction.CANVAS_MOVE_X; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.x; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(easeMethod().x, c.y, c.z); }; + return this; + } + + public LTDescr setCanvasMoveY(){ + this.type = TweenAction.CANVAS_MOVE_Y; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.y; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(c.x, easeMethod().x, c.z); }; + return this; + } + + public LTDescr setCanvasMoveZ(){ + this.type = TweenAction.CANVAS_MOVE_Z; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.z; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(c.x, c.y, easeMethod().x); }; + return this; + } + + private void initCanvasRotateAround(){ + this.lastVal = 0.0f; + this.fromInternal.x = 0.0f; + this._optional.origRotation = this.rectTransform.rotation; + } + + public LTDescr setCanvasRotateAround(){ + this.type = TweenAction.CANVAS_ROTATEAROUND; + this.initInternal = this.initCanvasRotateAround; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + RectTransform rect = this.rectTransform; + Vector3 origPos = rect.localPosition; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), this._optional.axis, -val); + Vector3 diff = origPos - rect.localPosition; + + rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + rect.rotation = this._optional.origRotation; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), this._optional.axis, val); + }; + return this; + } + + public LTDescr setCanvasRotateAroundLocal(){ + this.type = TweenAction.CANVAS_ROTATEAROUND_LOCAL; + this.initInternal = this.initCanvasRotateAround; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + RectTransform rect = this.rectTransform; + Vector3 origPos = rect.localPosition; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), -val); + Vector3 diff = origPos - rect.localPosition; + + rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + rect.rotation = this._optional.origRotation; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), val); + }; + return this; + } + + public LTDescr setCanvasPlaySprite(){ + this.type = TweenAction.CANVAS_PLAYSPRITE; + this.initInternal = ()=>{ + this.uiImage = trans.gameObject.GetComponent(); + this.fromInternal.x = 0f; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + int frame = (int)Mathf.Round( val ); + this.uiImage.sprite = this.sprites[ frame ]; + }; + return this; + } + + public LTDescr setCanvasMove(){ + this.type = TweenAction.CANVAS_MOVE; + this.initInternal = ()=>{ this.fromInternal = this.rectTransform.anchoredPosition3D; }; + this.easeInternal = ()=>{ this.rectTransform.anchoredPosition3D = easeMethod(); }; + return this; + } + + public LTDescr setCanvasScale(){ + this.type = TweenAction.CANVAS_SCALE; + this.initInternal = ()=>{ this.from = this.rectTransform.localScale; }; + this.easeInternal = ()=>{ this.rectTransform.localScale = easeMethod(); }; + return this; + } + + public LTDescr setCanvasSizeDelta(){ + this.type = TweenAction.CANVAS_SIZEDELTA; + this.initInternal = ()=>{ this.from = this.rectTransform.sizeDelta; }; + this.easeInternal = ()=>{ this.rectTransform.sizeDelta = easeMethod(); }; + return this; + } + #endif + + private void callback(){ newVect = easeMethod(); val = newVect.x; } + + public LTDescr setCallback(){ + this.type = TweenAction.CALLBACK; + this.initInternal = ()=>{}; + this.easeInternal = this.callback; + return this; + } + public LTDescr setValue3(){ + this.type = TweenAction.VALUE3; + this.initInternal = ()=>{}; + this.easeInternal = this.callback; + return this; + } + + public LTDescr setMove(){ + this.type = TweenAction.MOVE; + this.initInternal = ()=>{ this.from = trans.position; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.position = newVect; + }; + return this; + } + + public LTDescr setMoveLocal(){ + this.type = TweenAction.MOVE_LOCAL; + this.initInternal = ()=>{ this.from = trans.localPosition; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localPosition = newVect; + }; + return this; + } + + public LTDescr setMoveToTransform(){ + this.type = TweenAction.MOVE_TO_TRANSFORM; + this.initInternal = ()=>{ this.from = trans.position; }; + this.easeInternal = ()=>{ + this.to = this._optional.toTrans.position; + this.diff = this.to - this.from; + this.diffDiv2 = this.diff * 0.5f; + + newVect = easeMethod(); + this.trans.position = newVect; + }; + return this; + } + + public LTDescr setRotate(){ + this.type = TweenAction.ROTATE; + this.initInternal = ()=>{ this.from = trans.eulerAngles; this.to = new Vector3(LeanTween.closestRot( this.fromInternal.x, this.toInternal.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.eulerAngles = newVect; + }; + return this; + } + + public LTDescr setRotateLocal(){ + this.type = TweenAction.ROTATE_LOCAL; + this.initInternal = ()=>{ this.from = trans.localEulerAngles; this.to = new Vector3(LeanTween.closestRot( this.fromInternal.x, this.toInternal.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localEulerAngles = newVect; + }; + return this; + } + + public LTDescr setScale(){ + this.type = TweenAction.SCALE; + this.initInternal = ()=>{ this.from = trans.localScale; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localScale = newVect; + }; + return this; + } + + public LTDescr setGUIMove(){ + this.type = TweenAction.GUI_MOVE; + this.initInternal = ()=>{ this.from = new Vector3(this._optional.ltRect.rect.x, this._optional.ltRect.rect.y, 0); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.rect = new Rect( v.x, v.y, this._optional.ltRect.rect.width, this._optional.ltRect.rect.height); }; + return this; + } + + public LTDescr setGUIMoveMargin(){ + this.type = TweenAction.GUI_MOVE_MARGIN; + this.initInternal = ()=>{ this.from = new Vector2(this._optional.ltRect.margin.x, this._optional.ltRect.margin.y); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.margin = new Vector2(v.x, v.y); }; + return this; + } + + public LTDescr setGUIScale(){ + this.type = TweenAction.GUI_SCALE; + this.initInternal = ()=>{ this.from = new Vector3(this._optional.ltRect.rect.width, this._optional.ltRect.rect.height, 0); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.rect = new Rect( this._optional.ltRect.rect.x, this._optional.ltRect.rect.y, v.x, v.y); }; + return this; + } + + public LTDescr setGUIAlpha(){ + this.type = TweenAction.GUI_ALPHA; + this.initInternal = ()=>{ this.fromInternal.x = this._optional.ltRect.alpha; }; + this.easeInternal = ()=>{ this._optional.ltRect.alpha = easeMethod().x; }; + return this; + } + + public LTDescr setGUIRotate(){ + this.type = TweenAction.GUI_ROTATE; + this.initInternal = ()=>{ if(this._optional.ltRect.rotateEnabled==false){ + this._optional.ltRect.rotateEnabled = true; + this._optional.ltRect.resetForRotation(); + } + + this.fromInternal.x = this._optional.ltRect.rotation; + }; + this.easeInternal = ()=>{ this._optional.ltRect.rotation = easeMethod().x; }; + return this; + } + + public LTDescr setDelayedSound(){ + this.type = TweenAction.DELAYED_SOUND; + this.initInternal = ()=>{ this.hasExtraOnCompletes = true; }; + this.easeInternal = this.callback; + return this; + } + + private void init(){ + this.hasInitiliazed = true; + + usesNormalDt = !(useEstimatedTime || useManualTime || useFrames); // only set this to true if it uses non of the other timing modes + + if (useFrames) + this.optional.initFrameCount = Time.frameCount; + + if (this.time <= 0f) // avoid dividing by zero + this.time = Mathf.Epsilon; + + this.initInternal(); + + this.diff = this.to - this.from; + this.diffDiv2 = this.diff * 0.5f; + + if (this._optional.onStart != null) + this._optional.onStart(); + + if(this.onCompleteOnStart) + callOnCompletes(); + + if(this.speed>=0){ + initSpeed(); + } + } + + private void initSpeed(){ + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + this.time = this._optional.path.distance / this.speed; + }else if(this.type==TweenAction.MOVE_SPLINE || this.type==TweenAction.MOVE_SPLINE_LOCAL){ + this.time = this._optional.spline.distance/ this.speed; + }else{ + this.time = (this.to - this.from).magnitude / this.speed; + } + } + + public static float val; + public static float dt; + public static Vector3 newVect; + + /** + * If you need a tween to happen immediately instead of waiting for the next Update call, you can force it with this method + * + * @method updateNow + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 0f ).updateNow(); + */ + public LTDescr updateNow(){ + updateInternal(); + return this; + } + + public bool updateInternal(){ + + float directionLocal = this.direction; + if(this.usesNormalDt){ + dt = LeanTween.dtActual; + }else if( this.useEstimatedTime ){ + dt = LeanTween.dtEstimated; + }else if( this.useFrames ){ + dt = this.optional.initFrameCount==0 ? 0 : 1; + this.optional.initFrameCount = Time.frameCount; + }else if( this.useManualTime ){ + dt = LeanTween.dtManual; + } + +// Debug.Log ("tween:" + this+ " dt:"+dt); + if(this.delay<=0f && directionLocal!=0f){ + if(trans==null) + return true; + + // initialize if has not done so yet + if(!this.hasInitiliazed) + this.init(); + + dt = dt*directionLocal; + this.passed += dt; + + this.ratioPassed = Mathf.Clamp01(this.passed / this.time); // need to clamp when finished so it will finish at the exact spot and not overshoot + + this.easeInternal(); + + if(this.hasUpdateCallback) + this._optional.callOnUpdate(val, this.ratioPassed); + + bool isTweenFinished = directionLocal>0f ? this.passed>=this.time : this.passed<=0f; + // Debug.Log("lt "+this+" dt:"+dt+" fin:"+isTweenFinished); + if(isTweenFinished){ // increment or flip tween + this.loopCount--; + if(this.loopType==LeanTweenType.pingPong){ + this.direction = 0.0f-directionLocal; + }else{ + this.passed = Mathf.Epsilon; + } + + isTweenFinished = this.loopCount == 0 || this.loopType == LeanTweenType.once; // only return true if it is fully complete + + if(isTweenFinished==false && this.onCompleteOnRepeat && this.hasExtraOnCompletes) + callOnCompletes(); // this only gets called if onCompleteOnRepeat is set to true, otherwise LeanTween class takes care of calling it + + return isTweenFinished; + } + }else{ + this.delay -= dt; + } + + return false; + } + + public void callOnCompletes(){ + if(this.type==TweenAction.GUI_ROTATE) + this._optional.ltRect.rotateFinished = true; + + if(this.type==TweenAction.DELAYED_SOUND){ + AudioSource.PlayClipAtPoint((AudioClip)this._optional.onCompleteParam, this.to, this.from.x); + } + if(this._optional.onComplete!=null){ + this._optional.onComplete(); + }else if(this._optional.onCompleteObject!=null){ + this._optional.onCompleteObject(this._optional.onCompleteParam); + } + } + + // Helper Methods + + public LTDescr setFromColor( Color col ){ + this.from = new Vector3(0.0f, col.a, 0.0f); + this.diff = new Vector3(1.0f,0.0f,0.0f); + this._optional.axis = new Vector3( col.r, col.g, col.b ); + return this; + } + + private static void alphaRecursive( Transform transform, float val, bool useRecursion = true){ + Renderer renderer = transform.gameObject.GetComponent(); + if(renderer!=null){ + foreach(Material mat in renderer.materials){ + if(mat.HasProperty("_Color")){ + mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val); + }else if(mat.HasProperty("_TintColor")){ + Color col = mat.GetColor ("_TintColor"); + mat.SetColor("_TintColor", new Color( col.r, col.g, col.b, val)); + } + } + } + if(useRecursion && transform.childCount>0){ + foreach (Transform child in transform) { + alphaRecursive(child, val); + } + } + } + + private static void colorRecursive( Transform transform, Color toColor, bool useRecursion = true ){ + Renderer ren = transform.gameObject.GetComponent(); + if(ren!=null){ + foreach(Material mat in ren.materials){ + mat.color = toColor; + } + } + if(useRecursion && transform.childCount>0){ + foreach (Transform child in transform) { + colorRecursive(child, toColor); + } + } + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + private static void alphaRecursive( RectTransform rectTransform, float val, int recursiveLevel = 0){ + if(rectTransform.childCount>0){ + foreach (RectTransform child in rectTransform) { + UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent(); + if (uiImage != null) { + Color c = uiImage.color; c.a = val; uiImage.color = c; + } else { + uiImage = child.GetComponent(); + if (uiImage != null) { + Color c = uiImage.color; c.a = val; uiImage.color = c; + } + } + + alphaRecursive(child, val, recursiveLevel + 1); + } + } + } + + private static void alphaRecursiveSprite( Transform transform, float val ){ + if(transform.childCount>0){ + foreach (Transform child in transform) { + SpriteRenderer ren = child.GetComponent(); + if(ren!=null) + ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val); + alphaRecursiveSprite(child, val); + } + } + } + + private static void colorRecursiveSprite( Transform transform, Color toColor ){ + if(transform.childCount>0){ + foreach (Transform child in transform) { + SpriteRenderer ren = transform.gameObject.GetComponent(); + if(ren!=null) + ren.color = toColor; + colorRecursiveSprite(child, toColor); + } + } + } + + private static void colorRecursive( RectTransform rectTransform, Color toColor ){ + + if(rectTransform.childCount>0){ + foreach (RectTransform child in rectTransform) { + UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent(); + if (uiImage != null) { + uiImage.color = toColor; + } else { + uiImage = child.GetComponent(); + if (uiImage != null) + uiImage.color = toColor; + } + colorRecursive(child, toColor); + } + } + } + + private static void textAlphaRecursive( Transform trans, float val, bool useRecursion = true ){ + UnityEngine.UI.Text uiText = trans.gameObject.GetComponent(); + if(uiText!=null){ + Color c = uiText.color; + c.a = val; + uiText.color = c; + } + if(useRecursion && trans.childCount>0){ + foreach (Transform child in trans) { + textAlphaRecursive(child, val); + } + } + } + + private static void textColorRecursive(Transform trans, Color toColor ){ + if(trans.childCount>0){ + foreach (Transform child in trans) { + UnityEngine.UI.Text uiText = child.gameObject.GetComponent(); + if(uiText!=null){ + uiText.color = toColor; + } + textColorRecursive(child, toColor); + } + } + } + #endif + + private static Color tweenColor( LTDescr tween, float val ){ + Vector3 diff3 = tween._optional.point - tween._optional.axis; + float diffAlpha = tween.to.y - tween.from.y; + return new Color(tween._optional.axis.x + diff3.x*val, tween._optional.axis.y + diff3.y*val, tween._optional.axis.z + diff3.z*val, tween.from.y + diffAlpha*val); + } + + /** + * Pause a tween + * + * @method pause + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public LTDescr pause(){ + if(this.direction != 0.0f){ // check if tween is already paused + this.directionLast = this.direction; + this.direction = 0.0f; + } + + return this; + } + + /** + * Resume a paused tween + * + * @method resume + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public LTDescr resume(){ + this.direction = this.directionLast; + + return this; + } + + public LTDescr setAxis( Vector3 axis ){ + this._optional.axis = axis; + return this; + } + + /** + * Delay the start of a tween + * + * @method setDelay + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setDelay( 1.5f ); + */ + public LTDescr setDelay( float delay ){ + this.delay = delay; + + return this; + } + + /** + * Set the type of easing used for the tween.
    + * + * + * @method setEase + * @param {LeanTweenType} easeType:LeanTweenType the easing type to use + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); + */ + public LTDescr setEase( LeanTweenType easeType ){ + + switch( easeType ){ + case LeanTweenType.linear: + setEaseLinear(); break; + case LeanTweenType.easeOutQuad: + setEaseOutQuad(); break; + case LeanTweenType.easeInQuad: + setEaseInQuad(); break; + case LeanTweenType.easeInOutQuad: + setEaseInOutQuad(); break; + case LeanTweenType.easeInCubic: + setEaseInCubic();break; + case LeanTweenType.easeOutCubic: + setEaseOutCubic(); break; + case LeanTweenType.easeInOutCubic: + setEaseInOutCubic(); break; + case LeanTweenType.easeInQuart: + setEaseInQuart(); break; + case LeanTweenType.easeOutQuart: + setEaseOutQuart(); break; + case LeanTweenType.easeInOutQuart: + setEaseInOutQuart(); break; + case LeanTweenType.easeInQuint: + setEaseInQuint(); break; + case LeanTweenType.easeOutQuint: + setEaseOutQuint(); break; + case LeanTweenType.easeInOutQuint: + setEaseInOutQuint(); break; + case LeanTweenType.easeInSine: + setEaseInSine(); break; + case LeanTweenType.easeOutSine: + setEaseOutSine(); break; + case LeanTweenType.easeInOutSine: + setEaseInOutSine(); break; + case LeanTweenType.easeInExpo: + setEaseInExpo(); break; + case LeanTweenType.easeOutExpo: + setEaseOutExpo(); break; + case LeanTweenType.easeInOutExpo: + setEaseInOutExpo(); break; + case LeanTweenType.easeInCirc: + setEaseInCirc(); break; + case LeanTweenType.easeOutCirc: + setEaseOutCirc(); break; + case LeanTweenType.easeInOutCirc: + setEaseInOutCirc(); break; + case LeanTweenType.easeInBounce: + setEaseInBounce(); break; + case LeanTweenType.easeOutBounce: + setEaseOutBounce(); break; + case LeanTweenType.easeInOutBounce: + setEaseInOutBounce(); break; + case LeanTweenType.easeInBack: + setEaseInBack(); break; + case LeanTweenType.easeOutBack: + setEaseOutBack(); break; + case LeanTweenType.easeInOutBack: + setEaseInOutBack(); break; + case LeanTweenType.easeInElastic: + setEaseInElastic(); break; + case LeanTweenType.easeOutElastic: + setEaseOutElastic(); break; + case LeanTweenType.easeInOutElastic: + setEaseInOutElastic(); break; + case LeanTweenType.punch: + setEasePunch(); break; + case LeanTweenType.easeShake: + setEaseShake(); break; + case LeanTweenType.easeSpring: + setEaseSpring(); break; + default: + setEaseLinear(); break; + } + + return this; + } + + public LTDescr setEaseLinear(){ this.tweenType = LeanTweenType.linear; this.easeMethod = this.easeLinear; return this; } + + public LTDescr setEaseSpring(){ this.tweenType = LeanTweenType.easeSpring; this.easeMethod = this.easeSpring; return this; } + + public LTDescr setEaseInQuad(){ this.tweenType = LeanTweenType.easeInQuad; this.easeMethod = this.easeInQuad; return this; } + + public LTDescr setEaseOutQuad(){ this.tweenType = LeanTweenType.easeOutQuad; this.easeMethod = this.easeOutQuad; return this; } + + public LTDescr setEaseInOutQuad(){ this.tweenType = LeanTweenType.easeInOutQuad; this.easeMethod = this.easeInOutQuad; return this;} + + public LTDescr setEaseInCubic(){ this.tweenType = LeanTweenType.easeInCubic; this.easeMethod = this.easeInCubic; return this; } + + public LTDescr setEaseOutCubic(){ this.tweenType = LeanTweenType.easeOutCubic; this.easeMethod = this.easeOutCubic; return this; } + + public LTDescr setEaseInOutCubic(){ this.tweenType = LeanTweenType.easeInOutCubic; this.easeMethod = this.easeInOutCubic; return this; } + + public LTDescr setEaseInQuart(){ this.tweenType = LeanTweenType.easeInQuart; this.easeMethod = this.easeInQuart; return this; } + + public LTDescr setEaseOutQuart(){ this.tweenType = LeanTweenType.easeOutQuart; this.easeMethod = this.easeOutQuart; return this; } + + public LTDescr setEaseInOutQuart(){ this.tweenType = LeanTweenType.easeInOutQuart; this.easeMethod = this.easeInOutQuart; return this; } + + public LTDescr setEaseInQuint(){ this.tweenType = LeanTweenType.easeInQuint; this.easeMethod = this.easeInQuint; return this; } + + public LTDescr setEaseOutQuint(){ this.tweenType = LeanTweenType.easeOutQuint; this.easeMethod = this.easeOutQuint; return this; } + + public LTDescr setEaseInOutQuint(){ this.tweenType = LeanTweenType.easeInOutQuint; this.easeMethod = this.easeInOutQuint; return this; } + + public LTDescr setEaseInSine(){ this.tweenType = LeanTweenType.easeInSine; this.easeMethod = this.easeInSine; return this; } + + public LTDescr setEaseOutSine(){ this.tweenType = LeanTweenType.easeOutSine; this.easeMethod = this.easeOutSine; return this; } + + public LTDescr setEaseInOutSine(){ this.tweenType = LeanTweenType.easeInOutSine; this.easeMethod = this.easeInOutSine; return this; } + + public LTDescr setEaseInExpo(){ this.tweenType = LeanTweenType.easeInExpo; this.easeMethod = this.easeInExpo; return this; } + + public LTDescr setEaseOutExpo(){ this.tweenType = LeanTweenType.easeOutExpo; this.easeMethod = this.easeOutExpo; return this; } + + public LTDescr setEaseInOutExpo(){ this.tweenType = LeanTweenType.easeInOutExpo; this.easeMethod = this.easeInOutExpo; return this; } + + public LTDescr setEaseInCirc(){ this.tweenType = LeanTweenType.easeInCirc; this.easeMethod = this.easeInCirc; return this; } + + public LTDescr setEaseOutCirc(){ this.tweenType = LeanTweenType.easeOutCirc; this.easeMethod = this.easeOutCirc; return this; } + + public LTDescr setEaseInOutCirc(){ this.tweenType = LeanTweenType.easeInOutCirc; this.easeMethod = this.easeInOutCirc; return this; } + + public LTDescr setEaseInBounce(){ this.tweenType = LeanTweenType.easeInBounce; this.easeMethod = this.easeInBounce; return this; } + + public LTDescr setEaseOutBounce(){ this.tweenType = LeanTweenType.easeOutBounce; this.easeMethod = this.easeOutBounce; return this; } + + public LTDescr setEaseInOutBounce(){ this.tweenType = LeanTweenType.easeInOutBounce; this.easeMethod = this.easeInOutBounce; return this; } + + public LTDescr setEaseInBack(){ this.tweenType = LeanTweenType.easeInBack; this.easeMethod = this.easeInBack; return this; } + + public LTDescr setEaseOutBack(){ this.tweenType = LeanTweenType.easeOutBack; this.easeMethod = this.easeOutBack; return this; } + + public LTDescr setEaseInOutBack(){ this.tweenType = LeanTweenType.easeInOutBack; this.easeMethod = this.easeInOutBack; return this; } + + public LTDescr setEaseInElastic(){ this.tweenType = LeanTweenType.easeInElastic; this.easeMethod = this.easeInElastic; return this; } + + public LTDescr setEaseOutElastic(){ this.tweenType = LeanTweenType.easeOutElastic; this.easeMethod = this.easeOutElastic; return this; } + + public LTDescr setEaseInOutElastic(){ this.tweenType = LeanTweenType.easeInOutElastic; this.easeMethod = this.easeInOutElastic; return this; } + + public LTDescr setEasePunch(){ this._optional.animationCurve = LeanTween.punch; this.toInternal.x = this.from.x + this.to.x; this.easeMethod = this.tweenOnCurve; return this; } + + public LTDescr setEaseShake(){ this._optional.animationCurve = LeanTween.shake; this.toInternal.x = this.from.x + this.to.x; this.easeMethod = this.tweenOnCurve; return this; } + + private Vector3 tweenOnCurve(){ + return new Vector3(this.from.x + (this.diff.x) * this._optional.animationCurve.Evaluate(ratioPassed), + this.from.y + (this.diff.y) * this._optional.animationCurve.Evaluate(ratioPassed), + this.from.z + (this.diff.z) * this._optional.animationCurve.Evaluate(ratioPassed) ); + } + + // Vector3 Ease Methods + + private Vector3 easeInOutQuad(){ + val = this.ratioPassed * 2f; + + if (val < 1f) { + val = val * val; + return new Vector3( this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val = (1f-val) * (val - 3f) + 1f; + return new Vector3( this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInQuad(){ + val = ratioPassed * ratioPassed; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutQuad(){ + val = this.ratioPassed; + val = -val * (val - 2f); + return (this.diff * val + this.from); + } + + private Vector3 easeLinear(){ + val = this.ratioPassed; + return new Vector3(this.from.x+this.diff.x*val, this.from.y+this.diff.y*val, this.from.z+this.diff.z*val); + } + + private Vector3 easeSpring(){ + val = Mathf.Clamp01(this.ratioPassed); + val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f ) + val) * (1f + (1.2f * (1f - val) )); + return this.from + this.diff * val; + } + + private Vector3 easeInCubic(){ + val = this.ratioPassed * this.ratioPassed * this.ratioPassed; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutCubic(){ + val = this.ratioPassed - 1f; + val = (val * val * val + 1); + return new Vector3( this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z) ; + } + + private Vector3 easeInOutCubic(){ + val = this.ratioPassed * 2f; + if (val < 1f) { + val = val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = val * val * val + 2f; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y,this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInQuart(){ + val = this.ratioPassed * this.ratioPassed * this.ratioPassed * this.ratioPassed; + return diff * val + this.from; + } + + private Vector3 easeOutQuart(){ + val = this.ratioPassed - 1f; + val = -(val * val * val * val - 1); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y,this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutQuart(){ + val = this.ratioPassed * 2f; + if (val < 1f) { + val = val * val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; +// val = (val * val * val * val - 2f); + return -this.diffDiv2 * (val * val * val * val - 2f) + this.from; + } + + private Vector3 easeInQuint(){ + val = this.ratioPassed; + val = val * val * val * val * val; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutQuint(){ + val = this.ratioPassed - 1f; + val = (val * val * val * val * val + 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutQuint(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + val = val * val * val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x,this.diffDiv2.y * val + this.from.y,this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = (val * val * val * val * val + 2f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInSine(){ + val = - Mathf.Cos(this.ratioPassed * LeanTween.PI_DIV2); + return new Vector3(this.diff.x * val + this.diff.x + this.from.x, this.diff.y * val + this.diff.y + this.from.y, this.diff.z * val + this.diff.z + this.from.z); + } + + private Vector3 easeOutSine(){ + val = Mathf.Sin(this.ratioPassed * LeanTween.PI_DIV2); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y,this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutSine(){ + val = -(Mathf.Cos(Mathf.PI * this.ratioPassed) - 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInExpo(){ + val = Mathf.Pow(2f, 10f * (this.ratioPassed - 1f)); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutExpo(){ + val = (-Mathf.Pow(2f, -10f * this.ratioPassed) + 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutExpo(){ + val = this.ratioPassed * 2f; + val = Mathf.Pow(2f, 10f * (val - 1f)); + if (val < 1f) + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + val--; + val = (-Mathf.Pow(2f, -10f * val) + 2f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInCirc(){ + val = -(Mathf.Sqrt(1f - this.ratioPassed * this.ratioPassed) - 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutCirc(){ + val = this.ratioPassed - 1f; + val = Mathf.Sqrt(1f - val * val); + + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutCirc(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + val = -(Mathf.Sqrt(1f - val * val) - 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = (Mathf.Sqrt(1f - val * val) + 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInBounce(){ + val = this.ratioPassed; + val = 1f - val; + return new Vector3(this.diff.x - LeanTween.easeOutBounce(0, this.diff.x, val) + this.from.x, + this.diff.y - LeanTween.easeOutBounce(0, this.diff.y, val) + this.from.y, + this.diff.z - LeanTween.easeOutBounce(0, this.diff.z, val) + this.from.z); + } + + private Vector3 easeOutBounce(){ + val = ratioPassed; + if (val < (1 / 2.75f)){ + val = (7.5625f * val * val); + return this.diff * val + this.from; + }else if (val < (2 / 2.75f)){ + val -= (1.5f / 2.75f); + val = (7.5625f * (val) * val + .75f); + return this.diff * val + this.from; + }else if (val < (2.5 / 2.75)){ + val -= (2.25f / 2.75f); + val = (7.5625f * (val) * val + .9375f); + return this.diff * val + this.from; + }else{ + val -= (2.625f / 2.75f); + val = 7.5625f * (val) * val + .984375f; + return this.diff * val + this.from; + } + } + + private Vector3 easeInOutBounce(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + return new Vector3(LeanTween.easeInBounce(0, this.diff.x, val) * 0.5f + this.from.x, + LeanTween.easeInBounce(0, this.diff.y, val) * 0.5f + this.from.y, + LeanTween.easeInBounce(0, this.diff.z, val) * 0.5f + this.from.z); + }else { + val = val - 1f; + return new Vector3(LeanTween.easeOutBounce(0, this.diff.x, val) * 0.5f + this.diffDiv2.x + this.from.x, + LeanTween.easeOutBounce(0, this.diff.y, val) * 0.5f + this.diffDiv2.y + this.from.y, + LeanTween.easeOutBounce(0, this.diff.z, val) * 0.5f + this.diffDiv2.z + this.from.z); + } + } + + private Vector3 easeInBack(){ + val = this.ratioPassed; + val /= 1; + float s = 1.70158f * this.overshoot; + return this.diff * (val) * val * ((s + 1) * val - s) + this.from; + } + + private Vector3 easeOutBack(){ + float s = 1.70158f * this.overshoot; + val = (this.ratioPassed / 1) - 1; + val = ((val) * val * ((s + 1) * val + s) + 1); + return this.diff * val + this.from; + } + + private Vector3 easeInOutBack(){ + float s = 1.70158f * this.overshoot; + val = this.ratioPassed * 2f; + if ((val) < 1){ + s *= (1.525f) * overshoot; + return this.diffDiv2 * (val * val * (((s) + 1) * val - s)) + this.from; + } + val -= 2; + s *= (1.525f) * overshoot; + val = ((val) * val * (((s) + 1) * val + s) + 2); + return this.diffDiv2 * val + this.from; + } + + private Vector3 easeInElastic(){ + return new Vector3(LeanTween.easeInElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + private Vector3 easeOutElastic(){ + return new Vector3(LeanTween.easeOutElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeOutElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeOutElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + private Vector3 easeInOutElastic() + { + return new Vector3(LeanTween.easeInOutElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInOutElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInOutElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + /** + * Set how far past a tween will overshoot for certain ease types (compatible: easeInBack, easeInOutBack, easeOutBack, easeOutElastic, easeInElastic, easeInOutElastic).
    + * @method setOvershoot + * @param {float} overshoot:float how far past the destination it will go before settling in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutBack ).setOvershoot(2f); + */ + public LTDescr setOvershoot( float overshoot ){ + this.overshoot = overshoot; + return this; + } + + /** + * Set how short the iterations are for certain ease types (compatible: easeOutElastic, easeInElastic, easeInOutElastic).
    + * @method setPeriod + * @param {float} period:float how short the iterations are that the tween will animate at (default 0.3f) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutElastic ).setPeriod(0.3f); + */ + public LTDescr setPeriod( float period ){ + this.period = period; + return this; + } + + /** + * Set how large the effect is for certain ease types (compatible: punch, shake, animation curves).
    + * @method setScale + * @param {float} scale:float how much the ease will be multiplied by (default 1f) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.punch ).setScale(2f); + */ + public LTDescr setScale( float scale ){ + this.scale = scale; + return this; + } + + /** + * Set the type of easing used for the tween with a custom curve.
    + * @method setEase (AnimationCurve) + * @param {AnimationCurve} easeDefinition:AnimationCurve an AnimationCure that describes the type of easing you want, this is great for when you want a unique type of movement + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); + */ + public LTDescr setEase( AnimationCurve easeCurve ){ + this._optional.animationCurve = easeCurve; + this.easeMethod = this.tweenOnCurve; + this.tweenType = LeanTweenType.animationCurve; + return this; + } + + /** + * Set the end that the GameObject is tweening towards + * @method setTo + * @param {Vector3} to:Vector3 point at which you want the tween to reach + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LTDescr descr = LeanTween.move( cube, Vector3.up, new Vector3(1f,3f,0f), 1.0f ).setEase( LeanTweenType.easeInOutBounce );
    + * // Later your want to change your destination or your destiation is constantly moving
    + * descr.setTo( new Vector3(5f,10f,3f) );
    + */ + public LTDescr setTo( Vector3 to ){ + if(this.hasInitiliazed){ + this.to = to; + this.diff = to - this.from; + }else{ + this.to = to; + } + + return this; + } + + public LTDescr setTo( Transform to ){ + this._optional.toTrans = to; + return this; + } + + /** + * Set the beginning of the tween + * @method setFrom + * @param {Vector3} from:Vector3 the point you would like the tween to start at + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LTDescr descr = LeanTween.move( cube, Vector3.up, new Vector3(1f,3f,0f), 1.0f ).setFrom( new Vector3(5f,10f,3f) );
    + */ + public LTDescr setFrom( Vector3 from ){ + if(this.trans){ + this.init(); + } + this.from = from; + // this.hasInitiliazed = true; // this is set, so that the "from" value isn't overwritten later on when the tween starts + this.diff = this.to - this.from; + return this; + } + + public LTDescr setFrom( float from ){ + return setFrom( new Vector3(from, 0f, 0f) ); + } + + public LTDescr setDiff( Vector3 diff ){ + this.diff = diff; + return this; + } + + public LTDescr setHasInitialized( bool has ){ + this.hasInitiliazed = has; + return this; + } + + public LTDescr setId( uint id ){ + this._id = id; + this.counter = global_counter; + // Debug.Log("Global counter:"+global_counter); + return this; + } + + /** + * Set the finish time of the tween + * @method setTime + * @param {float} finishTime:float the length of time in seconds you wish the tween to complete in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * int tweenId = LeanTween.moveX(gameObject, 5f, 2.0f ).id;
    + * // Later
    + * LTDescr descr = description( tweenId );
    + * descr.setTime( 1f );
    + */ + public LTDescr setTime( float time ){ + float passedTimeRatio = this.passed / this.time; + this.passed = time * passedTimeRatio; + this.time = time; + return this; + } + + /** + * Set the finish time of the tween + * @method setSpeed + * @param {float} speed:float the speed in unity units per second you wish the object to travel (overrides the given time) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveLocalZ( gameObject, 10f, 1f).setSpeed(0.2f) // the given time is ignored when speed is set
    + */ + public LTDescr setSpeed( float speed ){ + this.speed = speed; + if(this.hasInitiliazed) + initSpeed(); + return this; + } + + /** + * Set the tween to repeat a number of times. + * @method setRepeat + * @param {int} repeatNum:int the number of times to repeat the tween. -1 to repeat infinite times + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong(); + */ + public LTDescr setRepeat( int repeat ){ + this.loopCount = repeat; + if((repeat>1 && this.loopType == LeanTweenType.once) || (repeat < 0 && this.loopType == LeanTweenType.once)){ + this.loopType = LeanTweenType.clamp; + } + if(this.type==TweenAction.CALLBACK || this.type==TweenAction.CALLBACK_COLOR){ + this.setOnCompleteOnRepeat(true); + } + return this; + } + + public LTDescr setLoopType( LeanTweenType loopType ){ + this.loopType = loopType; + return this; + } + + public LTDescr setUseEstimatedTime( bool useEstimatedTime ){ + this.useEstimatedTime = useEstimatedTime; + this.usesNormalDt = false; + return this; + } + + /** + * Set ignore time scale when tweening an object when you want the animation to be time-scale independent (ignores the Time.timeScale value). Great for pause screens, when you want all other action to be stopped (or slowed down) + * @method setIgnoreTimeScale + * @param {bool} useUnScaledTime:bool whether to use the unscaled time or not + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setIgnoreTimeScale( true ); + */ + public LTDescr setIgnoreTimeScale( bool useUnScaledTime ){ + this.useEstimatedTime = useUnScaledTime; + this.usesNormalDt = false; + return this; + } + + /** + * Use frames when tweening an object, when you don't want the animation to be time-frame independent... + * @method setUseFrames + * @param {bool} useFrames:bool whether to use estimated time or not + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setUseFrames( true ); + */ + public LTDescr setUseFrames( bool useFrames ){ + this.useFrames = useFrames; + this.usesNormalDt = false; + return this; + } + + public LTDescr setUseManualTime( bool useManualTime ){ + this.useManualTime = useManualTime; + this.usesNormalDt = false; + return this; + } + + public LTDescr setLoopCount( int loopCount ){ + this.loopType = LeanTweenType.clamp; + this.loopCount = loopCount; + return this; + } + + /** + * No looping involved, just run once (the default) + * @method setLoopOnce + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce(); + */ + public LTDescr setLoopOnce(){ this.loopType = LeanTweenType.once; return this; } + + /** + * When the animation gets to the end it starts back at where it began + * @method setLoopClamp + * @param {int} loops:int (defaults to -1) how many times you want the loop to happen (-1 for an infinite number of times) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopClamp( 2 ); + */ + public LTDescr setLoopClamp(){ + this.loopType = LeanTweenType.clamp; + if(this.loopCount==0) + this.loopCount = -1; + return this; + } + public LTDescr setLoopClamp( int loops ){ + this.loopCount = loops; + return this; + } + + /** + * When the animation gets to the end it then tweens back to where it started (and on, and on) + * @method setLoopPingPong + * @param {int} loops:int (defaults to -1) how many times you want the loop to happen in both directions (-1 for an infinite number of times). Passing a value of 1 will cause the object to go towards and back from it's destination once. + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopPingPong( 2 ); + */ + public LTDescr setLoopPingPong(){ + this.loopType = LeanTweenType.pingPong; + if(this.loopCount==0) + this.loopCount = -1; + return this; + } + public LTDescr setLoopPingPong( int loops ) { + this.loopType = LeanTweenType.pingPong; + this.loopCount = loops == -1 ? loops : loops * 2; + return this; + } + + /** + * Have a method called when the tween finishes + * @method setOnComplete + * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished(){ } + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished ); + */ + public LTDescr setOnComplete( Action onComplete ){ + this._optional.onComplete = onComplete; + this.hasExtraOnCompletes = true; + return this; + } + + /** + * Have a method called when the tween finishes + * @method setOnComplete (object) + * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished( object myObj ){ } + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished ); + */ + public LTDescr setOnComplete( Action onComplete ){ + this._optional.onCompleteObject = onComplete; + this.hasExtraOnCompletes = true; + return this; + } + public LTDescr setOnComplete( Action onComplete, object onCompleteParam ){ + this._optional.onCompleteObject = onComplete; + this.hasExtraOnCompletes = true; + if(onCompleteParam!=null) + this._optional.onCompleteParam = onCompleteParam; + return this; + } + + /** + * Pass an object to along with the onComplete Function + * @method setOnCompleteParam + * @param {object} onComplete:object an object that + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.delayedCall(1.5f, enterMiniGameStart).setOnCompleteParam( new object[]{""+5} );

    + * void enterMiniGameStart( object val ){
    + *  object[] arr = (object [])val;
    + *  int lvl = int.Parse((string)arr[0]);
    + * }
    + */ + public LTDescr setOnCompleteParam( object onCompleteParam ){ + this._optional.onCompleteParam = onCompleteParam; + this.hasExtraOnCompletes = true; + return this; + } + + + /** + * Have a method called on each frame that the tween is being animated (passes a float value) + * @method setOnUpdate + * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
    + *
    + * void tweenMoved( float val ){ }
    + */ + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateFloat = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateRatio(Action onUpdate) + { + this._optional.onUpdateFloatRatio = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + public LTDescr setOnUpdateObject( Action onUpdate ){ + this._optional.onUpdateFloatObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateVector2( Action onUpdate ){ + this._optional.onUpdateVector2 = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateVector3( Action onUpdate ){ + this._optional.onUpdateVector3 = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateColor( Action onUpdate ){ + this._optional.onUpdateColor = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateColor( Action onUpdate ){ + this._optional.onUpdateColorObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + #if !UNITY_FLASH + + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateColor = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateColorObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + /** + * Have a method called on each frame that the tween is being animated (passes a float value and a object) + * @method setOnUpdate (object) + * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object, and an object of the person's choosing + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );
    + *
    + * void tweenMoved( float val, object obj ){ }
    + */ + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateFloatObject = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector3Object = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector2 = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + /** + * Have a method called on each frame that the tween is being animated (passes a float value) + * @method setOnUpdate (Vector3) + * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
    + *
    + * void tweenMoved( Vector3 val ){ }
    + */ + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector3 = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + #endif + + + /** + * Have an object passed along with the onUpdate method + * @method setOnUpdateParam + * @param {object} onUpdateParam:object an object that will be passed along with the onUpdate method + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );
    + *
    + * void tweenMoved( float val, object obj ){ }
    + */ + public LTDescr setOnUpdateParam( object onUpdateParam ){ + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + /** + * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon + * @method setOrientToPath + * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);
    + */ + public LTDescr setOrientToPath( bool doesOrient ){ + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + if(this._optional.path==null) + this._optional.path = new LTBezierPath(); + this._optional.path.orientToPath = doesOrient; + }else{ + this._optional.spline.orientToPath = doesOrient; + } + return this; + } + + /** + * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon + * @method setOrientToPath2d + * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath2d(true).setAxis(Vector3.forward);
    + */ + public LTDescr setOrientToPath2d( bool doesOrient2d ){ + setOrientToPath(doesOrient2d); + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + this._optional.path.orientToPath2d = doesOrient2d; + }else{ + this._optional.spline.orientToPath2d = doesOrient2d; + } + return this; + } + + public LTDescr setRect( LTRect rect ){ + this._optional.ltRect = rect; + return this; + } + + public LTDescr setRect( Rect rect ){ + this._optional.ltRect = new LTRect(rect); + return this; + } + + public LTDescr setPath( LTBezierPath path ){ + this._optional.path = path; + return this; + } + + /** + * Set the point at which the GameObject will be rotated around + * @method setPoint + * @param {Vector3} point:Vector3 point at which you want the object to rotate around (local space) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.rotateAround( cube, Vector3.up, 360.0f, 1.0f ) .setPoint( new Vector3(1f,0f,0f) ) .setEase( LeanTweenType.easeInOutBounce );
    + */ + public LTDescr setPoint( Vector3 point ){ + this._optional.point = point; + return this; + } + + public LTDescr setDestroyOnComplete( bool doesDestroy ){ + this.destroyOnComplete = doesDestroy; + return this; + } + + public LTDescr setAudio( object audio ){ + this._optional.onCompleteParam = audio; + return this; + } + + /** + * Set the onComplete method to be called at the end of every loop cycle (also applies to the delayedCall method) + * @method setOnCompleteOnRepeat + * @param {bool} isOn:bool does call onComplete on every loop cycle + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true); + */ + public LTDescr setOnCompleteOnRepeat( bool isOn ){ + this.onCompleteOnRepeat = isOn; + return this; + } + + /** + * Set the onComplete method to be called at the beginning of the tween (it will still be called when it is completed as well) + * @method setOnCompleteOnStart + * @param {bool} isOn:bool does call onComplete at the start of the tween + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.delayedCall(gameObject, 2f, ()=>{
    // Flash an object 5 times + *  LeanTween.alpha(gameObject, 0f, 1f);
    + *  LeanTween.alpha(gameObject, 1f, 0f).setDelay(1f);
    + * }).setOnCompleteOnStart(true).setRepeat(5);
    + */ + public LTDescr setOnCompleteOnStart( bool isOn ){ + this.onCompleteOnStart = isOn; + return this; + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public LTDescr setRect( RectTransform rect ){ + this.rectTransform = rect; + return this; + } + + public LTDescr setSprites( UnityEngine.Sprite[] sprites ){ + this.sprites = sprites; + return this; + } + + public LTDescr setFrameRate( float frameRate ){ + this.time = this.sprites.Length / frameRate; + return this; + } + #endif + + /** + * Have a method called when the tween starts + * @method setOnStart + * @param {Action<>} onStart:Action<> the method that should be called when the tween is starting ex: tweenStarted( ){ } + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * C#:
    + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( ()=>{ Debug.Log("I started!"); }); + * Javascript:
    + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( function(){ Debug.Log("I started!"); } ); + */ + public LTDescr setOnStart( Action onStart ){ + this._optional.onStart = onStart; + return this; + } + + /** + * Set the direction of a tween -1f for backwards 1f for forwards (currently only bezier and spline paths are supported) + * @method setDirection + * @param {float} direction:float the direction that the tween should run, -1f for backwards 1f for forwards + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setDirection(-1f);
    + */ + + public LTDescr setDirection( float direction ){ + if(this.direction!=-1f && this.direction!=1f){ + Debug.LogWarning("You have passed an incorrect direction of '"+direction+"', direction must be -1f or 1f"); + return this; + } + + if(this.direction!=direction){ + // Debug.Log("reverse path:"+this.path+" spline:"+this._optional.spline+" hasInitiliazed:"+this.hasInitiliazed); + if(this.hasInitiliazed){ + this.direction = direction; + }else{ + if(this._optional.path!=null){ + this._optional.path = new LTBezierPath( LTUtility.reverse( this._optional.path.pts ) ); + }else if(this._optional.spline!=null){ + this._optional.spline = new LTSpline( LTUtility.reverse( this._optional.spline.pts ) ); + } + // this.passed = this.time - this.passed; + } + } + + return this; + } + + /** + * Set whether or not the tween will recursively effect an objects children in the hierarchy + * @method setRecursive + * @param {bool} useRecursion:bool whether the tween will recursively effect an objects children in the hierarchy + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(gameObject, 0f, 1f).setRecursive(true);
    + */ + + public LTDescr setRecursive( bool useRecursion ){ + this.useRecursion = useRecursion; + + return this; + } +} + +//} diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs.meta new file mode 100644 index 0000000..e47c628 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescr.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 381c8d6fb1acdc348870a7147bc98723 +timeCreated: 1463137984 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs new file mode 100644 index 0000000..f2b2476 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs @@ -0,0 +1,88 @@ +//namespace DentedPixel{ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; + +public class LTDescrOptional { + + public Transform toTrans { get; set; } + public Vector3 point { get; set; } + public Vector3 axis { get; set; } + public float lastVal{ get; set; } + public Quaternion origRotation { get; set; } + public LTBezierPath path { get; set; } + public LTSpline spline { get; set; } + public AnimationCurve animationCurve; + public int initFrameCount; + + public LTRect ltRect { get; set; } // maybe get rid of this eventually + + public Action onUpdateFloat { get; set; } + public Action onUpdateFloatRatio { get; set; } + public Action onUpdateFloatObject { get; set; } + public Action onUpdateVector2 { get; set; } + public Action onUpdateVector3 { get; set; } + public Action onUpdateVector3Object { get; set; } + public Action onUpdateColor { get; set; } + public Action onUpdateColorObject { get; set; } + public Action onComplete { get; set; } + public Action onCompleteObject { get; set; } + public object onCompleteParam { get; set; } + public object onUpdateParam { get; set; } + public Action onStart { get; set; } + + +// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 +// public SpriteRenderer spriteRen { get; set; } +// #endif +// +// #if LEANTWEEN_1 +// public Hashtable optional; +// #endif +// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 +// public RectTransform rectTransform; +// public UnityEngine.UI.Text uiText; +// public UnityEngine.UI.Image uiImage; +// public UnityEngine.Sprite[] sprites; +// #endif + + + public void reset(){ + animationCurve = null; + + this.onUpdateFloat = null; + this.onUpdateFloatRatio = null; + this.onUpdateVector2 = null; + this.onUpdateVector3 = null; + this.onUpdateFloatObject = null; + this.onUpdateVector3Object = null; + this.onUpdateColor = null; + this.onComplete = null; + this.onCompleteObject = null; + this.onCompleteParam = null; + this.onStart = null; + + this.point = Vector3.zero; + this.initFrameCount = 0; + } + + public void callOnUpdate( float val, float ratioPassed){ + if(this.onUpdateFloat!=null) + this.onUpdateFloat(val); + + if (this.onUpdateFloatRatio != null){ + this.onUpdateFloatRatio(val,ratioPassed); + }else if(this.onUpdateFloatObject!=null){ + this.onUpdateFloatObject(val, this.onUpdateParam); + }else if(this.onUpdateVector3Object!=null){ + this.onUpdateVector3Object(LTDescr.newVect, this.onUpdateParam); + }else if(this.onUpdateVector3!=null){ + this.onUpdateVector3(LTDescr.newVect); + }else if(this.onUpdateVector2!=null){ + this.onUpdateVector2(new Vector2(LTDescr.newVect.x,LTDescr.newVect.y)); + } + } +} + +//} diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs.meta new file mode 100644 index 0000000..8b83a30 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LTDescrOptional.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c1ba8f1ef97134cb39b52ae26678db63 +timeCreated: 1471504769 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs new file mode 100644 index 0000000..b7d1939 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs @@ -0,0 +1,418 @@ + +using UnityEngine; +using System.Collections.Generic; + +public class LeanAudioStream { + + public int position = 0; + + public AudioClip audioClip; + public float[] audioArr; + + public LeanAudioStream( float[] audioArr ){ + this.audioArr = audioArr; + } + + public void OnAudioRead(float[] data) { + int count = 0; + while (count < data.Length) { + data[count] = audioArr[this.position]; + position++; + count++; + } + } + + public void OnAudioSetPosition(int newPosition) { + this.position = newPosition; + } +} + +/** +* Create Audio dynamically and easily playback +* +* @class LeanAudio +* @constructor +*/ +public class LeanAudio : object { + + public static float MIN_FREQEUNCY_PERIOD = 0.000115f; + public static int PROCESSING_ITERATIONS_MAX = 50000; + public static float[] generatedWaveDistances; + public static int generatedWaveDistancesCount = 0; + + private static float[] longList; + + public static LeanAudioOptions options(){ + if(generatedWaveDistances==null){ + generatedWaveDistances = new float[ PROCESSING_ITERATIONS_MAX ]; + longList = new float[ PROCESSING_ITERATIONS_MAX ]; + } + return new LeanAudioOptions(); + } + + public static LeanAudioStream createAudioStream( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){ + if(options==null) + options = new LeanAudioOptions(); + + options.useSetData = false; + + int generatedWavePtsLength = createAudioWave( volume, frequency, options); + createAudioFromWave( generatedWavePtsLength, options ); + + return options.stream; + } + + /** + * Create dynamic audio from a set of Animation Curves and other options. + * + * @method createAudio + * @param {AnimationCurve} volumeCurve:AnimationCurve describing the shape of the audios volume (from 0-1). The length of the audio is dicated by the end value here. + * @param {AnimationCurve} frequencyCurve:AnimationCurve describing the width of the oscillations between the sound waves in seconds. Large numbers mean a lower note, while higher numbers mean a tighter frequency and therefor a higher note. Values are usually between 0.01 and 0.000001 (or smaller) + * @param {LeanAudioOptions} options:LeanAudioOptions You can pass any other values in here like vibrato or the frequency you would like the sound to be encoded at. See LeanAudioOptions for more details. + * @return {AudioClip} AudioClip of the procedurally generated audio + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ));
    + */ + public static AudioClip createAudio( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){ + if(options==null) + options = new LeanAudioOptions(); + + int generatedWavePtsLength = createAudioWave( volume, frequency, options); + // Debug.Log("generatedWavePtsLength:"+generatedWavePtsLength); + return createAudioFromWave( generatedWavePtsLength, options ); + } + + private static int createAudioWave( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options ){ + float time = volume[ volume.length - 1 ].time; + int listLength = 0; + // List list = new List(); + + // generatedWaveDistances = new List(); + // float[] vibratoValues = new float[ vibrato.Length ]; + float passed = 0f; + for(int i = 0; i < PROCESSING_ITERATIONS_MAX; i++){ + float f = frequency.Evaluate(passed); + if(f=time) + break; + if(listLength >= PROCESSING_ITERATIONS_MAX-1){ + Debug.LogError("LeanAudio has reached it's processing cap. To avoid this error increase the number of iterations ex: LeanAudio.PROCESSING_ITERATIONS_MAX = "+(PROCESSING_ITERATIONS_MAX*2)); + break; + }else{ + int distPoint = listLength / 2; + + //generatedWaveDistances.Add( f ); + passed += f; + + generatedWaveDistances[ distPoint ] = passed; + //Debug.Log("distPoint:"+distPoint+" passed:"+passed); + + //list.Add( passed ); + //list.Add( i%2==0 ? -height : height ); + + longList[ listLength ] = passed; + longList[ listLength + 1 ] = i%2==0 ? -height : height; + } + + + + listLength += 2; + + } + + listLength += -2; + generatedWaveDistancesCount = listLength / 2; + + /*float[] wave = new float[ listLength ]; + for(int i = 0; i < wave.Length; i++){ + wave[i] = longList[i]; + }*/ + return listLength; + } + + private static AudioClip createAudioFromWave( int waveLength, LeanAudioOptions options ){ + float time = longList[ waveLength - 2 ]; + float[] audioArr = new float[ (int)(options.frequencyRate*time) ]; + + int waveIter = 0; + float subWaveDiff = longList[waveIter]; + float subWaveTimeLast = 0f; + float subWaveTime = longList[waveIter]; + float waveHeight = longList[waveIter+1]; + for(int i = 0; i < audioArr.Length; i++){ + float passedTime = (float)i / (float)options.frequencyRate; + if(passedTime > longList[waveIter] ){ + subWaveTimeLast = longList[waveIter]; + waveIter += 2; + subWaveDiff = longList[waveIter] - longList[waveIter-2]; + waveHeight = longList[waveIter+1]; + // Debug.Log("passed wave i:"+i); + } + subWaveTime = passedTime - subWaveTimeLast; + float ratioElapsed = subWaveTime / subWaveDiff; + + float value = Mathf.Sin( ratioElapsed * Mathf.PI ); + + if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Square){ + if(value>0f) + value = 1f; + if(value<0f) + value = -1f; + }else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Sawtooth){ + float sign = value > 0f ? 1f : -1f; + if(ratioElapsed<0.5f){ + value = (ratioElapsed*2f)*sign; + }else{ // 0.5f - 1f + value = (1f - ratioElapsed)*2f*sign; + } + }else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Noise){ + float peakMulti = (1f-options.waveNoiseInfluence) + Mathf.PerlinNoise(0f, passedTime * options.waveNoiseScale ) * options.waveNoiseInfluence; + + /*if(i<25){ + Debug.Log("passedTime:"+passedTime+" peakMulti:"+peakMulti+" infl:"+options.waveNoiseInfluence); + }*/ + + value *= peakMulti; + } + + //if(i<25) + // Debug.Log("passedTime:"+passedTime+" value:"+value+" ratioElapsed:"+ratioElapsed+" subWaveTime:"+subWaveTime+" subWaveDiff:"+subWaveDiff); + + value *= waveHeight; + + + if(options.modulation!=null){ + for(int k=0; k(); // add an audio source + aSource.clip = clip; // define the clip + aSource.Play(); // start the sound + GameObject.Destroy(tempGO, clip.length); // destroy object after clip duration + return aSource; // return the AudioSource reference + } + + public static void printOutAudioClip( AudioClip audioClip, ref AnimationCurve curve, float scaleX = 1f ){ + // Debug.Log("Audio channels:"+audioClip.channels+" frequency:"+audioClip.frequency+" length:"+audioClip.length+" samples:"+audioClip.samples); + float[] samples = new float[audioClip.samples * audioClip.channels]; + audioClip.GetData(samples, 0); + int i = 0; + + Keyframe[] frames = new Keyframe[samples.Length]; + while (i < samples.Length) { + frames[i] = new Keyframe( (float)i * scaleX, samples[i] ); + ++i; + } + curve = new AnimationCurve( frames ); + } +} + + +/** +* Pass in options to LeanAudio +* +* @class LeanAudioOptions +* @constructor +*/ +public class LeanAudioOptions : object { + + public enum LeanAudioWaveStyle{ + Sine, + Square, + Sawtooth, + Noise + } + + public LeanAudioWaveStyle waveStyle = LeanAudioWaveStyle.Sine; + public Vector3[] vibrato; + public Vector3[] modulation; + public int frequencyRate = 44100; + public float waveNoiseScale = 1000; + public float waveNoiseInfluence = 1f; + + public bool useSetData = true; + public LeanAudioStream stream; + + public LeanAudioOptions(){} + + /** + * Set the frequency for the audio is encoded. 44100 is CD quality, but you can usually get away with much lower (or use a lower amount to get a more 8-bit sound). + * + * @method setFrequency + * @param {int} frequencyRate:int of the frequency you wish to encode the AudioClip at + * @return {LeanAudioOptions} LeanAudioOptions describing optional values + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ).setFrequency(12100) );
    + */ + public LeanAudioOptions setFrequency( int frequencyRate ){ + this.frequencyRate = frequencyRate; + return this; + } + + /** + * Set details about the shape of the curve by adding vibrato modulations through it (alters the peak values giving it a wah-wah effect). You can add as many as you want to sculpt out more detail in the sound wave. + * + * @method setVibrato + * @param {Vector3[]} vibratoArray:Vector3[] The first value is the period in seconds that you wish to have the vibrato wave fluctuate at. The second value is the minimum height you wish the vibrato wave to dip down to (default is zero). The third is reserved for future effects. + * @return {LeanAudioOptions} LeanAudioOptions describing optional values + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
    + * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
    + * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0.3f,0f)} ).setFrequency(12100) );
    + */ + public LeanAudioOptions setVibrato( Vector3[] vibrato ){ + this.vibrato = vibrato; + return this; + } + + /* + public LeanAudioOptions setModulation( Vector3[] modulation ){ + this.modulation = modulation; + return this; + }*/ + + public LeanAudioOptions setWaveSine(){ + this.waveStyle = LeanAudioWaveStyle.Sine; + return this; + } + + public LeanAudioOptions setWaveSquare(){ + this.waveStyle = LeanAudioWaveStyle.Square; + return this; + } + + public LeanAudioOptions setWaveSawtooth(){ + this.waveStyle = LeanAudioWaveStyle.Sawtooth; + return this; + } + + public LeanAudioOptions setWaveNoise(){ + this.waveStyle = LeanAudioWaveStyle.Noise; + return this; + } + + public LeanAudioOptions setWaveStyle( LeanAudioWaveStyle style ){ + this.waveStyle = style; + return this; + } + + + public LeanAudioOptions setWaveNoiseScale( float waveScale ){ + this.waveNoiseScale = waveScale; + return this; + } + + public LeanAudioOptions setWaveNoiseInfluence( float influence ){ + this.waveNoiseInfluence = influence; + return this; + } +} + + diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs.meta new file mode 100644 index 0000000..cd86baf --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanAudio.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 52e41e970d9353942b27458440bec9eb +timeCreated: 1427917971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs new file mode 100644 index 0000000..8289622 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs @@ -0,0 +1,123 @@ +using UnityEngine; +using System.Collections; + +public class LeanTester : MonoBehaviour { + public float timeout = 15f; + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public void Start(){ + StartCoroutine( timeoutCheck() ); + } + + IEnumerator timeoutCheck(){ + float pauseEndTime = Time.realtimeSinceStartup + timeout; + while (Time.realtimeSinceStartup < pauseEndTime) + { + yield return 0; + } + if(LeanTest.testsFinished==false){ + Debug.Log(LeanTest.formatB("Tests timed out!")); + LeanTest.overview(); + } + } + #endif +} + +public class LeanTest : object { + public static int expected = 0; + private static int tests = 0; + private static int passes = 0; + + public static float timeout = 15f; + public static bool timeoutStarted = false; + public static bool testsFinished = false; + + public static void debug( string name, bool didPass, string failExplaination = null){ + expect( didPass, name, failExplaination); + } + + public static void expect( bool didPass, string definition, string failExplaination = null){ + float len = printOutLength(definition); + int paddingLen = 40-(int)(len*1.05f); + #if UNITY_FLASH + string padding = padRight(paddingLen); + #else + string padding = "".PadRight(paddingLen,"_"[0]); + #endif + string logName = formatB(definition) +" " + padding + " [ "+ (didPass ? formatC("pass","green") : formatC("fail","red")) +" ]"; + if(didPass==false && failExplaination!=null) + logName += " - " + failExplaination; + Debug.Log(logName); + if(didPass) + passes++; + tests++; + + // Debug.Log("tests:"+tests+" expected:"+expected); + if(tests==expected && testsFinished==false){ + overview(); + }else if(tests>expected){ + Debug.Log(formatB("Too many tests for a final report!") + " set LeanTest.expected = "+tests); + } + + if(timeoutStarted==false){ + timeoutStarted = true; + GameObject tester = new GameObject(); + tester.name = "~LeanTest"; + LeanTester test = tester.AddComponent(typeof(LeanTester)) as LeanTester; + test.timeout = timeout; + #if !UNITY_EDITOR + tester.hideFlags = HideFlags.HideAndDontSave; + #endif + } + } + + public static string padRight(int len){ + string str = ""; + for(int i = 0; i < len; i++){ + str += "_"; + } + return str; + } + + public static float printOutLength( string str ){ + float len = 0.0f; + for(int i = 0; i < str.Length; i++){ + if(str[i]=="I"[0]){ + len += 0.5f; + }else if(str[i]=="J"[0]){ + len += 0.85f; + }else{ + len += 1.0f; + } + } + return len; + } + + public static string formatBC( string str, string color ){ + return formatC(formatB(str),color); + } + + public static string formatB( string str ){ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + return str; + #else + return ""+ str + ""; + #endif + } + + public static string formatC( string str, string color ){ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + return str; + #else + return ""+ str + ""; + #endif + } + + public static void overview(){ + testsFinished = true; + int failedCnt = (expected-passes); + string failedStr = failedCnt > 0 ? formatBC(""+failedCnt,"red") : ""+failedCnt; + Debug.Log(formatB("Final Report:")+" _____________________ PASSED: "+formatBC(""+passes,"green")+" FAILED: "+failedStr+" "); + } +} + \ No newline at end of file diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs.meta new file mode 100644 index 0000000..0af8aa2 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 82464f26ca2ba284a8f92f51248c574a +timeCreated: 1427917971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs new file mode 100644 index 0000000..03543a0 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs @@ -0,0 +1,3615 @@ +//namespace DentedPixel{ + +// LeanTween version 2.43 - http://dentedpixel.com/developer-diary/ +// +// The MIT License (MIT) +// +// Copyright (c) 2017 Russell Savage - Dented Pixel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + + +/* +TERMS OF USE - EASING EQUATIONS# +Open source under the BSD License. +Copyright (c)2001 Robert Penner +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +* Pass this to the "ease" parameter, to get a different easing behavior

    +* Example:
    LeanTween.rotateX(gameObject, 270.0f, 1.5f).setEase(LeanTweenType.easeInBack); +* +* @class LeanTweenType +*/ + +/** +* @property {integer} linear +*/ +/** +* @property {integer} easeOutQuad +*/ +/** +* @property {integer} easeInQuad +*/ +/** +* @property {integer} easeInOutQuad +*/ +/** +* @property {integer} easeInCubic +*/ +/** +* @property {integer} easeOutCubic +*/ +/** +* @property {integer} easeInOutCubic +*/ +/** +* @property {integer} easeInQuart +*/ +/** +* @property {integer} easeOutQuart +*/ +/** +* @property {integer} easeInOutQuart +*/ +/** +* @property {integer} easeInQuint +*/ +/** +* @property {integer} easeOutQuint +*/ +/** +* @property {integer} easeInOutQuint +*/ +/** +* @property {integer} easeInSine +*/ +/** +* @property {integer} easeOutSine +*/ +/** +* @property {integer} easeInOutSine +*/ +/** +* @property {integer} easeInExpo +*/ +/** +* @property {integer} easeOutExpo +*/ +/** +* @property {integer} easeInOutExpo +*/ +/** +* @property {integer} easeInCirc +*/ +/** +* @property {integer} easeOutCirc +*/ +/** +* @property {integer} easeInOutCirc +*/ +/** +* @property {integer} easeInBounce +*/ +/** +* @property {integer} easeOutBounce +*/ +/** +* @property {integer} easeInOutBounce +*/ +/** +* @property {integer} easeInBack +*/ +/** +* @property {integer} easeOutBack +*/ +/** +* @property {integer} easeInOutBack +*/ +/** +* @property {integer} easeInElastic +*/ +/** +* @property {integer} easeOutElastic +*/ +/** +* @property {integer} easeInOutElastic +*/ +/** +* @property {integer} punch +*/ +using UnityEngine; +using System; +using System.Collections.Generic; + +public enum TweenAction{ + MOVE_X, + MOVE_Y, + MOVE_Z, + MOVE_LOCAL_X, + MOVE_LOCAL_Y, + MOVE_LOCAL_Z, + MOVE_CURVED, + MOVE_CURVED_LOCAL, + MOVE_SPLINE, + MOVE_SPLINE_LOCAL, + SCALE_X, + SCALE_Y, + SCALE_Z, + ROTATE_X, + ROTATE_Y, + ROTATE_Z, + ROTATE_AROUND, + ROTATE_AROUND_LOCAL, + CANVAS_ROTATEAROUND, + CANVAS_ROTATEAROUND_LOCAL, + CANVAS_PLAYSPRITE, + ALPHA, + TEXT_ALPHA, + CANVAS_ALPHA, + CANVASGROUP_ALPHA, + ALPHA_VERTEX, + COLOR, + CALLBACK_COLOR, + TEXT_COLOR, + CANVAS_COLOR, + CANVAS_MOVE_X, + CANVAS_MOVE_Y, + CANVAS_MOVE_Z, + CALLBACK, + MOVE, + MOVE_LOCAL, + MOVE_TO_TRANSFORM, + ROTATE, + ROTATE_LOCAL, + SCALE, + VALUE3, + GUI_MOVE, + GUI_MOVE_MARGIN, + GUI_SCALE, + GUI_ALPHA, + GUI_ROTATE, + DELAYED_SOUND, + CANVAS_MOVE, + CANVAS_SCALE, + CANVAS_SIZEDELTA, +} + +public enum LeanTweenType{ + notUsed, linear, easeOutQuad, easeInQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, + easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, + easeInBounce, easeOutBounce, easeInOutBounce, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeSpring, easeShake, punch, once, clamp, pingPong, animationCurve +} + +/** +* LeanTween is an efficient tweening engine for Unity3d

    +* Index of All Methods | Optional Paramaters that can be passed

    +* Optional Parameters are passed at the end of every method
    +*
    +* Example:
    +* LeanTween.moveX( gameObject, 1f, 1f).setEase( LeanTweenType.easeInQuad ).setDelay(1f);
    +*
    +* You can pass the optional parameters in any order, and chain on as many as you wish!

    +* You can also modify this tween later, just save the unique id of the tween.
    +*

    Example:

    +* int id = LeanTween.moveX(gameObject, 1f, 1f).id;
    +* LTDescr d = LeanTween.descr( id );

    +* if(d!=null){ // if the tween has already finished it will return null
    +*    // change some parameters
    +*    d.setOnComplete( onCompleteFunc ).setEase( LeanTweenType.easeInOutBack );
    +* } +* +* @class LeanTween +*/ + +public class LeanTween : MonoBehaviour { + + public static bool throwErrors = true; + public static float tau = Mathf.PI*2.0f; + public static float PI_DIV2 = Mathf.PI / 2.0f; + + private static LTDescr[] tweens; + private static int[] tweensFinished; + private static LTDescr tween; + private static int tweenMaxSearch = -1; + private static int maxTweens = 400; + private static int frameRendered= -1; + private static GameObject _tweenEmpty; + public static float dtEstimated = -1f; + public static float dtManual; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 + private static float previousRealTime; + #endif + public static float dtActual; + private static int i; + private static int j; + private static int finishedCnt; + public static AnimationCurve punch = new AnimationCurve( new Keyframe(0.0f, 0.0f ), new Keyframe(0.112586f, 0.9976035f ), new Keyframe(0.3120486f, -0.1720615f ), new Keyframe(0.4316337f, 0.07030682f ), new Keyframe(0.5524869f, -0.03141804f ), new Keyframe(0.6549395f, 0.003909959f ), new Keyframe(0.770987f, -0.009817753f ), new Keyframe(0.8838775f, 0.001939224f ), new Keyframe(1.0f, 0.0f ) ); + public static AnimationCurve shake = new AnimationCurve( new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(0.75f, -1f), new Keyframe(1f, 0f) ) ; + + public static void init(){ + init(maxTweens); + } + + public static int maxSearch{ + get{ + return tweenMaxSearch; + } + } + + public static int maxSimulataneousTweens{ + get { + return maxTweens; + } + } + + /** + * Find out how many tweens you have animating at a given time + * + * @method LeanTween.tweensRunning + * @example + * Debug.Log("I have "+LeanTween.tweensRunning+" animating!"); + */ + public static int tweensRunning{ + get{ + int count = 0; + for (int i = 0; i <= tweenMaxSearch; i++){ + if (tweens[i].toggle){ + count++; + } + } + return count; + } + } + + /** + * This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective. + * + * @method LeanTween.init + * @param {integer} maxSimultaneousTweens:int The maximum number of tweens you will use, make sure you don't go over this limit, otherwise the code will throw an error + * @example + * LeanTween.init( 800 ); + */ + public static void init(int maxSimultaneousTweens){ + if(tweens==null){ + maxTweens = maxSimultaneousTweens; + tweens = new LTDescr[maxTweens]; + tweensFinished = new int[maxTweens]; + _tweenEmpty = new GameObject(); + _tweenEmpty.name = "~LeanTween"; + _tweenEmpty.AddComponent(typeof(LeanTween)); + _tweenEmpty.isStatic = true; + #if !UNITY_EDITOR + _tweenEmpty.hideFlags = HideFlags.HideAndDontSave; + #endif + #if UNITY_EDITOR + if(Application.isPlaying) + DontDestroyOnLoad( _tweenEmpty ); + #else + DontDestroyOnLoad( _tweenEmpty ); + #endif + for(int i = 0; i < maxTweens; i++){ + tweens[i] = new LTDescr(); + } + + #if UNITY_5_4_OR_NEWER + UnityEngine.SceneManagement.SceneManager.sceneLoaded += onLevelWasLoaded54; + #endif + } + } + + public static void reset(){ + if(tweens!=null){ + for (int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i]!=null) + tweens[i].toggle = false; + } + } + tweens = null; + Destroy(_tweenEmpty); + } + + public void Update(){ + LeanTween.update(); + } + + #if UNITY_5_4_OR_NEWER + private static void onLevelWasLoaded54( UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode ){ internalOnLevelWasLoaded( scene.buildIndex ); } + #else + public void OnLevelWasLoaded( int lvl ){ internalOnLevelWasLoaded( lvl ); } + #endif + + private static void internalOnLevelWasLoaded( int lvl ){ + // Debug.Log("reseting gui"); + LTGUI.reset(); + } + + private static int maxTweenReached; + + public static void update() { + if(frameRendered != Time.frameCount){ // make sure update is only called once per frame + init(); + + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 + dtEstimated = Time.realtimeSinceStartup - previousRealTime; + if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large + dtEstimated = 0.2f; + previousRealTime = Time.realtimeSinceStartup; + #else + + dtEstimated = dtEstimated<0f ? 0f : dtEstimated = Time.unscaledDeltaTime; + + // Debug.Log("Time.unscaledDeltaTime:"+Time.unscaledDeltaTime); + #endif + + dtActual = Time.deltaTime; + maxTweenReached = 0; + finishedCnt = 0; + // if(tweenMaxSearch>1500) + // Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens); + for( int i = 0; i <= tweenMaxSearch && i < maxTweens; i++){ + tween = tweens[i]; +// if(i==0 && tweens[i].toggle) +// Debug.Log("tweens["+i+"]"+tweens[i]); + if(tween.toggle){ + maxTweenReached = i; + + if (tween.updateInternal()) { // returns true if the tween is finished with it's loop + tweensFinished[finishedCnt] = i; + finishedCnt++; + } + } + } + + // Debug.Log("maxTweenReached:"+maxTweenReached); + tweenMaxSearch = maxTweenReached; + frameRendered = Time.frameCount; + + for(int i = 0; i < finishedCnt; i++){ + j = tweensFinished[i]; + tween = tweens[ j ]; + // Debug.Log("removing tween:"+tween); + removeTween(j); + if(tween.hasExtraOnCompletes && tween.trans!=null) + tween.callOnCompletes(); + } + + } + } + + + + public static void removeTween( int i, int uniqueId){ // Only removes the tween if the unique id matches + if(tweens[i].uniqueId==uniqueId){ + removeTween( i ); + } + } + + // This method is only used internally! Do not call this from your scripts. To cancel a tween use LeanTween.cancel + public static void removeTween( int i ){ + if(tweens[i].toggle){ + tweens[i].toggle = false; + //logError("Removing tween["+i+"]:"+tweens[i]); + if(tweens[i].destroyOnComplete){ + //Debug.Log("destroying tween.type:"+tween.type); + if(tweens[i].ltRect!=null){ + // Debug.Log("destroy i:"+i+" id:"+tweens[i].ltRect.id); + LTGUI.destroy( tweens[i].ltRect.id ); + }else{ // check if equal to tweenEmpty + if(tweens[i].trans!=null && tweens[i].trans.gameObject!=_tweenEmpty){ + Destroy(tweens[i].trans.gameObject); + } + } + } + //tweens[i].optional = null; + startSearch = i; + //Debug.Log("start search reset:"+startSearch + " i:"+i+" tweenMaxSearch:"+tweenMaxSearch); + if(i+1>=tweenMaxSearch){ + //Debug.Log("reset to zero"); + startSearch = 0; + //tweenMaxSearch--; + } + } + } + + public static Vector3[] add(Vector3[] a, Vector3 b){ + Vector3[] c = new Vector3[ a.Length ]; + for(i=0; i + */ + public static void cancelAll(){ + cancelAll(false); + } + public static void cancelAll(bool callComplete){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++) + { + if (tweens[i].trans != null){ + if (callComplete && tweens[i].optional.onComplete != null) + tweens[i].optional.onComplete(); + removeTween(i); + } + } + } + + /** + * Cancel all tweens that are currently targeting the gameObject + * + * @method LeanTween.cancel + * @param {GameObject} gameObject:GameObject gameObject whose tweens you wish to cancel + * @param {bool} callOnComplete:bool (optional) whether to call the onComplete method before canceling + * @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f);
    + * LeanTween.cancel( gameObject ); + */ + public static void cancel( GameObject gameObject ){ + cancel( gameObject, false); + } + public static void cancel( GameObject gameObject, bool callOnComplete ){ + init(); + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i].trans==trans){ + if (callOnComplete && tweens[i].optional.onComplete != null) + tweens[i].optional.onComplete(); + removeTween(i); + } + } + } + + public static void cancel( RectTransform rect ){ + cancel( rect.gameObject, false); + } + +// public static void cancel( GameObject gameObject, int uniqueId ){ +// if(uniqueId>=0){ +// init(); +// int backId = uniqueId & 0xFFFF; +// int backCounter = uniqueId >> 16; +// // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" counter:"+backCounter + " setCounter:"+ tweens[backId].counter + " tweens[id].type:"+tweens[backId].type); +// if(tweens[backId].trans==null || (tweens[backId].trans.gameObject == gameObject && tweens[backId].counter==backCounter)) +// removeTween((int)backId); +// } +// } + + public static void cancel( GameObject gameObject, int uniqueId, bool callOnComplete = false ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" counter:"+backCounter + " setCounter:"+ tw eens[backId].counter + " tweens[id].type:"+tweens[backId].type); + if(tweens[backId].trans==null || (tweens[backId].trans.gameObject == gameObject && tweens[backId].counter==backCounter)) { + if (callOnComplete && tweens[backId].optional.onComplete != null) + tweens[backId].optional.onComplete(); + removeTween((int)backId); + } + } + } + + public static void cancel( LTRect ltRect, int uniqueId ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); + if(tweens[backId].ltRect == ltRect && tweens[backId].counter==backCounter) + removeTween((int)backId); + } + } + + /** + * Cancel a specific tween with the provided id + * + * @method LeanTween.cancel + * @param {int} id:int unique id that represents that tween + * @param {bool} callOnComplete:int (optional) whether to call the onComplete method before canceling + * @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).id;
    + * LeanTween.cancel( id ); + */ + public static void cancel( int uniqueId ){ + cancel( uniqueId, false); + } + public static void cancel( int uniqueId, bool callOnComplete ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); + if(tweens[backId].counter==backCounter){ + if(callOnComplete && tweens[backId].optional.onComplete != null) + tweens[backId].optional.onComplete(); + removeTween((int)backId); + } + } + } + + /** + * Retrieve a tweens LTDescr object to modify + * + * @method LeanTween.descr + * @param {int} id:int unique id that represents that tween + * @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod ).id;

    + *
    // later I want decide I want to change onComplete method
    + * LTDescr descr = LeanTween.descr( id );
    + * if(descr!=null) // if the tween has already finished it will come back null
    + *   descr.setOnComplete( newMethod );
    + */ + public static LTDescr descr( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + + if(tweens[backId]!=null && tweens[backId].uniqueId == uniqueId && tweens[backId].counter==backCounter) + return tweens[backId]; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].uniqueId == uniqueId && tweens[i].counter==backCounter) + return tweens[i]; + } + return null; + } + + public static LTDescr description( int uniqueId ){ + return descr( uniqueId ); + } + + /** + * Retrieve a tweens LTDescr object(s) to modify + * + * @method LeanTween.descriptions + * @param {GameObject} id:GameObject object whose tween descriptions you want to retrieve + * @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod );

    + *
    // later I want decide I want to change onComplete method
    + * LTDescr[] descr = LeanTween.descriptions( gameObject );
    + * if(descr.Length>0) // make sure there is a valid description for this target
    + *   descr[0].setOnComplete( newMethod );// in this case we only ever expect there to be one tween on this object
    + */ + public static LTDescr[] descriptions(GameObject gameObject = null) { + if (gameObject == null) return null; + + List descrs = new List(); + Transform trans = gameObject.transform; + for (int i = 0; i <= tweenMaxSearch; i++) { + if (tweens[i].toggle && tweens[i].trans == trans) + descrs.Add( tweens[i] ); + } + return descrs.ToArray(); + } + + [System.Obsolete("Use 'pause( id )' instead")] + public static void pause( GameObject gameObject, int uniqueId ){ + pause( uniqueId ); + } + + /** + * Pause all tweens for a GameObject + * + * @method LeanTween.pause + * @param {int} id:int Id of the tween you want to pause + * @example + * int id = LeanTween.moveX(gameObject, 5, 1.0).id
    + * LeanTween.pause( id );
    + * // Later....
    + * LeanTween.resume( id ); + */ + public static void pause( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if(tweens[backId].counter==backCounter){ + tweens[backId].pause(); + } + } + + /** + * Pause all tweens for a GameObject + * + * @method LeanTween.pause + * @param {GameObject} gameObject:GameObject GameObject whose tweens you want to pause + */ + public static void pause( GameObject gameObject ){ + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].trans==trans){ + tweens[i].pause(); + } + } + } + + /** + * Pause all active tweens + * + * @method LeanTween.pauseAll + */ + public static void pauseAll(){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++){ + tweens[i].pause(); + } + } + + /** + * Resume all active tweens + * + * @method LeanTween.resumeAll + */ + public static void resumeAll(){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++){ + tweens[i].resume(); + } + } + + [System.Obsolete("Use 'resume( id )' instead")] + public static void resume( GameObject gameObject, int uniqueId ){ + resume( uniqueId ); + } + + /** + * Resume a specific tween + * + * @method LeanTween.resume + * @param {int} id:int Id of the tween you want to resume + * @example + * int id = LeanTween.moveX(gameObject, 5, 1.0).id
    + * LeanTween.pause( id );
    + * // Later....
    + * LeanTween.resume( id ); + */ + public static void resume( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if(tweens[backId].counter==backCounter){ + tweens[backId].resume(); + } + } + + /** + * Resume all the tweens on a GameObject + * + * @method LeanTween.resume + * @param {GameObject} gameObject:GameObject GameObject whose tweens you want to resume + */ + public static void resume( GameObject gameObject ){ + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].trans==trans) + tweens[i].resume(); + } + } + + /** + * Test whether or not a tween is active on a GameObject + * + * @method LeanTween.isTweening + * @param {GameObject} gameObject:GameObject GameObject that you want to test if it is tweening + */ + public static bool isTweening( GameObject gameObject = null ){ + if(gameObject==null){ + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle) + return true; + } + return false; + } + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i].trans==trans) + return true; + } + return false; + } + + public static bool isTweening( RectTransform rect ){ + return isTweening(rect.gameObject); + } + + /** + * Test whether or not a tween is active or not + * + * @method LeanTween.isTweening + * @param {GameObject} id:int id of the tween that you want to test if it is tweening + * @example + * int id = LeanTween.moveX(gameObject, 1f, 3f).id;
    + * if(LeanTween.isTweening( id ))
    + *      Debug.Log("I am tweening!");
    + */ + public static bool isTweening( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if (backId < 0 || backId >= maxTweens) return false; + // Debug.Log("tweens[backId].counter:"+tweens[backId].counter+" backCounter:"+backCounter +" toggle:"+tweens[backId].toggle); + if(tweens[backId].counter==backCounter && tweens[backId].toggle){ + return true; + } + return false; + } + + public static bool isTweening( LTRect ltRect ){ + for( int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i].ltRect==ltRect) + return true; + } + return false; + } + + public static void drawBezierPath(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float arrowSize = 0.0f, Transform arrowTransform = null){ + Vector3 last = a; + Vector3 p; + Vector3 aa = (-a + 3*(b-c) + d); + Vector3 bb = 3*(a+c) - 6*b; + Vector3 cc = 3*(b-a); + + float t; + + if(arrowSize>0.0f){ + Vector3 beforePos = arrowTransform.position; + Quaternion beforeQ = arrowTransform.rotation; + float distanceTravelled = 0f; + + for(float k = 1.0f; k <= 120.0f; k++){ + t = k / 120.0f; + p = ((aa* t + (bb))* t + cc)* t + a; + Gizmos.DrawLine(last, p); + distanceTravelled += (p-last).magnitude; + if(distanceTravelled>1f){ + distanceTravelled = distanceTravelled - 1f; + /*float deltaY = p.y - last.y; + float deltaX = p.x - last.x; + float ang = Mathf.Atan(deltaY / deltaX); + Vector3 arrow = p + new Vector3( Mathf.Cos(ang+2.5f), Mathf.Sin(ang+2.5f), 0f)*0.5f; + Gizmos.DrawLine(p, arrow); + arrow = p + new Vector3( Mathf.Cos(ang+-2.5f), Mathf.Sin(ang+-2.5f), 0f)*0.5f; + Gizmos.DrawLine(p, arrow);*/ + + arrowTransform.position = p; + arrowTransform.LookAt( last, Vector3.forward ); + Vector3 to = arrowTransform.TransformDirection(Vector3.right); + // Debug.Log("to:"+to+" tweenEmpty.transform.position:"+arrowTransform.position); + Vector3 back = (last-p); + back = back.normalized; + Gizmos.DrawLine(p, p + (to + back)*arrowSize); + to = arrowTransform.TransformDirection(-Vector3.right); + Gizmos.DrawLine(p, p + (to + back)*arrowSize); + } + last = p; + } + + arrowTransform.position = beforePos; + arrowTransform.rotation = beforeQ; + }else{ + for(float k = 1.0f; k <= 30.0f; k++){ + t = k / 30.0f; + p = ((aa* t + (bb))* t + cc)* t + a; + Gizmos.DrawLine(last, p); + last = p; + } + } + } + + public static object logError( string error ){ + if(throwErrors) Debug.LogError(error); else Debug.Log(error); + return null; + } + + // LeanTween 2.0 Methods + + public static LTDescr options(LTDescr seed){ Debug.LogError("error this function is no longer used"); return null; } + public static LTDescr options(){ + init(); + + bool found = false; + // Debug.Log("Search start"); + for(j=0, i = startSearch; j <= maxTweens; i++){ + if(j >= maxTweens) + return logError("LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( "+(maxTweens*2)+" );") as LTDescr; + if(i>=maxTweens) + i = 0; + // Debug.Log("searching i:"+i); + if(tweens[i].toggle==false){ + if(i+1>tweenMaxSearch) + tweenMaxSearch = i+1; + startSearch = i + 1; + found = true; + break; + } + + j++; + } + if(found==false) + logError("no available tween found!"); + + // Debug.Log("new tween with i:"+i+" counter:"+tweens[i].counter+" tweenMaxSearch:"+tweenMaxSearch+" tween:"+tweens[i]); + tweens[i].reset(); + tweens[i].setId( (uint)i ); + + return tweens[i]; + } + + public static GameObject tweenEmpty{ + get{ + init(maxTweens); + return _tweenEmpty; + } + } + + public static int startSearch = 0; + public static LTDescr d; + + private static LTDescr pushNewTween( GameObject gameObject, Vector3 to, float time, LTDescr tween ){ + init(maxTweens); + if(gameObject==null || tween==null) + return null; + + tween.trans = gameObject.transform; + tween.to = to; + tween.time = time; + //tween.hasPhysics = gameObject.rigidbody!=null; + + return tween; + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Play a sequence of images on a Unity UI Object + * + * @method LeanTween.play + * @param {RectTransform} rectTransform:RectTransform RectTransform that you want to play the sequence of sprites on + * @param {Sprite[]} sprites:Sprite[] Sequence of sprites to be played + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.play(gameObject.GetComponent(), sprites).setLoopPingPong(); + */ + public static LTDescr play(RectTransform rectTransform, UnityEngine.Sprite[] sprites){ + float defaultFrameRate = 0.25f; + float time = defaultFrameRate * sprites.Length; + return pushNewTween(rectTransform.gameObject, new Vector3((float)sprites.Length - 1.0f,0,0), time, options().setCanvasPlaySprite().setSprites( sprites ).setRepeat(-1)); + } + #endif + + /** + * Fade a gameobject's material to a certain alpha value. The material's shader needs to support alpha. Owl labs has some excellent efficient shaders. + * + * @method LeanTween.alpha + * @param {GameObject} gameObject:GameObject Gameobject that you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(gameObject, 1f, 1f) .setDelay(1f); + */ + public static LTDescr alpha(GameObject gameObject, float to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(to,0,0), time, options().setAlpha() ); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } + + /** + * Fade a GUI Object + * + * @method LeanTween.alpha + * @param {LTRect} ltRect:LTRect LTRect that you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(ltRect, 1f, 1f) .setEase(LeanTweenType.easeInCirc); + */ + public static LTDescr alpha(LTRect ltRect, float to, float time){ + ltRect.alphaEnabled = true; + return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, options().setGUIAlpha().setRect( ltRect ) ); + } + + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Fade a Unity UI Object + * + * @method LeanTween.alphaText + * @param {RectTransform} rectTransform:RectTransform RectTransform associated with the Text Component you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alphaText(gameObject.GetComponent<RectTransform>(), 1f, 1f) .setEase(LeanTweenType.easeInCirc); + */ + public static LTDescr textAlpha(RectTransform rectTransform, float to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(to,0,0), time, options().setTextAlpha()); + } + public static LTDescr alphaText(RectTransform rectTransform, float to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(to,0,0), time, options().setTextAlpha()); + } + + /** + * Fade a Unity UI Canvas Group + * + * @method LeanTween.alphaCanvas + * @param {RectTransform} rectTransform:RectTransform RectTransform that the CanvasGroup is attached to + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alphaCanvas(gameObject.GetComponent<RectTransform>(), 0f, 1f) .setLoopPingPong(); + */ + public static LTDescr alphaCanvas(CanvasGroup canvasGroup, float to, float time){ + return pushNewTween(canvasGroup.gameObject, new Vector3(to,0,0), time, options().setCanvasGroupAlpha()); + } + #endif + + /** + * This works by tweening the vertex colors directly.
    +
    + Vertex-based coloring is useful because you avoid making a copy of your + object's material for each instance that needs a different color.
    +
    + A shader that supports vertex colors is required for it to work + (for example the shaders in Mobile/Particles/) + * + * @method LeanTween.alphaVertex + * @param {GameObject} gameObject:GameObject Gameobject that you wish to alpha + * @param {float} to:float The alpha value you wish to tween to + * @param {float} time:float The time with which to delay before calling the function + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr alphaVertex(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0f,0f), time, options().setAlphaVertex() ); + } + + /** + * Change a gameobject's material to a certain color value. The material's shader needs to support color tinting. Owl labs has some excellent efficient shaders. + * + * @method LeanTween.color + * @param {GameObject} gameObject:GameObject Gameobject that you wish to change the color + * @param {Color} to:Color the final color value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.color(gameObject, Color.yellow, 1f) .setDelay(1f); + */ + public static LTDescr color(GameObject gameObject, Color to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setColor().setPoint( new Vector3(to.r, to.g, to.b) ) ); + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Change the color a Unity UI Object + * + * @method LeanTween.colorText + * @param {RectTransform} rectTransform:RectTransform RectTransform attached to the Text Component whose color you want to change + * @param {Color} to:Color the final alpha value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.colorText(gameObject.GetComponent<RectTransform>(), Color.yellow, 1f) .setDelay(1f); + */ + public static LTDescr textColor(RectTransform rectTransform, Color to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setTextColor().setPoint(new Vector3(to.r, to.g, to.b))); + } + public static LTDescr colorText(RectTransform rectTransform, Color to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setTextColor().setPoint(new Vector3(to.r, to.g, to.b))); + } + #endif + + /** + * Call a method after a specified amount of time + * + * @method LeanTween.delayedCall + * @param {GameObject} gameObject:GameObject Gameobject that you wish to associate with this delayed call + * @param {float} time:float delay The time you wish to pass before the method is called + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.delayedCall(gameObject, 1f, ()=>{
    Debug.Log("I am called one second later!");
    })); + */ + public static LTDescr delayedCall( float delayTime, Action callback){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } + + public static LTDescr delayedCall( float delayTime, Action callback){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } + + public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } + + public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } + + public static LTDescr destroyAfter( LTRect rect, float delayTime){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setRect( rect ).setDestroyOnComplete(true) ); + } + + /*public static LTDescr delayedCall(GameObject gameObject, float delayTime, string callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete( callback ) ); + }*/ + + /** + * Move a GameObject to a certain location + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3} vec:Vector3 to The final positin with which to move to + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject, new Vector3(0f,-3f,5f), 2.0f) .setEase( LeanTweenType.easeOutQuad ); + */ + public static LTDescr move(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setMove() ); + } + public static LTDescr move(GameObject gameObject, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x, to.y, gameObject.transform.position.z), time, options().setMove() ); + } + + + /** + * Move a GameObject along a set of bezier curves + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle2,Handle1,Point2,... + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
    + * LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + * C#:
    + * LeanTween.move(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);;
    + */ + public static LTDescr move(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveCurved(); + if(d.optional.path==null) + d.optional.path = new LTBezierPath( to ); + else + d.optional.path.setPoints( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } + + public static LTDescr move(GameObject gameObject, LTBezierPath to, float time) { + d = options().setMoveCurved(); + d.optional.path = to; + + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } + + public static LTDescr move(GameObject gameObject, LTSpline to, float time) { + d = options().setMoveSpline(); + d.optional.spline = to; + + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } + + /** + * Move a GameObject through a set of points + * + * @method LeanTween.moveSpline + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd
    Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value. + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
    + * LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + * C#:
    + * LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
    + */ + public static LTDescr moveSpline(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveSpline(); + d.optional.spline = new LTSpline( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } + + /** + * Move a GameObject through a set of points + * + * @method LeanTween.moveSpline + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {LTSpline} spline:LTSpline pass a pre-existing LTSpline for the object to move along + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
    + * LeanTween.moveSpline(gameObject, ltSpline, 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + * C#:
    + * LeanTween.moveSpline(gameObject, ltSpline, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
    + */ + public static LTDescr moveSpline(GameObject gameObject, LTSpline to, float time){ + d = options().setMoveSpline(); + d.optional.spline = to; + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } + + /** + * Move a GameObject through a set of points, in local space + * + * @method LeanTween.moveSplineLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
    + * LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + * C#:
    + * LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
    + */ + public static LTDescr moveSplineLocal(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveSplineLocal(); + d.optional.spline = new LTSpline( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } + + /** + * Move a GUI Element to a certain location + * + * @method LeanTween.move (GUI) + * @param {LTRect} ltRect:LTRect ltRect LTRect object that you wish to move + * @param {Vector2} vec:Vector2 to The final position with which to move to (pixel coordinates) + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr move(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIMove().setRect( ltRect ) ); + } + + public static LTDescr moveMargin(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIMoveMargin().setRect( ltRect ) ); + } + + /** + * Move a GameObject along the x-axis + * + * @method LeanTween.moveX + * @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to move + * @param {float} to:float to The final position with which to move to + * @param {float} time:float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveX() ); + } + + /** + * Move a GameObject along the y-axis + * + * @method LeanTween.moveY + * @param {GameObject} GameObject gameObject Gameobject that you wish to move + * @param {float} float to The final position with which to move to + * @param {float} float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveY() ); + } + + /** + * Move a GameObject along the z-axis + * + * @method LeanTween.moveZ + * @param {GameObject} GameObject gameObject Gameobject that you wish to move + * @param {float} float to The final position with which to move to + * @param {float} float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveZ() ); + } + + /** + * Move a GameObject to a certain location relative to the parent transform. + * + * @method LeanTween.moveLocal + * @param {GameObject} GameObject gameObject Gameobject that you wish to rotate + * @param {Vector3} Vector3 to The final positin with which to move to + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveLocal(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setMoveLocal() ); + } + + /** + * Move a GameObject along a set of bezier curves, in local space + * + * @method LeanTween.moveLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle1,Handle2,Point2,... + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
    + * LeanTween.moveLocal(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

    + * C#:
    + * LeanTween.moveLocal(gameObject, new Vector3[]{Vector3(0f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,1f)}).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
    + */ + public static LTDescr moveLocal(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveCurvedLocal(); + if(d.optional.path==null) + d.optional.path = new LTBezierPath( to ); + else + d.optional.path.setPoints( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } + + public static LTDescr moveLocalX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalX() ); + } + + public static LTDescr moveLocalY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalY() ); + } + + public static LTDescr moveLocalZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalZ() ); + } + + public static LTDescr moveLocal(GameObject gameObject, LTBezierPath to, float time) { + d = options().setMoveCurvedLocal(); + d.optional.path = to; + + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } + public static LTDescr moveLocal(GameObject gameObject, LTSpline to, float time) { + d = options().setMoveSplineLocal(); + d.optional.spline = to; + + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } + + /** + * Move a GameObject to another transform + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Transform} destination:Transform Transform whose position the tween will finally end on + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject, anotherTransform, 2.0f) .setEase( LeanTweenType.easeOutQuad ); + */ + public static LTDescr move(GameObject gameObject, Transform to, float time){ + return pushNewTween(gameObject, Vector3.zero, time, options().setTo(to).setMoveToTransform() ); + } + + /** + * Rotate a GameObject, to values are in passed in degrees + * + * @method LeanTween.rotate + * @param {GameObject} GameObject gameObject Gameobject that you wish to rotate + * @param {Vector3} Vector3 to The final rotation with which to rotate to + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotate(cube, new Vector3(180f,30f,0f), 1.5f); + */ + + public static LTDescr rotate(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setRotate() ); + } + + /** + * Rotate a GUI element (using an LTRect object), to a value that is in degrees + * + * @method LeanTween.rotate + * @param {LTRect} ltRect:LTRect LTRect that you wish to rotate + * @param {float} to:float The final rotation with which to rotate to + * @param {float} time:float The time to complete the tween in + * @param {Array} optional:Array Object Array where you can pass optional items. + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * if(GUI.Button(buttonRect.rect, "Rotate"))
    + * LeanTween.rotate( buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);
    + * GUI.matrix = Matrix4x4.identity;
    + */ + public static LTDescr rotate(LTRect ltRect, float to, float time){ + return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, options().setGUIRotate().setRect( ltRect ) ); + } + + /** + * Rotate a GameObject in the objects local space (on the transforms localEulerAngles object) + * + * @method LeanTween.rotateLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} to:Vector3 The final rotation with which to rotate to + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateLocal(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setRotateLocal() ); + } + + /** + * Rotate a GameObject only on the X axis + * + * @method LeanTween.rotateX + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final x-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateX() ); + } + + /** + * Rotate a GameObject only on the Y axis + * + * @method LeanTween.rotateY + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final y-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateY() ); + } + + /** + * Rotate a GameObject only on the Z axis + * + * @method LeanTween.rotateZ + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final z-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateZ() ); + } + + /** + * Rotate a GameObject around a certain Axis (the best method to use when you want to rotate beyond 180 degrees) + * + * @method LeanTween.rotateAround + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up + * @param {float} degrees:float the degrees in which to rotate + * @param {float} time:float time The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example:
    + * LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); + */ + public static LTDescr rotateAround(GameObject gameObject, Vector3 axis, float add, float time){ + return pushNewTween( gameObject, new Vector3(add,0f,0f), time, options().setAxis(axis).setRotateAround() ); + } + + /** + * Rotate a GameObject around a certain Axis in Local Space (the best method to use when you want to rotate beyond 180 degrees) + * + * @method LeanTween.rotateAroundLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up + * @param {float} degrees:float the degrees in which to rotate + * @param {float} time:float time The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example:
    + * LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); + */ + public static LTDescr rotateAroundLocal(GameObject gameObject, Vector3 axis, float add, float time){ + return pushNewTween( gameObject, new Vector3(add,0f,0f), time, options().setRotateAroundLocal().setAxis(axis) ); + } + + /** + * Scale a GameObject to a certain size + * + * @method LeanTween.scale + * @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to scale + * @param {Vector3} vec:Vector3 to The size with which to tween to + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scale(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setScale() ); + } + + /** + * Scale a GUI Element to a certain width and height + * + * @method LeanTween.scale (GUI) + * @param {LTRect} LTRect ltRect LTRect object that you wish to move + * @param {Vector2} Vector2 to The final width and height to scale to (pixel based) + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
    + * LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 ).setEase(LeanTweenType.easeOutBounce);
    + * function OnGUI(){
    + *   if(GUI.Button(bRect.rect, "Scale")){ }
    + * }
    + *
    + * Example C#:
    + * LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
    + * LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f ).setEase(LeanTweenType.easeOutBounce);
    + * void OnGUI(){
    + *   if(GUI.Button(bRect.rect, "Scale")){ }
    + * }
    + */ + public static LTDescr scale(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIScale().setRect( ltRect ) ); + } + + /** + * Scale a GameObject to a certain size along the x-axis only + * + * @method LeanTween.scaleX + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleX() ); + } + + /** + * Scale a GameObject to a certain size along the y-axis only + * + * @method LeanTween.scaleY + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleY() ); + } + + /** + * Scale a GameObject to a certain size along the z-axis only + * + * @method LeanTween.scaleZ + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleZ()); + } + + /** + * Tween any particular value (float) + * + * @method LeanTween.value (float) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {float} from:float The original value to start the tween from + * @param {Vector3} to:float The final float with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( function( val:float ){
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( (float val)=>{
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + */ + public static LTDescr value(GameObject gameObject, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setFrom( new Vector3(from,0,0) ) ); + } + public static LTDescr value(float from, float to, float time){ + return pushNewTween( tweenEmpty, new Vector3(to,0,0), time, options().setCallback().setFrom( new Vector3(from,0,0) ) ); + } + + /** + * Tween any particular value (Vector2) + * + * @method LeanTween.value (Vector2) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Vector2} from:Vector2 The original value to start the tween from + * @param {Vector3} to:Vector2 The final Vector2 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, new Vector2(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( function( val:Vector2 ){
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, new Vector3(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( (Vector2 val)=>{
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + */ + public static LTDescr value(GameObject gameObject, Vector2 from, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x,to.y,0), time, options().setValue3().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0) ) ); + } + + /** + * Tween any particular value (Vector3) + * + * @method LeanTween.value (Vector3) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Vector3} from:Vector3 The original value to start the tween from + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( function( val:Vector3 ){
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( (Vector3 val)=>{
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + */ + public static LTDescr value(GameObject gameObject, Vector3 from, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setValue3().setFrom( from ) ); + } + + /** + * Tween any particular value (Color) + * + * @method LeanTween.value (Color) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Color} from:Color The original value to start the tween from + * @param {Color} to:Color The final Color with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( function( val:Color ){
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( (Color val)=>{
    + *  Debug.Log("tweened val:"+val);
    + * } );
    + */ + public static LTDescr value(GameObject gameObject, Color from, Color to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(1f, to.a, 0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setFromColor(from).setHasInitialized(false) ); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } + + /** + * Tween any particular value, it does not need to be tied to any particular type or GameObject + * + * @method LeanTween.value (float) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( float val ){ } + * @param {float} float from The original value to start the tween from + * @param {float} float to The value to end the tween on + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + * function updateValueExampleCallback( val:float ){
    + *   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
    + * }
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + * void updateValueExampleCallback( float val ){
    + *   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
    + * }
    + */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdate(callOnUpdate) ); + } + + /** + * Tweens any float value, it does not need to be tied to any particular type or GameObject + * + * @method LeanTween.value (float) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdateRatio:Action Function that's called every Update frame. It must accept two float values ex: function updateValue( float val, float ratio){ } + * @param {float} float from The original value to start the tween from + * @param {float} float to The value to end the tween on + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + * function updateValueExampleCallback( val:float, ratio:float ){
    + *   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
    + * }
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
    + * void updateValueExampleCallback( float val, float ratio ){
    + *   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
    + * }
    + */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdateRatio, float from, float to, float time) { + return pushNewTween(gameObject, new Vector3(to, 0, 0), time, options().setCallback().setTo(new Vector3(to, 0, 0)).setFrom(new Vector3(from, 0, 0)).setOnUpdateRatio(callOnUpdateRatio)); + } + + /** + * Tween from one color to another + * + * @method LeanTween.value (Color) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a color value ex: function updateValue( Color val ){ } + * @param {Color} Color from The original value to start the tween from + * @param {Color} Color to The value to end the tween on + * @param {Color} Color time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
    + * LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
    + * function updateValueExampleCallback( val:Color ){
    + *   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
    + * }
    + *
    + * Example C#:
    + * LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
    + * void updateValueExampleCallback( Color val ){
    + *   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
    + * }
    + */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Color from, Color to, float time){ + return pushNewTween( gameObject, new Vector3(1.0f,to.a,0.0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setAxis( new Vector3(from.r, from.g, from.b) ).setFrom( new Vector3(0.0f, from.a, 0.0f) ).setHasInitialized(false).setOnUpdateColor(callOnUpdate) ); + } + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Color from, Color to, float time){ + return pushNewTween( gameObject, new Vector3(1.0f,to.a,0.0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setAxis( new Vector3(from.r, from.g, from.b) ).setFrom( new Vector3(0.0f, from.a, 0.0f) ).setHasInitialized(false).setOnUpdateColor(callOnUpdate) ); + } + + /** + * Tween any particular value (Vector2), this could be used to tween an arbitrary value like offset property + * + * @method LeanTween.value (Vector2) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } + * @param {float} from:Vector2 The original value to start the tween from + * @param {Vector2} to:Vector2 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector2 from, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x,to.y,0f), time, options().setValue3().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0f) ).setOnUpdateVector2(callOnUpdate) ); + } + + /** + * Tween any particular value (Vector3), this could be used to tween an arbitrary property that uses a Vector + * + * @method LeanTween.value (Vector3) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } + * @param {float} from:Vector3 The original value to start the tween from + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector3 from, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setValue3().setTo( to ).setFrom( from ).setOnUpdateVector3(callOnUpdate) ); + } + + /** + * Tween any particular value (float) + * + * @method LeanTween.value (float,object) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val, object obj ){ } + * @param {float} from:float The original value to start the tween from + * @param {Vector3} to:float The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdate(callOnUpdate, gameObject) ); + } + + public static LTDescr delayedSound( AudioClip audio, Vector3 pos, float volume ){ + //Debug.LogError("Delay sound??"); + return pushNewTween( tweenEmpty, pos, 0f, options().setDelayedSound().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); + } + + public static LTDescr delayedSound( GameObject gameObject, AudioClip audio, Vector3 pos, float volume ){ + //Debug.LogError("Delay sound??"); + return pushNewTween( gameObject, pos, 0f, options().setDelayedSound().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + /** + * Move a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.move (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject.GetComponent<RectTransform>(), new Vector3(200f,-100f,0f), 1f).setDelay(1f); + */ + public static LTDescr move(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasMove().setRect( rectTrans ) ); + } + + /** + * Move a RectTransform object affecting x-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.moveX (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final x location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveX(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveX(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveX().setRect( rectTrans ) ); + } + + /** + * Move a RectTransform object affecting y-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.moveY (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final y location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveY(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveY(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveY().setRect( rectTrans ) ); + } + + /** + * Move a RectTransform object affecting z-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.moveZ (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final x location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveZ(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveZ(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveZ().setRect( rectTrans ) ); + } + + /** + * Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotate (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotate(gameObject.GetComponent<RectTransform>(), 90f, 1f).setDelay(1f); + */ + public static LTDescr rotate(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(Vector3.forward) ); + } + + public static LTDescr rotate(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(Vector3.forward) ); + } + + /** + * Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotateAround (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} axis:Vector3 The axis in which to rotate the RectTransform (Vector3.forward is most commonly used) + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotateAround(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); + */ + public static LTDescr rotateAround(RectTransform rectTrans, Vector3 axis, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(axis) ); + } + + /** + * Rotate a RectTransform object around it's local axis (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotateAroundLocal (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} axis:Vector3 The local axis in which to rotate the RectTransform (Vector3.forward is most commonly used) + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotateAroundLocal(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); + */ + public static LTDescr rotateAroundLocal(RectTransform rectTrans, Vector3 axis, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAroundLocal().setRect( rectTrans ).setAxis(axis) ); + } + + /** + * Scale a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.scale (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.scale(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().localScale*2f, 1f).setDelay(1f); + */ + public static LTDescr scale(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasScale().setRect( rectTrans ) ); + } + + /** + * Change the sizeDelta of a RectTransform object (used in Unity Canvas, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.size (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector2} to:Vector2 The final Vector2 the tween will end at for sizeDelta property + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.size(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().sizeDelta*2f, 1f).setDelay(1f); + */ + public static LTDescr size(RectTransform rectTrans, Vector2 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasSizeDelta().setRect( rectTrans ) ); + } + + /** + * Alpha an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.alpha (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.alpha(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); + */ + public static LTDescr alpha(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasAlpha().setRect( rectTrans ) ); + } + + /** + * Change the Color of an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.alpha (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.color(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); + */ + public static LTDescr color(RectTransform rectTrans, Color to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setCanvasColor().setRect( rectTrans ).setPoint( new Vector3(to.r, to.g, to.b) ) ); + } + + #endif + + // Tweening Functions - Thanks to Robert Penner and GFX47 + + public static float tweenOnCurve( LTDescr tweenDescr, float ratioPassed ){ + // Debug.Log("single ratio:"+ratioPassed+" tweenDescr.animationCurve.Evaluate(ratioPassed):"+tweenDescr.animationCurve.Evaluate(ratioPassed)); + return tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed); + } + + public static Vector3 tweenOnCurveVector( LTDescr tweenDescr, float ratioPassed ){ + return new Vector3(tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed), + tweenDescr.from.y + (tweenDescr.diff.y) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed), + tweenDescr.from.z + (tweenDescr.diff.z) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed) ); + } + + public static float easeOutQuadOpt( float start, float diff, float ratioPassed ){ + return -diff * ratioPassed * (ratioPassed - 2) + start; + } + + public static float easeInQuadOpt( float start, float diff, float ratioPassed ){ + return diff * ratioPassed * ratioPassed + start; + } + + public static float easeInOutQuadOpt( float start, float diff, float ratioPassed ){ + ratioPassed /= .5f; + if (ratioPassed < 1) return diff / 2 * ratioPassed * ratioPassed + start; + ratioPassed--; + return -diff / 2 * (ratioPassed * (ratioPassed - 2) - 1) + start; + } + + public static Vector3 easeInOutQuadOpt( Vector3 start, Vector3 diff, float ratioPassed ){ + ratioPassed /= .5f; + if (ratioPassed < 1) return diff / 2 * ratioPassed * ratioPassed + start; + ratioPassed--; + return -diff / 2 * (ratioPassed * (ratioPassed - 2) - 1) + start; + } + + public static float linear(float start, float end, float val){ + return Mathf.Lerp(start, end, val); + } + + public static float clerp(float start, float end, float val){ + float min = 0.0f; + float max = 360.0f; + float half = Mathf.Abs((max - min) / 2.0f); + float retval = 0.0f; + float diff = 0.0f; + if ((end - start) < -half){ + diff = ((max - start) + end) * val; + retval = start + diff; + }else if ((end - start) > half){ + diff = -((max - end) + start) * val; + retval = start + diff; + }else retval = start + (end - start) * val; + return retval; + } + + public static float spring(float start, float end, float val ){ + val = Mathf.Clamp01(val); + val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f ) + val) * (1f + (1.2f * (1f - val) )); + return start + (end - start) * val; + } + + public static float easeInQuad(float start, float end, float val){ + end -= start; + return end * val * val + start; + } + + public static float easeOutQuad(float start, float end, float val){ + end -= start; + return -end * val * (val - 2) + start; + } + + public static float easeInOutQuad(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val + start; + val--; + return -end / 2 * (val * (val - 2) - 1) + start; + } + + + public static float easeInOutQuadOpt2(float start, float diffBy2, float val, float val2){ + val /= .5f; + if (val < 1) return diffBy2 * val2 + start; + val--; + return -diffBy2 * ((val2 - 2) - 1f) + start; + } + + public static float easeInCubic(float start, float end, float val){ + end -= start; + return end * val * val * val + start; + } + + public static float easeOutCubic(float start, float end, float val){ + val--; + end -= start; + return end * (val * val * val + 1) + start; + } + + public static float easeInOutCubic(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val + start; + val -= 2; + return end / 2 * (val * val * val + 2) + start; + } + + public static float easeInQuart(float start, float end, float val){ + end -= start; + return end * val * val * val * val + start; + } + + public static float easeOutQuart(float start, float end, float val){ + val--; + end -= start; + return -end * (val * val * val * val - 1) + start; + } + + public static float easeInOutQuart(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val * val + start; + val -= 2; + return -end / 2 * (val * val * val * val - 2) + start; + } + + public static float easeInQuint(float start, float end, float val){ + end -= start; + return end * val * val * val * val * val + start; + } + + public static float easeOutQuint(float start, float end, float val){ + val--; + end -= start; + return end * (val * val * val * val * val + 1) + start; + } + + public static float easeInOutQuint(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val * val * val + start; + val -= 2; + return end / 2 * (val * val * val * val * val + 2) + start; + } + + public static float easeInSine(float start, float end, float val){ + end -= start; + return -end * Mathf.Cos(val / 1 * (Mathf.PI / 2)) + end + start; + } + + public static float easeOutSine(float start, float end, float val){ + end -= start; + return end * Mathf.Sin(val / 1 * (Mathf.PI / 2)) + start; + } + + public static float easeInOutSine(float start, float end, float val){ + end -= start; + return -end / 2 * (Mathf.Cos(Mathf.PI * val / 1) - 1) + start; + } + + public static float easeInExpo(float start, float end, float val){ + end -= start; + return end * Mathf.Pow(2, 10 * (val / 1 - 1)) + start; + } + + public static float easeOutExpo(float start, float end, float val){ + end -= start; + return end * (-Mathf.Pow(2, -10 * val / 1) + 1) + start; + } + + public static float easeInOutExpo(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * Mathf.Pow(2, 10 * (val - 1)) + start; + val--; + return end / 2 * (-Mathf.Pow(2, -10 * val) + 2) + start; + } + + public static float easeInCirc(float start, float end, float val){ + end -= start; + return -end * (Mathf.Sqrt(1 - val * val) - 1) + start; + } + + public static float easeOutCirc(float start, float end, float val){ + val--; + end -= start; + return end * Mathf.Sqrt(1 - val * val) + start; + } + + public static float easeInOutCirc(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return -end / 2 * (Mathf.Sqrt(1 - val * val) - 1) + start; + val -= 2; + return end / 2 * (Mathf.Sqrt(1 - val * val) + 1) + start; + } + + public static float easeInBounce(float start, float end, float val){ + end -= start; + float d = 1f; + return end - easeOutBounce(0, end, d-val) + start; + } + + public static float easeOutBounce(float start, float end, float val){ + val /= 1f; + end -= start; + if (val < (1 / 2.75f)){ + return end * (7.5625f * val * val) + start; + }else if (val < (2 / 2.75f)){ + val -= (1.5f / 2.75f); + return end * (7.5625f * (val) * val + .75f) + start; + }else if (val < (2.5 / 2.75)){ + val -= (2.25f / 2.75f); + return end * (7.5625f * (val) * val + .9375f) + start; + }else{ + val -= (2.625f / 2.75f); + return end * (7.5625f * (val) * val + .984375f) + start; + } + } + + public static float easeInOutBounce(float start, float end, float val){ + end -= start; + float d= 1f; + if (val < d/2) return easeInBounce(0, end, val*2) * 0.5f + start; + else return easeOutBounce(0, end, val*2-d) * 0.5f + end*0.5f + start; + } + + public static float easeInBack(float start, float end, float val, float overshoot = 1.0f){ + end -= start; + val /= 1; + float s= 1.70158f * overshoot; + return end * (val) * val * ((s + 1) * val - s) + start; + } + + public static float easeOutBack(float start, float end, float val, float overshoot = 1.0f){ + float s = 1.70158f * overshoot; + end -= start; + val = (val / 1) - 1; + return end * ((val) * val * ((s + 1) * val + s) + 1) + start; + } + + public static float easeInOutBack(float start, float end, float val, float overshoot = 1.0f){ + float s = 1.70158f * overshoot; + end -= start; + val /= .5f; + if ((val) < 1){ + s *= (1.525f) * overshoot; + return end / 2 * (val * val * (((s) + 1) * val - s)) + start; + } + val -= 2; + s *= (1.525f) * overshoot; + return end / 2 * ((val) * val * (((s) + 1) * val + s) + 2) + start; + } + + public static float easeInElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ + end -= start; + + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + if (val == 1f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + + if(overshoot>1f && val>0.6f ) + overshoot = 1f + ((1f-val) / 0.4f * (overshoot-1f)); + // Debug.Log("ease in elastic val:"+val+" a:"+a+" overshoot:"+overshoot); + + val = val-1f; + return start-(a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; + } + + public static float easeOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ + end -= start; + + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + // Debug.Log("ease out elastic val:"+val+" a:"+a); + if (val == 1f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + if(overshoot>1f && val<0.4f ) + overshoot = 1f + (val / 0.4f * (overshoot-1f)); + // Debug.Log("ease out elastic val:"+val+" a:"+a+" overshoot:"+overshoot); + + return start + end + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * overshoot; + } + + public static float easeInOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f) + { + end -= start; + + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + val = val / (1f/2f); + if (val == 2f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + + if(overshoot>1f){ + if( val<0.2f ){ + overshoot = 1f + (val / 0.2f * (overshoot-1f)); + }else if( val > 0.8f ){ + overshoot = 1f + ((1f-val) / 0.2f * (overshoot-1f)); + } + } + + if (val < 1f){ + val = val-1f; + return start - 0.5f * (a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; + } + val = val-1f; + return end + start + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * 0.5f * overshoot; + } + + // LeanTween Listening/Dispatch + + private static System.Action[] eventListeners; + private static GameObject[] goListeners; + private static int eventsMaxSearch = 0; + public static int EVENTS_MAX = 10; + public static int LISTENERS_MAX = 10; + private static int INIT_LISTENERS_MAX = LISTENERS_MAX; + + public static void addListener( int eventId, System.Action callback ){ + addListener(tweenEmpty, eventId, callback); + } + + /** + * Add a listener method to be called when the appropriate LeanTween.dispatchEvent is called + * + * @method LeanTween.addListener + * @param {GameObject} caller:GameObject the gameObject the listener is attached to + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {System.Action} callback:System.Action the method to call when the event has been dispatched + * @example + * LeanTween.addListener(gameObject, (int)MyEvents.JUMP, jumpUp);
    + *
    + * void jumpUp( LTEvent e ){ Debug.Log("jump!"); }
    + */ + public static void addListener( GameObject caller, int eventId, System.Action callback ){ + if(eventListeners==null){ + INIT_LISTENERS_MAX = LISTENERS_MAX; + eventListeners = new System.Action[ EVENTS_MAX * LISTENERS_MAX ]; + goListeners = new GameObject[ EVENTS_MAX * LISTENERS_MAX ]; + } + // Debug.Log("searching for an empty space for:"+caller + " eventid:"+event); + for(i = 0; i < INIT_LISTENERS_MAX; i++){ + int point = eventId*INIT_LISTENERS_MAX + i; + if(goListeners[ point ]==null || eventListeners[ point ]==null){ + eventListeners[ point ] = callback; + goListeners[ point ] = caller; + if(i>=eventsMaxSearch) + eventsMaxSearch = i+1; + // Debug.Log("adding event for:"+caller.name); + + return; + } + #if UNITY_FLASH + if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback)){ + // Debug.Log("This event is already being listened for."); + return; + } + #else + if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback)){ + // Debug.Log("This event is already being listened for."); + return; + } + #endif + } + Debug.LogError("You ran out of areas to add listeners, consider increasing LISTENERS_MAX, ex: LeanTween.LISTENERS_MAX = "+(LISTENERS_MAX*2)); + } + + public static bool removeListener( int eventId, System.Action callback ){ + return removeListener( tweenEmpty, eventId, callback); + } + + /** + * Remove an event listener you have added + * @method LeanTween.removeListener + * @param {GameObject} caller:GameObject the gameObject the listener is attached to + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {System.Action} callback:System.Action the method that was specified to call when the event has been dispatched + * @example + * LeanTween.removeListener(gameObject, (int)MyEvents.JUMP, jumpUp);
    + *
    + * void jumpUp( LTEvent e ){ }
    + */ + public static bool removeListener( GameObject caller, int eventId, System.Action callback ){ + for(i = 0; i < eventsMaxSearch; i++){ + int point = eventId*INIT_LISTENERS_MAX + i; + #if UNITY_FLASH + if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback) ){ + #else + if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback) ){ + #endif + eventListeners[ point ] = null; + goListeners[ point ] = null; + return true; + } + } + return false; + } + + /** + * Tell the added listeners that you are dispatching the event + * @method LeanTween.dispatchEvent + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @example + * LeanTween.dispatchEvent( (int)MyEvents.JUMP );
    + */ + public static void dispatchEvent( int eventId ){ + dispatchEvent( eventId, null); + } + + /** + * Tell the added listeners that you are dispatching the event + * @method LeanTween.dispatchEvent + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {object} data:object Pass data to the listener, access it from the listener with *.data on the LTEvent object + * @example + * LeanTween.dispatchEvent( (int)MyEvents.JUMP, transform );
    + *
    + * void jumpUp( LTEvent e ){
    + *   Transform tran = (Transform)e.data;
    + * }
    + */ + public static void dispatchEvent( int eventId, object data ){ + for(int k = 0; k < eventsMaxSearch; k++){ + int point = eventId*INIT_LISTENERS_MAX + k; + if(eventListeners[ point ]!=null){ + if(goListeners[point]){ + eventListeners[ point ]( new LTEvent(eventId, data) ); + }else{ + eventListeners[ point ] = null; + } + } + } + } + + +} // End LeanTween class + +public class LTUtility { + + public static Vector3[] reverse( Vector3[] arr ){ + int length = arr.Length; + int left = 0; + int right = length - 1; + + for (; left < right; left += 1, right -= 1){ + Vector3 temporary = arr[left]; + arr[left] = arr[right]; + arr[right] = temporary; + } + return arr; + } +} + +public class LTBezier { + public float length; + + private Vector3 a; + private Vector3 aa; + private Vector3 bb; + private Vector3 cc; + private float len; + private float[] arcLengths; + + public LTBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float precision){ + this.a = a; + aa = (-a + 3*(b-c) + d); + bb = 3*(a+c) - 6*b; + cc = 3*(b-a); + + this.len = 1.0f / precision; + arcLengths = new float[(int)this.len + (int)1]; + arcLengths[0] = 0; + + Vector3 ov = a; + Vector3 v; + float clen = 0.0f; + for(int i = 1; i <= this.len; i++) { + v = bezierPoint(i * precision); + clen += (ov - v).magnitude; + this.arcLengths[i] = clen; + ov = v; + } + this.length = clen; + } + + private float map(float u) { + float targetLength = u * this.arcLengths[(int)this.len]; + int low = 0; + int high = (int)this.len; + int index = 0; + while (low < high) { + index = low + ((int)((high - low) / 2.0f) | 0); + if (this.arcLengths[index] < targetLength) { + low = index + 1; + } else { + high = index; + } + } + if(this.arcLengths[index] > targetLength) + index--; + if(index<0) + index = 0; + + return (index + (targetLength - arcLengths[index]) / (arcLengths[index + 1] - arcLengths[index])) / this.len; + } + + private Vector3 bezierPoint(float t){ + return ((aa* t + (bb))* t + cc)* t + a; + } + + public Vector3 point(float t){ + return bezierPoint( map(t) ); + } +} + +/** +* Manually animate along a bezier path with this class +* @class LTBezierPath +* @constructor +* @param {Vector3 Array} pts A set of points that define one or many bezier paths (the paths should be passed in multiples of 4, which correspond to each individual bezier curve)
    +* It goes in the order: startPoint,endControl,startControl,endPoint - Note: the control for the end and start are reversed! This is just a *quirk* of the API.
    +* +* @example +* LTBezierPath ltPath = new LTBezierPath( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(1f,0f,0f), new Vector3(1f,0f,0f), new Vector3(1f,1f,0f)} );

    +* LeanTween.move(lt, ltPath.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
    +* Vector3 pt = ltPath.point( 0.6f ); // retrieve a point along the path +*/ +public class LTBezierPath { + public Vector3[] pts; + public float length; + public bool orientToPath; + public bool orientToPath2d; + + private LTBezier[] beziers; + private float[] lengthRatio; + private int currentBezier=0,previousBezier=0; + + public LTBezierPath(){ } + public LTBezierPath( Vector3[] pts_ ){ + setPoints( pts_ ); + } + + public void setPoints( Vector3[] pts_ ){ + if(pts_.Length<4) + LeanTween.logError( "LeanTween - When passing values for a vector path, you must pass four or more values!" ); + if(pts_.Length%4!=0) + LeanTween.logError( "LeanTween - When passing values for a vector path, they must be in sets of four: controlPoint1, controlPoint2, endPoint2, controlPoint2, controlPoint2..." ); + + pts = pts_; + + int k = 0; + beziers = new LTBezier[ pts.Length / 4 ]; + lengthRatio = new float[ beziers.Length ]; + int i; + length = 0; + for(i = 0; i < pts.Length; i+=4){ + beziers[k] = new LTBezier(pts[i+0],pts[i+2],pts[i+1],pts[i+3],0.05f); + length += beziers[k].length; + k++; + } + // Debug.Log("beziers.Length:"+beziers.Length + " beziers:"+beziers); + for(i = 0; i < beziers.Length; i++){ + lengthRatio[i] = beziers[i].length / length; + } + } + + /** + * @property {float} distance distance of the path (in unity units) + */ + public float distance{ + get{ + return length; + } + } + + /** + * Retrieve a point along a path + * + * @method point + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @return {Vector3} Vector3 position of the point along the path + * @example + * transform.position = ltPath.point( 0.6f ); + */ + public Vector3 point( float ratio ){ + float added = 0.0f; + for(int i = 0; i < lengthRatio.Length; i++){ + added += lengthRatio[i]; + if(added >= ratio) + return beziers[i].point( (ratio-(added-lengthRatio[i])) / lengthRatio[i] ); + } + return beziers[lengthRatio.Length-1].point( 1.0f ); + } + + public void place2d( Transform transform, float ratio ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = point( ratio ) - transform.position; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + public void placeLocal2d( Transform transform, float ratio ){ + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = transform.parent.TransformPoint( point( ratio ) ) - transform.localPosition; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.place( transform, 0.6f ); + */ + public void place( Transform transform, float ratio ){ + place( transform, ratio, Vector3.up ); + + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.place( transform, 0.6f, Vector3.left ); + */ + public void place( Transform transform, float ratio, Vector3 worldUp ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( point( ratio ), worldUp ); + + } + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.placeLocal( transform, 0.6f ); + */ + public void placeLocal( Transform transform, float ratio ){ + placeLocal( transform, ratio, Vector3.up ); + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.placeLocal( transform, 0.6f, Vector3.left ); + */ + public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ + ratio = getRationInOneRange (ratio); + transform.localPosition = point( ratio ); + ratio = getRationInOneRange (ratio + 0.001f); + if(ratio<=1.0f) + transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); + } + + public float getRationInOneRange(float ratio){ + if (ratio >= 0.0f && ratio <= 1.0f) { + return ratio; + } else if (ratio < 0.0f) { + return Mathf.Ceil(ratio) - ratio; //if -1.4 => it returns 0.4 + } else { + return ratio - Mathf.Floor(ratio); //if 1.4 => it return 0.4 + } + } + + public void gizmoDraw(float t = -1.0f) + { + Vector3 prevPt = point(0); + + for (int i = 1; i <= 120; i++) + { + float pm = (float)i / 120f; + Vector3 currPt2 = point(pm); + //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); + Gizmos.color = (previousBezier == currentBezier) ? Color.magenta : Color.grey; + Gizmos.DrawLine(currPt2, prevPt); + prevPt = currPt2; + previousBezier = currentBezier; + } + } +} + +/** +* Animate along a set of points that need to be in the format: controlPoint, point1, point2.... pointLast, endControlPoint +* @class LTSpline +* @constructor +* @param {Vector3 Array} pts A set of points that define the points the path will pass through (starting with starting control point, and ending with a control point)
    +Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value. +* @example +* LTSpline ltSpline = new LTSpline( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(0f,0f,0f), new Vector3(0f,0.5f,0f), new Vector3(1f,1f,0f), new Vector3(1f,1f,0f)} );

    +* LeanTween.moveSpline(lt, ltSpline.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
    +* Vector3 pt = ltSpline.point( 0.6f ); // retrieve a point along the path +*/ +[System.Serializable] +public class LTSpline { + public static int DISTANCE_COUNT = 3; // increase for a more accurate constant speed + public static int SUBLINE_COUNT = 20; // increase for a more accurate smoothing of the curves into lines + + /** + * @property {float} distance distance of the spline (in unity units) + */ + public float distance = 0f; + + public bool constantSpeed = true; + + public Vector3[] pts; + [System.NonSerialized] + public Vector3[] ptsAdj; + public int ptsAdjLength; + public bool orientToPath; + public bool orientToPath2d; + private int numSections; + private int currPt; + + public LTSpline( Vector3[] pts ){ + init( pts, true); + } + + public LTSpline( Vector3[] pts, bool constantSpeed ) { + this.constantSpeed = constantSpeed; + init(pts, constantSpeed); + } + + private void init( Vector3[] pts, bool constantSpeed){ + if(pts.Length<4){ + LeanTween.logError( "LeanTween - When passing values for a spline path, you must pass four or more values!" ); + return; + } + + this.pts = new Vector3[pts.Length]; + System.Array.Copy(pts, this.pts, pts.Length); + + numSections = pts.Length - 3; + + float minSegment = float.PositiveInfinity; + Vector3 earlierPoint = this.pts[1]; + float totalDistance = 0f; + for(int i=1; i < this.pts.Length-1; i++){ + // float pointDistance = (this.pts[i]-earlierPoint).sqrMagnitude; + float pointDistance = Vector3.Distance(this.pts[i], earlierPoint); + //Debug.Log("pointDist:"+pointDistance); + if(pointDistance < minSegment){ + minSegment = pointDistance; + } + + totalDistance += pointDistance; + } + + if(constantSpeed){ + minSegment = totalDistance / (numSections*SUBLINE_COUNT); + //Debug.Log("minSegment:"+minSegment+" numSections:"+numSections); + + float minPrecision = minSegment / SUBLINE_COUNT; // number of subdivisions in each segment + int precision = (int)Mathf.Ceil(totalDistance / minPrecision) * DISTANCE_COUNT; + // Debug.Log("precision:"+precision); + if(precision<=1) // precision has to be greater than one + precision = 2; + + ptsAdj = new Vector3[ precision ]; + earlierPoint = interp( 0f ); + int num = 1; + ptsAdj[0] = earlierPoint; + distance = 0f; + for(int i = 0; i < precision + 1; i++){ + float fract = ((float)(i)) / precision; + // Debug.Log("fract:"+fract); + Vector3 point = interp( fract ); + float dist = Vector3.Distance(point, earlierPoint); + + // float dist = (point-earlierPoint).sqrMagnitude; + if(dist>=minPrecision || fract>=1.0f){ + ptsAdj[num] = point; + distance += dist; // only add it to the total distance once we know we are adding it as an adjusted point + + earlierPoint = point; + // Debug.Log("fract:"+fract+" point:"+point); + num++; + } + } + // make sure there is a point at the very end + /*num++; + Vector3 endPoint = interp( 1f ); + ptsAdj[num] = endPoint;*/ + // Debug.Log("fract 1f endPoint:"+endPoint); + + ptsAdjLength = num; + } + // Debug.Log("map 1f:"+map(1f)+" end:"+ptsAdj[ ptsAdjLength-1 ]); + + // Debug.Log("ptsAdjLength:"+ptsAdjLength+" minPrecision:"+minPrecision+" precision:"+precision); + } + + public Vector3 map( float u ){ + if(u>=1f) + return pts[ pts.Length - 2]; + float t = u * (ptsAdjLength-1); + int first = (int)Mathf.Floor( t ); + int next = (int)Mathf.Ceil( t ); + + if(first<0) + first = 0; + + Vector3 val = ptsAdj[ first ]; + + + Vector3 nextVal = ptsAdj[ next ]; + float diff = t - first; + + // Debug.Log("u:"+u+" val:"+val +" nextVal:"+nextVal+" diff:"+diff+" first:"+first+" next:"+next); + + val = val + (nextVal - val) * diff; + + return val; + } + + public Vector3 interp(float t) { + currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + //Debug.Log("currPt:"+currPt+" numSections:"+numSections+" pts.Length :"+pts.Length ); + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + Vector3 val = (.5f * ( + (-a + 3f * b - 3f * c + d) * (u * u * u) + + (2f * a - 5f * b + 4f * c - d) * (u * u) + + (-a + c) * u + + 2f * b)); + // Debug.Log("currPt:"+currPt+" t:"+t+" val.x"+val.x+" y:"+val.y+" z:"+val.z); + + return val; + } + + /** + * Retrieve a point along a path + * + * @method ratioAtPoint + * @param {Vector3} point:Vector3 given a current location it makes the best approximiation of where it is along the path ratio-wise (0-1) + * @return {float} float of ratio along the path + * @example + * ratioIter = ltSpline.ratioAtPoint( transform.position ); + */ + public float ratioAtPoint( Vector3 pt ){ + float closestDist = float.MaxValue; + int closestI = 0; + for (int i = 0; i < ptsAdjLength; i++) { + float dist = Vector3.Distance(pt, ptsAdj[i]); + // Debug.Log("i:"+i+" dist:"+dist); + if(dist1f?1f:ratio; + return constantSpeed ? map(t) : interp(t); + } + + public void place2d( Transform transform, float ratio ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = point( ratio ) - transform.position; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + public void placeLocal2d( Transform transform, float ratio ){ + Transform trans = transform.parent; + if(trans==null){ // this has no parent, just do a regular transform + place2d(transform, ratio); + return; + } + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 ptAhead = point( ratio );//trans.TransformPoint( ); + Vector3 v3Dir = ptAhead - transform.localPosition; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.place( transform, 0.6f ); + */ + public void place( Transform transform, float ratio ){ + place(transform, ratio, Vector3.up); + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.place( transform, 0.6f, Vector3.left ); + */ + public void place( Transform transform, float ratio, Vector3 worldUp ){ + // ratio = Mathf.Repeat(ratio, 1.0f); // make sure ratio is always between 0-1 + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( point( ratio ), worldUp ); + + } + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.placeLocal( transform, 0.6f ); + */ + public void placeLocal( Transform transform, float ratio ){ + placeLocal( transform, ratio, Vector3.up ); + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.placeLocal( transform, 0.6f, Vector3.left ); + */ + public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); + } + + public void gizmoDraw(float t = -1.0f) { + if(ptsAdj==null || ptsAdj.Length<=0) + return; + + Vector3 prevPt = ptsAdj[0]; + + for (int i = 0; i < ptsAdjLength; i++) { + Vector3 currPt2 = ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); + //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + } + + public void drawGizmo( Color color ) { + if( this.ptsAdjLength>=4){ + + Vector3 prevPt = this.ptsAdj[0]; + + Color colorBefore = Gizmos.color; + Gizmos.color = color; + for (int i = 0; i < this.ptsAdjLength; i++) { + Vector3 currPt2 = this.ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); + + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + Gizmos.color = colorBefore; + } + } + + public static void drawGizmo(Transform[] arr, Color color) { + if(arr.Length>=4){ + Vector3[] vec3s = new Vector3[arr.Length]; + for(int i = 0; i < arr.Length; i++){ + vec3s[i] = arr[i].position; + } + LTSpline spline = new LTSpline(vec3s); + Vector3 prevPt = spline.ptsAdj[0]; + + Color colorBefore = Gizmos.color; + Gizmos.color = color; + for (int i = 0; i < spline.ptsAdjLength; i++) { + Vector3 currPt2 = spline.ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); + + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + Gizmos.color = colorBefore; + } + } + + + public static void drawLine(Transform[] arr, float width, Color color) { + if(arr.Length>=4){ + + } + } + + /*public Vector3 Velocity(float t) { + t = map( t ); + + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + return 1.5f * (-a + 3f * b - 3f * c + d) * (u * u) + + (2f * a -5f * b + 4f * c - d) * u + + .5f * c - .5f * a; + }*/ + + public void drawLinesGLLines(Material outlineMaterial, Color color, float width){ + GL.PushMatrix(); + outlineMaterial.SetPass(0); + GL.LoadPixelMatrix(); + GL.Begin(GL.LINES); + GL.Color(color); + + if (constantSpeed) { + if (this.ptsAdjLength >= 4) { + + Vector3 prevPt = this.ptsAdj[0]; + + for (int i = 0; i < this.ptsAdjLength; i++) { + Vector3 currPt2 = this.ptsAdj[i]; + GL.Vertex(prevPt); + GL.Vertex(currPt2); + + prevPt = currPt2; + } + } + + } else { + if (this.pts.Length >= 4) { + + Vector3 prevPt = this.pts[0]; + + float split = 1f / ((float)this.pts.Length * 10f); + + float iter = 0f; + while (iter < 1f) { + float at = iter / 1f; + Vector3 currPt2 = interp(at); + // Debug.Log("currPt2:"+currPt2); + + GL.Vertex(prevPt); + GL.Vertex(currPt2); + + prevPt = currPt2; + + iter += split; + } + } + } + + + GL.End(); + GL.PopMatrix(); + + } + + public Vector3[] generateVectors(){ + if (this.pts.Length >= 4) { + List meshPoints = new List(); + Vector3 prevPt = this.pts[0]; + meshPoints.Add(prevPt); + + float split = 1f / ((float)this.pts.Length * 10f); + + float iter = 0f; + while (iter < 1f) { + float at = iter / 1f; + Vector3 currPt2 = interp(at); + // Debug.Log("currPt2:"+currPt2); + + // GL.Vertex(prevPt); + // GL.Vertex(currPt2); + meshPoints.Add(currPt2); + + // prevPt = currPt2; + + iter += split; + } + + meshPoints.ToArray(); + } + return null; + } +} + +/** +* Animate GUI Elements by creating this object and passing the *.rect variable to the GUI method

    +* Example Javascript:
    var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
    +* LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 );
    +* function OnGUI(){
    +*   if(GUI.Button(bRect.rect, "Scale")){ }
    +* }
    +*
    +* Example C#:
    +* LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
    +* LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f );
    +* void OnGUI(){
    +*   if(GUI.Button(bRect.rect, "Scale")){ }
    +* }
    +* +* @class LTRect +* @constructor +* @param {float} x:float X location +* @param {float} y:float Y location +* @param {float} width:float Width +* @param {float} height:float Height +* @param {float} alpha:float (Optional) initial alpha amount (0-1) +* @param {float} rotation:float (Optional) initial rotation in degrees (0-360) +*/ + +[System.Serializable] +public class LTRect : System.Object{ + /** + * Pass this value to the GUI Methods + * + * @property rect + * @type {Rect} rect:Rect Rect object that controls the positioning and size + */ + public Rect _rect; + public float alpha = 1f; + public float rotation; + public Vector2 pivot; + public Vector2 margin; + public Rect relativeRect = new Rect(0f,0f,float.PositiveInfinity,float.PositiveInfinity); + + public bool rotateEnabled; + [HideInInspector] + public bool rotateFinished; + public bool alphaEnabled; + public string labelStr; + public LTGUI.Element_Type type; + public GUIStyle style; + public bool useColor = false; + public Color color = Color.white; + public bool fontScaleToFit; + public bool useSimpleScale; + public bool sizeByHeight; + + public Texture texture; + + private int _id = -1; + [HideInInspector] + public int counter; + + public static bool colorTouched; + + public LTRect(){ + reset(); + this.rotateEnabled = this.alphaEnabled = true; + _rect = new Rect(0f,0f,1f,1f); + } + + public LTRect(Rect rect){ + _rect = rect; + reset(); + } + + public LTRect(float x, float y, float width, float height){ + _rect = new Rect(x,y,width,height); + this.alpha = 1.0f; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + } + + public LTRect(float x, float y, float width, float height, float alpha){ + _rect = new Rect(x,y,width,height); + this.alpha = alpha; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + } + + public LTRect(float x, float y, float width, float height, float alpha, float rotation){ + _rect = new Rect(x,y,width,height); + this.alpha = alpha; + this.rotation = rotation; + this.rotateEnabled = this.alphaEnabled = false; + if(rotation!=0.0f){ + this.rotateEnabled = true; + resetForRotation(); + } + } + + public bool hasInitiliazed{ + get{ + return _id!=-1; + } + } + + public int id{ + get{ + int toId = _id | counter << 16; + + /*uint backId = toId & 0xFFFF; + uint backCounter = toId >> 16; + if(_id!=backId || backCounter!=counter){ + Debug.LogError("BAD CONVERSION toId:"+_id); + }*/ + + return toId; + } + } + + public void setId( int id, int counter){ + this._id = id; + this.counter = counter; + } + + public void reset(){ + this.alpha = 1.0f; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + this.margin = Vector2.zero; + this.sizeByHeight = false; + this.useColor = false; + } + + public void resetForRotation(){ + Vector3 scale = new Vector3(GUI.matrix[0,0], GUI.matrix[1,1], GUI.matrix[2,2]); + if(pivot==Vector2.zero){ + pivot = new Vector2((_rect.x+((_rect.width)*0.5f )) * scale.x + GUI.matrix[0,3], (_rect.y+((_rect.height)*0.5f )) * scale.y + GUI.matrix[1,3]); + } + } + + public float x{ + get{ return _rect.x; } + set{ _rect.x = value; } + } + + public float y{ + get{ return _rect.y; } + set{ _rect.y = value; } + } + + public float width{ + get{ return _rect.width; } + set{ _rect.width = value; } + } + + public float height{ + get{ return _rect.height; } + set{ _rect.height = value; } + } + + public Rect rect{ + + get{ + if(colorTouched){ + colorTouched = false; + GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,1.0f); + } + if(rotateEnabled){ + if(rotateFinished){ + rotateFinished = false; + rotateEnabled = false; + //this.rotation = 0.0f; + pivot = Vector2.zero; + }else{ + GUIUtility.RotateAroundPivot(rotation, pivot); + } + } + if(alphaEnabled){ + GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,alpha); + colorTouched = true; + } + if(fontScaleToFit){ + if(this.useSimpleScale){ + style.fontSize = (int)(_rect.height*this.relativeRect.height); + }else{ + style.fontSize = (int)_rect.height; + } + } + return _rect; + } + + set{ + _rect = value; + } + } + + public LTRect setStyle( GUIStyle style ){ + this.style = style; + return this; + } + + public LTRect setFontScaleToFit( bool fontScaleToFit ){ + this.fontScaleToFit = fontScaleToFit; + return this; + } + + public LTRect setColor( Color color ){ + this.color = color; + this.useColor = true; + return this; + } + + public LTRect setAlpha( float alpha ){ + this.alpha = alpha; + return this; + } + + public LTRect setLabel( String str ){ + this.labelStr = str; + return this; + } + + public LTRect setUseSimpleScale( bool useSimpleScale, Rect relativeRect){ + this.useSimpleScale = useSimpleScale; + this.relativeRect = relativeRect; + return this; + } + + public LTRect setUseSimpleScale( bool useSimpleScale){ + this.useSimpleScale = useSimpleScale; + this.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); + return this; + } + + public LTRect setSizeByHeight( bool sizeByHeight){ + this.sizeByHeight = sizeByHeight; + return this; + } + + public override string ToString(){ + return "x:"+_rect.x+" y:"+_rect.y+" width:"+_rect.width+" height:"+_rect.height; + } +} + +/** +* Object that describes the event to an event listener +* @class LTEvent +* @constructor +* @param {object} data:object Data that has been passed from the dispatchEvent method +*/ +public class LTEvent { + public int id; + public object data; + + public LTEvent(int id, object data){ + this.id = id; + this.data = data; + } +} + +public class LTGUI { + public static int RECT_LEVELS = 5; + public static int RECTS_PER_LEVEL = 10; + public static int BUTTONS_MAX = 24; + + private static LTRect[] levels; + private static int[] levelDepths; + private static Rect[] buttons; + private static int[] buttonLevels; + private static int[] buttonLastFrame; + private static LTRect r; + private static Color color = Color.white; + private static bool isGUIEnabled = false; + private static int global_counter = 0; + + public enum Element_Type{ + Texture, + Label + } + + public static void init(){ + if(levels==null){ + levels = new LTRect[RECT_LEVELS*RECTS_PER_LEVEL]; + levelDepths = new int[RECT_LEVELS]; + } + } + + public static void initRectCheck(){ + if(buttons==null){ + buttons = new Rect[BUTTONS_MAX]; + buttonLevels = new int[BUTTONS_MAX]; + buttonLastFrame = new int[BUTTONS_MAX]; + for(int i = 0; i < buttonLevels.Length; i++){ + buttonLevels[i] = -1; + } + } + } + + public static void reset(){ + if(isGUIEnabled){ + isGUIEnabled = false; + for(int i = 0; i < levels.Length; i++){ + levels[i] = null; + } + + for(int i = 0; i < levelDepths.Length; i++){ + levelDepths[i] = 0; + } + } + } + + public static void update( int updateLevel ){ + if(isGUIEnabled){ + init(); + if(levelDepths[updateLevel]>0){ + color = GUI.color; + int baseI = updateLevel*RECTS_PER_LEVEL; + int maxLoop = baseI + levelDepths[updateLevel];// RECTS_PER_LEVEL;//; + + for(int i = baseI; i < maxLoop; i++){ + r = levels[i]; + // Debug.Log("r:"+r+" i:"+i); + if(r!=null /*&& checkOnScreen(r.rect)*/){ + //Debug.Log("label:"+r.labelStr+" textColor:"+r.style.normal.textColor); + if(r.useColor) + GUI.color = r.color; + if(r.type == Element_Type.Label){ + if(r.style!=null) + GUI.skin.label = r.style; + if(r.useSimpleScale){ + GUI.Label( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, r.rect.width*r.relativeRect.width, r.rect.height*r.relativeRect.height), r.labelStr ); + }else{ + GUI.Label( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, r.rect.width, r.rect.height), r.labelStr ); + } + }else if(r.type == Element_Type.Texture && r.texture!=null){ + Vector2 size = r.useSimpleScale ? new Vector2(0f, r.rect.height*r.relativeRect.height) : new Vector2(r.rect.width, r.rect.height); + if(r.sizeByHeight){ + size.x = (float)r.texture.width/(float)r.texture.height * size.y; + } + if(r.useSimpleScale){ + GUI.DrawTexture( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, size.x, size.y), r.texture ); + }else{ + GUI.DrawTexture( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, size.x, size.y), r.texture ); + } + } + } + } + GUI.color = color; + } + } + } + + public static bool checkOnScreen(Rect rect){ + bool offLeft = rect.x + rect.width < 0f; + bool offRight = rect.x > Screen.width; + bool offBottom = rect.y > Screen.height; + bool offTop = rect.y + rect.height < 0f; + + return !(offLeft || offRight || offBottom || offTop); + } + + public static void destroy( int id ){ + int backId = id & 0xFFFF; + int backCounter = id >> 16; + if(id>=0 && levels[backId]!=null && levels[backId].hasInitiliazed && levels[backId].counter==backCounter) + levels[backId] = null; + } + + public static void destroyAll( int depth ){ // clears all gui elements on depth + int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; + for(int i = depth*RECTS_PER_LEVEL; levels!=null && i < maxLoop; i++){ + levels[i] = null; + } + } + + public static LTRect label( Rect rect, string label, int depth){ + return LTGUI.label(new LTRect(rect), label, depth); + } + + public static LTRect label( LTRect rect, string label, int depth){ + rect.type = Element_Type.Label; + rect.labelStr = label; + return element(rect, depth); + } + + public static LTRect texture( Rect rect, Texture texture, int depth){ + return LTGUI.texture( new LTRect(rect), texture, depth); + } + + public static LTRect texture( LTRect rect, Texture texture, int depth){ + rect.type = Element_Type.Texture; + rect.texture = texture; + return element(rect, depth); + } + + public static LTRect element( LTRect rect, int depth){ + isGUIEnabled = true; + init(); + int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; + int k = 0; + if(rect!=null){ + destroy(rect.id); + } + if(rect.type==LTGUI.Element_Type.Label && rect.style!=null){ + if(rect.style.normal.textColor.a<=0f){ + Debug.LogWarning("Your GUI normal color has an alpha of zero, and will not be rendered."); + } + } + if(rect.relativeRect.width==float.PositiveInfinity){ + rect.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); + } + for(int i = depth*RECTS_PER_LEVEL; i < maxLoop; i++){ + r = levels[i]; + if(r==null){ + r = rect; + r.rotateEnabled = true; + r.alphaEnabled = true; + r.setId( i, global_counter ); + levels[i] = r; + // Debug.Log("k:"+k+ " maxDepth:"+levelDepths[depth]); + if(k>=levelDepths[depth]){ + levelDepths[depth] = k + 1; + } + global_counter++; + return r; + } + k++; + } + + Debug.LogError("You ran out of GUI Element spaces"); + + return null; + } + + public static bool hasNoOverlap( Rect rect, int depth ){ + initRectCheck(); + bool hasNoOverlap = true; + bool wasAddedToList = false; + for(int i = 0; i < buttonLevels.Length; i++){ + // Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]); + //Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); + if(buttonLevels[i]>=0){ + //Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]+" Time.frameCount:"+Time.frameCount); + if( buttonLastFrame[i] + 1 < Time.frameCount ){ // It has to have been visible within the current, or + buttonLevels[i] = -1; + // Debug.Log("resetting i:"+i); + }else{ + //if(buttonLevels[i]>=0) + // Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); + if(buttonLevels[i]>depth){ + /*if(firstTouch().x > 0){ + Debug.Log("buttons["+i+"]:"+buttons[i] + " firstTouch:"); + Debug.Log(firstTouch()); + Debug.Log(buttonLevels[i]); + }*/ + if(pressedWithinRect( buttons[i] )){ + hasNoOverlap = false; // there is an overlapping button that is higher + } + } + } + } + + if(wasAddedToList==false && buttonLevels[i]<0){ + wasAddedToList = true; + buttonLevels[i] = depth; + buttons[i] = rect; + buttonLastFrame[i] = Time.frameCount; + } + } + + return hasNoOverlap; + } + + public static bool pressedWithinRect( Rect rect ){ + Vector2 vec2 = firstTouch(); + if(vec2.x<0f) + return false; + float vecY = Screen.height-vec2.y; + return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vecY > rect.y && vecY < rect.y + rect.height); + } + + public static bool checkWithinRect(Vector2 vec2, Rect rect){ + vec2.y = Screen.height-vec2.y; + return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vec2.y > rect.y && vec2.y < rect.y + rect.height); + } + + public static Vector2 firstTouch(){ + if(Input.touchCount>0){ + return Input.touches[0].position; + }else if(Input.GetMouseButton(0)){ + return Input.mousePosition; + } + + return new Vector2(Mathf.NegativeInfinity,Mathf.NegativeInfinity); + } + +} + +namespace DentedPixel { public class LeanDummy {} } +//} diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs.meta new file mode 100644 index 0000000..bf90165 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c2f4b27196f84954b44753aaac214bb +timeCreated: 1463137984 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip new file mode 100644 index 0000000..029cde1 Binary files /dev/null and b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip differ diff --git a/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip.meta b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip.meta new file mode 100644 index 0000000..345e828 --- /dev/null +++ b/IronToad_UnityProject/Assets/Plugins/LeanTween/LeanTween.dll.zip.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ffeadda6aaa064923a3f7e28ff26afb1 +timeCreated: 1477948563 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Scripts/NotificationServer.cs b/IronToad_UnityProject/Assets/Scripts/NotificationServer.cs new file mode 100644 index 0000000..e12866f --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/NotificationServer.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NotificationServer : MonoBehaviour +{ + static Dictionary> notifications = new Dictionary>(); + static Dictionary>> notificationsWithArgument = new Dictionary>>(); + + static public void register(string key, Action action) + { + if (!notifications.ContainsKey(key)) + notifications[key] = new List(); + if (!notifications[key].Contains(action)) + notifications[key].Add(action); + } + + static public void unregister(string key, Action action) + { + if (!notifications.ContainsKey(key)) + return; + if (!notifications[key].Contains(action)) + return; + notifications[key].Remove(action); + } + + static public void notify(string key) + { + if (!notifications.ContainsKey(key)) + return; + for (int i=0; i action) + { + if (!notificationsWithArgument.ContainsKey(key)) + notificationsWithArgument[key] = new List>(); + if (!notificationsWithArgument[key].Contains(action)) + notificationsWithArgument[key].Add(action); + } + + static public void unregister(string key, Action action) + { + if (!notificationsWithArgument.ContainsKey(key)) + return; + if (!notificationsWithArgument[key].Contains(action)) + return; + notificationsWithArgument[key].Remove(action); + } + + static public void notify(string key, object argument) + { + if (!notificationsWithArgument.ContainsKey(key)) + return; + for (int i=0; i(); + canvasGroup = GetComponent(); + if (canvasGroup == null) + canvasGroup = gameObject.AddComponent(); + + if (overrideNotifyName == null || overrideNotifyName == "") + { + NotificationServer.register("show " + gameObject.name, showPanel); + NotificationServer.register("hide " + gameObject.name, hidePanel); + } + else + { + NotificationServer.register("show " + overrideNotifyName, showPanel); + NotificationServer.register("hide " + overrideNotifyName, hidePanel); + } + } + + void Start() + { + originalPos = rectTransform.anchoredPosition3D; + + if (showOnAwake) + setShowState(); + else + setHideState(); + } + + public void showPanel() + { + float startAlpha = 0f; + float endAlpha = 1f; + Vector3 startPos = originalPos; + Vector3 endPos = originalPos; + Vector3 startScale = Vector3.one; + Vector3 endScale = Vector3.one; + + if (showAnimType == UIAnimType.ZoomIn) + startScale /= zoomAmount; + else if (showAnimType == UIAnimType.ZoomOut) + startScale *= zoomAmount; + else if (showAnimType == UIAnimType.SlideRight) + startPos += Vector3.left * slideAmount; + else if (showAnimType == UIAnimType.SlideLeft) + startPos += Vector3.right * slideAmount; + else if (showAnimType == UIAnimType.SlideUp) + startPos += Vector3.down * slideAmount; + else if (showAnimType == UIAnimType.SlideDown) + startPos += Vector3.up * slideAmount; + + LeanTween.cancel(gameObject, true); + canvasGroup.interactable = false; + canvasGroup.blocksRaycasts = true; + canvasGroup.alpha = startAlpha; + rectTransform.anchoredPosition3D = startPos; + transform.localScale = startScale; + LeanTween.value(gameObject, 0f, 1f, time).setOnUpdate((float val)=>{ + canvasGroup.alpha = startAlpha + (endAlpha-startAlpha)*fadeCurve.Evaluate(val); + rectTransform.anchoredPosition3D = startPos + (endPos-startPos)*showCurve.Evaluate(val); + transform.localScale = startScale + (endScale-startScale)*showCurve.Evaluate(val); + }).setOnComplete(setShowState); + } + + public void hidePanel() + { + float startAlpha = 1f; + float endAlpha = 0f; + Vector3 startPos = originalPos; + Vector3 endPos = originalPos; + Vector3 startScale = Vector3.one; + Vector3 endScale = Vector3.one; + + if (hideAnimType == UIAnimType.ZoomIn) + endScale *= zoomAmount; + else if (hideAnimType == UIAnimType.ZoomOut) + endScale /= zoomAmount; + else if (hideAnimType == UIAnimType.SlideRight) + endPos += Vector3.right * slideAmount; + else if (hideAnimType == UIAnimType.SlideLeft) + endPos += Vector3.left * slideAmount; + else if (hideAnimType == UIAnimType.SlideUp) + endPos += Vector3.up * slideAmount; + else if (hideAnimType == UIAnimType.SlideDown) + endPos += Vector3.down * slideAmount; + + LeanTween.cancel(gameObject, true); + canvasGroup.interactable = false; + canvasGroup.blocksRaycasts = true; + canvasGroup.alpha = startAlpha; + rectTransform.anchoredPosition3D = startPos; + transform.localScale = startScale; + LeanTween.value(gameObject, 0f, 1f, time).setOnUpdate((float val)=>{ + canvasGroup.alpha = startAlpha + (endAlpha-startAlpha)*fadeCurve.Evaluate(val); + rectTransform.anchoredPosition3D = startPos + (endPos-startPos)*hideCurve.Evaluate(val); + transform.localScale = startScale + (endScale-startScale)*hideCurve.Evaluate(val); + }).setOnComplete(setHideState); + } + + public void setShowState() + { + canvasGroup.interactable = true; + canvasGroup.blocksRaycasts = true; + canvasGroup.alpha = 1f; + rectTransform.anchoredPosition3D = originalPos; + transform.localScale = Vector3.one; + } + + public void setHideState() + { + canvasGroup.interactable = false; + canvasGroup.blocksRaycasts = false; + canvasGroup.alpha = 0f; + } + + public void quitApplication() + { + Application.Quit(); + } + + public void startGame() + { + NotificationServer.notify("show GameUI"); + } +} diff --git a/IronToad_UnityProject/Assets/Scripts/UIPanel.cs.meta b/IronToad_UnityProject/Assets/Scripts/UIPanel.cs.meta new file mode 100644 index 0000000..6d7d565 --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/UIPanel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8aa49c1af99fd4b5089b614c16f08e8c +timeCreated: 1484954504 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/ThirdParty.txt b/IronToad_UnityProject/Assets/ThirdParty.txt new file mode 100644 index 0000000..095fee3 --- /dev/null +++ b/IronToad_UnityProject/Assets/ThirdParty.txt @@ -0,0 +1,2 @@ +BG Curve (1.2.2) by BansheeGz +LeanTween (2.43) by Dented Pixel diff --git a/IronToad_UnityProject/Assets/ThirdParty.txt.meta b/IronToad_UnityProject/Assets/ThirdParty.txt.meta new file mode 100644 index 0000000..f44789b --- /dev/null +++ b/IronToad_UnityProject/Assets/ThirdParty.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e5032c485b6414633a91c55c611f9d6a +timeCreated: 1484953148 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/UIArt.meta b/IronToad_UnityProject/Assets/UIArt.meta new file mode 100644 index 0000000..1107c81 --- /dev/null +++ b/IronToad_UnityProject/Assets/UIArt.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b74f3535a3a9243688681f369868c5b8 +folderAsset: yes +timeCreated: 1484960160 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png b/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png new file mode 100644 index 0000000..44ca0bc Binary files /dev/null and b/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png differ diff --git a/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png.meta b/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png.meta new file mode 100644 index 0000000..444c0f0 --- /dev/null +++ b/IronToad_UnityProject/Assets/UIArt/Icon_4-512.png.meta @@ -0,0 +1,124 @@ +fileFormatVersion: 2 +guid: 1cecc76fb3f1c48238c24811bb2c21e9 +timeCreated: 1484960141 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: iPhone + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: tvOS + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Tizen + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Samsung TV + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 1 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: ui + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity b/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity new file mode 100644 index 0000000..f3c5d53 Binary files /dev/null and b/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity differ diff --git a/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity.meta b/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity.meta new file mode 100644 index 0000000..c9a68a0 --- /dev/null +++ b/IronToad_UnityProject/Assets/_Scenes/UITestScene.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 02b5452cf323349359d4548b3e31c235 +timeCreated: 1484917387 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: