mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-02-04 14:24:55 +08:00
Modules working (upgrade features to complete)
This commit is contained in:
parent
833e1ecddb
commit
3da538a1a0
4
.gitignore
vendored
4
.gitignore
vendored
@ -34,6 +34,10 @@ zz UnityTests*
|
||||
zzTestBuilds
|
||||
*.tmp
|
||||
*.pdb
|
||||
*.DotSettings
|
||||
|
||||
UnityTests.Unity5BETA
|
||||
UnityTests.Unity5 - LastVersionBeforeModules
|
||||
ModulesTest.Unity2018
|
||||
biz
|
||||
zzTemp
|
||||
@ -17,10 +17,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DOTween46", "DOTween46\DOTw
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DOTween50", "DOTween50\DOTween50.csproj", "{930C3B07-B00A-44B8-A8E5-452A8FD125C7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DOTween_LooseScripts", "DOTween_LooseScripts\DOTween_LooseScripts.csproj", "{0B529A90-0B97-4840-BEB6-4A6700B46655}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55} = {DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legacy_NoModules", "Legacy_NoModules", "{3945F2EC-EA44-45DF-82B5-33E978AE8345}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CompatibilityMode|Any CPU = CompatibilityMode|Any CPU
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release_IncludeRigidbody|Any CPU = Release_IncludeRigidbody|Any CPU
|
||||
Release_NoRigidbody|Any CPU = Release_NoRigidbody|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
@ -29,6 +37,8 @@ Global
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Release_IncludeRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{DE17C145-3E8D-45D6-BBB6-D06BD7D80A55}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -37,6 +47,8 @@ Global
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Release_IncludeRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{421ACC19-8922-4E98-8921-B52240CE172A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -45,44 +57,49 @@ Global
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release_IncludeRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{20D2E542-D14F-4678-9C38-F3C0ECF6A2F6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.CompatibilityMode|Any CPU.ActiveCfg = CompatibilityMode|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.CompatibilityMode|Any CPU.ActiveCfg = CompatibilityMode|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release_IncludeRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{279545AE-D268-42F0-A4C6-AA5BA15FB9BE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.CompatibilityMode|Any CPU.ActiveCfg = CompatibilityMode|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.CompatibilityMode|Any CPU.ActiveCfg = CompatibilityMode|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.CompatibilityMode|Any CPU.Build.0 = CompatibilityMode|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Release_NoRigidbody|Any CPU.ActiveCfg = Release_IncludeRigidbody|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Release_NoRigidbody|Any CPU.Build.0 = Release_IncludeRigidbody|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0B529A90-0B97-4840-BEB6-4A6700B46655}.CompatibilityMode|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B529A90-0B97-4840-BEB6-4A6700B46655}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0B529A90-0B97-4840-BEB6-4A6700B46655}.Release_IncludeRigidbody|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B529A90-0B97-4840-BEB6-4A6700B46655}.Release_NoRigidbody|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B529A90-0B97-4840-BEB6-4A6700B46655}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{978C0952-38D0-4C22-B96C-823EAFEDF0FA} = {3945F2EC-EA44-45DF-82B5-33E978AE8345}
|
||||
{AC1E5A23-CE58-419C-B165-EB1CD39AB433} = {3945F2EC-EA44-45DF-82B5-33E978AE8345}
|
||||
{930C3B07-B00A-44B8-A8E5-452A8FD125C7} = {3945F2EC-EA44-45DF-82B5-33E978AE8345}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CY/@EntryIndexedValue">CY</s:String></wpf:ResourceDictionary>
|
||||
@ -4,7 +4,9 @@
|
||||
// License Copyright (c) Daniele Giardini.
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 1591
|
||||
@ -31,6 +33,11 @@ namespace DG.Tweening.Core
|
||||
{
|
||||
inspectorUpdater = 0;
|
||||
_unscaledTime = Time.realtimeSinceStartup;
|
||||
|
||||
// Initialize DOTweenModuleUtils via Reflection
|
||||
// TODO DOTweenModuleUtils.Init > verify that this works
|
||||
MethodInfo mi = Type.GetType("DG.Tweening.DOTweenModuleUtils").GetMethod("Init", BindingFlags.Static | BindingFlags.Public);
|
||||
mi.Invoke(null, null);
|
||||
}
|
||||
|
||||
void Start()
|
||||
|
||||
22
_DOTween.Assembly/DOTween/Core/DOTweenExternalCommand.cs
Normal file
22
_DOTween.Assembly/DOTween/Core/DOTweenExternalCommand.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13 19:21
|
||||
// License Copyright (c) Daniele Giardini
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
using System;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to dispatch commands that need to be captured externally, usually by Modules
|
||||
/// </summary>
|
||||
public static class DOTweenExternalCommand
|
||||
{
|
||||
public static event Action<PathOptions,Tween,Quaternion,Transform> SetOrientationOnPath;
|
||||
internal static void Dispatch_SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
||||
{ if (SetOrientationOnPath != null) SetOrientationOnPath(options, t, newRot, trans); }
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,10 @@
|
||||
// License Copyright (c) Daniele Giardini.
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening.Core.Enums
|
||||
{
|
||||
internal enum SpecialStartupMode
|
||||
public enum SpecialStartupMode
|
||||
{
|
||||
None,
|
||||
SetLookAt,
|
||||
|
||||
@ -14,27 +14,33 @@ namespace DG.Tweening.Core
|
||||
/// </summary>
|
||||
public static class Extensions
|
||||
{
|
||||
// Used internally by DO shortcuts to set special startup mode
|
||||
internal static T SetSpecialStartupMode<T>(this T t, SpecialStartupMode mode) where T : Tween
|
||||
/// <summary>
|
||||
/// INTERNAL: used by DO shortcuts and Modules to set special startup mode
|
||||
/// </summary>
|
||||
public static T SetSpecialStartupMode<T>(this T t, SpecialStartupMode mode) where T : Tween
|
||||
{
|
||||
t.specialStartupMode = mode;
|
||||
return t;
|
||||
}
|
||||
|
||||
// Prevents a tween to use a From setup even if passed
|
||||
internal static TweenerCore<T1, T2, TPlugOptions> NoFrom<T1, T2, TPlugOptions>(this TweenerCore<T1, T2, TPlugOptions> t)
|
||||
where TPlugOptions : struct, IPlugOptions
|
||||
{
|
||||
t.isFromAllowed = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
// Sets the tween as blendable
|
||||
internal static TweenerCore<T1, T2, TPlugOptions> Blendable<T1, T2, TPlugOptions>(this TweenerCore<T1, T2, TPlugOptions> t)
|
||||
/// <summary>
|
||||
/// INTERNAL: used by DO shortcuts and Modules to set the tween as blendable
|
||||
/// </summary>
|
||||
public static TweenerCore<T1, T2, TPlugOptions> Blendable<T1, T2, TPlugOptions>(this TweenerCore<T1, T2, TPlugOptions> t)
|
||||
where TPlugOptions : struct, IPlugOptions
|
||||
{
|
||||
t.isBlendable = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// INTERNAL: used by DO shortcuts and Modules to prevent a tween from using a From setup even if passed
|
||||
/// </summary>
|
||||
public static TweenerCore<T1, T2, TPlugOptions> NoFrom<T1, T2, TPlugOptions>(this TweenerCore<T1, T2, TPlugOptions> t)
|
||||
where TPlugOptions : struct, IPlugOptions
|
||||
{
|
||||
t.isFromAllowed = false;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.1.755";
|
||||
public static readonly string Version = "1.2.000"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>C:\Program Files (x86)\Unity 3\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||
<HintPath>C:\Program Files (x86)\Unity 46\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -87,6 +87,7 @@
|
||||
<Compile Include="Core\Enums\UpdateNotice.cs" />
|
||||
<Compile Include="Core\Enums\UpdateMode.cs" />
|
||||
<Compile Include="Core\Extensions.cs" />
|
||||
<Compile Include="Core\DOTweenExternalCommand.cs" />
|
||||
<Compile Include="Core\SequenceCallback.cs" />
|
||||
<Compile Include="Core\Surrogates\ColorWrapper.cs" />
|
||||
<Compile Include="Core\Surrogates\QuaternionWrapper.cs" />
|
||||
@ -166,47 +167,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set BinDir=bin.Global\DOTween
|
||||
set DestinationDir=$(SolutionDir)..\..\%25BinDir%25
|
||||
set BinDirNoMeta=bin.Global_no_meta\DOTween
|
||||
set DestinationDirNoMeta=$(SolutionDir)..\..\%25BinDirNoMeta%25
|
||||
set BinDirUnityTests=UnityTests.Unity4\Assets\Demigiant\DOTween
|
||||
set DestinationDirUnityTests=$(SolutionDir)..\%25BinDirUnityTests%25
|
||||
set BinDirUnity5Tests=UnityTests.Unity5\Assets\Demigiant\DOTween
|
||||
set DestinationDirUnity5Tests=$(SolutionDir)..\%25BinDirUnity5Tests%25
|
||||
set BinDirCompatibilityTests=UnityCompatibilityTests.Unity35\Assets\Demigiant\DOTween
|
||||
set DestinationDirCompatibilityTests=$(SolutionDir)..\%25BinDirCompatibilityTests%25
|
||||
set BinDirExtPluginsTests=ExternalPluginsTestsAndExamples.Unity5\Assets\Demigiant\DOTween
|
||||
set DestinationDirExtPluginsTests=$(SolutionDir)..\%25BinDirExtPluginsTests%25
|
||||
|
||||
echo %25DestinationDir%25
|
||||
|
||||
echo Deleting TMPs...
|
||||
DEL $(TargetDir)\*.tmp
|
||||
|
||||
CD $(TargetDir)
|
||||
echo Converting PDB to MDB and deleting PDB...
|
||||
"c:\Program Files\pdb2mdb\pdb2mdb.exe" $(TargetFileName)
|
||||
DEL $(TargetName).pdb
|
||||
|
||||
echo Exporting Assembly to %25DestinationDir%25
|
||||
echo Copying files to Destination...
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDir%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirNoMeta%25
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDirNoMeta%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirUnityTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDirUnityTests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirUnity5Tests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDirUnity5Tests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirCompatibilityTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDirCompatibilityTests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirExtPluginsTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin" %25DestinationDirExtPluginsTests%25 /Y /I /E</PostBuildEvent>
|
||||
<PostBuildEvent>call $(SolutionDir)PostBuild_DOTween.bat $(SolutionDir) $(TargetDir) $(TargetFileName) $(TargetName) DOTween bin</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@ -11,9 +11,9 @@ namespace DG.Tweening.Plugins.Options
|
||||
{
|
||||
public struct QuaternionOptions : IPlugOptions
|
||||
{
|
||||
internal RotateMode rotateMode;
|
||||
internal AxisConstraint axisConstraint; // Used by SpecialStartupMode SetLookAt
|
||||
internal Vector3 up; // Used by SpecialStartupMode SetLookAt
|
||||
public RotateMode rotateMode; // Accessed by shortcuts and Modules
|
||||
public AxisConstraint axisConstraint; // Used by SpecialStartupMode SetLookAt, accessed by shortcuts and Modules
|
||||
public Vector3 up; // Used by SpecialStartupMode SetLookAt, accessed by shortcuts and Modules
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
@ -217,12 +217,13 @@ namespace DG.Tweening.Plugins
|
||||
}
|
||||
|
||||
if (options.hasCustomForwardDirection) newRot *= options.forward;
|
||||
#if RIGIDBODY
|
||||
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
||||
else trans.rotation = newRot;
|
||||
#else
|
||||
trans.rotation = newRot;
|
||||
#endif
|
||||
DOTweenExternalCommand.Dispatch_SetOrientationOnPath(options, t, newRot, trans);
|
||||
//#if RIGIDBODY
|
||||
// if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
||||
// else trans.rotation = newRot;
|
||||
//#else
|
||||
// trans.rotation = newRot;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -31,28 +31,6 @@ namespace DG.Tweening
|
||||
// ===================================================================================
|
||||
// CREATION SHORTCUTS ----------------------------------------------------------------
|
||||
|
||||
#region Audio Shortcuts
|
||||
|
||||
/// <summary>Tweens an AudioSource's volume to the given value.
|
||||
/// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this AudioSource target, float endValue, float duration)
|
||||
{
|
||||
if (endValue < 0) endValue = 0;
|
||||
else if (endValue > 1) endValue = 1;
|
||||
return DOTween.To(() => target.volume, x => target.volume = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an AudioSource's pitch to the given value.
|
||||
/// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOPitch(this AudioSource target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Camera Shortcuts
|
||||
|
||||
/// <summary>Tweens a Camera's <code>aspect</code> to the given value.
|
||||
@ -355,233 +333,6 @@ namespace DG.Tweening
|
||||
|
||||
#endregion
|
||||
|
||||
#if RIGIDBODY
|
||||
#region Rigidbody Shortcuts
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
return DOTween.To(() => target.position, x=> target.MovePosition(x.value), endValue, duration)
|
||||
#else
|
||||
return DOTween.To(() => target.position, target.MovePosition, endValue, duration)
|
||||
#endif
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's X position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
return DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue, 0, 0), duration)
|
||||
#else
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's Y position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
return DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, endValue, 0), duration)
|
||||
#else
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's Z position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
return DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, 0, endValue), duration)
|
||||
#else
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's rotation to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="mode">Rotation mode</param>
|
||||
public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
TweenerCore<DOQuaternion, DOVector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.MoveRotation(x), endValue, duration);
|
||||
#else
|
||||
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration);
|
||||
#endif
|
||||
t.SetTarget(target);
|
||||
t.plugOptions.rotateMode = mode;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's rotation so that it will look towards the given position.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="towards">The position to look at</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
/// <param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
|
||||
{
|
||||
#if COMPATIBLE
|
||||
TweenerCore<DOQuaternion, DOVector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.MoveRotation(x), towards, duration)
|
||||
#else
|
||||
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration)
|
||||
#endif
|
||||
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);
|
||||
t.plugOptions.axisConstraint = axisConstraint;
|
||||
t.plugOptions.up = (up == null) ? Vector3.up : (Vector3)up;
|
||||
return t;
|
||||
}
|
||||
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Rigidbody target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
float startPosY = 0;
|
||||
float offsetY = -1;
|
||||
bool offsetYSet = false;
|
||||
Sequence s = DOTween.Sequence();
|
||||
#if COMPATIBLE
|
||||
Tween yTween = DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(()=> startPosY = target.position.y);
|
||||
s.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration)
|
||||
#else
|
||||
Tween yTween = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(() => startPosY = target.position.y);
|
||||
s.Append(DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue.x, 0, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
#if COMPATIBLE
|
||||
).Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, 0, endValue.z), duration)
|
||||
#else
|
||||
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue.z), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
|
||||
).Join(yTween)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
yTween.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector3 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position through the given path waypoints, using the chosen path algorithm.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations.
|
||||
/// <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
|
||||
/// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
|
||||
/// If you plan to publish there you should use a regular transform.DOPath.</para></summary>
|
||||
/// <param name="path">The waypoints to go through</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
/// <param name="resolution">The resolution of the path (useless in case of Linear paths): higher resolutions make for more detailed curved paths but are more expensive.
|
||||
/// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
|
||||
/// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
|
||||
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
|
||||
)
|
||||
{
|
||||
if (resolution < 1) resolution = 1;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, new Path(pathType, path, resolution, gizmoColor), duration)
|
||||
.SetTarget(target).SetUpdate(UpdateType.Fixed);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
return t;
|
||||
}
|
||||
/// <summary>Tweens a Rigidbody's localPosition through the given path waypoints, using the chosen path algorithm.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations
|
||||
/// <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
|
||||
/// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
|
||||
/// If you plan to publish there you should use a regular transform.DOLocalPath.</para></summary>
|
||||
/// <param name="path">The waypoint to go through</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
/// <param name="resolution">The resolution of the path: higher resolutions make for more detailed curved paths but are more expensive.
|
||||
/// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
|
||||
/// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
|
||||
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
|
||||
)
|
||||
{
|
||||
if (resolution < 1) resolution = 1;
|
||||
Transform trans = target.transform;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => trans.localPosition, x => target.MovePosition(trans.parent == null ? x : trans.parent.TransformPoint(x)), new Path(pathType, path, resolution, gizmoColor), duration)
|
||||
.SetTarget(target).SetUpdate(UpdateType.Fixed);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
t.plugOptions.useLocalPosition = true;
|
||||
return t;
|
||||
}
|
||||
// Used by path editor when creating the actual tween, so it can pass a pre-compiled path
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, path, duration)
|
||||
.SetTarget(target);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
return t;
|
||||
}
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
Transform trans = target.transform;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => trans.localPosition, x => target.MovePosition(trans.parent == null ? x : trans.parent.TransformPoint(x)), path, duration)
|
||||
.SetTarget(target);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
t.plugOptions.useLocalPosition = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region TrailRenderer Shortcuts
|
||||
|
||||
/// <summary>Tweens a TrailRenderer's startWidth/endWidth to the given value.
|
||||
@ -1102,7 +853,13 @@ namespace DG.Tweening
|
||||
return t;
|
||||
}
|
||||
// Used by path editor when creating the actual tween, so it can pass a pre-compiled path
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
/// <summary>IMPORTANT: Unless you really know what you're doing, you should use the overload that accepts a Vector3 array instead.<para/>
|
||||
/// Tweens a Transform's position via the given path.
|
||||
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="path">The path to use</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
this Transform target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
@ -1112,7 +869,14 @@ namespace DG.Tweening
|
||||
t.plugOptions.mode = pathMode;
|
||||
return t;
|
||||
}
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
// Used by path editor when creating the actual tween, so it can pass a pre-compiled path
|
||||
/// <summary>IMPORTANT: Unless you really know what you're doing, you should use the overload that accepts a Vector3 array instead.<para/>
|
||||
/// Tweens a Transform's localPosition via the given path.
|
||||
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="path">The path to use</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
this Transform target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
|
||||
@ -69,7 +69,8 @@ namespace DG.Tweening
|
||||
internal LoopType loopType;
|
||||
// Tweeners-only (shared by Sequences only for compatibility reasons, otherwise not used)
|
||||
internal float delay;
|
||||
internal bool isRelative;
|
||||
/// <summary>Tweeners-only (ignored by Sequences), returns TRUE if the tween was set as relative</summary>
|
||||
public bool isRelative { get; internal set; } // Required by Modules
|
||||
internal Ease easeType;
|
||||
internal EaseFunction customEase; // Used both for AnimationCurve and custom eases
|
||||
#pragma warning disable 1591
|
||||
@ -82,7 +83,8 @@ namespace DG.Tweening
|
||||
internal Type typeofT1; // Only used by Tweeners
|
||||
internal Type typeofT2; // Only used by Tweeners
|
||||
internal Type typeofTPlugOptions; // Only used by Tweeners
|
||||
internal bool active; // FALSE when tween is (or should be) despawned - set only by TweenManager
|
||||
/// <summary>FALSE when tween is (or should be) despawned - set only by TweenManager</summary>
|
||||
public bool active { get; internal set; } // Required by Modules
|
||||
internal bool isSequenced; // Set by Sequence when adding a Tween to it
|
||||
internal Sequence sequenceParent; // Set by Sequence when adding a Tween to it
|
||||
internal int activeId = -1; // Index inside its active list (touched only by TweenManager)
|
||||
@ -95,8 +97,10 @@ namespace DG.Tweening
|
||||
|
||||
internal bool creationLocked; // TRUE after the tween was updated the first time (even if it was delayed), or when added to a Sequence
|
||||
internal bool startupDone; // TRUE the first time the actual tween starts, AFTER any delay has elapsed (unless it's a FROM tween)
|
||||
internal bool playedOnce; // TRUE after the tween was set in a play state at least once, AFTER any delay is elapsed
|
||||
internal float position; // Time position within a single loop cycle
|
||||
/// <summary>TRUE after the tween was set in a play state at least once, AFTER any delay is elapsed</summary>
|
||||
public bool playedOnce { get; private set; } // Required by Modules
|
||||
/// <summary>Time position within a single loop cycle</summary>
|
||||
public float position { get; internal set; } // Required by Modules
|
||||
internal float fullDuration; // Total duration loops included
|
||||
internal int completedLoops;
|
||||
internal bool isPlaying; // Set by TweenManager when getting a new tween
|
||||
|
||||
@ -20,9 +20,9 @@ namespace DG.Tweening
|
||||
/// </summary>
|
||||
public static class ShortcutExtensions46
|
||||
{
|
||||
#region Unity UI
|
||||
#region Unity UI
|
||||
|
||||
#region CanvasGroup
|
||||
#region CanvasGroup
|
||||
|
||||
/// <summary>Tweens a CanvasGroup's alpha color to the given value.
|
||||
/// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -33,9 +33,9 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Graphic
|
||||
#region Graphic
|
||||
|
||||
/// <summary>Tweens an Graphic's color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -54,9 +54,9 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
#region Image
|
||||
|
||||
/// <summary>Tweens an Image's color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -109,9 +109,9 @@ namespace DG.Tweening
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region LayoutElement
|
||||
#region LayoutElement
|
||||
|
||||
/// <summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
/// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -167,9 +167,9 @@ namespace DG.Tweening
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Outline
|
||||
#region Outline
|
||||
|
||||
/// <summary>Tweens a Outline's effectColor to the given value.
|
||||
/// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -197,9 +197,9 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region RectTransform
|
||||
#region RectTransform
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -366,7 +366,7 @@ namespace DG.Tweening
|
||||
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
|
||||
}
|
||||
|
||||
#region Special
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
@ -428,11 +428,11 @@ namespace DG.Tweening
|
||||
// return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region ScrollRect
|
||||
#region ScrollRect
|
||||
|
||||
/// <summary>Tweens a ScrollRect's horizontal/verticalNormalizedPosition to the given value.
|
||||
/// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -474,9 +474,9 @@ namespace DG.Tweening
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Slider
|
||||
#region Slider
|
||||
|
||||
/// <summary>Tweens a Slider's value to the given value.
|
||||
/// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -488,9 +488,9 @@ namespace DG.Tweening
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
#region Text
|
||||
|
||||
/// <summary>Tweens a Text's color to the given value.
|
||||
/// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -525,13 +525,13 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Blendables
|
||||
#region Blendables
|
||||
|
||||
#region Graphic
|
||||
#region Graphic
|
||||
|
||||
/// <summary>Tweens a Graphic's color to the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
@ -554,9 +554,9 @@ namespace DG.Tweening
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
#region Image
|
||||
|
||||
/// <summary>Tweens a Image's color to the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
@ -579,9 +579,9 @@ namespace DG.Tweening
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
#region Text
|
||||
|
||||
/// <summary>Tweens a Text's color BY the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
@ -604,8 +604,8 @@ namespace DG.Tweening
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using DG.Tweening;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@ -29,6 +30,7 @@ namespace DG.DOTweenEditor.Core
|
||||
public static string pathSlash { get; private set; } // for full paths
|
||||
public static string pathSlashToReplace { get; private set; } // for full paths
|
||||
|
||||
static readonly StringBuilder _Strb = new StringBuilder();
|
||||
static bool _hasPro;
|
||||
static string _proVersion;
|
||||
static bool _hasCheckedForPro;
|
||||
@ -87,6 +89,37 @@ namespace DG.DOTweenEditor.Core
|
||||
return Directory.GetFiles(dotweenDir, "*.addon").Length > 0 || hasPro && Directory.GetFiles(dotweenProDir, "*.addon").Length > 0;
|
||||
}
|
||||
|
||||
// Deletes the files used in older versions of DOTween where Modules still didn't exist
|
||||
public static void DeleteLegacyNoModulesDOTweenFiles()
|
||||
{
|
||||
string adbDOTweenDir = FullPathToADBPath(dotweenDir);
|
||||
AssetDatabase.StartAssetEditing();
|
||||
DeleteAssetsIfExist(new[] {
|
||||
adbDOTweenDir + "/DOTween43.dll",
|
||||
adbDOTweenDir + "/DOTween43.xml",
|
||||
adbDOTweenDir + "/DOTween43.dll.mdb",
|
||||
adbDOTweenDir + "/DOTween43.dll.addon",
|
||||
adbDOTweenDir + "/DOTween43.xml.addon",
|
||||
adbDOTweenDir + "/DOTween43.dll.mdb.addon",
|
||||
adbDOTweenDir + "/DOTween46.dll",
|
||||
adbDOTweenDir + "/DOTween46.xml",
|
||||
adbDOTweenDir + "/DOTween46.dll.mdb",
|
||||
adbDOTweenDir + "/DOTween46.dll.addon",
|
||||
adbDOTweenDir + "/DOTween46.xml.addon",
|
||||
adbDOTweenDir + "/DOTween46.dll.mdb.addon",
|
||||
adbDOTweenDir + "/DOTween50.dll",
|
||||
adbDOTweenDir + "/DOTween50.xml",
|
||||
adbDOTweenDir + "/DOTween50.dll.mdb",
|
||||
adbDOTweenDir + "/DOTween50.dll.addon",
|
||||
adbDOTweenDir + "/DOTween50.xml.addon",
|
||||
adbDOTweenDir + "/DOTween50.dll.mdb.addon",
|
||||
//
|
||||
adbDOTweenDir + "/DOTweenTextMeshPro.cs.addon",
|
||||
adbDOTweenDir + "/DOTweenTk2d.cs.addon",
|
||||
});
|
||||
AssetDatabase.StopAssetEditing();
|
||||
}
|
||||
|
||||
// Deletes old DemiLib core if new one (inside Core directory) exists
|
||||
public static void DeleteOldDemiLibCore()
|
||||
{
|
||||
@ -117,6 +150,7 @@ namespace DG.DOTweenEditor.Core
|
||||
AssetDatabase.ImportAsset(demiLibNewCoreDir, ImportAssetOptions.ImportRecursive);
|
||||
}
|
||||
}
|
||||
|
||||
static void DeleteAssetsIfExist(string[] adbFilePaths)
|
||||
{
|
||||
foreach (string f in adbFilePaths) {
|
||||
@ -206,6 +240,70 @@ namespace DG.DOTweenEditor.Core
|
||||
return Path.GetFullPath(assembly.Location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given global define if it's not already present
|
||||
/// </summary>
|
||||
public static void AddGlobalDefine(string id)
|
||||
{
|
||||
bool added = false;
|
||||
BuildTargetGroup[] targetGroups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
|
||||
foreach(BuildTargetGroup btg in targetGroups) {
|
||||
if (btg == BuildTargetGroup.Unknown) continue;
|
||||
string defs = PlayerSettings.GetScriptingDefineSymbolsForGroup(btg);
|
||||
string[] singleDefs = defs.Split(';');
|
||||
if (Array.IndexOf(singleDefs, id) != -1) continue; // Already present
|
||||
added = true;
|
||||
defs += defs.Length > 0 ? ";" + id : id;
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(btg, defs);
|
||||
}
|
||||
if (added) Debug.Log("DOTween : added global define " + id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given global define if it's present
|
||||
/// </summary>
|
||||
public static void RemoveGlobalDefine(string id)
|
||||
{
|
||||
bool removed = false;
|
||||
BuildTargetGroup[] targetGroups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
|
||||
foreach(BuildTargetGroup btg in targetGroups) {
|
||||
if (btg == BuildTargetGroup.Unknown) continue;
|
||||
string defs = PlayerSettings.GetScriptingDefineSymbolsForGroup(btg);
|
||||
string[] singleDefs = defs.Split(';');
|
||||
if (Array.IndexOf(singleDefs, id) == -1) continue; // Not present
|
||||
removed = true;
|
||||
_Strb.Length = 0;
|
||||
for (int i = 0; i < singleDefs.Length; ++i) {
|
||||
if (singleDefs[i] == id) continue;
|
||||
if (_Strb.Length > 0) _Strb.Append(';');
|
||||
_Strb.Append(singleDefs[i]);
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(btg, _Strb.ToString());
|
||||
}
|
||||
_Strb.Length = 0;
|
||||
if (removed) Debug.Log("DOTween : removed global define " + id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns TRUE if the given global define is present in all the <see cref="BuildTargetGroup"/>
|
||||
/// or only in the given <see cref="BuildTargetGroup"/>, depending on passed parameters.<para/>
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="buildTargetGroup"><see cref="BuildTargetGroup"/>to use. Leave NULL to check in all of them.</param>
|
||||
public static bool HasGlobalDefine(string id, BuildTargetGroup? buildTargetGroup = null)
|
||||
{
|
||||
BuildTargetGroup[] targetGroups = buildTargetGroup == null
|
||||
? (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup))
|
||||
: new[] {(BuildTargetGroup)buildTargetGroup};
|
||||
foreach(BuildTargetGroup btg in targetGroups) {
|
||||
if (btg == BuildTargetGroup.Unknown) continue;
|
||||
string defs = PlayerSettings.GetScriptingDefineSymbolsForGroup(btg);
|
||||
string[] singleDefs = defs.Split(';');
|
||||
if (Array.IndexOf(singleDefs, id) != -1) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// METHODS ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEditor">
|
||||
<HintPath>C:\Program Files (x86)\Unity 3\Editor\Data\Managed\UnityEditor.dll</HintPath>
|
||||
<HintPath>C:\Program Files (x86)\Unity 46\Editor\Data\Managed\UnityEditor.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>C:\Program Files (x86)\Unity 3\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||
<HintPath>C:\Program Files (x86)\Unity 46\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -77,6 +77,7 @@
|
||||
<Compile Include="Core\EditorGUIUtils.cs" />
|
||||
<Compile Include="Core\EditorUtils.cs" />
|
||||
<Compile Include="DOTweenInspector.cs" />
|
||||
<Compile Include="DOTweenModulesSetupGUI.cs" />
|
||||
<Compile Include="DOTweenSettingsInspector.cs" />
|
||||
<Compile Include="DOTweenSetupMenuItem.cs" />
|
||||
<Compile Include="DOTweenUtilityWindow.cs" />
|
||||
@ -91,47 +92,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set BinDir=bin.Global\DOTween\Editor
|
||||
set DestinationDir=$(SolutionDir)..\..\%25BinDir%25
|
||||
set BinDirNoMeta=bin.Global_no_meta\DOTween\Editor
|
||||
set DestinationDirNoMeta=$(SolutionDir)..\..\%25BinDirNoMeta%25
|
||||
set BinDirUnityTests=UnityTests.Unity4\Assets\Demigiant\DOTween\Editor
|
||||
set DestinationDirUnityTests=$(SolutionDir)..\%25BinDirUnityTests%25
|
||||
set BinDirUnity5Tests=UnityTests.Unity5\Assets\Demigiant\DOTween\Editor
|
||||
set DestinationDirUnity5Tests=$(SolutionDir)..\%25BinDirUnity5Tests%25
|
||||
set BinDirCompatibilityTests=UnityCompatibilityTests.Unity35\Assets\Demigiant\DOTween\Editor
|
||||
set DestinationDirCompatibilityTests=$(SolutionDir)..\%25BinDirCompatibilityTests%25
|
||||
set BinDirExtPluginsTests=ExternalPluginsTestsAndExamples.Unity5\Assets\Demigiant\DOTween\Editor
|
||||
set DestinationDirExtPluginsTests=$(SolutionDir)..\%25BinDirExtPluginsTests%25
|
||||
|
||||
echo %25DestinationDir%25
|
||||
|
||||
echo Deleting TMPs...
|
||||
DEL $(TargetDir)\*.tmp
|
||||
|
||||
CD $(TargetDir)
|
||||
echo Converting PDB to MDB and deleting PDB...
|
||||
"c:\Program Files\pdb2mdb\pdb2mdb.exe" $(TargetFileName)
|
||||
DEL $(TargetName).pdb
|
||||
|
||||
echo Exporting Assembly to %25DestinationDir%25
|
||||
echo Copying files to Destination...
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDir%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirNoMeta%25
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDirNoMeta%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirUnityTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDirUnityTests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirUnity5Tests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDirUnity5Tests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirCompatibilityTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDirCompatibilityTests%25 /Y /I /E
|
||||
|
||||
echo Exporting Assembly to %25DestinationDirExtPluginsTests%25
|
||||
echo f | xcopy "$(SolutionDir)\bin\Editor" %25DestinationDirExtPluginsTests%25 /Y /I /E</PostBuildEvent>
|
||||
<PostBuildEvent>call $(SolutionDir)PostBuild_DOTween.bat $(SolutionDir) $(TargetDir) $(TargetFileName) $(TargetName) DOTween bin Editor</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
94
_DOTween.Assembly/DOTweenEditor/DOTweenModulesSetupGUI.cs
Normal file
94
_DOTween.Assembly/DOTweenEditor/DOTweenModulesSetupGUI.cs
Normal file
@ -0,0 +1,94 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/14 18:56
|
||||
// License Copyright (c) Daniele Giardini
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
using DG.DOTweenEditor.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using EditorUtils = DG.DOTweenEditor.Core.EditorUtils;
|
||||
|
||||
namespace DG.DOTweenEditor
|
||||
{
|
||||
public static class DOTweenModulesSetupGUI
|
||||
{
|
||||
static bool _hasAudioModule;
|
||||
static bool _hasPhysicsModule;
|
||||
static bool _hasPhysics2DModule;
|
||||
static bool _hasSpriteModule;
|
||||
static bool _hasUIModule;
|
||||
|
||||
static bool _hasTextMeshProModule;
|
||||
static bool _hasTk2DModule;
|
||||
|
||||
public static void Refresh()
|
||||
{
|
||||
_hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_AudioModule);
|
||||
_hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_PhysicsModule);
|
||||
_hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_Physics2DModule);
|
||||
_hasSpriteModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_SpriteModule);
|
||||
_hasUIModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_UIModule);
|
||||
|
||||
_hasTextMeshProModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TextMeshPro);
|
||||
_hasTk2DModule = EditorUtils.HasGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TK2D);
|
||||
}
|
||||
|
||||
// Returns TRUE if it should be closed
|
||||
public static bool Draw()
|
||||
{
|
||||
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
|
||||
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
|
||||
_hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule);
|
||||
_hasPhysicsModule = EditorGUILayout.Toggle("Physics", _hasPhysicsModule);
|
||||
_hasPhysics2DModule = EditorGUILayout.Toggle("Physics2D", _hasPhysics2DModule);
|
||||
_hasSpriteModule = EditorGUILayout.Toggle("Sprites", _hasSpriteModule);
|
||||
_hasUIModule = EditorGUILayout.Toggle("UI", _hasUIModule);
|
||||
EditorGUILayout.EndVertical();
|
||||
if (EditorUtils.hasPro) {
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
|
||||
_hasTk2DModule = EditorGUILayout.Toggle("2D Toolkit", _hasTk2DModule);
|
||||
_hasTextMeshProModule = EditorGUILayout.Toggle("TextMesh Pro", _hasTextMeshProModule);
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
GUILayout.Space(2);
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Apply")) Apply();
|
||||
if (GUILayout.Button("Cancel")) return true;
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
"NOTE: if you get \"PlayerSettings Validation\" or [CS0618] errors when you press apply don't worry:" +
|
||||
" it's ok and it allows the setup to work on all possible Unity versions",
|
||||
MessageType.Warning
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Apply()
|
||||
{
|
||||
ModifyDefineIfChanged(_hasAudioModule, DOTweenSetupMenuItem.GlobalDefine_AudioModule);
|
||||
ModifyDefineIfChanged(_hasPhysicsModule, DOTweenSetupMenuItem.GlobalDefine_PhysicsModule);
|
||||
ModifyDefineIfChanged(_hasPhysics2DModule, DOTweenSetupMenuItem.GlobalDefine_Physics2DModule);
|
||||
ModifyDefineIfChanged(_hasSpriteModule, DOTweenSetupMenuItem.GlobalDefine_SpriteModule);
|
||||
ModifyDefineIfChanged(_hasUIModule, DOTweenSetupMenuItem.GlobalDefine_UIModule);
|
||||
|
||||
if (EditorUtils.hasPro) {
|
||||
ModifyDefineIfChanged(_hasTextMeshProModule, DOTweenSetupMenuItem.GlobalDefine_TextMeshPro);
|
||||
ModifyDefineIfChanged(_hasTk2DModule, DOTweenSetupMenuItem.GlobalDefine_TK2D);
|
||||
}
|
||||
}
|
||||
|
||||
static void ModifyDefineIfChanged(bool wantsToBeSet, string defineId)
|
||||
{
|
||||
bool hasDefine = EditorUtils.HasGlobalDefine(defineId);
|
||||
if (wantsToBeSet != hasDefine) {
|
||||
if (wantsToBeSet) EditorUtils.AddGlobalDefine(defineId);
|
||||
else EditorUtils.RemoveGlobalDefine(defineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DG.DOTweenEditor.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@ -16,13 +15,22 @@ namespace DG.DOTweenEditor
|
||||
/// <summary>
|
||||
/// Not used as menu item anymore, but as a utiity function
|
||||
/// </summary>
|
||||
class DOTweenSetupMenuItem
|
||||
static class DOTweenSetupMenuItem
|
||||
{
|
||||
// TODO Remove old defines and add new ones
|
||||
// Modules
|
||||
public const string GlobalDefine_AudioModule = "DOTAUDIO";
|
||||
public const string GlobalDefine_PhysicsModule = "DOTPHYSICS";
|
||||
public const string GlobalDefine_Physics2DModule = "DOTPHYSICS2D";
|
||||
public const string GlobalDefine_SpriteModule = "DOTSPRITE";
|
||||
public const string GlobalDefine_UIModule = "DOTUI";
|
||||
// External assets defines
|
||||
public const string GlobalDefine_TK2D = "DOTWEEN_TK2D";
|
||||
public const string GlobalDefine_TextMeshPro = "DOTWEEN_TMP";
|
||||
public const string GlobalDefine_NoRigidbody = "DOTWEEN_NORBODY";
|
||||
// Legacy (in versions older than 1.2.000)
|
||||
public const string GlobalDefine_Legacy_NoRigidbody = "DOTWEEN_NORBODY";
|
||||
|
||||
const string _Title = "DOTween Setup";
|
||||
static Assembly _proEditorAssembly;
|
||||
|
||||
/// <summary>
|
||||
/// Setups DOTween
|
||||
@ -74,42 +82,18 @@ namespace DG.DOTweenEditor
|
||||
// PRO > 2DToolkit shortcuts
|
||||
if (Has2DToolkit()) {
|
||||
totImported += ImportAddons("Tk2d", proAddonsDir);
|
||||
ProEditor_AddGlobalDefine(GlobalDefine_TK2D);
|
||||
} else ProEditor_RemoveGlobalDefine(GlobalDefine_TK2D);
|
||||
EditorUtils.AddGlobalDefine(GlobalDefine_TK2D);
|
||||
} else EditorUtils.RemoveGlobalDefine(GlobalDefine_TK2D);
|
||||
// PRO > TextMeshPro shortcuts
|
||||
if (HasTextMeshPro()) {
|
||||
totImported += ImportAddons("TextMeshPro", proAddonsDir);
|
||||
ProEditor_AddGlobalDefine(GlobalDefine_TextMeshPro);
|
||||
} else ProEditor_RemoveGlobalDefine(GlobalDefine_TextMeshPro);
|
||||
// PRO > Rigidbody inclusion
|
||||
#if RIGIDBODY
|
||||
ProEditor_RemoveGlobalDefine(GlobalDefine_NoRigidbody);
|
||||
#else
|
||||
totImported += ImportAddons("TextMeshPro", proAddonsDir);
|
||||
ProEditor_AddGlobalDefine(GlobalDefine_NoRigidbody);
|
||||
#endif
|
||||
EditorUtils.AddGlobalDefine(GlobalDefine_TextMeshPro);
|
||||
} else EditorUtils.RemoveGlobalDefine(GlobalDefine_TextMeshPro);
|
||||
}
|
||||
|
||||
SetupComplete(addonsDir, proAddonsDir, totImported);
|
||||
}
|
||||
|
||||
// Uses reflection to call DOTweenPro's AddGlobalDefine method (because older version of Unity didn't have it)
|
||||
public static void ProEditor_AddGlobalDefine(string id)
|
||||
{
|
||||
if (!EditorUtils.hasPro || ProEditorAssembly() == null) return;
|
||||
|
||||
Type type = _proEditorAssembly.GetType("DG.DOTweenEditor.Core.ProEditorUtils");
|
||||
type.GetMethod("AddGlobalDefine", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { id });
|
||||
}
|
||||
// Uses reflection to call DOTweenPro's RemoveGlobalDefine method (because older version of Unity didn't have it)
|
||||
public static void ProEditor_RemoveGlobalDefine(string id)
|
||||
{
|
||||
if (!EditorUtils.hasPro || ProEditorAssembly() == null) return;
|
||||
|
||||
Type type = _proEditorAssembly.GetType("DG.DOTweenEditor.Core.ProEditorUtils");
|
||||
type.GetMethod("RemoveGlobalDefine", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { id });
|
||||
}
|
||||
|
||||
static void SetupComplete(string addonsDir, string proAddonsDir, int totImported)
|
||||
{
|
||||
int totRemoved = 0;
|
||||
@ -207,11 +191,5 @@ namespace DG.DOTweenEditor
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static Assembly ProEditorAssembly()
|
||||
{
|
||||
if (_proEditorAssembly == null) _proEditorAssembly = Assembly.LoadFile(EditorUtils.dotweenProDir + "Editor" + EditorUtils.pathSlash + "DOTweenProEditor.dll");
|
||||
return _proEditorAssembly;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ using UnityEngine;
|
||||
|
||||
namespace DG.DOTweenEditor
|
||||
{
|
||||
public class UtilityWindowModificationProcessor : AssetModificationProcessor
|
||||
public class UtilityWindowModificationProcessor : UnityEditor.AssetModificationProcessor
|
||||
{
|
||||
// Checks if deleted folder contains DOTween Pro and in case removes scripting define symbols
|
||||
static AssetDeleteResult OnWillDeleteAsset(string asset, RemoveAssetOptions options)
|
||||
@ -20,7 +20,7 @@ namespace DG.DOTweenEditor
|
||||
// Check if asset is a directory
|
||||
string dir = EditorUtils.ADBPathToFullPath(asset);
|
||||
if (!Directory.Exists(dir)) return AssetDeleteResult.DidNotDelete;
|
||||
// Check if directory contains DOTweenPro.dll
|
||||
// Check if directory contains DOTween.dll
|
||||
string[] files = Directory.GetFiles(dir, "DOTween.dll", SearchOption.AllDirectories);
|
||||
int len = files.Length;
|
||||
bool containsDOTween = false;
|
||||
@ -31,10 +31,19 @@ namespace DG.DOTweenEditor
|
||||
}
|
||||
if (!containsDOTween) return AssetDeleteResult.DidNotDelete;
|
||||
// DOTween found: remove scripting define symbols
|
||||
DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TK2D);
|
||||
DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TextMeshPro);
|
||||
DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_NoRigidbody);
|
||||
EditorUtility.DisplayDialog("DOTween Deleted", "DOTween was deleted and any of its scripting define symbols removed.\nThis might show an error depending on your previous setup. If this happens, please close and reopen Unity or reimport DOTween.", "Ok");
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_AudioModule);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_PhysicsModule);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_Physics2DModule);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_SpriteModule);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_UIModule);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TK2D);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_TextMeshPro);
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_Legacy_NoRigidbody);
|
||||
// Remove EditorPrefs
|
||||
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.Id);
|
||||
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.IdPro);
|
||||
//
|
||||
EditorUtility.DisplayDialog("DOTween Deleted", "DOTween was deleted and all of its scripting define symbols removed.\nThis might show an error depending on your previous setup. If this happens, please close and reopen Unity or reimport DOTween.", "Ok");
|
||||
return AssetDeleteResult.DidNotDelete;
|
||||
}
|
||||
}
|
||||
@ -50,24 +59,22 @@ namespace DG.DOTweenEditor
|
||||
string[] dotweenEntries = System.Array.FindAll(importedAssets, name => name.Contains("DOTween") && !name.EndsWith(".meta") && !name.EndsWith(".jpg") && !name.EndsWith(".png"));
|
||||
bool dotweenImported = dotweenEntries.Length > 0;
|
||||
if (dotweenImported) {
|
||||
// Delete old DOTween files
|
||||
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
|
||||
// Delete old DemiLib configuration
|
||||
EditorUtils.DeleteOldDemiLibCore();
|
||||
// Setup rigidbody/no rigidbody version
|
||||
#if RIGIDBODY
|
||||
DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_NoRigidbody);
|
||||
#else
|
||||
DOTweenSetupMenuItem.ProEditor_AddGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_NoRigidbody);
|
||||
|
||||
#endif
|
||||
// Remove old NoRigidbody define
|
||||
EditorUtils.RemoveGlobalDefine(DOTweenSetupMenuItem.GlobalDefine_Legacy_NoRigidbody);
|
||||
//
|
||||
bool openSetupDialog = EditorUtils.DOTweenSetupRequired()
|
||||
&& (EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version
|
||||
|| EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion);
|
||||
bool openSetupDialog = EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version
|
||||
|| EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion;
|
||||
if (openSetupDialog) {
|
||||
Debug.Log("Should open setup dialogue");
|
||||
_setupDialogRequested = true;
|
||||
EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.Id, Application.dataPath + DOTween.Version);
|
||||
EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.IdPro, Application.dataPath + EditorUtils.proVersion);
|
||||
EditorUtility.DisplayDialog("DOTween", "DOTween needs to be setup.\n\nSelect \"Tools > DOTween Utility Panel\" and press \"Setup DOTween...\" in the panel that opens.", "Ok");
|
||||
EditorUtility.DisplayDialog("DOTween", "New version of DOTween imported.\n\nSelect \"Tools > Demigiant > DOTween Utility Panel\" and press \"Setup DOTween...\" in the window that opens to set it up.", "Ok");
|
||||
// EditorUtility.DisplayDialog("DOTween", "New version of DOTween imported.\n\nUse the Setup Panel to add/remove its Modules.", "Ok");
|
||||
// Opening window after a postProcess doesn't work on Unity 3 so check that
|
||||
string[] vs = Application.unityVersion.Split("."[0]);
|
||||
int majorVersion = System.Convert.ToInt32(vs[0]);
|
||||
@ -96,6 +103,7 @@ namespace DG.DOTweenEditor
|
||||
bool _setupRequired;
|
||||
|
||||
int _selectedTab;
|
||||
bool _isModulesMode;
|
||||
string[] _tabLabels = new[] { "Setup", "Preferences" };
|
||||
string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources", "Demigiant > Resources"};
|
||||
|
||||
@ -141,6 +149,11 @@ namespace DG.DOTweenEditor
|
||||
_setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_isModulesMode = false;
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
Connect();
|
||||
@ -153,6 +166,9 @@ namespace DG.DOTweenEditor
|
||||
GUILayout.Label("DOTween Utility Panel\nis disabled while in Play Mode", EditorGUIUtils.wrapCenterLabelStyle, GUILayout.ExpandWidth(true));
|
||||
GUILayout.Space(40);
|
||||
GUILayout.EndHorizontal();
|
||||
} else {
|
||||
if (_isModulesMode) {
|
||||
if (DOTweenModulesSetupGUI.Draw()) _isModulesMode = false;
|
||||
} else {
|
||||
Rect areaRect = new Rect(0, 0, _headerSize.x, 30);
|
||||
_selectedTab = GUI.Toolbar(areaRect, _selectedTab, _tabLabels);
|
||||
@ -167,6 +183,7 @@ namespace DG.DOTweenEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// GUI METHODS -----------------------------------------------------------------------
|
||||
@ -185,19 +202,17 @@ namespace DG.DOTweenEditor
|
||||
GUILayout.EndVertical();
|
||||
GUI.backgroundColor = Color.white;
|
||||
} else GUILayout.Space(8);
|
||||
#if RIGIDBODY
|
||||
if (GUILayout.Button("Setup DOTween...", EditorGUIUtils.btStyle)) {
|
||||
#else
|
||||
if (GUILayout.Button("Setup DOTween (No Rigidbody Version)...", EditorGUIUtils.btStyle)) {
|
||||
#endif
|
||||
DOTweenSetupMenuItem.Setup();
|
||||
_setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||
// DOTweenSetupMenuItem.Setup();
|
||||
// _setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||
DOTweenModulesSetupGUI.Refresh();
|
||||
_isModulesMode = true;
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
"NOTE: if you get \"Requested build target group (N) doesn't exist\" or [CS0618] errors during the setup don't worry: it's ok and allows the setup to work on all possible Unity versions",
|
||||
MessageType.Info
|
||||
);
|
||||
// EditorGUILayout.HelpBox(
|
||||
// "NOTE: if you get \"Requested build target group (N) doesn't exist\" or [CS0618] errors during the setup don't worry: it's ok and allows the setup to work on all possible Unity versions",
|
||||
// MessageType.Info
|
||||
// );
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Documentation", EditorGUIUtils.btStyle, GUILayout.Width(_HalfBtSize))) Application.OpenURL("http://dotween.demigiant.com/documentation.php");
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0B529A90-0B97-4840-BEB6-4A6700B46655}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DG.Tweening</RootNamespace>
|
||||
<AssemblyName>DOTween_LooseScripts</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE;DOTAUDIO;DOTPHYSICS;DOTPHYSICS2D;DOTSPRITE;DOTUI;UNITY_4_3;UNITY_4_6;UNITY_5;UNITY_2017_0_OR_NEWER</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1573</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DemiEditor">
|
||||
<HintPath>..\..\..\bin.Global_no_meta\DemiLib\Core\Editor\DemiEditor.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DemiLib">
|
||||
<HintPath>..\..\..\bin.Global_no_meta\DemiLib\Core\DemiLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEditor">
|
||||
<HintPath>C:\Program Files\Unity\Editor\Data\Managed\UnityEditor.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>C:\Program Files\Unity\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="..\bin\*.cs">
|
||||
<Link>bin\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin\*.txt">
|
||||
<Link>bin\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin\Modules\*.cs">
|
||||
<Link>bin\Modules\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin\Modules\*.txt">
|
||||
<Link>bin\Modules\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin_pro\*.cs">
|
||||
<Link>bin_pro\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin_pro\*.txt">
|
||||
<Link>bin_pro\%(FileName)</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bin_pro\Editor\*.cs">
|
||||
<Link>bin_pro\Editor\%(FileName)</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DOTweenEditor\DOTweenEditor.csproj">
|
||||
<Project>{421acc19-8922-4e98-8921-b52240ce172a}</Project>
|
||||
<Name>DOTweenEditor</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DOTweenProEditor\DOTweenProEditor.csproj">
|
||||
<Project>{279545ae-d268-42f0-a4c6-aa5ba15fb9be}</Project>
|
||||
<Name>DOTweenProEditor</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DOTweenPro\DOTweenPro.csproj">
|
||||
<Project>{20d2e542-d14f-4678-9c38-f3c0ecf6a2f6}</Project>
|
||||
<Name>DOTweenPro</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DOTween\DOTween.csproj">
|
||||
<Project>{de17c145-3e8d-45d6-bbb6-d06bd7d80a55}</Project>
|
||||
<Name>DOTween</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DOTween_LooseScripts")]
|
||||
[assembly: AssemblyDescription("Deals with lose scripts inside bin and bin_pro folders")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Demigiant")]
|
||||
[assembly: AssemblyProduct("DOTween_LooseScripts")]
|
||||
[assembly: AssemblyCopyright("Copyright © Daniele Giardini, Demigiant 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("807e068c-2a0e-4c81-a303-4b4fd3924511")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
81
_DOTween.Assembly/PostBuild_DOTween.bat
Normal file
81
_DOTween.Assembly/PostBuild_DOTween.bat
Normal file
@ -0,0 +1,81 @@
|
||||
:: %1 = $(SolutionDir) ► Solution dir path - with final slash
|
||||
:: %2 = $(TargetDir) ► Bin folder dir path - with final slash
|
||||
:: %3 = $(TargetFileName) ► DLL filename with extension
|
||||
:: %4 = $(TargetName) ► DLL filename without extension
|
||||
:: %5 = Main export dir ► Main folder inside bin.Global/etc where to copy the files (ex: "DOTween", "DOTweenPro")
|
||||
:: %6 = Bin dir name ► (ex: "bin", "bin_pro")
|
||||
:: %7 = Eventual export subdir (can be NULL) ► Eventual subdirectory inside the main export dir (ex: "Editor")
|
||||
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
echo :::::::::::::::::: EXECUTING BATCH FILE :::::::::::::::::::::::
|
||||
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :::::: TARGET: %5 %7
|
||||
|
||||
echo :::::: Deleting TMPs...
|
||||
DEL %2*.tmp
|
||||
|
||||
echo :::::: Converting PDB to MDB and deleting PDB...
|
||||
CD %2
|
||||
"c:\Program Files\pdb2mdb\pdb2mdb.exe" %3
|
||||
echo ::: Deleting PDB files: %4.pdb
|
||||
DEL %4.pdb
|
||||
echo ::: PDB files deleted, PAUSE for 0.5 second
|
||||
waitfor pdbsToBeDeletedHopefully /t 0.5 2>NUL || type nul>nul
|
||||
|
||||
echo :::::: Starting export...
|
||||
|
||||
set SubDir=%7
|
||||
if not "%SubDir%"=="" ( set SubDir=\%7 )
|
||||
set CopyFromDir=%1%6%SubDir%
|
||||
|
||||
set CopyToDir=%1..\..\bin.Global\%5%SubDir%
|
||||
set CopyToDirNoMeta=%1..\..\bin.Global_no_meta\%5%SubDir%
|
||||
set CopyToDirUnityTests=%1..\UnityTests.Unity4\Assets\Demigiant\%5%SubDir%
|
||||
set CopyToDirUnity5Tests=%1..\UnityTests.Unity5\Assets\Demigiant\%5%SubDir%
|
||||
set CopyToDirCompatibilityTests=%1..\UnityCompatibilityTests.Unity35\Assets\Demigiant\%5%SubDir%
|
||||
set CopyToDirExtPluginsTests=%1..\ExternalPluginsTestsAndExamples.Unity5\Assets\Demigiant\%5%SubDir%
|
||||
set CopyToDirModulesTest=%1..\ModulesTest.Unity2018\Assets\Demigiant\%5%SubDir%
|
||||
|
||||
:: For now build only to Modules test project
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirModulesTest%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirModulesTest% /Y /I /E
|
||||
|
||||
exit /B
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDir%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDir% /Y /I /E
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirNoMeta%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirNoMeta% /Y /I /E
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirUnityTests%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirUnityTests% /Y /I /E
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirUnity5Tests%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirUnity5Tests% /Y /I /E
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirCompatibilityTests%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirCompatibilityTests% /Y /I /E
|
||||
|
||||
echo ::: Exporting from %CopyFromDir% to %CopyToDirExtPluginsTests%
|
||||
echo ::: f | xcopy %CopyFromDir% %CopyToDirExtPluginsTests% /Y /I /E
|
||||
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
echo ::::::::::::::::::::: BATCH FILE END ::::::::::::::::::::::::::
|
||||
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
echo :
|
||||
193
_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs
Normal file
193
_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs
Normal file
@ -0,0 +1,193 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
#if DOTAUDIO
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
public static class DOTweenModuleAudio
|
||||
{
|
||||
#region Shortcuts
|
||||
|
||||
#region Audio
|
||||
|
||||
/// <summary>Tweens an AudioSource's volume to the given value.
|
||||
/// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this AudioSource target, float endValue, float duration)
|
||||
{
|
||||
if (endValue < 0) endValue = 0;
|
||||
else if (endValue > 1) endValue = 1;
|
||||
return DOTween.To(() => target.volume, x => target.volume = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an AudioSource's pitch to the given value.
|
||||
/// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOPitch(this AudioSource target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if UNITY_5 || UNITY_2017_0_OR_NEWER
|
||||
#region AudioMixer (Unity 5 or Newer)
|
||||
|
||||
/// <summary>Tweens an AudioMixer's exposed float to the given value.
|
||||
/// Also stores the AudioMixer as the tween's target so it can be used for filtered operations.
|
||||
/// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer.</summary>
|
||||
/// <param name="floatName">Name given to the exposed float to set</param>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(()=> {
|
||||
float currVal;
|
||||
target.GetFloat(floatName, out currVal);
|
||||
return currVal;
|
||||
}, x=> target.SetFloat(floatName, x), endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#region Operation Shortcuts
|
||||
|
||||
/// <summary>
|
||||
/// Completes all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens completed
|
||||
/// (meaning the tweens that don't have infinite loops and were not already complete)
|
||||
/// </summary>
|
||||
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
|
||||
/// otherwise they will be ignored</param>
|
||||
public static int DOComplete(this AudioMixer target, bool withCallbacks = false)
|
||||
{
|
||||
return DOTween.Complete(target, withCallbacks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kills all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens killed.
|
||||
/// </summary>
|
||||
/// <param name="complete">If TRUE completes the tween before killing it</param>
|
||||
public static int DOKill(this AudioMixer target, bool complete = false)
|
||||
{
|
||||
return DOTween.Kill(target, complete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flips the direction (backwards if it was going forward or viceversa) of all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens flipped.
|
||||
/// </summary>
|
||||
public static int DOFlip(this AudioMixer target)
|
||||
{
|
||||
return DOTween.Flip(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends to the given position all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens involved.
|
||||
/// </summary>
|
||||
/// <param name="to">Time position to reach
|
||||
/// (if higher than the whole tween duration the tween will simply reach its end)</param>
|
||||
/// <param name="andPlay">If TRUE will play the tween after reaching the given position, otherwise it will pause it</param>
|
||||
public static int DOGoto(this AudioMixer target, float to, bool andPlay = false)
|
||||
{
|
||||
return DOTween.Goto(target, to, andPlay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pauses all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens paused.
|
||||
/// </summary>
|
||||
public static int DOPause(this AudioMixer target)
|
||||
{
|
||||
return DOTween.Pause(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens played.
|
||||
/// </summary>
|
||||
public static int DOPlay(this AudioMixer target)
|
||||
{
|
||||
return DOTween.Play(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays backwards all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens played.
|
||||
/// </summary>
|
||||
public static int DOPlayBackwards(this AudioMixer target)
|
||||
{
|
||||
return DOTween.PlayBackwards(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays forward all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens played.
|
||||
/// </summary>
|
||||
public static int DOPlayForward(this AudioMixer target)
|
||||
{
|
||||
return DOTween.PlayForward(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restarts all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens restarted.
|
||||
/// </summary>
|
||||
public static int DORestart(this AudioMixer target)
|
||||
{
|
||||
return DOTween.Restart(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rewinds all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens rewinded.
|
||||
/// </summary>
|
||||
public static int DORewind(this AudioMixer target)
|
||||
{
|
||||
return DOTween.Rewind(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly rewinds all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens rewinded.
|
||||
/// </summary>
|
||||
public static int DOSmoothRewind(this AudioMixer target)
|
||||
{
|
||||
return DOTween.SmoothRewind(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the paused state (plays if it was paused, pauses if it was playing) of all tweens that have this target as a reference
|
||||
/// (meaning tweens that were started from this target, or that had this target added as an Id)
|
||||
/// and returns the total number of tweens involved.
|
||||
/// </summary>
|
||||
public static int DOTogglePause(this AudioMixer target)
|
||||
{
|
||||
return DOTween.TogglePause(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
212
_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs
Normal file
212
_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs
Normal file
@ -0,0 +1,212 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
#if DOTPHYSICS
|
||||
using System;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Core.Enums;
|
||||
using DG.Tweening.Plugins;
|
||||
using DG.Tweening.Plugins.Core.PathCore;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
public static class DOTweenModulePhysics
|
||||
{
|
||||
#region Shortcuts
|
||||
|
||||
#region Rigidbody
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's X position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's Y position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration)
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's Z position to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration)
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's rotation to the given value.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="mode">Rotation mode</param>
|
||||
public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast)
|
||||
{
|
||||
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration);
|
||||
t.SetTarget(target);
|
||||
t.plugOptions.rotateMode = mode;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's rotation so that it will look towards the given position.
|
||||
/// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="towards">The position to look at</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="axisConstraint">Eventual axis constraint for the rotation</param>
|
||||
/// <param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
|
||||
public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
|
||||
{
|
||||
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration)
|
||||
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);
|
||||
t.plugOptions.axisConstraint = axisConstraint;
|
||||
t.plugOptions.up = (up == null) ? Vector3.up : (Vector3)up;
|
||||
return t;
|
||||
}
|
||||
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Rigidbody target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
float startPosY = 0;
|
||||
float offsetY = -1;
|
||||
bool offsetYSet = false;
|
||||
Sequence s = DOTween.Sequence();
|
||||
Tween yTween = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(() => startPosY = target.position.y);
|
||||
s.Append(DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue.x, 0, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue.z), duration)
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)
|
||||
).Join(yTween)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
yTween.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector3 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody's position through the given path waypoints, using the chosen path algorithm.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations.
|
||||
/// <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
|
||||
/// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
|
||||
/// If you plan to publish there you should use a regular transform.DOPath.</para></summary>
|
||||
/// <param name="path">The waypoints to go through</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
/// <param name="resolution">The resolution of the path (useless in case of Linear paths): higher resolutions make for more detailed curved paths but are more expensive.
|
||||
/// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
|
||||
/// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
|
||||
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
|
||||
)
|
||||
{
|
||||
if (resolution < 1) resolution = 1;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, new Path(pathType, path, resolution, gizmoColor), duration)
|
||||
.SetTarget(target).SetUpdate(UpdateType.Fixed);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
return t;
|
||||
}
|
||||
/// <summary>Tweens a Rigidbody's localPosition through the given path waypoints, using the chosen path algorithm.
|
||||
/// Also stores the Rigidbody as the tween's target so it can be used for filtered operations
|
||||
/// <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
|
||||
/// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
|
||||
/// If you plan to publish there you should use a regular transform.DOLocalPath.</para></summary>
|
||||
/// <param name="path">The waypoint to go through</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
|
||||
/// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
|
||||
/// <param name="resolution">The resolution of the path: higher resolutions make for more detailed curved paths but are more expensive.
|
||||
/// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
|
||||
/// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
|
||||
public static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
|
||||
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
|
||||
)
|
||||
{
|
||||
if (resolution < 1) resolution = 1;
|
||||
Transform trans = target.transform;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => trans.localPosition, x => target.MovePosition(trans.parent == null ? x : trans.parent.TransformPoint(x)), new Path(pathType, path, resolution, gizmoColor), duration)
|
||||
.SetTarget(target).SetUpdate(UpdateType.Fixed);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
t.plugOptions.useLocalPosition = true;
|
||||
return t;
|
||||
}
|
||||
// Used by path editor when creating the actual tween, so it can pass a pre-compiled path
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOPath(
|
||||
this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, path, duration)
|
||||
.SetTarget(target);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
return t;
|
||||
}
|
||||
internal static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
|
||||
this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D
|
||||
)
|
||||
{
|
||||
Transform trans = target.transform;
|
||||
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => trans.localPosition, x => target.MovePosition(trans.parent == null ? x : trans.parent.TransformPoint(x)), path, duration)
|
||||
.SetTarget(target);
|
||||
|
||||
t.plugOptions.isRigidbody = true;
|
||||
t.plugOptions.mode = pathMode;
|
||||
t.plugOptions.useLocalPosition = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
101
_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs
Normal file
101
_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs
Normal file
@ -0,0 +1,101 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
#if DOTPHYSICS2D && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_0_OR_NEWER)
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
public static class DOTweenModulePhysics2D
|
||||
{
|
||||
#region Shortcuts
|
||||
|
||||
#region Rigidbody2D Shortcuts
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's position to the given value.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's X position to the given value.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's Y position to the given value.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMoveY(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.position, target.MovePosition, new Vector2(0, endValue), duration)
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's rotation to the given value.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DORotate(this Rigidbody2D target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
/// <para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJump(this Rigidbody2D target, Vector2 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
float startPosY = 0;
|
||||
float offsetY = -1;
|
||||
bool offsetYSet = false;
|
||||
Sequence s = DOTween.Sequence();
|
||||
Tween yTween = DOTween.To(() => target.position, x => target.position = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(() => startPosY = target.position.y);
|
||||
s.Append(DOTween.To(() => target.position, x => target.position = x, new Vector2(endValue.x, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
).Join(yTween)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
yTween.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector3 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, yTween.ElapsedPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
88
_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs
Normal file
88
_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs
Normal file
@ -0,0 +1,88 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
#if DOTSPRITE && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_0_OR_NEWER)
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using DG.Tweening.Core;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
public static class DOTweenModuleSprite
|
||||
{
|
||||
#region Shortcuts
|
||||
|
||||
#region SpriteRenderer
|
||||
|
||||
/// <summary>Tweens a SpriteRenderer's color to the given value.
|
||||
/// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOColor(this SpriteRenderer target, Color endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Material's alpha color to the given value.
|
||||
/// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this SpriteRenderer target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a SpriteRenderer's color using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this SpriteRenderer target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Blendables
|
||||
|
||||
#region SpriteRenderer
|
||||
|
||||
/// <summary>Tweens a SpriteRenderer's color to the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
/// instead than fight each other as multiple DOColor would do.
|
||||
/// Also stores the SpriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOBlendableColor(this SpriteRenderer target, Color endValue, float duration)
|
||||
{
|
||||
endValue = endValue - target.color;
|
||||
Color to = new Color(0, 0, 0, 0);
|
||||
return DOTween.To(() => to, x => {
|
||||
Color diff = x - to;
|
||||
to = x;
|
||||
target.color += diff;
|
||||
}, endValue, duration)
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
570
_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs
Normal file
570
_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs
Normal file
@ -0,0 +1,570 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
#if DOTUI && (UNITY_4_6 || UNITY_5 || UNITY_2017_0_OR_NEWER)
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Core.Enums;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
public static class DOTweenModuleUI
|
||||
{
|
||||
#region Shortcuts
|
||||
|
||||
#region CanvasGroup
|
||||
|
||||
/// <summary>Tweens a CanvasGroup's alpha color to the given value.
|
||||
/// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this CanvasGroup target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Graphic
|
||||
|
||||
/// <summary>Tweens an Graphic's color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOColor(this Graphic target, Color endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an Graphic's alpha color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this Graphic target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>Tweens an Image's color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOColor(this Image target, Color endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an Image's alpha color to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this Image target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an Image's fillAmount to the given value.
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFillAmount(this Image target, float endValue, float duration)
|
||||
{
|
||||
if (endValue > 1) endValue = 1;
|
||||
else if (endValue < 0) endValue = 0;
|
||||
return DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an Image's colors using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Image target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LayoutElement
|
||||
|
||||
/// <summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
/// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => {
|
||||
target.flexibleWidth = x.x;
|
||||
target.flexibleHeight = x.y;
|
||||
}, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an LayoutElement's minWidth/Height to the given value.
|
||||
/// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => {
|
||||
target.minWidth = x.x;
|
||||
target.minHeight = x.y;
|
||||
}, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an LayoutElement's preferredWidth/Height to the given value.
|
||||
/// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => {
|
||||
target.preferredWidth = x.x;
|
||||
target.preferredHeight = x.y;
|
||||
}, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Outline
|
||||
|
||||
/// <summary>Tweens a Outline's effectColor to the given value.
|
||||
/// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOColor(this Outline target, Color endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Outline's effectColor alpha to the given value.
|
||||
/// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this Outline target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Outline's effectDistance to the given value.
|
||||
/// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOScale(this Outline target, Vector2 endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RectTransform
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition X to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition Y to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration)
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition3D to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition3D X to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition3D Y to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration)
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition3D Z to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration)
|
||||
.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchorMax to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchorMin to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a RectTransform's pivot to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOPivot(this RectTransform target, Vector2 endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's pivot X to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOPivotX(this RectTransform target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration)
|
||||
.SetOptions(AxisConstraint.X).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a RectTransform's pivot Y to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOPivotY(this RectTransform target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration)
|
||||
.SetOptions(AxisConstraint.Y).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a RectTransform's sizeDelta to the given value.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Punches a RectTransform's anchoredPosition towards the given direction and then back to the starting one
|
||||
/// as if it was connected to the starting position via an elastic.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="punch">The direction and strength of the punch (added to the RectTransform's current position)</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="vibrato">Indicates how much will the punch vibrate</param>
|
||||
/// <param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting position when bouncing backwards.
|
||||
/// 1 creates a full oscillation between the punch direction and the opposite direction,
|
||||
/// while 0 oscillates only between the punch and the start position</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOPunchAnchorPos(this RectTransform target, Vector2 punch, float duration, int vibrato = 10, float elasticity = 1, bool snapping = false)
|
||||
{
|
||||
return DOTween.Punch(() => target.anchoredPosition, x => target.anchoredPosition = x, punch, duration, vibrato, elasticity)
|
||||
.SetTarget(target).SetOptions(snapping);
|
||||
}
|
||||
|
||||
/// <summary>Shakes a RectTransform's anchoredPosition with the given values.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="strength">The shake strength</param>
|
||||
/// <param name="vibrato">Indicates how much will the shake vibrate</param>
|
||||
/// <param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
/// Setting it to 0 will shake along a single direction.</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
/// <param name="fadeOut">If TRUE the shake will automatically fadeOut smoothly within the tween's duration, otherwise it will not</param>
|
||||
public static Tweener DOShakeAnchorPos(this RectTransform target, float duration, float strength = 100, int vibrato = 10, float randomness = 90, bool snapping = false, bool fadeOut = true)
|
||||
{
|
||||
return DOTween.Shake(() => target.anchoredPosition, x => target.anchoredPosition = x, duration, strength, vibrato, randomness, true, fadeOut)
|
||||
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
|
||||
}
|
||||
/// <summary>Shakes a RectTransform's anchoredPosition with the given values.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="strength">The shake strength on each axis</param>
|
||||
/// <param name="vibrato">Indicates how much will the shake vibrate</param>
|
||||
/// <param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware).
|
||||
/// Setting it to 0 will shake along a single direction.</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
/// <param name="fadeOut">If TRUE the shake will automatically fadeOut smoothly within the tween's duration, otherwise it will not</param>
|
||||
public static Tweener DOShakeAnchorPos(this RectTransform target, float duration, Vector2 strength, int vibrato = 10, float randomness = 90, bool snapping = false, bool fadeOut = true)
|
||||
{
|
||||
return DOTween.Shake(() => target.anchoredPosition, x => target.anchoredPosition = x, duration, strength, vibrato, randomness, fadeOut)
|
||||
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
|
||||
}
|
||||
|
||||
#region Special
|
||||
|
||||
/// <summary>Tweens a RectTransform's anchoredPosition to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Sequence DOJumpAnchorPos(this RectTransform target, Vector2 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
float startPosY = 0;
|
||||
float offsetY = -1;
|
||||
bool offsetYSet = false;
|
||||
|
||||
// Separate Y Tween so we can elaborate elapsedPercentage on that insted of on the Sequence
|
||||
// (in case users add a delay or other elements to the Sequence)
|
||||
Sequence s = DOTween.Sequence();
|
||||
Tween yTween = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(()=> startPosY = target.anchoredPosition.y);
|
||||
s.Append(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue.x, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
).Join(yTween)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector2 pos = target.anchoredPosition;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.anchoredPosition = pos;
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ScrollRect
|
||||
|
||||
/// <summary>Tweens a ScrollRect's horizontal/verticalNormalizedPosition to the given value.
|
||||
/// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DONormalizedPos(this ScrollRect target, Vector2 endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => new Vector2(target.horizontalNormalizedPosition, target.verticalNormalizedPosition),
|
||||
x => {
|
||||
target.horizontalNormalizedPosition = x.x;
|
||||
target.verticalNormalizedPosition = x.y;
|
||||
}, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a ScrollRect's horizontalNormalizedPosition to the given value.
|
||||
/// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOHorizontalNormalizedPos(this ScrollRect target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.horizontalNormalizedPosition, x => target.horizontalNormalizedPosition = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
/// <summary>Tweens a ScrollRect's verticalNormalizedPosition to the given value.
|
||||
/// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOVerticalNormalizedPos(this ScrollRect target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.verticalNormalizedPosition, x => target.verticalNormalizedPosition = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Slider
|
||||
|
||||
/// <summary>Tweens a Slider's value to the given value.
|
||||
/// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
|
||||
public static Tweener DOValue(this Slider target, float endValue, float duration, bool snapping = false)
|
||||
{
|
||||
return DOTween.To(() => target.value, x => target.value = x, endValue, duration)
|
||||
.SetOptions(snapping).SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>Tweens a Text's color to the given value.
|
||||
/// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOColor(this Text target, Color endValue, float duration)
|
||||
{
|
||||
return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Text's alpha color to the given value.
|
||||
/// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOFade(this Text target, float endValue, float duration)
|
||||
{
|
||||
return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a Text's text to the given value.
|
||||
/// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The end string to tween to</param><param name="duration">The duration of the tween</param>
|
||||
/// <param name="richTextEnabled">If TRUE (default), rich text will be interpreted correctly while animated,
|
||||
/// otherwise all tags will be considered as normal text</param>
|
||||
/// <param name="scrambleMode">The type of scramble mode to use, if any</param>
|
||||
/// <param name="scrambleChars">A string containing the characters to use for scrambling.
|
||||
/// Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better results with more characters.
|
||||
/// Leave it to NULL (default) to use default ones</param>
|
||||
public static Tweener DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
|
||||
{
|
||||
return DOTween.To(() => target.text, x => target.text = x, endValue, duration)
|
||||
.SetOptions(richTextEnabled, scrambleMode, scrambleChars)
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Blendables
|
||||
|
||||
#region Graphic
|
||||
|
||||
/// <summary>Tweens a Graphic's color to the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
/// instead than fight each other as multiple DOColor would do.
|
||||
/// Also stores the Graphic as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOBlendableColor(this Graphic target, Color endValue, float duration)
|
||||
{
|
||||
endValue = endValue - target.color;
|
||||
Color to = new Color(0, 0, 0, 0);
|
||||
return DOTween.To(() => to, x => {
|
||||
Color diff = x - to;
|
||||
to = x;
|
||||
target.color += diff;
|
||||
}, endValue, duration)
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>Tweens a Image's color to the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
/// instead than fight each other as multiple DOColor would do.
|
||||
/// Also stores the Image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOBlendableColor(this Image target, Color endValue, float duration)
|
||||
{
|
||||
endValue = endValue - target.color;
|
||||
Color to = new Color(0, 0, 0, 0);
|
||||
return DOTween.To(() => to, x => {
|
||||
Color diff = x - to;
|
||||
to = x;
|
||||
target.color += diff;
|
||||
}, endValue, duration)
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>Tweens a Text's color BY the given value,
|
||||
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
|
||||
/// instead than fight each other as multiple DOColor would do.
|
||||
/// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
|
||||
public static Tweener DOBlendableColor(this Text target, Color endValue, float duration)
|
||||
{
|
||||
endValue = endValue - target.color;
|
||||
Color to = new Color(0, 0, 0, 0);
|
||||
return DOTween.To(() => to, x => {
|
||||
Color diff = x - to;
|
||||
to = x;
|
||||
target.color += diff;
|
||||
}, endValue, duration)
|
||||
.Blendable().SetTarget(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
|
||||
public static class Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the anchoredPosition of the first RectTransform to the second RectTransform,
|
||||
/// taking into consideration offset, anchors and pivot, and returns the new anchoredPosition
|
||||
/// </summary>
|
||||
public static Vector2 SwitchToRectTransform(RectTransform from, RectTransform to)
|
||||
{
|
||||
Vector2 localPoint;
|
||||
Vector2 fromPivotDerivedOffset = new Vector2(from.rect.width * 0.5f + from.rect.xMin, from.rect.height * 0.5f + from.rect.yMin);
|
||||
Vector2 screenP = RectTransformUtility.WorldToScreenPoint(null, from.position);
|
||||
screenP += fromPivotDerivedOffset;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(to, screenP, null, out localPoint);
|
||||
Vector2 pivotDerivedOffset = new Vector2(to.rect.width * 0.5f + to.rect.xMin, to.rect.height * 0.5f + to.rect.yMin);
|
||||
return to.anchoredPosition + localPoint - pivotDerivedOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
252
_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs
Normal file
252
_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs
Normal file
@ -0,0 +1,252 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using DG.Tweening.Core;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
/// <summary>
|
||||
/// Shortcuts/functions that are not strictly related to specific Modules
|
||||
/// but are available only on some Unity versions
|
||||
/// </summary>
|
||||
public static class DOTweenModuleUnityVersion
|
||||
{
|
||||
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_0_OR_NEWER
|
||||
#region Unity 4.3 or Newer
|
||||
|
||||
#region Material
|
||||
|
||||
/// <summary>Tweens a Material's color using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Material target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
/// <summary>Tweens a Material's named color property using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param>
|
||||
/// <param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Material target, Gradient gradient, string property, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, property, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#if UNITY_5_3_OR_NEWER || UNITY_2017_0_OR_NEWER
|
||||
#region CustomYieldInstructions (Unity 5.3 or Newer)
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or complete.
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForCompletion(true);</code>
|
||||
/// </summary>
|
||||
public static CustomYieldInstruction WaitForCompletion(this Tween t, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForCompletion(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or rewinded.
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForRewind();</code>
|
||||
/// </summary>
|
||||
public static CustomYieldInstruction WaitForRewind(this Tween t, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForRewind(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed.
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForKill();</code>
|
||||
/// </summary>
|
||||
public static CustomYieldInstruction WaitForKill(this Tween t, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForKill(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or has gone through the given amount of loops.
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForElapsedLoops(2);</code>
|
||||
/// </summary>
|
||||
/// <param name="elapsedLoops">Elapsed loops to wait for</param>
|
||||
public static CustomYieldInstruction WaitForElapsedLoops(this Tween t, int elapsedLoops, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForElapsedLoops(t, elapsedLoops);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or has reached the given position (loops included, delays excluded).
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForPosition(2.5f);</code>
|
||||
/// </summary>
|
||||
/// <param name="position">Position (loops included, delays excluded) to wait for</param>
|
||||
public static CustomYieldInstruction WaitForPosition(this Tween t, float position, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForPosition(t, position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or started
|
||||
/// (meaning when the tween is set in a playing state the first time, after any eventual delay).
|
||||
/// It can be used inside a coroutine as a yield.
|
||||
/// <para>Example usage:</para><code>yield return myTween.WaitForStart();</code>
|
||||
/// </summary>
|
||||
public static CustomYieldInstruction WaitForStart(this Tween t, bool returnCustomYieldInstruction)
|
||||
{
|
||||
if (!t.active) {
|
||||
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
|
||||
return null;
|
||||
}
|
||||
return new DOTweenCYInstruction.WaitForStart(t);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
}
|
||||
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// ███ CLASSES █████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
|
||||
#if UNITY_5_3_OR_NEWER || UNITY_2017_0_OR_NEWER
|
||||
public static class DOTweenCYInstruction
|
||||
{
|
||||
public class WaitForCompletion : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active && !t.IsComplete();
|
||||
}}
|
||||
readonly Tween t;
|
||||
public WaitForCompletion(Tween tween)
|
||||
{
|
||||
t = tween;
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForRewind : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active && (!t.playedOnce || t.position * (t.CompletedLoops() + 1) > 0);
|
||||
}}
|
||||
readonly Tween t;
|
||||
public WaitForRewind(Tween tween)
|
||||
{
|
||||
t = tween;
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForKill : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active;
|
||||
}}
|
||||
readonly Tween t;
|
||||
public WaitForKill(Tween tween)
|
||||
{
|
||||
t = tween;
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForElapsedLoops : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active && t.CompletedLoops() < elapsedLoops;
|
||||
}}
|
||||
readonly Tween t;
|
||||
readonly int elapsedLoops;
|
||||
public WaitForElapsedLoops(Tween tween, int elapsedLoops)
|
||||
{
|
||||
t = tween;
|
||||
this.elapsedLoops = elapsedLoops;
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForPosition : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active && t.position * (t.CompletedLoops() + 1) < position;
|
||||
}}
|
||||
readonly Tween t;
|
||||
readonly float position;
|
||||
public WaitForPosition(Tween tween, float position)
|
||||
{
|
||||
t = tween;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForStart : CustomYieldInstruction
|
||||
{
|
||||
public override bool keepWaiting { get {
|
||||
return t.active && !t.playedOnce;
|
||||
}}
|
||||
readonly Tween t;
|
||||
public WaitForStart(Tween tween)
|
||||
{
|
||||
t = tween;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
108
_DOTween.Assembly/bin/Modules/DOTweenModuleUtils.cs
Normal file
108
_DOTween.Assembly/bin/Modules/DOTweenModuleUtils.cs
Normal file
@ -0,0 +1,108 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2018/07/13
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Core.PathCore;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility functions that deal with available Modules.
|
||||
/// Modules defines:
|
||||
/// - DOTAUDIO
|
||||
/// - DOTPHYSICS
|
||||
/// - DOTPHYSICS2D
|
||||
/// - DOTSPRITE
|
||||
/// - DOTUI
|
||||
/// Extra defines set and used for implementation of external assets:
|
||||
/// - DOTWEEN_TMP ► TextMesh Pro
|
||||
/// - DOTWEEN_TK2D ► 2D Toolkit
|
||||
/// </summary>
|
||||
public static class DOTweenModuleUtils
|
||||
{
|
||||
static bool _initialized;
|
||||
|
||||
/// <summary>
|
||||
/// Called via Reflection by DOTweenComponent on Awake
|
||||
/// </summary>
|
||||
public static void Init()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
_initialized = true;
|
||||
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
|
||||
}
|
||||
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
|
||||
public static class Physics
|
||||
{
|
||||
// Called via DOTweenExternalCommand callback
|
||||
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
||||
{
|
||||
#if DOTPHYSICS
|
||||
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
||||
else trans.rotation = newRot;
|
||||
#else
|
||||
trans.rotation = newRot;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached
|
||||
public static bool HasRigidbody2D(Component target)
|
||||
{
|
||||
#if DOTPHYSICS2D
|
||||
return target.GetComponent<Rigidbody2D>() != null;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#region Called via Reflection
|
||||
|
||||
|
||||
// Called via Reflection by DOTweenPathInspector
|
||||
// Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached
|
||||
public static bool HasRigidbody(Component target)
|
||||
{
|
||||
#if DOTPHYSICS
|
||||
return target.GetComponent<Rigidbody>() != null;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called via Reflection by DOTweenPath
|
||||
public static TweenerCore<Vector3, Path, PathOptions> CreateDOTweenPathTween(
|
||||
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
|
||||
){
|
||||
TweenerCore<Vector3, Path, PathOptions> t;
|
||||
#if DOTPHYSICS
|
||||
Rigidbody rBody = tweenRigidbody ? target.GetComponent<Rigidbody>() : null;
|
||||
if (tweenRigidbody && rBody != null) {
|
||||
t = isLocal
|
||||
? rBody.DOLocalPath(path, duration, pathMode)
|
||||
: rBody.DOPath(path, duration, pathMode);
|
||||
} else {
|
||||
t = isLocal
|
||||
? target.transform.DOLocalPath(path, duration, pathMode)
|
||||
: target.transform.DOPath(path, duration, pathMode);
|
||||
}
|
||||
#else
|
||||
t = isLocal
|
||||
? target.transform.DOLocalPath(path, duration, pathMode)
|
||||
: target.transform.DOPath(path, duration, pathMode);
|
||||
#endif
|
||||
return t;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user