c# - How to add to a chain of methods by checking if statements -
i don't know right terminology have simple c# code snippet tweens objects this:
camera.gameobject.transform.domove(target,3.0f) .setease(ease.inoutquad) .oncomplete(animation.fadein);
but need add method chain based on condition this:
camera.gameobject.transform.domove(target,3.0f) .setease(ease.inoutquad) //the general idea if(visible == true){ .onstart(animation.fadeout); } .oncomplete(animation.fadein);
obviously syntax error, not know correct way handle syntax.
how should approach it?
you need place entire chunk in if
-else
statement, cannot break down:
if(visible == true){ camera.gameobject.transform.domove(target,3.0f) .setease(ease.inoutquad) .onstart(animation.fadeout).oncomplete(animation.fadein); } else { camera.gameobject.transform.domove(target,3.0f) .setease(ease.inoutquad).oncomplete(animation.fadein); }
alertnatively:
var intermediateobject = camera.gameobject.transform.domove(target,3.0f) .setease(ease.inoutquad); if (visible) { intermediateobject.onstart(animation.fadeout).oncomplete(animation.fadein);; } else { intermediateobject.oncomplete(animation.fadein);; }
the var
keyword means not need worry type of object yourself, again, usage hinder readability (in opinion).
Comments
Post a Comment