50 lines
3.8 KiB
Plaintext
50 lines
3.8 KiB
Plaintext
|
%YAML 1.1
|
||
|
%TAG !u! tag:unity3d.com,2011:
|
||
|
--- !u!114 &11400000
|
||
|
MonoBehaviour:
|
||
|
m_ObjectHideFlags: 0
|
||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||
|
m_PrefabInstance: {fileID: 0}
|
||
|
m_PrefabAsset: {fileID: 0}
|
||
|
m_GameObject: {fileID: 0}
|
||
|
m_Enabled: 1
|
||
|
m_EditorHideFlags: 0
|
||
|
m_Script: {fileID: 11500000, guid: a0e5d060f45ca564cba1173332d781d0, type: 3}
|
||
|
m_Name: VectorElementAB
|
||
|
m_EditorClassIdentifier:
|
||
|
Body: "using TARGET = {COMPONENT_FULL};\r\n\r\nnamespace Lean.Transition.Method\r\n{\r\n\t///
|
||
|
<summary>This component allows you to transition the {COMPONENT}'s {PROPERTY}.{ELEMENT_A}{ELEMENT_B}
|
||
|
value.</summary>\r\n\t[UnityEngine.HelpURL(LeanTransition.HelpUrlPrefix + \"Lean{TITLE}\")]\r\n\t[UnityEngine.AddComponentMenu(LeanTransition.MethodsMenuPrefix
|
||
|
+ \"{COMPONENT}/{COMPONENT}.{PROPERTY}.{ELEMENT_A}{ELEMENT_B}\" + LeanTransition.MethodsMenuSuffix
|
||
|
+ \"(Lean{TITLE})\")]\r\n\tpublic class Lean{TITLE} : LeanMethodWithStateAndTarget\r\n\t{\r\n\t\tpublic
|
||
|
override System.Type GetTargetType()\r\n\t\t{\r\n\t\t\treturn typeof(TARGET);\r\n\t\t}\r\n\r\n\t\tpublic
|
||
|
override void Register()\r\n\t\t{\r\n\t\t\tPreviousState = Register(GetAliasedTarget(Data.Target),
|
||
|
Data.Value, Data.Duration, Data.Ease);\r\n\t\t}\r\n\r\n\t\tpublic static LeanState
|
||
|
Register(TARGET target, UnityEngine.Vector2 value, float duration, LeanEase ease
|
||
|
= LeanEase.Smooth)\r\n\t\t{\r\n\t\t\tvar state = LeanTransition.SpawnWithTarget(State.Pool,
|
||
|
target);\r\n\r\n\t\t\tstate.Value = value;\r\n\t\t\t\r\n\t\t\tstate.Ease = ease;\r\n\r\n\t\t\treturn
|
||
|
LeanTransition.Register(state, duration);\r\n\t\t}\r\n\r\n\t\t[System.Serializable]\r\n\t\tpublic
|
||
|
class State : LeanStateWithTarget<TARGET>\r\n\t\t{\r\n\t\t\t[UnityEngine.Tooltip(\"The
|
||
|
{PROPERTY} value will transition to this.\")]\r\n\t\t\t{FSA}{ATTRIBUTE}public
|
||
|
UnityEngine.Vector2 Value{DEFAULT};\r\n\r\n\t\t\t[UnityEngine.Tooltip(\"This
|
||
|
allows you to control how the transition will look.\")]\r\n\t\t\tpublic LeanEase
|
||
|
Ease = LeanEase.Smooth;\r\n\r\n\t\t\t[System.NonSerialized] private UnityEngine.Vector2
|
||
|
oldValue;\r\n\r\n\t\t\tpublic override int CanFill\r\n\t\t\t{\r\n\t\t\t\tget\r\n\t\t\t\t{\r\n\t\t\t\t\treturn
|
||
|
Target != null && (Target.{PROPERTY}.{ELEMENT_A} != Value.x || Target.{PROPERTY}.{ELEMENT_B}
|
||
|
!= Value.y) ? 1 : 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tpublic override void
|
||
|
FillWithTarget()\r\n\t\t\t{\r\n\t\t\t\tvar vector = Target.{PROPERTY};\r\n\t\t\t\t\r\n\t\t\t\tValue.x
|
||
|
= vector.{ELEMENT_A};\r\n\t\t\t\tValue.y = vector.{ELEMENT_B};\r\n\t\t\t}\r\n\r\n\t\t\tpublic
|
||
|
override void BeginWithTarget()\r\n\t\t\t{\r\n\t\t\t\tvar vector = Target.{PROPERTY};\r\n\t\t\t\t\r\n\t\t\t\toldValue.x
|
||
|
= vector.{ELEMENT_A};\r\n\t\t\t\toldValue.y = vector.{ELEMENT_B};\r\n\t\t\t}\r\n\r\n\t\t\tpublic
|
||
|
override void UpdateWithTarget(float progress)\r\n\t\t\t{\r\n\t\t\t\tvar vector
|
||
|
= Target.{PROPERTY};\r\n\t\t\t\tvar smooth = Smooth(Ease, progress);\r\n\t\t\t\t\r\n\t\t\t\tvector.{ELEMENT_A}
|
||
|
= UnityEngine.Mathf.LerpUnclamped(oldValue.x, Value.x, smooth);\r\n\t\t\t\tvector.{ELEMENT_B}
|
||
|
= UnityEngine.Mathf.LerpUnclamped(oldValue.y, Value.y, smooth);\r\n\t\t\t\t \r\n\t\t\t\tTarget.{PROPERTY}
|
||
|
= vector;\r\n\t\t\t}\r\n\r\n\t\t\tpublic static System.Collections.Generic.Stack<State>
|
||
|
Pool = new System.Collections.Generic.Stack<State>(); public override void Despawn()
|
||
|
{ Pool.Push(this); }\r\n\t\t}\r\n\r\n\t\tpublic State Data;\r\n\t}\r\n}\r\n\r\nnamespace
|
||
|
Lean.Transition\r\n{\r\n\tpublic static partial class LeanExtensions\r\n\t{\r\n\t\tpublic
|
||
|
static TARGET {PROPERTY}Transition_{ELEMENT_A}{ELEMENT_B}(this TARGET target,
|
||
|
UnityEngine.Vector2 value, float duration, LeanEase ease = LeanEase.Smooth)\r\n\t\t{\r\n\t\t\tMethod.Lean{TITLE}.Register(target,
|
||
|
value, duration, ease); return target;\r\n\t\t}\r\n\t}\r\n}"
|