Compare commits

...

1 Commits

Author SHA1 Message Date
yanghua ff2957ff92 数字孪生模板提交 2025-04-24 16:20:44 +08:00
1388 changed files with 864997 additions and 709 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22092a8e57e14d6439eb6544535afb2d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7dc0413751d0e4a449c6cd98f4d5f186
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: a811bde74b26b53498b4f6d872b09b6d
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5e96fed4f7f91064bbf4c4a3da23fda8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 45d5034162d6cf04dbe46da84fc7d074
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3f77e3fa136a7a41bfa3c2112fe0993
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,202 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
#if true // MODULE_MARKER
using System;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
#if UNITY_5 || UNITY_2017_1_OR_NEWER
using UnityEngine.Audio; // Required for AudioMixer
#endif
#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 TweenerCore<float, float, FloatOptions> DOFade(this AudioSource target, float endValue, float duration)
{
if (endValue < 0) endValue = 0;
else if (endValue > 1) endValue = 1;
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.volume, x => target.volume = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<float, float, FloatOptions> DOPitch(this AudioSource target, float endValue, float duration)
{
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration);
t.SetTarget(target);
return t;
}
#endregion
#if UNITY_5 || UNITY_2017_1_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 TweenerCore<float, float, FloatOptions> DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration)
{
TweenerCore<float, float, FloatOptions> t = DOTween.To(()=> {
float currVal;
target.GetFloat(floatName, out currVal);
return currVal;
}, x=> target.SetFloat(floatName, x), endValue, duration);
t.SetTarget(target);
return t;
}
#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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b766d08851589514b97afb23c6f30a70
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,142 @@
using UnityEngine;
#if false || EPO_DOTWEEN // MODULE_MARKER
using EPOOutline;
using DG.Tweening.Plugins.Options;
using DG.Tweening;
using DG.Tweening.Core;
namespace DG.Tweening
{
public static class DOTweenModuleEPOOutline
{
public static int DOKill(this SerializedPass target, bool complete)
{
return DOTween.Kill(target, complete);
}
public static TweenerCore<float, float, FloatOptions> DOFloat(this SerializedPass target, string propertyName, float endValue, float duration)
{
var tweener = DOTween.To(() => target.GetFloat(propertyName), x => target.SetFloat(propertyName, x), endValue, duration);
tweener.SetOptions(true).SetTarget(target);
return tweener;
}
public static TweenerCore<Color, Color, ColorOptions> DOFade(this SerializedPass target, string propertyName, float endValue, float duration)
{
var tweener = DOTween.ToAlpha(() => target.GetColor(propertyName), x => target.SetColor(propertyName, x), endValue, duration);
tweener.SetOptions(true).SetTarget(target);
return tweener;
}
public static TweenerCore<Color, Color, ColorOptions> DOColor(this SerializedPass target, string propertyName, Color endValue, float duration)
{
var tweener = DOTween.To(() => target.GetColor(propertyName), x => target.SetColor(propertyName, x), endValue, duration);
tweener.SetOptions(false).SetTarget(target);
return tweener;
}
public static TweenerCore<Vector4, Vector4, VectorOptions> DOVector(this SerializedPass target, string propertyName, Vector4 endValue, float duration)
{
var tweener = DOTween.To(() => target.GetVector(propertyName), x => target.SetVector(propertyName, x), endValue, duration);
tweener.SetOptions(false).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DOFloat(this SerializedPass target, int propertyId, float endValue, float duration)
{
var tweener = DOTween.To(() => target.GetFloat(propertyId), x => target.SetFloat(propertyId, x), endValue, duration);
tweener.SetOptions(true).SetTarget(target);
return tweener;
}
public static TweenerCore<Color, Color, ColorOptions> DOFade(this SerializedPass target, int propertyId, float endValue, float duration)
{
var tweener = DOTween.ToAlpha(() => target.GetColor(propertyId), x => target.SetColor(propertyId, x), endValue, duration);
tweener.SetOptions(true).SetTarget(target);
return tweener;
}
public static TweenerCore<Color, Color, ColorOptions> DOColor(this SerializedPass target, int propertyId, Color endValue, float duration)
{
var tweener = DOTween.To(() => target.GetColor(propertyId), x => target.SetColor(propertyId, x), endValue, duration);
tweener.SetOptions(false).SetTarget(target);
return tweener;
}
public static TweenerCore<Vector4, Vector4, VectorOptions> DOVector(this SerializedPass target, int propertyId, Vector4 endValue, float duration)
{
var tweener = DOTween.To(() => target.GetVector(propertyId), x => target.SetVector(propertyId, x), endValue, duration);
tweener.SetOptions(false).SetTarget(target);
return tweener;
}
public static int DOKill(this Outlinable.OutlineProperties target, bool complete = false)
{
return DOTween.Kill(target, complete);
}
public static int DOKill(this Outliner target, bool complete = false)
{
return DOTween.Kill(target, complete);
}
public static TweenerCore<Color, Color, ColorOptions> DOFade(this Outlinable.OutlineProperties target, float endValue, float duration)
{
var tweener = DOTween.ToAlpha(() => target.Color, x => target.Color = x, endValue, duration);
tweener.SetOptions(true).SetTarget(target);
return tweener;
}
public static TweenerCore<Color, Color, ColorOptions> DOColor(this Outlinable.OutlineProperties target, Color endValue, float duration)
{
var tweener = DOTween.To(() => target.Color, x => target.Color = x, endValue, duration);
tweener.SetOptions(false).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DODilateShift(this Outlinable.OutlineProperties target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.DilateShift, x => target.DilateShift = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DOBlurShift(this Outlinable.OutlineProperties target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.BlurShift, x => target.BlurShift = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DOBlurShift(this Outliner target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.BlurShift, x => target.BlurShift = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DODilateShift(this Outliner target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.DilateShift, x => target.DilateShift = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DOInfoRendererScale(this Outliner target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.InfoRendererScale, x => target.InfoRendererScale = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
public static TweenerCore<float, float, FloatOptions> DOPrimaryRendererScale(this Outliner target, float endValue, float duration, bool snapping = false)
{
var tweener = DOTween.To(() => target.PrimaryRendererScale, x => target.PrimaryRendererScale = x, endValue, duration);
tweener.SetOptions(snapping).SetTarget(target);
return tweener;
}
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e944529dcaee98f4e9498d80e541d93e
timeCreated: 1602593330
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,216 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
#if true // MODULE_MARKER
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 TweenerCore<Vector3, Vector3, VectorOptions> DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration);
t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration);
t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration);
t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Quaternion, Vector3, QuaternionOptions> 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 TweenerCore<Quaternion, Vector3, QuaternionOptions> 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), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)</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), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)</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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dae9aa560b4242648a3affa2bfabc365
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,193 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
using System;
using DG.Tweening.Core;
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 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 TweenerCore<Vector2, Vector2, VectorOptions> DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration);
t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOMoveY(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector2(0, endValue), duration);
t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<float, float, FloatOptions> DORotate(this Rigidbody2D target, float endValue, float duration)
{
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration);
t.SetTarget(target);
return t;
}
#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;
}
/// <summary>Tweens a Rigidbody2D's position through the given path waypoints, using the chosen path algorithm.
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
/// <para>NOTE: to tween a Rigidbody2D 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), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)</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 Rigidbody2D target, Vector2[] path, float duration, PathType pathType = PathType.Linear,
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
)
{
if (resolution < 1) resolution = 1;
int len = path.Length;
Vector3[] path3D = new Vector3[len];
for (int i = 0; i < len; ++i) path3D[i] = path[i];
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, x => target.MovePosition(x), new Path(pathType, path3D, resolution, gizmoColor), duration)
.SetTarget(target).SetUpdate(UpdateType.Fixed);
t.plugOptions.isRigidbody2D = true;
t.plugOptions.mode = pathMode;
return t;
}
/// <summary>Tweens a Rigidbody2D's localPosition through the given path waypoints, using the chosen path algorithm.
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations
/// <para>NOTE: to tween a Rigidbody2D 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), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)</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 Rigidbody2D target, Vector2[] path, float duration, PathType pathType = PathType.Linear,
PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
)
{
if (resolution < 1) resolution = 1;
int len = path.Length;
Vector3[] path3D = new Vector3[len];
for (int i = 0; i < len; ++i) path3D[i] = path[i];
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, path3D, resolution, gizmoColor), duration)
.SetTarget(target).SetUpdate(UpdateType.Fixed);
t.plugOptions.isRigidbody2D = 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 Rigidbody2D target, Path path, float duration, PathMode pathMode = PathMode.Full3D
)
{
TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, x => target.MovePosition(x), path, duration)
.SetTarget(target);
t.plugOptions.isRigidbody2D = true;
t.plugOptions.mode = pathMode;
return t;
}
internal static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
this Rigidbody2D 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.isRigidbody2D = true;
t.plugOptions.mode = pathMode;
t.plugOptions.useLocalPosition = true;
return t;
}
#endregion
#endregion
#endregion
}
}
#endif

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 230fe34542e175245ba74b4659dae700
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,93 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
using System;
using UnityEngine;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
#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 TweenerCore<Color, Color, ColorOptions> DOColor(this SpriteRenderer target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Color, Color, ColorOptions> DOFade(this SpriteRenderer target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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));
}
s.SetTarget(target);
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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 188918ab119d93148aa0de59ccf5286b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,660 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
#if true && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
using System;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening.Core;
using DG.Tweening.Core.Enums;
using DG.Tweening.Plugins;
using DG.Tweening.Plugins.Options;
using Outline = UnityEngine.UI.Outline;
using Text = UnityEngine.UI.Text;
#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 TweenerCore<float, float, FloatOptions> DOFade(this CanvasGroup target, float endValue, float duration)
{
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration);
t.SetTarget(target);
return t;
}
#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 TweenerCore<Color, Color, ColorOptions> DOColor(this Graphic target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Color, Color, ColorOptions> DOFade(this Graphic target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
#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 TweenerCore<Color, Color, ColorOptions> DOColor(this Image target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<float, float, FloatOptions> DOFillAmount(this Image target, float endValue, float duration)
{
if (endValue > 1) endValue = 1;
else if (endValue < 0) endValue = 0;
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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));
}
s.SetTarget(target);
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 TweenerCore<Vector2, Vector2, VectorOptions> DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => {
target.flexibleWidth = x.x;
target.flexibleHeight = x.y;
}, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => {
target.minWidth = x.x;
target.minHeight = x.y;
}, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => {
target.preferredWidth = x.x;
target.preferredHeight = x.y;
}, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
#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 TweenerCore<Color, Color, ColorOptions> DOColor(this Outline target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Color, Color, ColorOptions> DOFade(this Outline target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOScale(this Outline target, Vector2 endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration);
t.SetTarget(target);
return t;
}
#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 TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration);
t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration);
t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration);
t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration);
t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration);
t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOPivot(this RectTransform target, Vector2 endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOPivotX(this RectTransform target, float endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration);
t.SetOptions(AxisConstraint.X).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOPivotY(this RectTransform target, float endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration);
t.SetOptions(AxisConstraint.Y).SetTarget(target);
return t;
}
/// <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 TweenerCore<Vector2, Vector2, VectorOptions> DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
/// <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 TweenerCore<float, float, FloatOptions> DOValue(this Slider target, float endValue, float duration, bool snapping = false)
{
TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.value, x => target.value = x, endValue, duration);
t.SetOptions(snapping).SetTarget(target);
return t;
}
#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 TweenerCore<Color, Color, ColorOptions> DOColor(this Text target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>
/// Tweens a Text's text from one integer to another, with options for thousands separators
/// </summary>
/// <param name="fromValue">The value to start from</param>
/// <param name="endValue">The end value to reach</param>
/// <param name="duration">The duration of the tween</param>
/// <param name="addThousandsSeparator">If TRUE (default) also adds thousands separators</param>
/// <param name="culture">The <see cref="CultureInfo"/> to use (InvariantCulture if NULL)</param>
public static TweenerCore<int, int, NoOptions> DOCounter(
this Text target, int fromValue, int endValue, float duration, bool addThousandsSeparator = true, CultureInfo culture = null
){
int v = fromValue;
CultureInfo cInfo = !addThousandsSeparator ? null : culture ?? CultureInfo.InvariantCulture;
TweenerCore<int, int, NoOptions> t = DOTween.To(() => v, x => {
v = x;
target.text = addThousandsSeparator
? v.ToString("N0", cInfo)
: v.ToString();
}, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<Color, Color, ColorOptions> DOFade(this Text target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <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 TweenerCore<string, string, StringOptions> DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
{
if (endValue == null) {
if (Debugger.logPriority > 0) Debugger.LogWarning("You can't pass a NULL string to DOText: an empty string will be used instead to avoid errors");
endValue = "";
}
TweenerCore<string, string, StringOptions> t = DOTween.To(() => target.text, x => target.text = x, endValue, duration);
t.SetOptions(richTextEnabled, scrambleMode, scrambleChars)
.SetTarget(target);
return t;
}
#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
#region Shapes
/// <summary>Tweens a RectTransform's anchoredPosition so that it draws a circle around the given center.
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations.<para/>
/// IMPORTANT: SetFrom(value) requires a <see cref="Vector2"/> instead of a float, where the X property represents the "from degrees value"</summary>
/// <param name="center">Circle-center/pivot around which to rotate (in UI anchoredPosition coordinates)</param>
/// <param name="endValueDegrees">The end value degrees to reach (to rotate counter-clockwise pass a negative value)</param>
/// <param name="duration">The duration of the tween</param>
/// <param name="relativeCenter">If TRUE the <see cref="center"/> coordinates will be considered as relative to the target's current anchoredPosition</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static TweenerCore<Vector2, Vector2, CircleOptions> DOShapeCircle(
this RectTransform target, Vector2 center, float endValueDegrees, float duration, bool relativeCenter = false, bool snapping = false
)
{
TweenerCore<Vector2, Vector2, CircleOptions> t = DOTween.To(
CirclePlugin.Get(), () => target.anchoredPosition, x => target.anchoredPosition = x, center, duration
);
t.SetOptions(endValueDegrees, relativeCenter, snapping).SetTarget(target);
return t;
}
#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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a060394c03331a64392db53a10e7f2d1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,403 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
using System;
using UnityEngine;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
//#if UNITY_2018_1_OR_NEWER && (NET_4_6 || NET_STANDARD_2_0)
//using Task = System.Threading.Tasks.Task;
//#endif
#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_1_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));
}
s.SetTarget(target);
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.SetColor(property, 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));
}
s.SetTarget(target);
return s;
}
#endregion
#endregion
#endif
#if UNITY_5_3_OR_NEWER || UNITY_2017_1_OR_NEWER
#region Unity 5.3 or Newer
#region CustomYieldInstructions
/// <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 time 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
#endregion
#endif
#if UNITY_2018_1_OR_NEWER
#region Unity 2018.1 or Newer
#region Material
/// <summary>Tweens a Material's named texture offset property with the given ID to the given value.
/// Also stores the material 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="propertyID">The ID of the material property to tween (also called nameID in Unity's manual)</param>
/// <param name="duration">The duration of the tween</param>
public static TweenerCore<Vector2, Vector2, VectorOptions> DOOffset(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a Material's named texture scale property with the given ID to the given value.
/// Also stores the material 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="propertyID">The ID of the material property to tween (also called nameID in Unity's manual)</param>
/// <param name="duration">The duration of the tween</param>
public static TweenerCore<Vector2, Vector2, VectorOptions> DOTiling(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration);
t.SetTarget(target);
return t;
}
#endregion
#region .NET 4.6 or Newer
#if UNITY_2018_1_OR_NEWER && (NET_4_6 || NET_STANDARD_2_0)
#region Async Instructions
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> that waits until the tween is killed or complete.
/// It can be used inside an async operation.
/// <para>Example usage:</para><code>await myTween.WaitForCompletion();</code>
/// </summary>
public static async System.Threading.Tasks.Task AsyncWaitForCompletion(this Tween t)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active && !t.IsComplete()) await System.Threading.Tasks.Task.Yield();
}
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> that waits until the tween is killed or rewinded.
/// It can be used inside an async operation.
/// <para>Example usage:</para><code>await myTween.AsyncWaitForRewind();</code>
/// </summary>
public static async System.Threading.Tasks.Task AsyncWaitForRewind(this Tween t)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active && (!t.playedOnce || t.position * (t.CompletedLoops() + 1) > 0)) await System.Threading.Tasks.Task.Yield();
}
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> that waits until the tween is killed.
/// It can be used inside an async operation.
/// <para>Example usage:</para><code>await myTween.AsyncWaitForKill();</code>
/// </summary>
public static async System.Threading.Tasks.Task AsyncWaitForKill(this Tween t)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active) await System.Threading.Tasks.Task.Yield();
}
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> that waits until the tween is killed or has gone through the given amount of loops.
/// It can be used inside an async operation.
/// <para>Example usage:</para><code>await myTween.AsyncWaitForElapsedLoops();</code>
/// </summary>
/// <param name="elapsedLoops">Elapsed loops to wait for</param>
public static async System.Threading.Tasks.Task AsyncWaitForElapsedLoops(this Tween t, int elapsedLoops)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active && t.CompletedLoops() < elapsedLoops) await System.Threading.Tasks.Task.Yield();
}
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> 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 an async operation.
/// <para>Example usage:</para><code>await myTween.AsyncWaitForPosition();</code>
/// </summary>
/// <param name="position">Position (loops included, delays excluded) to wait for</param>
public static async System.Threading.Tasks.Task AsyncWaitForPosition(this Tween t, float position)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active && t.position * (t.CompletedLoops() + 1) < position) await System.Threading.Tasks.Task.Yield();
}
/// <summary>
/// Returns an async <see cref="System.Threading.Tasks.Task"/> that waits until the tween is killed.
/// It can be used inside an async operation.
/// <para>Example usage:</para><code>await myTween.AsyncWaitForKill();</code>
/// </summary>
public static async System.Threading.Tasks.Task AsyncWaitForStart(this Tween t)
{
if (!t.active) {
if (Debugger.logPriority > 0) Debugger.LogInvalidTween(t);
return;
}
while (t.active && !t.playedOnce) await System.Threading.Tasks.Task.Yield();
}
#endregion
#endif
#endregion
#endregion
#endif
}
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
// ███ CLASSES █████████████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
#if UNITY_5_3_OR_NEWER || UNITY_2017_1_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
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 63c02322328255542995bd02b47b0457
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,167 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
using System;
using System.Reflection;
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;
#region Reflection
/// <summary>
/// Called via Reflection by DOTweenComponent on Awake
/// </summary>
#if UNITY_2018_1_OR_NEWER
[UnityEngine.Scripting.Preserve]
#endif
public static void Init()
{
if (_initialized) return;
_initialized = true;
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
#if UNITY_EDITOR
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1
UnityEditor.EditorApplication.playmodeStateChanged += PlaymodeStateChanged;
#else
UnityEditor.EditorApplication.playModeStateChanged += PlaymodeStateChanged;
#endif
#endif
}
#if UNITY_2018_1_OR_NEWER
#pragma warning disable
[UnityEngine.Scripting.Preserve]
// Just used to preserve methods when building, never called
static void Preserver()
{
Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
MethodInfo mi = typeof(MonoBehaviour).GetMethod("Stub");
}
#pragma warning restore
#endif
#endregion
#if UNITY_EDITOR
// Fires OnApplicationPause in DOTweenComponent even when Editor is paused (otherwise it's only fired at runtime)
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1
static void PlaymodeStateChanged()
#else
static void PlaymodeStateChanged(UnityEditor.PlayModeStateChange state)
#endif
{
if (DOTween.instance == null) return;
DOTween.instance.OnApplicationPause(UnityEditor.EditorApplication.isPaused);
}
#endif
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
public static class Physics
{
// Called via DOTweenExternalCommand callback
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
{
#if true // PHYSICS_MARKER
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 true // PHYSICS2D_MARKER
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
#if UNITY_2018_1_OR_NEWER
[UnityEngine.Scripting.Preserve]
#endif
public static bool HasRigidbody(Component target)
{
#if true // PHYSICS_MARKER
return target.GetComponent<Rigidbody>() != null;
#else
return false;
#endif
}
// Called via Reflection by DOTweenPath
#if UNITY_2018_1_OR_NEWER
[UnityEngine.Scripting.Preserve]
#endif
public static TweenerCore<Vector3, Path, PathOptions> CreateDOTweenPathTween(
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
){
TweenerCore<Vector3, Path, PathOptions> t = null;
bool rBodyFoundAndTweened = false;
#if true // PHYSICS_MARKER
if (tweenRigidbody) {
Rigidbody rBody = target.GetComponent<Rigidbody>();
if (rBody != null) {
rBodyFoundAndTweened = true;
t = isLocal
? rBody.DOLocalPath(path, duration, pathMode)
: rBody.DOPath(path, duration, pathMode);
}
}
#endif
#if true // PHYSICS2D_MARKER
if (!rBodyFoundAndTweened && tweenRigidbody) {
Rigidbody2D rBody2D = target.GetComponent<Rigidbody2D>();
if (rBody2D != null) {
rBodyFoundAndTweened = true;
t = isLocal
? rBody2D.DOLocalPath(path, duration, pathMode)
: rBody2D.DOPath(path, duration, pathMode);
}
}
#endif
if (!rBodyFoundAndTweened) {
t = isLocal
? target.transform.DOLocalPath(path, duration, pathMode)
: target.transform.DOPath(path, duration, pathMode);
}
return t;
}
#endregion
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7bcaf917d9cf5b84090421a5a2abe42e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9827c8652e84ad644829065699a0ab3a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,884 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/03/12 15:55
using System;
using System.Collections.Generic;
using DG.Tweening.Core;
using UnityEngine;
#if true // UI_MARKER
using UnityEngine.UI;
#endif
#if false // TEXTMESHPRO_MARKER
using TMPro;
#endif
#pragma warning disable 1591
namespace DG.Tweening
{
/// <summary>
/// Attach this to a GameObject to create a tween
/// </summary>
[AddComponentMenu("DOTween/DOTween Animation")]
public class DOTweenAnimation : ABSAnimationComponent
{
public enum AnimationType
{
None,
Move, LocalMove,
Rotate, LocalRotate,
Scale,
Color, Fade,
Text,
PunchPosition, PunchRotation, PunchScale,
ShakePosition, ShakeRotation, ShakeScale,
CameraAspect, CameraBackgroundColor, CameraFieldOfView, CameraOrthoSize, CameraPixelRect, CameraRect,
UIWidthHeight
}
public enum TargetType
{
Unset,
Camera,
CanvasGroup,
Image,
Light,
RectTransform,
Renderer, SpriteRenderer,
Rigidbody, Rigidbody2D,
Text,
Transform,
tk2dBaseSprite,
tk2dTextMesh,
TextMeshPro,
TextMeshProUGUI
}
#region EVENTS - EDITOR-ONLY
/// <summary>Used internally by the editor</summary>
public static event Action<DOTweenAnimation> OnReset;
static void Dispatch_OnReset(DOTweenAnimation anim) { if (OnReset != null) OnReset(anim); }
#endregion
public bool targetIsSelf = true; // If FALSE allows to set the target manually
public GameObject targetGO = null; // Used in case targetIsSelf is FALSE
// If FALSE always uses the GO containing this DOTweenAnimation (and not the one containing the target) as DOTween's SetTarget target
public bool tweenTargetIsTargetGO = true;
public float delay;
public float duration = 1;
public Ease easeType = Ease.OutQuad;
public AnimationCurve easeCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
public LoopType loopType = LoopType.Restart;
public int loops = 1;
public string id = "";
public bool isRelative;
public bool isFrom;
public bool isIndependentUpdate = false;
public bool autoKill = true;
public bool autoGenerate = true; // If TRUE automatically creates the tween at startup
public bool isActive = true;
public bool isValid;
public Component target;
public AnimationType animationType;
public TargetType targetType;
public TargetType forcedTargetType; // Used when choosing between multiple targets
public bool autoPlay = true;
public bool useTargetAsV3;
public float endValueFloat;
public Vector3 endValueV3;
public Vector2 endValueV2;
public Color endValueColor = new Color(1, 1, 1, 1);
public string endValueString = "";
public Rect endValueRect = new Rect(0, 0, 0, 0);
public Transform endValueTransform;
public bool optionalBool0, optionalBool1;
public float optionalFloat0;
public int optionalInt0;
public RotateMode optionalRotationMode = RotateMode.Fast;
public ScrambleMode optionalScrambleMode = ScrambleMode.None;
public string optionalString;
bool _tweenAutoGenerationCalled; // TRUE after the tweens have been autoGenerated
int _playCount = -1; // Used when calling DOPlayNext
#region Unity Methods
void Awake()
{
if (!isActive || !autoGenerate) return;
if (animationType != AnimationType.Move || !useTargetAsV3) {
// Don't create tweens if we're using a RectTransform as a Move target,
// because that will work only inside Start
CreateTween(false, autoPlay);
_tweenAutoGenerationCalled = true;
}
}
void Start()
{
if (_tweenAutoGenerationCalled || !isActive || !autoGenerate) return;
CreateTween(false, autoPlay);
_tweenAutoGenerationCalled = true;
}
void Reset()
{
Dispatch_OnReset(this);
}
void OnDestroy()
{
if (tween != null && tween.active) tween.Kill();
tween = null;
}
/// <summary>
/// Creates/recreates the tween without playing it, but first rewinding and killing the existing one if present.
/// </summary>
public void RewindThenRecreateTween()
{
if (tween != null && tween.active) tween.Rewind();
CreateTween(true, false);
}
/// <summary>
/// Creates/recreates the tween and plays it, first rewinding and killing the existing one if present.
/// </summary>
public void RewindThenRecreateTweenAndPlay()
{
if (tween != null && tween.active) tween.Rewind();
CreateTween(true, true);
}
/// <summary>
/// Creates/recreates the tween from its target's current value without playing it, but first killing the existing one if present.
/// </summary>
public void RecreateTween()
{ CreateTween(true, false); }
/// <summary>
/// Creates/recreates the tween from its target's current value and plays it, first killing the existing one if present.
/// </summary>
public void RecreateTweenAndPlay()
{ CreateTween(true, true); }
// Used also by DOTweenAnimationInspector when applying runtime changes and restarting
/// <summary>
/// Creates the tween manually (called automatically if AutoGenerate is set in the Inspector)
/// from its target's current value.
/// </summary>
/// <param name="regenerateIfExists">If TRUE and an existing tween was already created (and not killed), kills it and recreates it with the current
/// parameters. Otherwise, if a tween already exists, does nothing.</param>
/// <param name="andPlay">If TRUE also plays the tween, otherwise only creates it</param>
public void CreateTween(bool regenerateIfExists = false, bool andPlay = true)
{
if (!isValid) {
if (regenerateIfExists) { // Called manually: warn users
Debug.LogWarning(string.Format("{0} :: This DOTweenAnimation isn't valid and its tween won't be created", this.gameObject.name), this.gameObject);
}
return;
}
if (tween != null) {
if (tween.active) {
if (regenerateIfExists) tween.Kill();
else return;
}
tween = null;
}
// if (target == null) {
// Debug.LogWarning(string.Format("{0} :: This DOTweenAnimation's target is NULL, because the animation was created with a DOTween Pro version older than 0.9.255. To fix this, exit Play mode then simply select this object, and it will update automatically", this.gameObject.name), this.gameObject);
// return;
// }
GameObject tweenGO = GetTweenGO();
if (target == null || tweenGO == null) {
if (targetIsSelf && target == null) {
// Old error caused during upgrade from DOTween Pro 0.9.255
Debug.LogWarning(string.Format("{0} :: This DOTweenAnimation's target is NULL, because the animation was created with a DOTween Pro version older than 0.9.255. To fix this, exit Play mode then simply select this object, and it will update automatically", this.gameObject.name), this.gameObject);
} else {
// Missing non-self target
Debug.LogWarning(string.Format("{0} :: This DOTweenAnimation's target/GameObject is unset: the tween will not be created.", this.gameObject.name), this.gameObject);
}
return;
}
if (forcedTargetType != TargetType.Unset) targetType = forcedTargetType;
if (targetType == TargetType.Unset) {
// Legacy DOTweenAnimation (made with a version older than 0.9.450) without stored targetType > assign it now
targetType = TypeToDOTargetType(target.GetType());
}
switch (animationType) {
case AnimationType.None:
break;
case AnimationType.Move:
if (useTargetAsV3) {
isRelative = false;
if (endValueTransform == null) {
Debug.LogWarning(string.Format("{0} :: This tween's TO target is NULL, a Vector3 of (0,0,0) will be used instead", this.gameObject.name), this.gameObject);
endValueV3 = Vector3.zero;
} else {
#if true // UI_MARKER
if (targetType == TargetType.RectTransform) {
RectTransform endValueT = endValueTransform as RectTransform;
if (endValueT == null) {
Debug.LogWarning(string.Format("{0} :: This tween's TO target should be a RectTransform, a Vector3 of (0,0,0) will be used instead", this.gameObject.name), this.gameObject);
endValueV3 = Vector3.zero;
} else {
RectTransform rTarget = target as RectTransform;
if (rTarget == null) {
Debug.LogWarning(string.Format("{0} :: This tween's target and TO target are not of the same type. Please reassign the values", this.gameObject.name), this.gameObject);
} else {
// Problem: doesn't work inside Awake (ararargh!)
endValueV3 = DOTweenModuleUI.Utils.SwitchToRectTransform(endValueT, rTarget);
}
}
} else
#endif
endValueV3 = endValueTransform.position;
}
}
switch (targetType) {
case TargetType.Transform:
tween = ((Transform)target).DOMove(endValueV3, duration, optionalBool0);
break;
case TargetType.RectTransform:
#if true // UI_MARKER
tween = ((RectTransform)target).DOAnchorPos3D(endValueV3, duration, optionalBool0);
#else
tween = ((Transform)target).DOMove(endValueV3, duration, optionalBool0);
#endif
break;
case TargetType.Rigidbody:
#if true // PHYSICS_MARKER
tween = ((Rigidbody)target).DOMove(endValueV3, duration, optionalBool0);
#else
tween = ((Transform)target).DOMove(endValueV3, duration, optionalBool0);
#endif
break;
case TargetType.Rigidbody2D:
#if true // PHYSICS2D_MARKER
tween = ((Rigidbody2D)target).DOMove(endValueV3, duration, optionalBool0);
#else
tween = ((Transform)target).DOMove(endValueV3, duration, optionalBool0);
#endif
break;
}
break;
case AnimationType.LocalMove:
tween = tweenGO.transform.DOLocalMove(endValueV3, duration, optionalBool0);
break;
case AnimationType.Rotate:
switch (targetType) {
case TargetType.Transform:
tween = ((Transform)target).DORotate(endValueV3, duration, optionalRotationMode);
break;
case TargetType.Rigidbody:
#if true // PHYSICS_MARKER
tween = ((Rigidbody)target).DORotate(endValueV3, duration, optionalRotationMode);
#else
tween = ((Transform)target).DORotate(endValueV3, duration, optionalRotationMode);
#endif
break;
case TargetType.Rigidbody2D:
#if true // PHYSICS2D_MARKER
tween = ((Rigidbody2D)target).DORotate(endValueFloat, duration);
#else
tween = ((Transform)target).DORotate(endValueV3, duration, optionalRotationMode);
#endif
break;
}
break;
case AnimationType.LocalRotate:
tween = tweenGO.transform.DOLocalRotate(endValueV3, duration, optionalRotationMode);
break;
case AnimationType.Scale:
switch (targetType) {
#if false // TK2D_MARKER
case TargetType.tk2dTextMesh:
tween = ((tk2dTextMesh)target).DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration);
break;
case TargetType.tk2dBaseSprite:
tween = ((tk2dBaseSprite)target).DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration);
break;
#endif
default:
tween = tweenGO.transform.DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration);
break;
}
break;
#if true // UI_MARKER
case AnimationType.UIWidthHeight:
tween = ((RectTransform)target).DOSizeDelta(optionalBool0 ? new Vector2(endValueFloat, endValueFloat) : endValueV2, duration);
break;
#endif
case AnimationType.Color:
isRelative = false;
switch (targetType) {
case TargetType.Renderer:
tween = ((Renderer)target).material.DOColor(endValueColor, duration);
break;
case TargetType.Light:
tween = ((Light)target).DOColor(endValueColor, duration);
break;
#if true // SPRITE_MARKER
case TargetType.SpriteRenderer:
tween = ((SpriteRenderer)target).DOColor(endValueColor, duration);
break;
#endif
#if true // UI_MARKER
case TargetType.Image:
tween = ((Graphic)target).DOColor(endValueColor, duration);
break;
case TargetType.Text:
tween = ((Text)target).DOColor(endValueColor, duration);
break;
#endif
#if false // TK2D_MARKER
case TargetType.tk2dTextMesh:
tween = ((tk2dTextMesh)target).DOColor(endValueColor, duration);
break;
case TargetType.tk2dBaseSprite:
tween = ((tk2dBaseSprite)target).DOColor(endValueColor, duration);
break;
#endif
#if false // TEXTMESHPRO_MARKER
case TargetType.TextMeshProUGUI:
tween = ((TextMeshProUGUI)target).DOColor(endValueColor, duration);
break;
case TargetType.TextMeshPro:
tween = ((TextMeshPro)target).DOColor(endValueColor, duration);
break;
#endif
}
break;
case AnimationType.Fade:
isRelative = false;
switch (targetType) {
case TargetType.Renderer:
tween = ((Renderer)target).material.DOFade(endValueFloat, duration);
break;
case TargetType.Light:
tween = ((Light)target).DOIntensity(endValueFloat, duration);
break;
#if true // SPRITE_MARKER
case TargetType.SpriteRenderer:
tween = ((SpriteRenderer)target).DOFade(endValueFloat, duration);
break;
#endif
#if true // UI_MARKER
case TargetType.Image:
tween = ((Graphic)target).DOFade(endValueFloat, duration);
break;
case TargetType.Text:
tween = ((Text)target).DOFade(endValueFloat, duration);
break;
case TargetType.CanvasGroup:
tween = ((CanvasGroup)target).DOFade(endValueFloat, duration);
break;
#endif
#if false // TK2D_MARKER
case TargetType.tk2dTextMesh:
tween = ((tk2dTextMesh)target).DOFade(endValueFloat, duration);
break;
case TargetType.tk2dBaseSprite:
tween = ((tk2dBaseSprite)target).DOFade(endValueFloat, duration);
break;
#endif
#if false // TEXTMESHPRO_MARKER
case TargetType.TextMeshProUGUI:
tween = ((TextMeshProUGUI)target).DOFade(endValueFloat, duration);
break;
case TargetType.TextMeshPro:
tween = ((TextMeshPro)target).DOFade(endValueFloat, duration);
break;
#endif
}
break;
case AnimationType.Text:
#if true // UI_MARKER
switch (targetType) {
case TargetType.Text:
tween = ((Text)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
break;
}
#endif
#if false // TK2D_MARKER
switch (targetType) {
case TargetType.tk2dTextMesh:
tween = ((tk2dTextMesh)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
break;
}
#endif
#if false // TEXTMESHPRO_MARKER
switch (targetType) {
case TargetType.TextMeshProUGUI:
tween = ((TextMeshProUGUI)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
break;
case TargetType.TextMeshPro:
tween = ((TextMeshPro)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
break;
}
#endif
break;
case AnimationType.PunchPosition:
switch (targetType) {
case TargetType.Transform:
tween = ((Transform)target).DOPunchPosition(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0);
break;
#if true // UI_MARKER
case TargetType.RectTransform:
tween = ((RectTransform)target).DOPunchAnchorPos(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0);
break;
#endif
}
break;
case AnimationType.PunchScale:
tween = tweenGO.transform.DOPunchScale(endValueV3, duration, optionalInt0, optionalFloat0);
break;
case AnimationType.PunchRotation:
tween = tweenGO.transform.DOPunchRotation(endValueV3, duration, optionalInt0, optionalFloat0);
break;
case AnimationType.ShakePosition:
switch (targetType) {
case TargetType.Transform:
tween = ((Transform)target).DOShakePosition(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0, optionalBool1);
break;
#if true // UI_MARKER
case TargetType.RectTransform:
tween = ((RectTransform)target).DOShakeAnchorPos(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0, optionalBool1);
break;
#endif
}
break;
case AnimationType.ShakeScale:
tween = tweenGO.transform.DOShakeScale(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool1);
break;
case AnimationType.ShakeRotation:
tween = tweenGO.transform.DOShakeRotation(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool1);
break;
case AnimationType.CameraAspect:
tween = ((Camera)target).DOAspect(endValueFloat, duration);
break;
case AnimationType.CameraBackgroundColor:
tween = ((Camera)target).DOColor(endValueColor, duration);
break;
case AnimationType.CameraFieldOfView:
tween = ((Camera)target).DOFieldOfView(endValueFloat, duration);
break;
case AnimationType.CameraOrthoSize:
tween = ((Camera)target).DOOrthoSize(endValueFloat, duration);
break;
case AnimationType.CameraPixelRect:
tween = ((Camera)target).DOPixelRect(endValueRect, duration);
break;
case AnimationType.CameraRect:
tween = ((Camera)target).DORect(endValueRect, duration);
break;
}
if (tween == null) return;
// Created
if (isFrom) {
((Tweener)tween).From(isRelative);
} else {
tween.SetRelative(isRelative);
}
GameObject setTarget = GetTweenTarget();
tween.SetTarget(setTarget).SetDelay(delay).SetLoops(loops, loopType).SetAutoKill(autoKill)
.OnKill(()=> tween = null);
if (isSpeedBased) tween.SetSpeedBased();
if (easeType == Ease.INTERNAL_Custom) tween.SetEase(easeCurve);
else tween.SetEase(easeType);
if (!string.IsNullOrEmpty(id)) tween.SetId(id);
tween.SetUpdate(isIndependentUpdate);
if (hasOnStart) {
if (onStart != null) tween.OnStart(onStart.Invoke);
} else onStart = null;
if (hasOnPlay) {
if (onPlay != null) tween.OnPlay(onPlay.Invoke);
} else onPlay = null;
if (hasOnUpdate) {
if (onUpdate != null) tween.OnUpdate(onUpdate.Invoke);
} else onUpdate = null;
if (hasOnStepComplete) {
if (onStepComplete != null) tween.OnStepComplete(onStepComplete.Invoke);
} else onStepComplete = null;
if (hasOnComplete) {
if (onComplete != null) tween.OnComplete(onComplete.Invoke);
} else onComplete = null;
if (hasOnRewind) {
if (onRewind != null) tween.OnRewind(onRewind.Invoke);
} else onRewind = null;
if (andPlay) tween.Play();
else tween.Pause();
if (hasOnTweenCreated && onTweenCreated != null) onTweenCreated.Invoke();
}
#endregion
#region Public Methods
#region Special
/// <summary>
/// Returns the tweens (if generated and not killed) created by all DOTweenAnimations on this gameObject,
/// in the same order as they appear in the Inspector (top to bottom).<para/>
/// Note that a tween is generated inside the Awake call (except RectTransform tweens which are generated inside Start),
/// so this method won't return them before that
/// </summary>
public List<Tween> GetTweens()
{
List<Tween> result = new List<Tween>();
DOTweenAnimation[] anims = this.GetComponents<DOTweenAnimation>();
foreach (DOTweenAnimation anim in anims) {
if (anim.tween != null && anim.tween.active) result.Add(anim.tween);
}
return result;
}
/// <summary>
/// Sets the animation target (which must be of the same type of the one set in the Inspector).
/// This is useful if you want to change it BEFORE this <see cref="DOTweenAnimation"/>
/// creates a tween, while after that it won't have any effect.<para/>
/// Consider that a <see cref="DOTweenAnimation"/> creates its tween inside its Awake (except for special tweens),
/// so you will need to sure your code runs before this object's Awake (via ScriptExecutionOrder or enabling/disabling methods)
/// </summary>
/// <param name="tweenTarget">
/// New target for the animation (must be of the same type of the previous one)</param>
/// <param name="useTweenTargetGameObjectForGroupOperations">If TRUE also uses tweenTarget's gameObject when settings the target-ID of the tween
/// (which is used with DOPlay/DORestart/etc to apply the same operation on all tweens that have the same target-id).<para/>
/// You should usually leave this to TRUE if you change the target.
/// </param>
public void SetAnimationTarget(Component tweenTarget, bool useTweenTargetGameObjectForGroupOperations = true)
{
TargetType newTargetType = TypeToDOTargetType(target.GetType());
if (newTargetType != targetType) {
Debug.LogError("DOTweenAnimation ► SetAnimationTarget: the new target is of a different type from the one set in the Inspector");
return;
}
target = tweenTarget;
targetGO = target.gameObject;
tweenTargetIsTargetGO = useTweenTargetGameObjectForGroupOperations;
}
#endregion
/// <summary>
/// Plays all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOPlay()
{
DOTween.Play(GetTweenTarget());
}
/// <summary>
/// Plays backwards all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOPlayBackwards()
{
DOTween.PlayBackwards(GetTweenTarget());
}
/// <summary>
/// Plays foward all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOPlayForward()
{
DOTween.PlayForward(GetTweenTarget());
}
/// <summary>
/// Pauses all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOPause()
{
DOTween.Pause(GetTweenTarget());
}
/// <summary>
/// Pauses/unpauses (depending on the current state) all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOTogglePause()
{
DOTween.TogglePause(GetTweenTarget());
}
/// <summary>
/// Rewinds all tweens created by this animation in the correct order
/// </summary>
public override void DORewind()
{
_playCount = -1;
// Rewind using Components order (in case there are multiple animations on the same property)
DOTweenAnimation[] anims = this.gameObject.GetComponents<DOTweenAnimation>();
for (int i = anims.Length - 1; i > -1; --i) {
Tween t = anims[i].tween;
if (t != null && t.IsInitialized()) anims[i].tween.Rewind();
}
// DOTween.Rewind(GetTweenTarget());
}
/// <summary>
/// Restarts all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DORestart()
{ DORestart(false); }
/// <summary>
/// Restarts all tweens whose target-id is the same as the one set by this animation
/// </summary>
/// <param name="fromHere">If TRUE, re-evaluates the tween's start and end values from its current position.
/// Set it to TRUE when spawning the same DOTweenAnimation in different positions (like when using a pooling system)</param>
public override void DORestart(bool fromHere)
{
_playCount = -1;
if (tween == null) {
if (Debugger.logPriority > 1) Debugger.LogNullTween(tween); return;
}
if (fromHere && isRelative) ReEvaluateRelativeTween();
DOTween.Restart(GetTweenTarget());
}
/// <summary>
/// Completes all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOComplete()
{
DOTween.Complete(GetTweenTarget());
}
/// <summary>
/// Kills all tweens whose target-id is the same as the one set by this animation
/// </summary>
public override void DOKill()
{
DOTween.Kill(GetTweenTarget());
tween = null;
}
#region Specifics
/// <summary>
/// Plays all tweens with the given ID and whose target-id is the same as the one set by this animation
/// </summary>
public void DOPlayById(string id)
{
DOTween.Play(GetTweenTarget(), id);
}
/// <summary>
/// Plays all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DOPlayAllById(string id)
{
DOTween.Play(id);
}
/// <summary>
/// Pauses all tweens that with the given ID (regardless of their target gameObject)
/// </summary>
public void DOPauseAllById(string id)
{
DOTween.Pause(id);
}
/// <summary>
/// Plays backwards all tweens with the given ID and whose target-id is the same as the one set by this animation
/// </summary>
public void DOPlayBackwardsById(string id)
{
DOTween.PlayBackwards(GetTweenTarget(), id);
}
/// <summary>
/// Plays backwards all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DOPlayBackwardsAllById(string id)
{
DOTween.PlayBackwards(id);
}
/// <summary>
/// Plays forward all tweens with the given ID and whose target-id is the same as the one set by this animation
/// </summary>
public void DOPlayForwardById(string id)
{
DOTween.PlayForward(GetTweenTarget(), id);
}
/// <summary>
/// Plays forward all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DOPlayForwardAllById(string id)
{
DOTween.PlayForward(id);
}
/// <summary>
/// Plays the next animation on this animation's gameObject (if any)
/// </summary>
public void DOPlayNext()
{
DOTweenAnimation[] anims = this.GetComponents<DOTweenAnimation>();
while (_playCount < anims.Length - 1) {
_playCount++;
DOTweenAnimation anim = anims[_playCount];
if (anim != null && anim.tween != null && anim.tween.active && !anim.tween.IsPlaying() && !anim.tween.IsComplete()) {
anim.tween.Play();
break;
}
}
}
/// <summary>
/// Rewinds all tweens with the given ID and whose target-id is the same as the one set by this animation,
/// then plays the next animation on this animation's gameObject (if any)
/// </summary>
public void DORewindAndPlayNext()
{
_playCount = -1;
DOTween.Rewind(GetTweenTarget());
DOPlayNext();
}
/// <summary>
/// Rewinds all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DORewindAllById(string id)
{
_playCount = -1;
DOTween.Rewind(id);
}
/// <summary>
/// Restarts all tweens with the given ID and whose target-id is the same as the one set by this animation
/// </summary>
public void DORestartById(string id)
{
_playCount = -1;
DOTween.Restart(GetTweenTarget(), id);
}
/// <summary>
/// Restarts all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DORestartAllById(string id)
{
_playCount = -1;
DOTween.Restart(id);
}
/// <summary>
/// Kills all tweens with the given ID and whose target-id is the same as the one set by this animation
/// </summary>
public void DOKillById(string id)
{
DOTween.Kill(GetTweenTarget(), id);
}
/// <summary>
/// Kills all tweens with the given ID (regardless of their target gameObject)
/// </summary>
public void DOKillAllById(string id)
{
DOTween.Kill(id);
}
#endregion
#region Internal (also used by Inspector)
public static TargetType TypeToDOTargetType(Type t)
{
string str = t.ToString();
int dotIndex = str.LastIndexOf(".");
if (dotIndex != -1) str = str.Substring(dotIndex + 1);
if (str.IndexOf("Renderer") != -1 && (str != "SpriteRenderer")) str = "Renderer";
//#if true // PHYSICS_MARKER
// if (str == "Rigidbody") str = "Transform";
//#endif
//#if true // PHYSICS2D_MARKER
// if (str == "Rigidbody2D") str = "Transform";
//#endif
#if true // UI_MARKER
// if (str == "RectTransform") str = "Transform";
if (str == "RawImage" || str == "Graphic") str = "Image"; // RawImages/Graphics are managed like Images for DOTweenAnimation (color and fade use Graphic target anyway)
#endif
return (TargetType)Enum.Parse(typeof(TargetType), str);
}
// Editor preview system
/// <summary>
/// Previews the tween in the editor. Only for DOTween internal usage: don't use otherwise.
/// </summary>
public Tween CreateEditorPreview()
{
if (Application.isPlaying) return null;
// CHANGE: first param switched to TRUE otherwise changing an animation and replaying in editor would still play old one
CreateTween(true, autoPlay);
return tween;
}
#endregion
#endregion
#region Private
/// <summary>
/// Returns the gameObject whose target component should be animated
/// </summary>
/// <returns></returns>
GameObject GetTweenGO()
{
return targetIsSelf ? this.gameObject : targetGO;
}
/// <summary>
/// Returns the GameObject which should be used/retrieved for SetTarget
/// </summary>
GameObject GetTweenTarget()
{
return targetIsSelf || !tweenTargetIsTargetGO ? this.gameObject : targetGO;
}
// Re-evaluate relative position of path
void ReEvaluateRelativeTween()
{
GameObject tweenGO = GetTweenGO();
if (tweenGO == null) {
Debug.LogWarning(string.Format("{0} :: This DOTweenAnimation's target/GameObject is unset: the tween will not be created.", this.gameObject.name), this.gameObject);
return;
}
if (animationType == AnimationType.Move) {
((Tweener)tween).ChangeEndValue(tweenGO.transform.position + endValueV3, true);
} else if (animationType == AnimationType.LocalMove) {
((Tweener)tween).ChangeEndValue(tweenGO.transform.localPosition + endValueV3, true);
}
}
#endregion
}
public static class DOTweenAnimationExtensions
{
// // Doesn't work on Win 8.1
// public static bool IsSameOrSubclassOf(this Type t, Type tBase)
// {
// return t.IsSubclassOf(tBase) || t == tBase;
// }
public static bool IsSameOrSubclassOf<T>(this Component t)
{
return t is T;
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4d0390bd8b8ffd640b34fe25065ff1df
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,9 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/03/27 19:02
//
// License Copyright (c) Daniele Giardini.
// This work is subject to the terms at http://dotween.demigiant.com/license.php
#if false // MODULE_MARKER
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1d1aa01bacf85c04ea18116651a7f0db
timeCreated: 1587116610
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/03/27 19:02
//
// License Copyright (c) Daniele Giardini.
// This work is subject to the terms at http://dotween.demigiant.com/license.php
#if false // MODULE_MARKER
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0a0cc3e90c4a6ea41bb14d7f35c577c3
timeCreated: 1587116610
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: aa0b1eebb5db27a419fa4564bbe5c9c5
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,90 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/13
using System;
using DG.Tweening.Core;
using DG.Tweening.Plugins;
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening
{
public static class DOTweenProShortcuts
{
static DOTweenProShortcuts()
{
// Create stub instances of custom plugins, in order to allow IL2CPP to understand they must be included in the build
#pragma warning disable 219
SpiralPlugin stub = new SpiralPlugin();
#pragma warning restore 219
}
#region Shortcuts
#region Transform
/// <summary>Tweens a Transform's localPosition in a spiral shape.
/// Also stores the transform 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="axis">The axis around which the spiral will rotate</param>
/// <param name="mode">The type of spiral movement</param>
/// <param name="speed">Speed of the rotations</param>
/// <param name="frequency">Frequency of the rotation. Lower values lead to wider spirals</param>
/// <param name="depth">Indicates how much the tween should move along the spiral's axis</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOSpiral(
this Transform target, float duration, Vector3? axis = null, SpiralMode mode = SpiralMode.Expand,
float speed = 1, float frequency = 10, float depth = 0, bool snapping = false
) {
if (Mathf.Approximately(speed, 0)) speed = 1;
if (axis == null || axis == Vector3.zero) axis = Vector3.forward;
TweenerCore<Vector3, Vector3, SpiralOptions> t = DOTween.To(SpiralPlugin.Get(), () => target.localPosition, x => target.localPosition = x, (Vector3)axis, duration)
.SetTarget(target);
t.plugOptions.mode = mode;
t.plugOptions.speed = speed;
t.plugOptions.frequency = frequency;
t.plugOptions.depth = depth;
t.plugOptions.snapping = snapping;
return t;
}
#endregion
#if true // PHYSICS_MARKER
#region Rigidbody
/// <summary>Tweens a Rigidbody's position in a spiral shape.
/// Also stores the transform 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="axis">The axis around which the spiral will rotate</param>
/// <param name="mode">The type of spiral movement</param>
/// <param name="speed">Speed of the rotations</param>
/// <param name="frequency">Frequency of the rotation. Lower values lead to wider spirals</param>
/// <param name="depth">Indicates how much the tween should move along the spiral's axis</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOSpiral(
this Rigidbody target, float duration, Vector3? axis = null, SpiralMode mode = SpiralMode.Expand,
float speed = 1, float frequency = 10, float depth = 0, bool snapping = false
) {
if (Mathf.Approximately(speed, 0)) speed = 1;
if (axis == null || axis == Vector3.zero) axis = Vector3.forward;
TweenerCore<Vector3, Vector3, SpiralOptions> t = DOTween.To(SpiralPlugin.Get(), () => target.position, target.MovePosition, (Vector3)axis, duration)
.SetTarget(target);
t.plugOptions.mode = mode;
t.plugOptions.speed = speed;
t.plugOptions.frequency = frequency;
t.plugOptions.depth = depth;
t.plugOptions.snapping = snapping;
return t;
}
#endregion
#endif
#endregion
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c3190a1a1c53f449926f6d5542b4ce5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8fb0d65aa5b048649a3a785b82b8f8db
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,247 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2014/10/27 15:59
//
// License Copyright (c) Daniele Giardini.
// This work is subject to the terms at http://dotween.demigiant.com/license.php
#if false // MODULE_MARKER
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
namespace DG.Tweening
{
/// <summary>
/// Methods that extend 2D Toolkit objects and allow to directly create and control tweens from their instances.
/// </summary>
public static class ShortcutExtensionsTk2d
{
#region Sprite
/// <summary>Tweens a 2D Toolkit Sprite's dimensions to the given value.
/// Also stores the Sprite 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScale(this tk2dBaseSprite target, Vector3 endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a Sprite's dimensions to the given value.
/// Also stores the Sprite 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleX(this tk2dBaseSprite target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(endValue, 0, 0), duration);
t.SetOptions(AxisConstraint.X)
.SetTarget(target);
return t;
}
/// <summary>Tweens a Sprite's dimensions to the given value.
/// Also stores the Sprite 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleY(this tk2dBaseSprite target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(0, endValue, 0), duration);
t.SetOptions(AxisConstraint.Y)
.SetTarget(target);
return t;
}
/// <summary>Tweens a Sprite's dimensions to the given value.
/// Also stores the Sprite 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleZ(this tk2dBaseSprite target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(0, 0, endValue), duration);
t.SetOptions(AxisConstraint.Z)
.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit Sprite's color to the given value.
/// Also stores the Sprite 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 TweenerCore<Color, Color, ColorOptions> DOColor(this tk2dBaseSprite target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit Sprite's alpha color to the given value.
/// Also stores the Sprite 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 TweenerCore<Color, Color, ColorOptions> DOFade(this tk2dBaseSprite target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit Sprite'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 tk2dBaseSprite 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));
}
s.SetTarget(target);
return s;
}
#endregion
#region tk2dSlicedSprite
/// <summary>Tweens a 2D Toolkit SlicedSprite's dimensions to the given value.
/// Also stores the SlicedSprite 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 TweenerCore<Vector2, Vector2, VectorOptions> DOScaleDimensions(this tk2dSlicedSprite target, Vector2 endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.dimensions, x => target.dimensions = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a SlicedSprite's dimensions to the given value.
/// Also stores the SlicedSprite 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 TweenerCore<Vector2, Vector2, VectorOptions> DOScaleDimensionsX(this tk2dSlicedSprite target, float endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.dimensions, x => target.dimensions = x, new Vector2(endValue, 0), duration);
t.SetOptions(AxisConstraint.X)
.SetTarget(target);
return t;
}
/// <summary>Tweens a SlicedSprite's dimensions to the given value.
/// Also stores the SlicedSprite 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 TweenerCore<Vector2, Vector2, VectorOptions> DOScaleDimensionsY(this tk2dSlicedSprite target, float endValue, float duration)
{
TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.dimensions, x => target.dimensions = x, new Vector2(0, endValue), duration);
t.SetOptions(AxisConstraint.Y)
.SetTarget(target);
return t;
}
#endregion
#region TextMesh
/// <summary>Tweens a 2D Toolkit TextMesh's dimensions to the given value.
/// Also stores the TextMesh 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScale(this tk2dTextMesh target, Vector3 endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh's dimensions to the given value.
/// Also stores the TextMesh 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleX(this tk2dTextMesh target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(endValue, 0, 0), duration);
t.SetOptions(AxisConstraint.X)
.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh's dimensions to the given value.
/// Also stores the TextMesh 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleY(this tk2dTextMesh target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(0, endValue, 0), duration);
t.SetOptions(AxisConstraint.Y)
.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh's dimensions to the given value.
/// Also stores the TextMesh 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 TweenerCore<Vector3, Vector3, VectorOptions> DOScaleZ(this tk2dTextMesh target, float endValue, float duration)
{
TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(0, 0, endValue), duration);
t.SetOptions(AxisConstraint.Z)
.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh's color to the given value.
/// Also stores the TextMesh 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 TweenerCore<Color, Color, ColorOptions> DOColor(this tk2dTextMesh target, Color endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh's alpha color to the given value.
/// Also stores the TextMesh 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 TweenerCore<Color, Color, ColorOptions> DOFade(this tk2dTextMesh target, float endValue, float duration)
{
TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
t.SetTarget(target);
return t;
}
/// <summary>Tweens a 2D Toolkit TextMesh'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 tk2dTextMesh 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));
}
s.SetTarget(target);
return s;
}
/// <summary>Tweens a tk2dTextMesh's text to the given value.
/// Also stores the tk2dTextMesh 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 TweenerCore<string, string, StringOptions> DOText(this tk2dTextMesh target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
{
TweenerCore<string, string, StringOptions> t = DOTween.To(() => target.text, x => target.text = x, endValue, duration);
t.SetOptions(richTextEnabled, scrambleMode, scrambleChars)
.SetTarget(target);
return t;
}
#endregion
}
}
#endif

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b590cd7c24ffa5d4faa5b6fa993cccad
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f18446277e1d621419d56d93004f2031
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,750 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/03/12 16:03
using System;
using System.Collections.Generic;
using System.IO;
using DG.DemiEditor;
using DG.DOTweenEditor.Core;
using DG.DOTweenEditor.UI;
using DG.Tweening;
using DG.Tweening.Core;
using UnityEditor;
using UnityEngine;
using DOTweenSettings = DG.Tweening.Core.DOTweenSettings;
#if true // UI_MARKER
using UnityEngine.UI;
#endif
#if false // TEXTMESHPRO_MARKER
using TMPro;
#endif
namespace DG.DOTweenEditor
{
[CustomEditor(typeof(DOTweenAnimation))]
public class DOTweenAnimationInspector : ABSAnimationInspector
{
enum FadeTargetType
{
CanvasGroup,
Image
}
enum ChooseTargetMode
{
None,
BetweenCanvasGroupAndImage
}
static readonly Dictionary<DOTweenAnimation.AnimationType, Type[]> _AnimationTypeToComponent = new Dictionary<DOTweenAnimation.AnimationType, Type[]>() {
{ DOTweenAnimation.AnimationType.Move, new[] {
#if true // PHYSICS_MARKER
typeof(Rigidbody),
#endif
#if true // PHYSICS2D_MARKER
typeof(Rigidbody2D),
#endif
#if true // UI_MARKER
typeof(RectTransform),
#endif
typeof(Transform)
}},
{ DOTweenAnimation.AnimationType.Rotate, new[] {
#if true // PHYSICS_MARKER
typeof(Rigidbody),
#endif
#if true // PHYSICS2D_MARKER
typeof(Rigidbody2D),
#endif
typeof(Transform)
}},
{ DOTweenAnimation.AnimationType.LocalMove, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.LocalRotate, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.Scale, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.Color, new[] {
typeof(Light),
#if true // SPRITE_MARKER
typeof(SpriteRenderer),
#endif
#if true // UI_MARKER
typeof(Image), typeof(Text), typeof(RawImage), typeof(Graphic),
#endif
typeof(Renderer),
}},
{ DOTweenAnimation.AnimationType.Fade, new[] {
typeof(Light),
#if true // SPRITE_MARKER
typeof(SpriteRenderer),
#endif
#if true // UI_MARKER
typeof(Image), typeof(Text), typeof(CanvasGroup), typeof(RawImage), typeof(Graphic),
#endif
typeof(Renderer),
}},
#if true // UI_MARKER
{ DOTweenAnimation.AnimationType.Text, new[] { typeof(Text) } },
#endif
{ DOTweenAnimation.AnimationType.PunchPosition, new[] {
#if true // UI_MARKER
typeof(RectTransform),
#endif
typeof(Transform)
}},
{ DOTweenAnimation.AnimationType.PunchRotation, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.PunchScale, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.ShakePosition, new[] {
#if true // UI_MARKER
typeof(RectTransform),
#endif
typeof(Transform)
}},
{ DOTweenAnimation.AnimationType.ShakeRotation, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.ShakeScale, new[] { typeof(Transform) } },
{ DOTweenAnimation.AnimationType.CameraAspect, new[] { typeof(Camera) } },
{ DOTweenAnimation.AnimationType.CameraBackgroundColor, new[] { typeof(Camera) } },
{ DOTweenAnimation.AnimationType.CameraFieldOfView, new[] { typeof(Camera) } },
{ DOTweenAnimation.AnimationType.CameraOrthoSize, new[] { typeof(Camera) } },
{ DOTweenAnimation.AnimationType.CameraPixelRect, new[] { typeof(Camera) } },
{ DOTweenAnimation.AnimationType.CameraRect, new[] { typeof(Camera) } },
#if true // UI_MARKER
{ DOTweenAnimation.AnimationType.UIWidthHeight, new[] { typeof(RectTransform) } },
#endif
};
#if false // TK2D_MARKER
static readonly Dictionary<DOTweenAnimation.AnimationType, Type[]> _Tk2dAnimationTypeToComponent = new Dictionary<DOTweenAnimation.AnimationType, Type[]>() {
{ DOTweenAnimation.AnimationType.Scale, new[] { typeof(tk2dBaseSprite), typeof(tk2dTextMesh) } },
{ DOTweenAnimation.AnimationType.Color, new[] { typeof(tk2dBaseSprite), typeof(tk2dTextMesh) } },
{ DOTweenAnimation.AnimationType.Fade, new[] { typeof(tk2dBaseSprite), typeof(tk2dTextMesh) } },
{ DOTweenAnimation.AnimationType.Text, new[] { typeof(tk2dTextMesh) } }
};
#endif
#if false // TEXTMESHPRO_MARKER
static readonly Dictionary<DOTweenAnimation.AnimationType, Type[]> _TMPAnimationTypeToComponent = new Dictionary<DOTweenAnimation.AnimationType, Type[]>() {
{ DOTweenAnimation.AnimationType.Color, new[] { typeof(TextMeshPro), typeof(TextMeshProUGUI) } },
{ DOTweenAnimation.AnimationType.Fade, new[] { typeof(TextMeshPro), typeof(TextMeshProUGUI) } },
{ DOTweenAnimation.AnimationType.Text, new[] { typeof(TextMeshPro), typeof(TextMeshProUGUI) } }
};
#endif
static readonly string[] _AnimationType = new[] {
"None",
"Move", "LocalMove",
"Rotate", "LocalRotate",
"Scale",
"Color", "Fade",
#if true // UI_MARKER
"Text",
#endif
#if false // TK2D_MARKER
"Text",
#endif
#if false // TEXTMESHPRO_MARKER
"Text",
#endif
#if true // UI_MARKER
"UIWidthHeight",
#endif
"Punch/Position", "Punch/Rotation", "Punch/Scale",
"Shake/Position", "Shake/Rotation", "Shake/Scale",
"Camera/Aspect", "Camera/BackgroundColor", "Camera/FieldOfView", "Camera/OrthoSize", "Camera/PixelRect", "Camera/Rect"
};
static string[] _animationTypeNoSlashes; // _AnimationType list without slashes in values
static string[] _datString; // String representation of DOTweenAnimation enum (here for caching reasons)
DOTweenAnimation _src;
DOTweenSettings _settings;
bool _runtimeEditMode; // If TRUE allows to change and save stuff at runtime
bool _refreshRequired; // If TRUE refreshes components data
int _totComponentsOnSrc; // Used to determine if a Component is added or removed from the source
bool _isLightSrc; // Used to determine if we're tweening a Light, to set the max Fade value to more than 1
#pragma warning disable 414
ChooseTargetMode _chooseTargetMode = ChooseTargetMode.None;
#pragma warning restore 414
static readonly GUIContent _GuiC_selfTarget_true = new GUIContent(
"SELF", "Will animate components on this gameObject"
);
static readonly GUIContent _GuiC_selfTarget_false = new GUIContent(
"OTHER", "Will animate components on the given gameObject instead than on this one"
);
static readonly GUIContent _GuiC_tweenTargetIsTargetGO_true = new GUIContent(
"Use As Tween Target", "Will set the tween target (via SetTarget, used to control a tween directly from a target) to the \"OTHER\" gameObject"
);
static readonly GUIContent _GuiC_tweenTargetIsTargetGO_false = new GUIContent(
"Use As Tween Target", "Will set the tween target (via SetTarget, used to control a tween directly from a target) to the gameObject containing this animation, not the \"OTHER\" one"
);
#region MonoBehaviour Methods
void OnEnable()
{
_src = target as DOTweenAnimation;
_settings = DOTweenUtilityWindow.GetDOTweenSettings();
onStartProperty = base.serializedObject.FindProperty("onStart");
onPlayProperty = base.serializedObject.FindProperty("onPlay");
onUpdateProperty = base.serializedObject.FindProperty("onUpdate");
onStepCompleteProperty = base.serializedObject.FindProperty("onStepComplete");
onCompleteProperty = base.serializedObject.FindProperty("onComplete");
onRewindProperty = base.serializedObject.FindProperty("onRewind");
onTweenCreatedProperty = base.serializedObject.FindProperty("onTweenCreated");
// Convert _AnimationType to _animationTypeNoSlashes
int len = _AnimationType.Length;
_animationTypeNoSlashes = new string[len];
for (int i = 0; i < len; ++i) {
string a = _AnimationType[i];
a = a.Replace("/", "");
_animationTypeNoSlashes[i] = a;
}
}
void OnDisable()
{
DOTweenPreviewManager.StopAllPreviews();
}
override public void OnInspectorGUI()
{
base.OnInspectorGUI();
GUILayout.Space(3);
EditorGUIUtils.SetGUIStyles();
bool playMode = Application.isPlaying;
_runtimeEditMode = _runtimeEditMode && playMode;
GUILayout.BeginHorizontal();
EditorGUIUtils.InspectorLogo();
GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle);
// Up-down buttons
GUILayout.FlexibleSpace();
if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) UnityEditorInternal.ComponentUtility.MoveComponentUp(_src);
if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) UnityEditorInternal.ComponentUtility.MoveComponentDown(_src);
GUILayout.EndHorizontal();
if (playMode) {
if (_runtimeEditMode) {
} else {
GUILayout.Space(8);
GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle);
if (!_src.isActive) {
GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle);
GUI.enabled = false;
}
if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) {
_runtimeEditMode = true;
}
GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle);
GUILayout.Space(10);
if (!_runtimeEditMode) return;
}
}
Undo.RecordObject(_src, "DOTween Animation");
Undo.RecordObject(_settings, "DOTween Animation");
// _src.isValid = Validate(); // Moved down
EditorGUIUtility.labelWidth = 110;
if (playMode) {
GUILayout.Space(4);
DeGUILayout.Toolbar("Edit Mode Commands");
DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop);
GUILayout.BeginHorizontal();
if (GUILayout.Button("TogglePause")) _src.tween.TogglePause();
if (GUILayout.Button("Rewind")) _src.tween.Rewind();
if (GUILayout.Button("Restart")) _src.tween.Restart();
GUILayout.EndHorizontal();
if (GUILayout.Button("Commit changes and restart")) {
_src.tween.Rewind();
_src.tween.Kill();
if (_src.isValid) {
_src.CreateTween();
_src.tween.Play();
}
}
GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap);
DeGUILayout.EndVBox();
} else {
GUILayout.BeginHorizontal();
bool hasManager = _src.GetComponent<DOTweenVisualManager>() != null;
EditorGUI.BeginChangeCheck();
_settings.showPreviewPanel = hasManager
? DeGUILayout.ToggleButton(_settings.showPreviewPanel, "Preview Controls", styles.custom.inlineToggle)
: DeGUILayout.ToggleButton(_settings.showPreviewPanel, "Preview Controls", styles.custom.inlineToggle, GUILayout.Width(120));
if (EditorGUI.EndChangeCheck()) {
EditorUtility.SetDirty(_settings);
DOTweenPreviewManager.StopAllPreviews();
}
if (!hasManager) {
if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) {
_src.gameObject.AddComponent<DOTweenVisualManager>();
}
}
GUILayout.EndHorizontal();
}
// Preview in editor
bool isPreviewing = _settings.showPreviewPanel ? DOTweenPreviewManager.PreviewGUI(_src) : false;
EditorGUI.BeginDisabledGroup(isPreviewing);
// Choose target
GUILayout.BeginHorizontal();
_src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(14));
EditorGUI.BeginChangeCheck();
EditorGUI.BeginChangeCheck();
_src.targetIsSelf = DeGUILayout.ToggleButton(
_src.targetIsSelf, _src.targetIsSelf ? _GuiC_selfTarget_true : _GuiC_selfTarget_false,
new Color(1f, 0.78f, 0f), DeGUI.colors.bg.toggleOn, new Color(0.33f, 0.14f, 0.02f), DeGUI.colors.content.toggleOn,
null, GUILayout.Width(47)
);
bool innerChanged = EditorGUI.EndChangeCheck();
if (innerChanged) {
_src.targetGO = null;
GUI.changed = true;
}
if (_src.targetIsSelf) GUILayout.Label(_GuiC_selfTarget_true.tooltip);
else {
using (new DeGUI.ColorScope(null, null, _src.targetGO == null ? Color.red : Color.white)) {
_src.targetGO = (GameObject)EditorGUILayout.ObjectField(_src.targetGO, typeof(GameObject), true);
}
_src.tweenTargetIsTargetGO = DeGUILayout.ToggleButton(
_src.tweenTargetIsTargetGO, _src.tweenTargetIsTargetGO ? _GuiC_tweenTargetIsTargetGO_true : _GuiC_tweenTargetIsTargetGO_false,
GUILayout.Width(131)
);
}
bool check = EditorGUI.EndChangeCheck();
if (check) _refreshRequired = true;
GUILayout.EndHorizontal();
GameObject targetGO = _src.targetIsSelf ? _src.gameObject : _src.targetGO;
if (targetGO == null) {
// Uses external target gameObject but it's not set
if (_src.targetGO != null || _src.target != null) {
_src.targetGO = null;
_src.target = null;
GUI.changed = true;
}
} else {
GUILayout.BeginHorizontal();
DOTweenAnimation.AnimationType prevAnimType = _src.animationType;
// _src.animationType = (DOTweenAnimation.AnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton);
GUI.enabled = GUI.enabled && _src.isActive;
_src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]);
_src.autoGenerate = DeGUILayout.ToggleButton(_src.autoGenerate, new GUIContent("AutoGenerate", "If selected, the tween will be generated at startup (during Start for RectTransform position tween, Awake for all the others)"));
if (_src.autoGenerate) {
_src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"));
}
_src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"));
GUILayout.EndHorizontal();
if (prevAnimType != _src.animationType) {
// Set default optional values based on animation type
_src.endValueTransform = null;
_src.useTargetAsV3 = false;
switch (_src.animationType) {
case DOTweenAnimation.AnimationType.Move:
case DOTweenAnimation.AnimationType.LocalMove:
case DOTweenAnimation.AnimationType.Rotate:
case DOTweenAnimation.AnimationType.LocalRotate:
case DOTweenAnimation.AnimationType.Scale:
_src.endValueV3 = Vector3.zero;
_src.endValueFloat = 0;
_src.optionalBool0 = _src.animationType == DOTweenAnimation.AnimationType.Scale;
break;
case DOTweenAnimation.AnimationType.UIWidthHeight:
_src.endValueV3 = Vector3.zero;
_src.endValueFloat = 0;
_src.optionalBool0 = _src.animationType == DOTweenAnimation.AnimationType.UIWidthHeight;
break;
case DOTweenAnimation.AnimationType.Color:
case DOTweenAnimation.AnimationType.Fade:
_isLightSrc = targetGO.GetComponent<Light>() != null;
_src.endValueFloat = 0;
break;
case DOTweenAnimation.AnimationType.Text:
_src.optionalBool0 = true;
break;
case DOTweenAnimation.AnimationType.PunchPosition:
case DOTweenAnimation.AnimationType.PunchRotation:
case DOTweenAnimation.AnimationType.PunchScale:
_src.endValueV3 = _src.animationType == DOTweenAnimation.AnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one;
_src.optionalFloat0 = 1;
_src.optionalInt0 = 10;
_src.optionalBool0 = false;
break;
case DOTweenAnimation.AnimationType.ShakePosition:
case DOTweenAnimation.AnimationType.ShakeRotation:
case DOTweenAnimation.AnimationType.ShakeScale:
_src.endValueV3 = _src.animationType == DOTweenAnimation.AnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one;
_src.optionalInt0 = 10;
_src.optionalFloat0 = 90;
_src.optionalBool0 = false;
_src.optionalBool1 = true;
break;
case DOTweenAnimation.AnimationType.CameraAspect:
case DOTweenAnimation.AnimationType.CameraFieldOfView:
case DOTweenAnimation.AnimationType.CameraOrthoSize:
_src.endValueFloat = 0;
break;
case DOTweenAnimation.AnimationType.CameraPixelRect:
case DOTweenAnimation.AnimationType.CameraRect:
_src.endValueRect = new Rect(0, 0, 0, 0);
break;
}
}
if (_src.animationType == DOTweenAnimation.AnimationType.None) {
_src.isValid = false;
if (GUI.changed) EditorUtility.SetDirty(_src);
return;
}
if (_refreshRequired || prevAnimType != _src.animationType || ComponentsChanged()) {
_refreshRequired = false;
_src.isValid = Validate(targetGO);
// See if we need to choose between multiple targets
#if true // UI_MARKER
if (_src.animationType == DOTweenAnimation.AnimationType.Fade && targetGO.GetComponent<CanvasGroup>() != null && targetGO.GetComponent<Image>() != null) {
_chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage;
// Reassign target and forcedTargetType if lost
if (_src.forcedTargetType == DOTweenAnimation.TargetType.Unset) _src.forcedTargetType = _src.targetType;
switch (_src.forcedTargetType) {
case DOTweenAnimation.TargetType.CanvasGroup:
_src.target = targetGO.GetComponent<CanvasGroup>();
break;
case DOTweenAnimation.TargetType.Image:
_src.target = targetGO.GetComponent<Image>();
break;
}
} else {
#endif
_chooseTargetMode = ChooseTargetMode.None;
_src.forcedTargetType = DOTweenAnimation.TargetType.Unset;
#if true // UI_MARKER
}
#endif
}
if (!_src.isValid) {
GUI.color = Color.red;
GUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle);
GUILayout.EndVertical();
GUI.color = Color.white;
if (GUI.changed) EditorUtility.SetDirty(_src);
return;
}
#if true // UI_MARKER
// Special cases in which multiple target types could be used (set after validation)
if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != DOTweenAnimation.TargetType.Unset) {
FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString());
DOTweenAnimation.TargetType prevTargetType = _src.forcedTargetType;
_src.forcedTargetType = (DOTweenAnimation.TargetType)Enum.Parse(typeof(DOTweenAnimation.TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString());
if (_src.forcedTargetType != prevTargetType) {
// Target type change > assign correct target
switch (_src.forcedTargetType) {
case DOTweenAnimation.TargetType.CanvasGroup:
_src.target = targetGO.GetComponent<CanvasGroup>();
break;
case DOTweenAnimation.TargetType.Image:
_src.target = targetGO.GetComponent<Image>();
break;
}
}
}
#endif
GUILayout.BeginHorizontal();
_src.duration = EditorGUILayout.FloatField("Duration", _src.duration);
if (_src.duration < 0) _src.duration = 0;
_src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75));
GUILayout.EndHorizontal();
_src.delay = EditorGUILayout.FloatField("Delay", _src.delay);
if (_src.delay < 0) _src.delay = 0;
_src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
_src.easeType = EditorGUIUtils.FilteredEasePopup("Ease", _src.easeType);
if (_src.easeType == Ease.INTERNAL_Custom) {
_src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", _src.easeCurve);
}
_src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops);
if (_src.loops < -1) _src.loops = -1;
if (_src.loops > 1 || _src.loops == -1)
_src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _src.loopType);
_src.id = EditorGUILayout.TextField("ID", _src.id);
bool canBeRelative = true;
// End value and eventual specific options
switch (_src.animationType) {
case DOTweenAnimation.AnimationType.Move:
case DOTweenAnimation.AnimationType.LocalMove:
GUIEndValueV3(targetGO, _src.animationType == DOTweenAnimation.AnimationType.Move);
_src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0);
canBeRelative = !_src.useTargetAsV3;
break;
case DOTweenAnimation.AnimationType.Rotate:
case DOTweenAnimation.AnimationType.LocalRotate:
bool isRigidbody2D = DOTweenModuleUtils.Physics.HasRigidbody2D(_src);
if (isRigidbody2D) GUIEndValueFloat();
else {
GUIEndValueV3(targetGO);
_src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup(" Rotation Mode", _src.optionalRotationMode);
}
break;
case DOTweenAnimation.AnimationType.Scale:
if (_src.optionalBool0) GUIEndValueFloat();
else GUIEndValueV3(targetGO);
_src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
break;
case DOTweenAnimation.AnimationType.UIWidthHeight:
if (_src.optionalBool0) GUIEndValueFloat();
else GUIEndValueV2();
_src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
break;
case DOTweenAnimation.AnimationType.Color:
GUIEndValueColor();
canBeRelative = false;
break;
case DOTweenAnimation.AnimationType.Fade:
GUIEndValueFloat();
if (_src.endValueFloat < 0) _src.endValueFloat = 0;
if (!_isLightSrc && _src.endValueFloat > 1) _src.endValueFloat = 1;
canBeRelative = false;
break;
case DOTweenAnimation.AnimationType.Text:
GUIEndValueString();
_src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0);
_src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode);
_src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString);
break;
case DOTweenAnimation.AnimationType.PunchPosition:
case DOTweenAnimation.AnimationType.PunchRotation:
case DOTweenAnimation.AnimationType.PunchScale:
GUIEndValueV3(targetGO);
canBeRelative = false;
_src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50);
_src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1);
if (_src.animationType == DOTweenAnimation.AnimationType.PunchPosition) _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0);
break;
case DOTweenAnimation.AnimationType.ShakePosition:
case DOTweenAnimation.AnimationType.ShakeRotation:
case DOTweenAnimation.AnimationType.ShakeScale:
GUIEndValueV3(targetGO);
canBeRelative = false;
_src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50);
_src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90);
_src.optionalBool1 = EditorGUILayout.Toggle(new GUIContent(" FadeOut", "If selected the shake will fade out, otherwise it will constantly play with full force"), _src.optionalBool1);
if (_src.animationType == DOTweenAnimation.AnimationType.ShakePosition) _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0);
break;
case DOTweenAnimation.AnimationType.CameraAspect:
case DOTweenAnimation.AnimationType.CameraFieldOfView:
case DOTweenAnimation.AnimationType.CameraOrthoSize:
GUIEndValueFloat();
canBeRelative = false;
break;
case DOTweenAnimation.AnimationType.CameraBackgroundColor:
GUIEndValueColor();
canBeRelative = false;
break;
case DOTweenAnimation.AnimationType.CameraPixelRect:
case DOTweenAnimation.AnimationType.CameraRect:
GUIEndValueRect();
canBeRelative = false;
break;
}
// Final settings
if (canBeRelative) _src.isRelative = EditorGUILayout.Toggle(" Relative", _src.isRelative);
// Events
AnimationInspectorGUI.AnimationEvents(this, _src);
}
EditorGUI.EndDisabledGroup();
if (GUI.changed) EditorUtility.SetDirty(_src);
}
#endregion
#region Methods
// Returns TRUE if the Component layout on the src gameObject changed (a Component was added or removed)
bool ComponentsChanged()
{
int prevTotComponentsOnSrc = _totComponentsOnSrc;
_totComponentsOnSrc = _src.gameObject.GetComponents<Component>().Length;
return prevTotComponentsOnSrc != _totComponentsOnSrc;
}
// Checks if a Component that can be animated with the given animationType is attached to the src
bool Validate(GameObject targetGO)
{
if (_src.animationType == DOTweenAnimation.AnimationType.None) return false;
Component srcTarget;
// First check for external plugins
#if false // TK2D_MARKER
if (_Tk2dAnimationTypeToComponent.ContainsKey(_src.animationType)) {
foreach (Type t in _Tk2dAnimationTypeToComponent[_src.animationType]) {
srcTarget = targetGO.GetComponent(t);
if (srcTarget != null) {
_src.target = srcTarget;
_src.targetType = DOTweenAnimation.TypeToDOTargetType(t);
return true;
}
}
}
#endif
#if false // TEXTMESHPRO_MARKER
if (_TMPAnimationTypeToComponent.ContainsKey(_src.animationType)) {
foreach (Type t in _TMPAnimationTypeToComponent[_src.animationType]) {
srcTarget = targetGO.GetComponent(t);
if (srcTarget != null) {
_src.target = srcTarget;
_src.targetType = DOTweenAnimation.TypeToDOTargetType(t);
return true;
}
}
}
#endif
// Then check for regular stuff
if (_AnimationTypeToComponent.ContainsKey(_src.animationType)) {
foreach (Type t in _AnimationTypeToComponent[_src.animationType]) {
srcTarget = targetGO.GetComponent(t);
if (srcTarget != null) {
_src.target = srcTarget;
_src.targetType = DOTweenAnimation.TypeToDOTargetType(t);
return true;
}
}
}
return false;
}
DOTweenAnimation.AnimationType AnimationToDOTweenAnimationType(string animation)
{
if (_datString == null) _datString = Enum.GetNames(typeof(DOTweenAnimation.AnimationType));
animation = animation.Replace("/", "");
return (DOTweenAnimation.AnimationType)(Array.IndexOf(_datString, animation));
}
int DOTweenAnimationTypeToPopupId(DOTweenAnimation.AnimationType animation)
{
return Array.IndexOf(_animationTypeNoSlashes, animation.ToString());
}
#endregion
#region GUI Draw Methods
void GUIEndValueFloat()
{
GUILayout.BeginHorizontal();
GUIToFromButton();
_src.endValueFloat = EditorGUILayout.FloatField(_src.endValueFloat);
GUILayout.EndHorizontal();
}
void GUIEndValueColor()
{
GUILayout.BeginHorizontal();
GUIToFromButton();
_src.endValueColor = EditorGUILayout.ColorField(_src.endValueColor);
GUILayout.EndHorizontal();
}
void GUIEndValueV3(GameObject targetGO, bool optionalTransform = false)
{
GUILayout.BeginHorizontal();
GUIToFromButton();
if (_src.useTargetAsV3) {
Transform prevT = _src.endValueTransform;
_src.endValueTransform = EditorGUILayout.ObjectField(_src.endValueTransform, typeof(Transform), true) as Transform;
if (_src.endValueTransform != prevT && _src.endValueTransform != null) {
#if true // UI_MARKER
// Check that it's a Transform for a Transform or a RectTransform for a RectTransform
if (targetGO.GetComponent<RectTransform>() != null) {
if (_src.endValueTransform.GetComponent<RectTransform>() == null) {
EditorUtility.DisplayDialog("DOTween Pro", "For Unity UI elements, the target must also be a UI element", "Ok");
_src.endValueTransform = null;
}
} else if (_src.endValueTransform.GetComponent<RectTransform>() != null) {
EditorUtility.DisplayDialog("DOTween Pro", "You can't use a UI target for a non UI object", "Ok");
_src.endValueTransform = null;
}
#endif
}
} else {
_src.endValueV3 = EditorGUILayout.Vector3Field("", _src.endValueV3, GUILayout.Height(16));
}
if (optionalTransform) {
if (GUILayout.Button(_src.useTargetAsV3 ? "target" : "value", EditorGUIUtils.sideBtStyle, GUILayout.Width(44))) _src.useTargetAsV3 = !_src.useTargetAsV3;
}
GUILayout.EndHorizontal();
#if true // UI_MARKER
if (_src.useTargetAsV3 && _src.endValueTransform != null && _src.target is RectTransform) {
EditorGUILayout.HelpBox("NOTE: when using a UI target, the tween will be created during Start instead of Awake", MessageType.Info);
}
#endif
}
void GUIEndValueV2()
{
GUILayout.BeginHorizontal();
GUIToFromButton();
_src.endValueV2 = EditorGUILayout.Vector2Field("", _src.endValueV2, GUILayout.Height(16));
GUILayout.EndHorizontal();
}
void GUIEndValueString()
{
GUILayout.BeginHorizontal();
GUIToFromButton();
_src.endValueString = EditorGUILayout.TextArea(_src.endValueString, EditorGUIUtils.wordWrapTextArea);
GUILayout.EndHorizontal();
}
void GUIEndValueRect()
{
GUILayout.BeginHorizontal();
GUIToFromButton();
_src.endValueRect = EditorGUILayout.RectField(_src.endValueRect);
GUILayout.EndHorizontal();
}
void GUIToFromButton()
{
if (GUILayout.Button(_src.isFrom ? "FROM" : "TO", EditorGUIUtils.sideBtStyle, GUILayout.Width(90))) _src.isFrom = !_src.isFrom;
GUILayout.Space(16);
}
#endregion
}
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
[InitializeOnLoad]
static class Initializer
{
static Initializer()
{
DOTweenAnimation.OnReset += OnReset;
}
static void OnReset(DOTweenAnimation src)
{
DOTweenSettings settings = DOTweenUtilityWindow.GetDOTweenSettings();
if (settings == null) return;
Undo.RecordObject(src, "DOTweenAnimation");
src.autoPlay = settings.defaultAutoPlay == AutoPlay.All || settings.defaultAutoPlay == AutoPlay.AutoPlayTweeners;
src.autoKill = settings.defaultAutoKill;
EditorUtility.SetDirty(src);
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e0203fd81362bab4d842d87ad09ee76e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,263 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/03/12 16:03
using System;
using System.Collections.Generic;
using DG.DemiEditor;
using DG.DemiLib;
using DG.Tweening;
using DG.Tweening.Core;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using Object = UnityEngine.Object;
namespace DG.DOTweenEditor
{
public static class DOTweenPreviewManager
{
static bool _previewOnlyIfSetToAutoPlay = true;
static readonly Dictionary<DOTweenAnimation,TweenInfo> _AnimationToTween = new Dictionary<DOTweenAnimation,TweenInfo>();
static readonly List<DOTweenAnimation> _TmpKeys = new List<DOTweenAnimation>();
#region Public Methods & GUI
/// <summary>
/// Returns TRUE if its actually previewing animations
/// </summary>
public static bool PreviewGUI(DOTweenAnimation src)
{
if (EditorApplication.isPlaying) return false;
Styles.Init();
bool isPreviewing = _AnimationToTween.Count > 0;
bool isPreviewingThis = isPreviewing && _AnimationToTween.ContainsKey(src);
// Preview in editor
GUI.backgroundColor = isPreviewing
? new DeSkinColor(new Color(0.49f, 0.8f, 0.86f), new Color(0.15f, 0.26f, 0.35f))
: new DeSkinColor(Color.white, new Color(0.13f, 0.13f, 0.13f));
GUILayout.BeginVertical(Styles.previewBox);
DeGUI.ResetGUIColors();
GUILayout.BeginHorizontal();
GUILayout.Label("Preview Mode - Experimental", Styles.previewLabel);
_previewOnlyIfSetToAutoPlay = DeGUILayout.ToggleButton(
_previewOnlyIfSetToAutoPlay,
new GUIContent("AutoPlay only", "If toggled only previews animations that have AutoPlay turned ON"),
Styles.btOption
);
GUILayout.EndHorizontal();
GUILayout.Space(1);
// Preview - Play
GUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(
isPreviewingThis || src.animationType == DOTweenAnimation.AnimationType.None
|| !src.isActive || _previewOnlyIfSetToAutoPlay && !src.autoPlay
);
if (GUILayout.Button("► Play", Styles.btPreview)) {
if (!isPreviewing) StartupGlobalPreview();
AddAnimationToGlobalPreview(src);
}
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(isPreviewing);
if (GUILayout.Button("► Play All <i>on GameObject</i>", Styles.btPreview)) {
if (!isPreviewing) StartupGlobalPreview();
DOTweenAnimation[] anims = src.gameObject.GetComponents<DOTweenAnimation>();
foreach (DOTweenAnimation anim in anims) AddAnimationToGlobalPreview(anim);
}
if (GUILayout.Button("► Play All <i>in Scene</i>", Styles.btPreview)) {
if (!isPreviewing) StartupGlobalPreview();
DOTweenAnimation[] anims = Object.FindObjectsOfType<DOTweenAnimation>();
foreach (DOTweenAnimation anim in anims) AddAnimationToGlobalPreview(anim);
}
EditorGUI.EndDisabledGroup();
GUILayout.EndHorizontal();
// Preview - Stop
GUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(!isPreviewingThis);
if (GUILayout.Button("■ Stop", Styles.btPreview)) {
if (_AnimationToTween.ContainsKey(src)) StopPreview(_AnimationToTween[src].tween);
}
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(!isPreviewing);
if (GUILayout.Button("■ Stop All <i>on GameObject</i>", Styles.btPreview)) {
StopPreview(src.gameObject);
}
if (GUILayout.Button("■ Stop All <i>in Scene</i>", Styles.btPreview)) {
StopAllPreviews();
}
EditorGUI.EndDisabledGroup();
GUILayout.EndHorizontal();
if (isPreviewing) {
int playingTweens = 0;
int completedTweens = 0;
int pausedTweens = 0;
foreach (KeyValuePair<DOTweenAnimation, TweenInfo> kvp in _AnimationToTween) {
Tween t = kvp.Value.tween;
if (t.IsPlaying()) playingTweens++;
else if (t.IsComplete()) completedTweens++;
else pausedTweens++;
}
GUILayout.Label("Playing Tweens: " + playingTweens, Styles.previewStatusLabel);
GUILayout.Label("Completed Tweens: " + completedTweens, Styles.previewStatusLabel);
// GUILayout.Label("Paused Tweens: " + playingTweens);
}
GUILayout.EndVertical();
return isPreviewing;
}
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5)
public static void StopAllPreviews(PlayModeStateChange state)
{
StopAllPreviews();
}
#endif
public static void StopAllPreviews()
{
_TmpKeys.Clear();
foreach (KeyValuePair<DOTweenAnimation,TweenInfo> kvp in _AnimationToTween) {
_TmpKeys.Add(kvp.Key);
}
StopPreview(_TmpKeys);
_TmpKeys.Clear();
_AnimationToTween.Clear();
DOTweenEditorPreview.Stop();
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5
UnityEditor.EditorApplication.playmodeStateChanged -= StopAllPreviews;
#else
UnityEditor.EditorApplication.playModeStateChanged -= StopAllPreviews;
#endif
// EditorApplication.playmodeStateChanged -= StopAllPreviews;
InternalEditorUtility.RepaintAllViews();
}
#endregion
#region Methods
static void StartupGlobalPreview()
{
DOTweenEditorPreview.Start();
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5
UnityEditor.EditorApplication.playmodeStateChanged += StopAllPreviews;
#else
UnityEditor.EditorApplication.playModeStateChanged += StopAllPreviews;
#endif
// EditorApplication.playmodeStateChanged += StopAllPreviews;
}
static void AddAnimationToGlobalPreview(DOTweenAnimation src)
{
if (!src.isActive) return; // Ignore sources whose tweens have been set to inactive
if (_previewOnlyIfSetToAutoPlay && !src.autoPlay) return;
Tween t = src.CreateEditorPreview();
_AnimationToTween.Add(src, new TweenInfo(src, t, src.isFrom));
// Tween setup
DOTweenEditorPreview.PrepareTweenForPreview(t);
}
static void StopPreview(GameObject go)
{
_TmpKeys.Clear();
foreach (KeyValuePair<DOTweenAnimation,TweenInfo> kvp in _AnimationToTween) {
if (kvp.Key.gameObject != go) continue;
_TmpKeys.Add(kvp.Key);
}
StopPreview(_TmpKeys);
_TmpKeys.Clear();
if (_AnimationToTween.Count == 0) StopAllPreviews();
else InternalEditorUtility.RepaintAllViews();
}
static void StopPreview(Tween t)
{
TweenInfo tInfo = null;
foreach (KeyValuePair<DOTweenAnimation,TweenInfo> kvp in _AnimationToTween) {
if (kvp.Value.tween != t) continue;
tInfo = kvp.Value;
_AnimationToTween.Remove(kvp.Key);
break;
}
if (tInfo == null) {
Debug.LogWarning("DOTween Preview ► Couldn't find tween to stop");
return;
}
if (tInfo.isFrom) {
int totLoops = tInfo.tween.Loops();
if (totLoops < 0 || totLoops > 1) {
tInfo.tween.Goto(tInfo.tween.Duration(false));
} else tInfo.tween.Complete();
} else tInfo.tween.Rewind();
tInfo.tween.Kill();
EditorUtility.SetDirty(tInfo.animation); // Refresh views
if (_AnimationToTween.Count == 0) StopAllPreviews();
else InternalEditorUtility.RepaintAllViews();
}
// Stops while iterating inversely, which deals better with tweens that overwrite each other
static void StopPreview(List<DOTweenAnimation> keys)
{
for (int i = keys.Count - 1; i > -1; --i) {
DOTweenAnimation anim = keys[i];
TweenInfo tInfo = _AnimationToTween[anim];
if (tInfo.isFrom) {
int totLoops = tInfo.tween.Loops();
if (totLoops < 0 || totLoops > 1) {
tInfo.tween.Goto(tInfo.tween.Duration(false));
} else tInfo.tween.Complete();
} else tInfo.tween.Rewind();
tInfo.tween.Kill();
EditorUtility.SetDirty(anim); // Refresh views
_AnimationToTween.Remove(anim);
}
}
#endregion
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
class TweenInfo
{
public DOTweenAnimation animation;
public Tween tween;
public bool isFrom;
public TweenInfo(DOTweenAnimation animation, Tween tween, bool isFrom)
{
this.animation = animation;
this.tween = tween;
this.isFrom = isFrom;
}
}
static class Styles
{
static bool _initialized;
public static GUIStyle previewBox, previewLabel, btOption, btPreview, previewStatusLabel;
public static void Init()
{
if (_initialized) return;
_initialized = true;
previewBox = new GUIStyle(GUI.skin.box).Clone().Padding(1, 1, 0, 3)
.Background(DeStylePalette.squareBorderCurved_darkBorders).Border(7, 7, 7, 7);
previewLabel = new GUIStyle(GUI.skin.label).Clone(10, FontStyle.Bold).Padding(1, 0, 3, 0).Margin(3, 6, 0, 0).StretchWidth(false);
btOption = DeGUI.styles.button.bBlankBorderCompact.MarginBottom(2).MarginRight(4);
btPreview = EditorStyles.miniButton.Clone(Format.RichText);
previewStatusLabel = EditorStyles.miniLabel.Clone().Padding(4, 0, 0, 0).Margin(0);
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22292a5f27a9a644ba9e6ad1bf863531
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: a6402d4311c862b4eb1325590d6466af
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d5ead26a750b3c64bb28773a90a95fc3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22e137d8c40d64441b7d22cc9c899055
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 54be29b67d0d29a478da2c6e5c62f091
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2483b07572a7a0147b554cd9a0c382b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 202f9ddaf2c1a8a429504f7f3cd7b84f
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Prefabs.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5287d9320a7a07e43a9402a4850122d1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,666 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &230337080
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 230337081}
- component: {fileID: 230337083}
- component: {fileID: 230337082}
m_Layer: 5
m_Name: code
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &230337081
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 230337080}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2064988582187225391}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 879}
m_SizeDelta: {x: 775.5948, y: 155.1736}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &230337083
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 230337080}
m_CullTransparentMesh: 1
--- !u!114 &230337082
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 230337080}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 66
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 66
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!1 &1640741503
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1640741504}
- component: {fileID: 1640741506}
- component: {fileID: 1640741505}
m_Layer: 5
m_Name: data
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1640741504
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640741503}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2064988582187225391}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -147.43347}
m_SizeDelta: {x: 775.5948, y: 528.0406}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1640741506
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640741503}
m_CullTransparentMesh: 1
--- !u!114 &1640741505
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640741503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 66
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 66
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!1 &2035195015
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2035195016}
- component: {fileID: 2035195018}
- component: {fileID: 2035195017}
m_Layer: 5
m_Name: msg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2035195016
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2035195015}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2064988582187225391}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 445}
m_SizeDelta: {x: 775.5948, y: 155.1736}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2035195018
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2035195015}
m_CullTransparentMesh: 1
--- !u!114 &2035195017
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2035195015}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 66
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 66
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!1 &2064988581257965615
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064988581257965614}
- component: {fileID: 2064988581257965608}
- component: {fileID: 2064988581257965609}
- component: {fileID: 2064988581257965605}
- component: {fileID: 2064988581257965610}
- component: {fileID: 2064988581257965611}
m_Layer: 5
m_Name: LeftBoard
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2064988581257965614
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2064988582965767865}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1140, y: 0}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &2064988581257965608
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_CullTransparentMesh: 1
--- !u!114 &2064988581257965609
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!114 &2064988581257965605
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35bf0bd4ded61a34f9be34f6738e4010, type: 3}
m_Name:
m_EditorClassIdentifier:
_url:
_width: 512
_height: 512
generateMipmap: 0
baseColor:
serializedVersion: 2
rgba: 0
_zoom: 0
allowContextMenuOn: 2
newWindowAction: 2
--- !u!114 &2064988581257965610
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9f0449828438f1c4eb0712205cc11bb7, type: 3}
m_Name:
m_EditorClassIdentifier:
dragMovementThreshold: 0
viewCamera: {fileID: 0}
enableMouseInput: 1
enableTouchInput: 1
enableFPSInput: 0
enableVRInput: 0
maxDistance: Infinity
disableMouseEmulation: 0
enableInput: 1
automaticResize: 1
--- !u!114 &2064988581257965611
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581257965615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b27bad8d50722bb4083b964da1d1cae4, type: 3}
m_Name:
m_EditorClassIdentifier:
cursorNormallyVisible: 1
--- !u!1 &2064988581488332674
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064988581488332701}
- component: {fileID: 2064988581488332696}
- component: {fileID: 2064988581488332697}
- component: {fileID: 2064988581488332702}
- component: {fileID: 2064988581488332703}
- component: {fileID: 2064988581488332700}
m_Layer: 5
m_Name: RightBoard
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2064988581488332701
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2064988582965767865}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1140, y: 0}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &2064988581488332696
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_CullTransparentMesh: 1
--- !u!114 &2064988581488332697
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!114 &2064988581488332702
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35bf0bd4ded61a34f9be34f6738e4010, type: 3}
m_Name:
m_EditorClassIdentifier:
_url:
_width: 512
_height: 512
generateMipmap: 0
baseColor:
serializedVersion: 2
rgba: 0
_zoom: 0
allowContextMenuOn: 2
newWindowAction: 2
--- !u!114 &2064988581488332703
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9f0449828438f1c4eb0712205cc11bb7, type: 3}
m_Name:
m_EditorClassIdentifier:
dragMovementThreshold: 0
viewCamera: {fileID: 0}
enableMouseInput: 1
enableTouchInput: 1
enableFPSInput: 0
enableVRInput: 0
maxDistance: Infinity
disableMouseEmulation: 0
enableInput: 1
automaticResize: 1
--- !u!114 &2064988581488332700
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988581488332674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b27bad8d50722bb4083b964da1d1cae4, type: 3}
m_Name:
m_EditorClassIdentifier:
cursorNormallyVisible: 1
--- !u!1 &2064988582187225427
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064988582187225391}
- component: {fileID: 2064988582187225388}
- component: {fileID: 2064988582187225389}
- component: {fileID: 2064988582187225426}
m_Layer: 5
m_Name: BulletinBoard
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2064988582187225391
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582187225427}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2064988582965767865}
- {fileID: 230337081}
- {fileID: 2035195016}
- {fileID: 1640741504}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!223 &2064988582187225388
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582187225427}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &2064988582187225389
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582187225427}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 3840, y: 2160}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!114 &2064988582187225426
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582187225427}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!1 &2064988582965767870
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064988582965767865}
- component: {fileID: 2064988582965767864}
m_Layer: 5
m_Name: Boards
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2064988582965767865
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582965767870}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2064988581257965614}
- {fileID: 2064988581488332701}
m_Father: {fileID: 2064988582187225391}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2064988582965767864
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064988582965767870}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eec04440ce1a5864a8a98c67ef786586, type: 3}
m_Name:
m_EditorClassIdentifier:
bullerinBoards:
- {fileID: 2064988581257965605}
- {fileID: 2064988581488332702}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a58bdddf03c0d8c4db53fb2316615584
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Prefabs/HUD.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fd0e6e76dd60f0b4789e04b4d22a7914
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,150 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8992645734443754309
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8992645734443754306}
- component: {fileID: 8992645734443754307}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8992645734443754306
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8992645734443754309}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.499, z: 0}
m_LocalScale: {x: 0.22218, y: 0.22218, z: 0.22218}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8992645734844834622}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8992645734443754307
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8992645734443754309}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 1705ebcb01175a54ba549314203ad4fc, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8992645734844834592
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8992645734844834622}
- component: {fileID: 8992645734844834593}
- component: {fileID: 355914467147041394}
m_Layer: 0
m_Name: StationInformation
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8992645734844834622
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8992645734844834592}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.419, y: 0.423, z: 0.909}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8992645734443754306}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8992645734844834593
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8992645734844834592}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 58e2fbd82adbcd14aac54bb85f5464ce, type: 3}
m_Name:
m_EditorClassIdentifier:
worldOrLocal: 0
lockXZ: 0
onClick:
m_PersistentCalls:
m_Calls: []
--- !u!65 &355914467147041394
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8992645734844834592}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 0.3}
m_Center: {x: 0, y: 0.5, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6fe0e639b544b9b44aa22ea2bb34e59c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,424 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!114 &230337082 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 230337082, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
m_PrefabInstance: {fileID: 2064988581258076397}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &856809286
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 856809289}
- component: {fileID: 856809288}
- component: {fileID: 856809287}
- component: {fileID: 856809290}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &856809287
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856809286}
m_Enabled: 1
--- !u!20 &856809288
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856809286}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 2000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &856809289
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856809286}
m_LocalRotation: {x: 0.3432682, y: -0.0042265477, z: 0.0015447179, w: 0.9392267}
m_LocalPosition: {x: 8, y: 397, z: -674}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &856809290
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856809286}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f494cd076a3a1ae47ba0e8dada6aee7a, type: 3}
m_Name:
m_EditorClassIdentifier:
url: http://192.168.196.211:30000/api/system/DataInterface/411511950225204933/Actions/Response?tenantId=bzcp
code: {fileID: 230337082}
msg: {fileID: 2035195017}
data: {fileID: 1640741505}
--- !u!1 &960352287
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 960352290}
- component: {fileID: 960352289}
- component: {fileID: 960352288}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &960352288
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 960352287}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &960352289
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 960352287}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &960352290
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 960352287}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1640741505 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1640741505, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
m_PrefabInstance: {fileID: 2064988581258076397}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &2035195017 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2035195017, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
m_PrefabInstance: {fileID: 2064988581258076397}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &2064988581258076397
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225391, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2064988582187225427, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}
propertyPath: m_Name
value: BulletinBoard
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a58bdddf03c0d8c4db53fb2316615584, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0facab4c8f26bc74ca5ffa8716e25c90
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2803
Assets/Scenes/Focus.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c5968322b51b24a4699568f3b5fe636c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9b54ea6dbe14fe94e9f2a93169ad785c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -37,8 +37,8 @@ RenderSettings:
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -123,100 +123,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &960966153
GameObject:
m_ObjectHideFlags: 0
@ -257,189 +163,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1813878352}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &963194226
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1813878351
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1813878352}
- component: {fileID: 1813878354}
- component: {fileID: 1813878353}
m_Layer: 0
m_Name: Tips
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1813878352
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813878351}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 6.0841, z: 0}
m_LocalScale: {x: 0.11481021, y: 0.11481021, z: 0.11481021}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 960966155}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!102 &1813878353
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813878351}
m_Text: "<color=yellow>\u6309\u952ES\u663E\u793AUI\uFF0C\u6309\u952EH\u5173\u95EDUI\uFF0C\u6309\u952EE\u63A7\u5236\u7269\u4F53\u53D8\u8272\uFF0C\u6309\u952EV\u8DF3\u573A\u666F</color>"
m_OffsetZ: 0
m_CharacterSize: 1
m_LineSpacing: 1
m_Anchor: 1
m_Alignment: 0
m_TabSize: 4
m_FontSize: 53
m_FontStyle: 0
m_RichText: 1
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4294967295
--- !u!23 &1813878354
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813878351}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}

8
Assets/Scripts/Base.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2bc7ed7e2f4041340871c1faa4e87ad0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
// [SerializeField] private bool _isLoadNotDestory = true;
private static T instance;
private static object locker = new object();
public static T Instance
{
get
{
if (instance == null)
{
lock (locker)
{
T[] instances = FindObjectsOfType<T>();
if (FindObjectsOfType<T>().Length >= 1)
{
instance = instances[0];
for (int i = 1; i < instances.Length; i++)
{
#if UNITY_EDITOR
Debug.LogError($"{typeof(T)} 不应该存在多个单例!{instances[i].name}");
#endif
Destroy(instances[i]);
}
return instance;
}
if (instance == null && Application.isPlaying)
{
var singleton = new GameObject();
instance = singleton.AddComponent<T>();
singleton.name = "(singleton)_" + typeof(T);
}
else
{
// DontDestroyOnLoad(instance.gameObject);
}
}
// instance.hideFlags = HideFlags.None;
}
return instance;
}
}
// public static bool IsInitialized
// {
// get
// {
// return instance != null;
// }
// }
protected virtual void Awake()
{
// if (_isLoadNotDestory)
// {
// DontDestroyOnLoad(this);
// }
// if (instance != null)
// {
// Debug.LogErrorFormat("Trying to instantiate a second instance of singleton class {0}", GetType().Name);
// }
// else
// {
// instance = (T)this;
// }
}
// public virtual void OnDestroy()
// {
// if (instance == this)
// {
// instance = null;
// }
// }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 940d26f8b14309d4196d0b4b9adb88f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -21,18 +21,18 @@ public class Bootstrap : SingletonMono<Bootstrap>
private void Start()
{
Debug.Log("<color=yellow>按键S显示UI按键H关闭UI按键E控制物体变色按键V跳场景</color>");
uiManager.ShowPanel<UI_LoadingPanel>(E_UI_Layer.System, (panel) =>
{
///1 为进度条速度
///1 为进度条速度
eventCenter.EventTrigger(Enum_EventType.UpdateProgress, 1f);
scenesManager.LoadSceneAsyn("TestScene", () =>
{
Debug.Log("加载场景成功");
Debug.Log("加载场景成功");
eventCenter.EventTrigger(Enum_EventType.UpdateProgress, 5f);
});
});
}
// Update is called once per frame
@ -44,7 +44,7 @@ public class Bootstrap : SingletonMono<Bootstrap>
uiManager.ShowPanel<UI_TestPanel>( E_UI_Layer.Bot, (panel) =>
{
panel.OnInit();
Debug.Log("UI_TestPanel显示成功");
Debug.Log("UI_TestPanel显示成功");
});
}
if (Input.GetKeyDown("h"))

View File

@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ZenFulcrum.EmbeddedBrowser;
using UnityEngine.UI;
//============================================================
//支持中文文件使用UTF-8编码
//@author Zhaozibo
//@create 20230131
//@company WT
//
//@description:看板展示脚本需要在StreamingAssets文件下创建“看板地址管理.txt”文件
//里面需要填入前端提供的网页地址bullerinBoards的数量需要和“看板地址管理”里中的链接
//数量一致。插件中提供链接参考。
//============================================================
namespace Controller
{
public class BulletinBoardController : MonoBehaviour
{
public Browser[] bullerinBoards;
//获取网页传来得信息“SendMachineStationNumberToUnity”网页端必须有这个方法
// bullerinBoards[0].RegisterFunction("SendMachineStationNumberToUnity", (JSONNode jk)=>{function});
//调用网页上得方法“GetCurrentStationNumberFormUnity”网页端必须有这个方法
//bullerinBoards[3].CallFunction("GetCurrentStationNumberFormUnity", currentStationName).Done();
private void Start()
{
string[] urls = FileUtil.ReadAllFromLocal("看板地址管理.txt");
for (int i = 0; i < bullerinBoards.Length; i++)
{
int index = i;
bullerinBoards[index].Url = urls[index+1];
}
// bullerinBoards[0].RegisterFunction("SendMachineStationNumberToUnity", (JSONNode jk) =>
//{
// stationInformation.SwitchSelf(true);
// currentStationName = jk[0].Value.ToString();
// if (MachineManager.Instance.GetMachineByName(currentStationName, out machineBase))
// {
// target = machineBase.BoxCollider.bounds.center;
// stationInformation.Init(target, currentStationName);
// }
// Debug.Log(jk[0].Value);
//});
// stationInformation.selfBtn.onClick.AddListener(OnStationInformationClick);
}
//public void OnStationInformationClick()
//{
// currentStationName = stationInformation.stationName.text;
// bullerinBoards[3].CallFunction("GetCurrentStationNumberFormUnity", currentStationName).Done();
// informationToggle.isOn = true;
// stationInformation.SwitchSelf(false);
//}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eec04440ce1a5864a8a98c67ef786586
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8113cb1da3645d74c9e02ae9ecbece43
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class CameraMgr : MonoSingleton<CameraMgr>
{
CameraRT camera_Rt;
Vector3 originPos;
Vector3 originRot;
// [Header("业务视角点")]
public List<Transform> logicViewList = new List<Transform>();
private void Awake()
{
camera_Rt = GetComponent<CameraRT>();
}
public void SetOrigin()
{
originPos = Camera.main.transform.position;
originRot = Camera.main.transform.localEulerAngles;
}
public void GotoView(string viewName)
{
Transform viewTarget = logicViewList.Find(x => x.name == viewName);
camera_Rt.SetTarget(viewTarget);
}
public void GotoView(string viewName, float _distance)
{
Transform viewTarget = logicViewList.Find(x => x.name == viewName);
camera_Rt.SetTarget(viewTarget, _distance);
}
public void GotoView(Transform viewTarget, float _distance)
{
camera_Rt.SetTarget(viewTarget, _distance);
}
public void GotoView(Vector3 viewTarget, float _distance)
{
camera_Rt.SetTarget(viewTarget, _distance);
}
public void ReturnToMain()
{
Camera.main.transform.DORotate(originRot, 1);
Camera.main.transform.DOMove(originPos, 1);
}
#region
//[Header("漫游视角自动切换")]
//public bool autoChangeView = false;
//public float changeViewTimer;
//public List<Transform> autoChangeViewList;
//int index = 0;
//void ChangeView()
//{
// if (!autoChangeView)
// return;
// if (index > autoChangeViewList.Count - 1)
// {
// index = 0;
// ReturnToMain();
// return;
// }
// Camera.main.transform.position = autoChangeViewList[index].position;
// Camera.main.transform.localEulerAngles = autoChangeViewList[index].localEulerAngles;
// index++;
//}
//public void AutoChangeView_Open()
//{
// autoChangeView = true;
// CancelInvoke("ChangeView");
// InvokeRepeating("ChangeView", 15, 15);
//}
//public void AutoChangeView_Close()
//{
// autoChangeView = false;
//}
#endregion
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3eb4821edfbe33540a04ab32d1cf7212
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,271 @@
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.EventSystems;
/// <summary>
/// 相机控制
/// </summary>
public class CameraRT : MonoBehaviour
{
public Camera cam;
[Header("目标物体")]
Transform target;
[Header("旋转角度")]
public float x = 0f;
public float y = 0f;
public float z = 0f;
[Header("移动、旋转、缩放速度值")]
public float xSpeed_move = 600;
public float ySpeed_move = 600;
public float xSpeed_rotate = 2;
public float ySpeed_rotate = 2;
public float mSpeed_scale = 150;
[Header("y轴角度限制")]
public float yMinLimit = 2;
public float yMaxLimit = 90;
[Header("x轴角度限制")]
public float leftMax = -365;
public float rightMax = 365;
[Header("距离限制")]
public float distance = 400;
public float minDistance = 10f;
public float maxDistance = 400f;
[Header("阻尼设置")]
public bool needDamping = true;
public float damping = 6f;
[Header("相机活动范围")]
public bool isRangeClamped;
public float xMinValue = -100f;
public float xMaxValue = 100f;
public float zMinValue = -100f;
public float zMaxValue = 100f;
[Header("自动旋转")]
public bool autoRotate;
public float rotateTimer = 15;
public float rotateSpeed = 5;
float rotateTimer_temp;
bool isAutoRotating = false;
//动态调节相机缩放的灵敏度
float tempSpeed;
private void Start()
{
if (cam == null)
{
cam = Camera.main;
}
target = transform.GetChild(0);
target.gameObject.AddComponent<CameraTargetFollowCam>();
x = cam.transform.localEulerAngles.y;
y = cam.transform.localEulerAngles.x;
tempSpeed = xSpeed_move;
rotateTimer_temp = rotateTimer;
}
public void SetTarget(Transform _target)
{
target.position = _target.position;
distance = _target.localScale.x;
y = _target.eulerAngles.x;
x = _target.eulerAngles.y;
}
public void SetTarget(Transform _target, float _distance)
{
target.position = _target.position;
distance = _distance;
y = _target.eulerAngles.x;
x = _target.eulerAngles.y;
}
public void SetTarget(Vector3 _target, float _distance)
{
target.position = _target;
distance = _distance;
//y = _target.eulerAngles.x;
//x = _target.eulerAngles.y;
}
Vector3 oldMousePos;
void Update()
{
if (!autoRotate)
return;
if (oldMousePos != Input.mousePosition || Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
{
rotateTimer = rotateTimer_temp;
if (isAutoRotating)
{
x = cam.transform.eulerAngles.y;
y = cam.transform.eulerAngles.x;
}
}
oldMousePos = Input.mousePosition;
if (rotateTimer <= 0)
{
isAutoRotating = true;
//cam.transform.LookAt(target);
//cam.transform.RotateAround(target.position, Vector3.up, -Time.deltaTime * rotateSpeed);
rotateTimer = rotateTimer_temp;
}
else
{
rotateTimer -= Time.deltaTime;
isAutoRotating = false;
}
}
void LateUpdate()
{
if (isAutoRotating)
return;
if (target)
{
Scroll();
Move();
Rotate();
Quaternion rotation = Quaternion.Euler(y, x, z);
Vector3 disVector = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * disVector + target.position;
// 阻尼感
if (needDamping)
{
cam.transform.rotation = Quaternion.Lerp(cam.transform.rotation, rotation, Time.deltaTime * damping);
cam.transform.position = Vector3.Lerp(cam.transform.position, position, Time.deltaTime * damping);
}
else
{
cam.transform.rotation = rotation;
cam.transform.position = position;
}
}
}
void Move()
{
if (EventSystem.current.IsPointerOverGameObject())
return;
if (Input.GetMouseButton(0))
{
float h = Input.GetAxis("Mouse X") * Time.deltaTime * xSpeed_move;
float v = Input.GetAxis("Mouse Y") * Time.deltaTime * ySpeed_move;
target.Translate(-h, 0, -v);
if (!isRangeClamped)
return;
float targetX = target.position.x;
targetX = Mathf.Clamp(targetX, xMinValue, xMaxValue);
float targetZ = target.position.z;
targetZ = Mathf.Clamp(targetZ, zMinValue, zMaxValue);
target.position = new Vector3(targetX, target.position.y, targetZ);
}
}
void Rotate()
{
if (Input.GetMouseButton(1))
{
// 判断是否需要反向旋转
if ((y > 90f && y < 270f) || (y < -90 && y > -270f))
{
x -= Input.GetAxis("Mouse X") * xSpeed_rotate;
}
else
{
x += Input.GetAxis("Mouse X") * xSpeed_rotate;
}
y -= Input.GetAxis("Mouse Y") * ySpeed_rotate;
x = ClampAngle(x, leftMax, rightMax);
y = ClampAngle(y, yMinLimit, yMaxLimit);
}
}
void Scroll()
{
distance -= Input.GetAxis("Mouse ScrollWheel") * mSpeed_scale;
distance = Mathf.Clamp(distance, minDistance, maxDistance);
xSpeed_move = distance / maxDistance * tempSpeed;
ySpeed_move = distance / maxDistance * tempSpeed;
}
// 对数值进行限制
float ClampAngle(float angle, float min, float max)
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp(angle, min, max);
}
#if UNITY_EDITOR
private void OnDrawGizmosSelected()
{
//如果限制活动范围 将区域范围绘制出来
if (isRangeClamped)
{
Handles.color = Color.cyan;
Vector3[] points = new Vector3[8]
{
new Vector3(xMinValue, 0, zMinValue),
new Vector3(xMaxValue, 0, zMinValue),
new Vector3(xMaxValue, 0, zMaxValue),
new Vector3(xMinValue, 0, zMaxValue),
new Vector3(xMinValue, 0, zMinValue),
new Vector3(xMaxValue, 0, zMinValue),
new Vector3(xMaxValue, 0, zMaxValue),
new Vector3(xMinValue, 0, zMaxValue)
};
for (int i = 0; i < 4; i++)
{
int start = i % 4;
int end = (i + 1) % 4;
Handles.DrawLine(points[start], points[end]);
Handles.DrawLine(points[start + 4], points[end + 4]);
Handles.DrawLine(points[start], points[i + 4]);
}
}
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0b9e0f8345b2384394ba306242cd2a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraTargetFollowCam : MonoBehaviour
{
void Update()
{
transform.localEulerAngles = new Vector3(0, Camera.main.transform.localEulerAngles.y, Camera.main.transform.localEulerAngles.z);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5dd7a8c053d2b724197101a3ce4d0f94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,61 @@
using UnityEngine;
/// <summary>
/// 面向相机
/// </summary>
public class Face2Camera : MonoBehaviour
{
//主相机
public Camera mainCamera;
//翻转背面
public bool invertBack;
//是否启用垂直方向上的朝向
//设为false时 仅在水平方向上面向相机
public bool isEnableVertical = true;
//是否启用插值运算
public bool isEnableLerp;
//插值到目标值所需的时间 isEnableLerp为true时起作用
[Range(0.01f, 1f), SerializeField] private float lerpTime = 1f;
public float _distance;//最大距离
Vector3 initScale;
private void Start()
{
if (mainCamera == null)
{
mainCamera = Camera.main ?? FindObjectOfType<Camera>();
}
initScale = transform.localScale;
}
private void Update()
{
if (mainCamera == null)
return;
Vector3 forward = (isEnableVertical
? -mainCamera.transform.forward
: Vector3.ProjectOnPlane((mainCamera.transform.position - transform.position).normalized, Vector3.up))
* (invertBack ? 1 : -1);
transform.forward = !isEnableLerp ? forward
: Vector3.Lerp(transform.forward, forward, 1f - Mathf.Exp(Mathf.Log(1f - .99f) / lerpTime * Time.deltaTime));
float distance = Vector3.Distance(Camera.main.transform.position, transform.position);//不断变化的距离
float scale = distance / _distance;
if (scale > 1f)
scale = 1f;
transform.localScale = initScale * scale;
}
//public Face2Camera Set(Camera mainCamera, bool invertBack, bool isEnableVertical)
//{
// this.mainCamera = mainCamera;
// this.invertBack = invertBack;
// this.isEnableVertical = isEnableVertical;
// return this;
//}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddfad4468ea99f145bc0b1cd5782d954
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1382d272c1878d447a37b350848d1eda
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230531
//@company Adam
//
//@description:
//============================================================
namespace Focus
{
public class ModelClick : MonoBehaviour
{
private void OnMouseDown()
{
CameraMgr.Instance.GotoView(transform, 10f);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eb2c3e0639c2b164d9cad2af0bb107ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author #AUTHOR#
//@create #CREATEDATE#
//@company #COMPANY#
//
//@description:
//============================================================
public enum Status
{
Normal,
Warn,
}
public class SwitchStatus : MonoBehaviour
{
public Status status = Status.Normal;
private void Update()
{
if (status == Status.Warn)
{
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
}
else
{
gameObject.GetComponent<Renderer>().material.color = Color.green;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1f347c5db58cd2448b4b926d5f2d5f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230531
//@company Adam
//
//@description:
//============================================================
namespace Focus
{
public class SwitchViews : MonoBehaviour
{
public Transform viewOne;
public Transform viewTwo;
public void OnViewOneClick()
{
CameraMgr.Instance.GotoView(viewOne, 10f);
}
public void OnViewTwoClick()
{
CameraMgr.Instance.GotoView(viewTwo, 10f);
}
public Bounds CalculateBounding(List<GameObject> objs)
{
if (objs.Count > 0)
{
Bounds b = objs[0].GetComponent<Renderer>().bounds;
if (objs.Count > 1)
{
for (int i = 1; i < objs.Count; i++)
{
b.Encapsulate(objs[i].GetComponent<Renderer>().bounds);
}
return b;
}
else
{
return b;
}
}
return new Bounds();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d1adfbb027f8d39459702be3e8fb2b14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,36 @@
using Adam;
using HUD;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230531
//@company Adam
//
//@description:
//============================================================
namespace Focus
{
public class ThreeDUIClick : MonoBehaviour
{
public HUDController hudController;
// Use this for initialization
private void Start()
{
for (int i = 0; i < hudController.modelInformations.Count; i++)
{
for (int j = 0; j < hudController.modelInformations[i].tations.Count; j++)
{
int modelIndex = i;
int tationIndex = j;
hudController.modelInformations[i].tations[j].transform.GetChild(0).GetComponent<StationInformation>().onClick.AddListener(() =>
{
CameraMgr.Instance.GotoView(hudController.modelInformations[modelIndex].tations[tationIndex].transform, 20f);
});
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fcd3914edcdca4049a13e3cea681062d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/HUD.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 342be691e5652e644bbd5d5acf77d5e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,62 @@
using HUD;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230426
//@company Adam
//
//@description:
//============================================================
namespace Adam
{
[Serializable]
public struct ModelInformation
{
public StationInformation stationInformation;
public List<GameObject> tations;
}
public class HUDController : MonoBehaviour
{
public List<ModelInformation> modelInformations = new List<ModelInformation>();
// Use this for initialization
private void Awake()
{
for (int i = 0; i < modelInformations.Count; i++)
{
for (int j = 0; j < modelInformations[i].tations.Count; j++)
{
StationInformation si = Instantiate(modelInformations[i].stationInformation);
GameObject go = modelInformations[i].tations[j];
si.SetTarget(Camera.main.transform);
si.Init(go.transform, GetBounds(go));
}
}
}
private Bounds GetBounds(GameObject obj)
{
Bounds bounds = new Bounds();
if (obj.transform.childCount != 0)
{
Renderer[] renderers = obj.GetComponentsInChildren<Renderer>();
for (int i = 0; i < renderers.Length; i++)
{
bounds.Encapsulate(renderers[i].bounds);
}
}
else
{
bounds = obj.GetComponent<Renderer>().bounds;
}
return bounds;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2d77674999936547b8cbaec26ef8322
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,82 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230426
//@company Adam
//
//@description:
//============================================================
namespace HUD
{
public enum WorldOrLocal
{
World,
Local
}
public class StationInformation : MonoBehaviour
{
//public float offsetY = 1f;
public WorldOrLocal worldOrLocal = WorldOrLocal.World;
public bool lockXZ = false;
public UnityEvent onClick;
private Transform lookAtTarget;
public void SetTarget(Transform target)
{
lookAtTarget = target;
}
public void Init(Transform parent, Bounds b)
{
transform.SetParent(parent);
transform.localPosition = Vector3.zero;
Vector3 pos = b.center;
Vector3 extentsPos = b.extents;
if (worldOrLocal == WorldOrLocal.Local)
{
//transform.localEulerAngles = Vector3.zero;
Vector3 localPos = transform.InverseTransformPoint(pos);
transform.localPosition = new Vector3(localPos.x, localPos.y + extentsPos.y, localPos.z);
}
else if (worldOrLocal == WorldOrLocal.World)
{
Vector3 localPos = transform.InverseTransformPoint(pos);
Vector3 worldPos = transform.TransformPoint(localPos);
transform.position = new Vector3(worldPos.x, worldPos.y + extentsPos.y + 1f, worldPos.z);
}
else
{
}
}
private void Update()
{
if (lookAtTarget != null)
{
Vector3 pos;
if (lockXZ)
{
pos = new Vector3(lookAtTarget.localPosition.x, 0, lookAtTarget.localPosition.z);
}
else
{
pos = lookAtTarget.localPosition;
}
transform.LookAt(pos);
}
}
private void OnMouseDown()
{
onClick?.Invoke();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58e2fbd82adbcd14aac54bb85f5464ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 556b73066feaa56439215bc4abb108b3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//============================================================
//支持中文文件使用UTF-8编码
//@author YangHua
//@create 20230414
//@company Adam
//
//@description:
//============================================================
namespace Models
{
[Serializable]
public class ValueObject
{
public int code;
public string msg;
public Data[] data;
}
[Serializable]
public class Data
{
public string op_code;
public string op_desc;
public int f_id;
}
public class Requset
{
}
}

Some files were not shown because too many files have changed in this diff Show More