Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha tween now affects itself and all its children. #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 44 additions & 24 deletions Assets/Plugins/LeanTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,18 @@ public static void update() {
SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
if(ren!=null){
tween.from.x = ren.color.a;
}else if(trans.gameObject.renderer!=null){
tween.from.x = trans.gameObject.renderer.material.color.a;
}
else{
TextMesh tm = trans.gameObject.GetComponent<TextMesh>();
if (tm != null) {
tween.from.x = tm.color.a;
}
else if(trans.gameObject.renderer!=null){
tween.from.x = trans.gameObject.renderer.material.color.a;
}
else{
tween.from.x = 1f;
}
}
break;
#endif
Expand Down Expand Up @@ -1811,12 +1821,21 @@ public static void update() {
tween.from = new Vector3(0.0f, ren2.color.a, 0.0f);
tween.diff = new Vector3(1.0f,0.0f,0.0f);
tween.axis = new Vector3( ren2.color.r, ren2.color.g, ren2.color.b );
}else if(trans.gameObject.renderer!=null){
if(trans.gameObject.renderer){
Color col = trans.gameObject.renderer.material.color;
tween.from = new Vector3(0.0f, col.a, 0.0f);
}
else {
TextMesh tm2 = trans.gameObject.GetComponent<TextMesh>();
if (tm2 != null) {
tween.from = new Vector3(0.0f, tm2.color.a, 0.0f);
tween.diff = new Vector3(1.0f,0.0f,0.0f);
tween.axis = new Vector3( col.r, col.g, col.b );
tween.axis = new Vector3( tm2.color.r, tm2.color.g, tm2.color.b );
}
else if(trans.gameObject.renderer!=null){
if(trans.gameObject.renderer){
Color col = trans.gameObject.renderer.material.color;
tween.from = new Vector3(0.0f, col.a, 0.0f);
tween.diff = new Vector3(1.0f,0.0f,0.0f);
tween.axis = new Vector3( col.r, col.g, col.b );
}
}
}
#endif
Expand Down Expand Up @@ -2076,24 +2095,25 @@ public static void update() {

#else

SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
if(ren!=null){
ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val);
}else{
if(trans.gameObject.renderer!=null){
foreach(Material mat in trans.gameObject.renderer.materials){
mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
}
}
if(trans.childCount>0){
foreach (Transform child in trans) {
if(child.gameObject.renderer!=null){
foreach(Material mat in child.gameObject.renderer.materials){
mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
}
}
// Applies to all itself and all children of any level
Transform[] children = trans.GetComponentsInChildren<Transform>();
foreach (Transform t in children)
{
SpriteRenderer ren = t.gameObject.GetComponent<SpriteRenderer>();
if(ren!=null){
ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val);
}
else {
TextMesh tm = t.gameObject.GetComponent<TextMesh>();
if (tm != null) {
tm.color = new Color( tm.color.r, tm.color.g, tm.color.b, val);
}
else if(t.gameObject.renderer!=null){
foreach(Material mat in t.gameObject.renderer.materials){
mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
}
}
}
}
}

#endif
Expand Down