34 return _tween.
AddInterpolator(Pool<MaterialColorInterpolator>.Spawn().Init(a, b,
new MaterialPropertyKey(_target, propertyId)));
38 return Color(a, b, Shader.PropertyToID(propertyName));
42 return _tween.
AddInterpolator(Pool<MaterialGradientInterpolator>.Spawn().Init(gradient,
new MaterialPropertyKey(_target, propertyId)));
45 public Tween Color(Gradient gradient,
string propertyName =
"_Color") {
46 return Color(gradient, Shader.PropertyToID(propertyName));
50 return _tween.
AddInterpolator(Pool<MaterialColorInterpolator>.Spawn().Init(_target.GetColor(propertyId), b,
new MaterialPropertyKey(_target, propertyId)));
54 return ToColor(b, Shader.PropertyToID(propertyName));
58 return _tween.
AddInterpolator(Pool<MaterialRGBInterpolator>.Spawn().Init((Vector4)a, (Vector4)b,
new MaterialPropertyKey(_target, propertyId)));
62 return RGB(a, b, Shader.PropertyToID(propertyName));
66 return _tween.
AddInterpolator(Pool<MaterialRGBInterpolator>.Spawn().Init((Vector4)_target.GetColor(propertyId), (Vector4)b,
new MaterialPropertyKey(_target, propertyId)));
70 return ToRGB(b, Shader.PropertyToID(propertyName));
74 return _tween.
AddInterpolator(Pool<MaterialAlphaInterpolator>.Spawn().Init(a, b,
new MaterialPropertyKey(_target, propertyId)));
77 public Tween Alpha(
float a,
float b,
string propertyName =
"_Color") {
78 return Alpha(a, b, Shader.PropertyToID(propertyName));
82 return _tween.
AddInterpolator(Pool<MaterialAlphaInterpolator>.Spawn().Init(_target.GetColor(propertyId).a, b,
new MaterialPropertyKey(_target, propertyId)));
86 return ToAlpha(b, Shader.PropertyToID(propertyName));
91 public override void Interpolate(
float percent) {
92 _target.material.SetColor(_target.propertyId, _a + _b * percent);
95 public override void Dispose() {
96 _target.material =
null;
97 Pool<MaterialColorInterpolator>.Recycle(
this);
100 public override bool isValid {
get {
return _target.material !=
null; } }
103 private class MaterialGradientInterpolator : GradientInterpolatorBase {
105 private MaterialPropertyKey _matPropKey;
107 public MaterialGradientInterpolator
Init(Gradient gradient, MaterialPropertyKey matPropKey) {
108 this._matPropKey = matPropKey;
113 public override void Interpolate(
float percent) {
114 _matPropKey.material.SetColor(_matPropKey.propertyId,
_gradient.Evaluate(percent));
117 public override bool isValid {
get {
return _matPropKey.material !=
null; } }
120 private class MaterialRGBInterpolator : Vector3InterpolatorBase<MaterialPropertyKey> {
122 public override void Interpolate(
float percent) {
123 float currAlpha = _target.material.GetColor(_target.propertyId).a;
126 _target.material.SetColor(_target.propertyId, color);
129 public override void Dispose() {
130 _target.material =
null;
131 Pool<MaterialRGBInterpolator>.Recycle(
this);
134 public override bool isValid {
get {
return _target.material !=
null; } }
137 private class MaterialAlphaInterpolator : FloatInterpolatorBase<MaterialPropertyKey> {
139 public override void Interpolate(
float percent) {
140 Color color = _target.material.GetColor(_target.propertyId);
141 color.a = Mathf.Lerp(_a, _b, percent);
142 _target.material.SetColor(_target.propertyId, color);
145 public override void Dispose() {
146 _target.material =
null;
147 Pool<MaterialAlphaInterpolator>.Recycle(
this);
150 public override bool isValid {
get {
return _target.material !=
null; } }
156 return _tween.
AddInterpolator(Pool<MaterialFloatInterpolator>.Spawn().Init(a, b,
new MaterialPropertyKey(_target, propertyId)));
160 return Float(a, b, Shader.PropertyToID(propertyName));
164 return _tween.
AddInterpolator(Pool<MaterialFloatInterpolator>.Spawn().Init(_target.GetFloat(propertyId), b,
new MaterialPropertyKey(_target, propertyId)));
168 return ToFloat(b, Shader.PropertyToID(propertyName));
172 public override void Interpolate(
float percent) {
173 _target.material.SetFloat(_target.propertyId, _a + _b * percent);
176 public override void Dispose() {
177 _target.material =
null;
178 Pool<MaterialFloatInterpolator>.Recycle(
this);
181 public override bool isValid {
get {
return _target.material !=
null; } }
187 return _tween.
AddInterpolator(Pool<MaterialVectorInterpolator>.Spawn().Init(a, b,
new MaterialPropertyKey(_target, propertyId)));
191 return Vector(a, b, Shader.PropertyToID(propertyName));
195 return _tween.
AddInterpolator(Pool<MaterialVectorInterpolator>.Spawn().Init(a, b,
new MaterialPropertyKey(_target, propertyId)));
199 return Vector(a, b, Shader.PropertyToID(propertyName));
203 return _tween.
AddInterpolator(Pool<MaterialVectorInterpolator>.Spawn().Init(_target.GetVector(propertyId), b,
new MaterialPropertyKey(_target, propertyId)));
207 return ToVector(b, Shader.PropertyToID(propertyName));
211 return _tween.
AddInterpolator(Pool<MaterialVectorInterpolator>.Spawn().Init(_target.GetVector(propertyId), b,
new MaterialPropertyKey(_target, propertyId)));
215 return ToVector(b, Shader.PropertyToID(propertyName));
219 public override void Interpolate(
float percent) {
220 _target.material.SetVector(_target.propertyId, _a + _b * percent);
223 public override void Dispose() {
224 _target.material =
null;
225 Pool<MaterialVectorInterpolator>.Recycle(
this);
228 public override bool isValid {
get {
return _target.material !=
null; } }
234 return _tween.
AddInterpolator(Pool<MaterialInterpolator>.Spawn().Init(a, b, _target));
238 public override float length {
244 public override void Interpolate(
float percent) {
245 _target.Lerp(_a, _b, percent);
248 public override void Dispose() {
252 Pool<MaterialInterpolator>.Recycle(
this);
255 public override bool isValid {
get {
return _target !=
null; } }
259 private struct MaterialPropertyKey {
261 public int propertyId;
263 public MaterialPropertyKey(
Material material,
int propertyId) {
264 this.material = material;
265 this.propertyId = propertyId;
using Leap.Unity.Interaction. Internal
GradientInterpolatorBase Init(Gradient gradient)
Tween ToColor(Color b, string propertyName="_Color")
Tween ToColor(Color b, int propertyId)
Tween ToVector(Vector4 b, string propertyName)
Tween Float(float a, float b, string propertyName)
Tween ToRGB(Color b, string propertyName="_Color")
Tween ToVector(Vector3 b, string propertyName)
Tween ToAlpha(float b, string propertyName="_Color")
Tween Material(Material a, Material b)
Tween Color(Gradient gradient, int propertyId)
Tween ToFloat(float b, int propertyId)
Tween ToVector(Vector3 b, int propertyId)
Tween Alpha(float a, float b, string propertyName="_Color")
Tween Alpha(float a, float b, int propertyId)
Tween Vector(Vector4 a, Vector4 b, string propertyName)
Tween Float(float a, float b, int propertyId)
Tween Vector(Vector3 a, Vector3 b, string propertyName)
Tween Vector(Vector3 a, Vector3 b, int propertyId)
Tween Color(Color a, Color b, string propertyName="_Color")
Tween Color(Color a, Color b, int propertyId)
Tween Vector(Vector4 a, Vector4 b, int propertyId)
Tween RGB(Color a, Color b, int propertyId)
Tween ToAlpha(float b, int propertyId)
Tween RGB(Color a, Color b, string propertyName="_Color")
MaterialSelector(Material target, Tween tween)
Tween ToVector(Vector4 b, int propertyId)
Tween Color(Gradient gradient, string propertyName="_Color")
Tween ToRGB(Color b, int propertyId)
Tween ToFloat(float b, string propertyName)
Tween AddInterpolator(IInterpolator interpolator)
Adds a new Interpolator to this Tween. This Interpolator will have it's Interpolate method called eve...
MaterialSelector Target(Material material)