12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499 |
- // Copyright (c) 2011 Bob Berkebile (pixelplacment)
- // Please direct any bugs/comments/suggestions to http://pixelplacement.com
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- /*
- TERMS OF USE - EASING EQUATIONS
- Open source under the BSD License.
- Copyright (c)2001 Robert Penner
- All rights reserved.
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #region Namespaces
- using System;
- using System.Collections;
- using System.Reflection;
- using UnityEngine;
- #endregion
- /// <summary>
- /// <para>Version: 2.0.45</para>
- /// <para>Author: Bob Berkebile (http://pixelplacement.com)</para>
- /// <para>Support: http://itween.pixelplacement.com</para>
- /// </summary>
- public class iTween : MonoBehaviour{
-
- #region Variables
-
- //repository of all living iTweens:
- public static ArrayList tweens = new ArrayList();
-
- //camera fade object:
- private static GameObject cameraFade;
-
- //status members (made public for visual troubleshooting in the inspector):
- public string id, type, method;
- public iTween.EaseType easeType;
- public float time, delay;
- public LoopType loopType;
- public bool isRunning,isPaused;
- /* GFX47 MOD START */
- public string _name;
- /* GFX47 MOD END */
-
- //private members:
- private float runningTime, percentage;
- private float delayStarted; //probably not neccesary that this be protected but it shuts Unity's compiler up about this being "never used"
- private bool kinematic, isLocal, loop, reverse, wasPaused, physics;
- //AV PATCH
- private bool useFixedUpdate;
- //END AV PATCH
- private Hashtable tweenArguments;
- private Space space;
- private delegate float EasingFunction(float start, float end, float value);
- private delegate void ApplyTween();
- private EasingFunction ease;
- private ApplyTween apply;
- private AudioSource audioSource;
- private Vector3[] vector3s;
- private Vector2[] vector2s;
- private Color[,] colors;
- private float[] floats;
- private Rect[] rects;
- private CRSpline path;
- private Vector3 preUpdate;
- private Vector3 postUpdate;
- private NamedValueColor namedcolorvalue;
- private float lastRealTime; // Added by PressPlay
- private bool useRealTime; // Added by PressPlay
- /// <summary>
- /// The type of easing to use based on Robert Penner's open source easing equations (http://www.robertpenner.com/easing_terms_of_use.html).
- /// </summary>
- public enum EaseType{
- easeInQuad,
- easeOutQuad,
- easeInOutQuad,
- easeInCubic,
- easeOutCubic,
- easeInOutCubic,
- easeInQuart,
- easeOutQuart,
- easeInOutQuart,
- easeInQuint,
- easeOutQuint,
- easeInOutQuint,
- easeInSine,
- easeOutSine,
- easeInOutSine,
- easeInExpo,
- easeOutExpo,
- easeInOutExpo,
- easeInCirc,
- easeOutCirc,
- easeInOutCirc,
- linear,
- spring,
- /* GFX47 MOD START */
- //bounce,
- easeInBounce,
- easeOutBounce,
- easeInOutBounce,
- /* GFX47 MOD END */
- easeInBack,
- easeOutBack,
- easeInOutBack,
- /* GFX47 MOD START */
- //elastic,
- easeInElastic,
- easeOutElastic,
- easeInOutElastic,
- /* GFX47 MOD END */
- punch
- }
-
- /// <summary>
- /// The type of loop (if any) to use.
- /// </summary>
- public enum LoopType{
- /// <summary>
- /// Do not loop.
- /// </summary>
- none,
- /// <summary>
- /// Rewind and replay.
- /// </summary>
- loop,
- /// <summary>
- /// Ping pong the animation back and forth.
- /// </summary>
- pingPong
- }
-
- /// <summary>
- /// Many shaders use more than one color. Use can have iTween's Color methods operate on them by name.
- /// </summary>
- public enum NamedValueColor{
- /// <summary>
- /// The main color of a material. Used by default and not required for Color methods to work in iTween.
- /// </summary>
- _Color,
- /// <summary>
- /// The specular color of a material (used in specular/glossy/vertexlit shaders).
- /// </summary>
- _SpecColor,
- /// <summary>
- /// The emissive color of a material (used in vertexlit shaders).
- /// </summary>
- _Emission,
- /// <summary>
- /// The reflection color of the material (used in reflective shaders).
- /// </summary>
- _ReflectColor
- }
-
- #endregion
-
- #region Defaults
-
- /// <summary>
- /// A collection of baseline presets that iTween needs and utilizes if certain parameters are not provided.
- /// </summary>
- public static class Defaults{
- //general defaults:
- public static float time = 1f;
- public static float delay = 0f;
- public static NamedValueColor namedColorValue = NamedValueColor._Color;
- public static LoopType loopType = LoopType.none;
- public static EaseType easeType = iTween.EaseType.easeOutExpo;
- public static float lookSpeed = 3f;
- public static bool isLocal = false;
- public static Space space = Space.Self;
- public static bool orientToPath = false;
- public static Color color = Color.white;
- //update defaults:
- public static float updateTimePercentage = .05f;
- public static float updateTime = 1f*updateTimePercentage;
- //cameraFade defaults:
- public static int cameraFadeDepth = 999999;
- //path look ahead amount:
- public static float lookAhead = .05f;
- public static bool useRealTime = false; // Added by PressPlay
- //look direction:
- public static Vector3 up = Vector3.up;
- }
-
- #endregion
-
- #region #1 Static Registers
- /// <summary>
- /// Sets up a GameObject to avoid hiccups when an initial iTween is added. It's advisable to run this on every object you intend to run iTween on in its Start or Awake.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target to be initialized for iTween.
- /// </param>
- public static void Init(GameObject target){
- MoveBy(target,Vector3.zero,0);
- }
-
- /// <summary>
- /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with MINIMUM customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how transparent the Texture2D that the camera fade uses is.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void CameraFadeFrom(float amount, float time){
- if(cameraFade){
- CameraFadeFrom(Hash("amount",amount,"time",time));
- }else{
- Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading.");
- }
- }
-
- /// <summary>
- /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how transparent the Texture2D that the camera fade uses is.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void CameraFadeFrom(Hashtable args){
- //establish iTween:
- if(cameraFade){
- ColorFrom(cameraFade,args);
- }else{
- Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading.");
- }
- }
-
- /// <summary>
- /// Changes the amount(transparency) of a camera fade over time with MINIMUM customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how transparent the Texture2D that the camera fade uses is.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void CameraFadeTo(float amount, float time){
- if(cameraFade){
- CameraFadeTo(Hash("amount",amount,"time",time));
- }else{
- Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading.");
- }
- }
-
- /// <summary>
- /// Changes the amount(transparency) of a camera fade over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how transparent the Texture2D that the camera fade uses is.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void CameraFadeTo(Hashtable args){
- /*
- CameraFadeAdd(Defaults.cameraFadeDepth);
-
- //rescale cameraFade just in case screen size has changed to ensure it takes up the full screen:
- cameraFade.guiTexture.pixelInset=new Rect(0,0,Screen.width,Screen.height);
- */
-
- if(cameraFade){
- //establish iTween:
- ColorTo(cameraFade,args);
- }else{
- Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading.");
- }
- }
-
- /// <summary>
- /// Returns a value to an 'oncallback' method interpolated between the supplied 'from' and 'to' values for application as desired. Requires an 'onupdate' callback that accepts the same type as the supplied 'from' and 'to' properties.
- /// </summary>
- /// <param name="from">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> or <see cref="Vector3"/> or <see cref="Vector2"/> or <see cref="Color"/> or <see cref="Rect"/> for the starting value.
- /// </param>
- /// <param name="to">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> or <see cref="Vector3"/> or <see cref="Vector2"/> or <see cref="Color"/> or <see cref="Rect"/> for the ending value.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed (only works with Vector2, Vector3, and Floats)
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ValueTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- if (!args.Contains("onupdate") || !args.Contains("from") || !args.Contains("to")) {
- Debug.LogError("iTween Error: ValueTo() requires an 'onupdate' callback function and a 'from' and 'to' property. The supplied 'onupdate' callback must accept a single argument that is the same type as the supplied 'from' and 'to' properties!");
- return;
- }else{
- //establish iTween:
- args["type"]="value";
-
- if (args["from"].GetType() == typeof(Vector2)) {
- args["method"]="vector2";
- }else if (args["from"].GetType() == typeof(Vector3)) {
- args["method"]="vector3";
- }else if (args["from"].GetType() == typeof(Rect)) {
- args["method"]="rect";
- }else if (args["from"].GetType() == typeof(Single)) {
- args["method"]="float";
- }else if (args["from"].GetType() == typeof(Color)) {
- args["method"]="color";
- }else{
- Debug.LogError("iTween Error: ValueTo() only works with interpolating Vector3s, Vector2s, floats, ints, Rects and Colors!");
- return;
- }
-
- //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable:
- if (!args.Contains("easetype")) {
- args.Add("easetype",EaseType.linear);
- }
-
- Launch(target,args);
- }
- }
-
- /// <summary>
- /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void FadeFrom(GameObject target, float alpha, float time){
- FadeFrom(target,Hash("alpha",alpha,"time",time));
- }
-
- /// <summary>
- /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter.
- /// </summary>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the initial alpha value of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the initial alpha value of the animation.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void FadeFrom(GameObject target, Hashtable args){
- ColorFrom(target,args);
- }
-
- /// <summary>
- /// Changes a GameObject's alpha value over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void FadeTo(GameObject target, float alpha, float time){
- FadeTo(target,Hash("alpha",alpha,"time",time));
- }
- /// <summary>
- /// Changes a GameObject's alpha value over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter.
- /// </summary>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void FadeTo(GameObject target, Hashtable args){
- ColorTo(target,args);
- }
-
- /// <summary>
- /// Changes a GameObject's color values instantly then returns them to the provided properties over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ColorFrom(GameObject target, Color color, float time){
- ColorFrom(target,Hash("color",color,"time",time));
- }
-
- /// <summary>
- /// Changes a GameObject's color values instantly then returns them to the provided properties over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation.
- /// </summary>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="r">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color red.
- /// </param>
- /// <param name="g">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="b">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="a">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="namedcolorvalue">
- /// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ColorFrom(GameObject target, Hashtable args){
- Color fromColor = new Color();
- Color tempColor = new Color();
-
- //clean args:
- args = iTween.CleanArgs(args);
-
- //handle children:
- if(!args.Contains("includechildren") || (bool)args["includechildren"]){
- foreach(Transform child in target.transform){
- Hashtable argsCopy = (Hashtable)args.Clone();
- argsCopy["ischild"]=true;
- ColorFrom(child.gameObject,argsCopy);
- }
- }
-
- //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable:
- if (!args.Contains("easetype")) {
- args.Add("easetype",EaseType.linear);
- }
-
- //set tempColor and base fromColor:
- if(target.GetComponent(typeof(GUITexture))){
- tempColor=fromColor=target.GetComponent<GUITexture>().color;
- }else if(target.GetComponent(typeof(GUIText))){
- tempColor=fromColor=target.GetComponent<GUIText>().material.color;
- }else if(target.GetComponent<Renderer>()){
- tempColor=fromColor=target.GetComponent<Renderer>().material.color;
- }else if(target.GetComponent<Light>()){
- tempColor=fromColor=target.GetComponent<Light>().color;
- }
-
- //set augmented fromColor:
- if(args.Contains("color")){
- fromColor=(Color)args["color"];
- }else{
- if (args.Contains("r")) {
- fromColor.r=(float)args["r"];
- }
- if (args.Contains("g")) {
- fromColor.g=(float)args["g"];
- }
- if (args.Contains("b")) {
- fromColor.b=(float)args["b"];
- }
- if (args.Contains("a")) {
- fromColor.a=(float)args["a"];
- }
- }
-
- //alpha or amount?
- if(args.Contains("amount")){
- fromColor.a=(float)args["amount"];
- args.Remove("amount");
- }else if(args.Contains("alpha")){
- fromColor.a=(float)args["alpha"];
- args.Remove("alpha");
- }
-
- //apply fromColor:
- if(target.GetComponent(typeof(GUITexture))){
- target.GetComponent<GUITexture>().color=fromColor;
- }else if(target.GetComponent(typeof(GUIText))){
- target.GetComponent<GUIText>().material.color=fromColor;
- }else if(target.GetComponent<Renderer>()){
- target.GetComponent<Renderer>().material.color=fromColor;
- }else if(target.GetComponent<Light>()){
- target.GetComponent<Light>().color=fromColor;
- }
-
- //set new color arg:
- args["color"]=tempColor;
-
- //establish iTween:
- args["type"]="color";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Changes a GameObject's color values over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ColorTo(GameObject target, Color color, float time){
- ColorTo(target,Hash("color",color,"time",time));
- }
-
- /// <summary>
- /// Changes a GameObject's color values over time with FULL customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation.
- /// </summary>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="r">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color red.
- /// </param>
- /// <param name="g">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="b">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="a">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="namedcolorvalue">
- /// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ColorTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //handle children:
- if(!args.Contains("includechildren") || (bool)args["includechildren"]){
- foreach(Transform child in target.transform){
- Hashtable argsCopy = (Hashtable)args.Clone();
- argsCopy["ischild"]=true;
- ColorTo(child.gameObject,argsCopy);
- }
- }
-
- //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable:
- if (!args.Contains("easetype")) {
- args.Add("easetype",EaseType.linear);
- }
-
- //establish iTween:
- args["type"]="color";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation which holds the AudioSource to be changed.
- /// </param>
- /// <param name="volume"> for the target level of volume.
- /// A <see cref="System.Single"/>
- /// </param>
- /// <param name="pitch"> for the target pitch.
- /// A <see cref="System.Single"/>
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void AudioFrom(GameObject target, float volume, float pitch, float time){
- AudioFrom(target,Hash("volume",volume,"pitch",pitch,"time",time));
- }
-
- /// <summary>
- /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied.
- /// </summary>
- /// <param name="audiosource">
- /// A <see cref="AudioSource"/> for which AudioSource to use.
- /// </param>
- /// <param name="volume">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target level of volume.
- /// </param>
- /// <param name="pitch">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target pitch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void AudioFrom(GameObject target, Hashtable args){
- Vector2 tempAudioProperties;
- Vector2 fromAudioProperties;
- AudioSource tempAudioSource;
-
- //clean args:
- args = iTween.CleanArgs(args);
-
- //set tempAudioSource:
- if(args.Contains("audiosource")){
- tempAudioSource=(AudioSource)args["audiosource"];
- }else{
- if(target.GetComponent(typeof(AudioSource))){
- tempAudioSource=target.GetComponent<AudioSource>();
- }else{
- //throw error if no AudioSource is available:
- Debug.LogError("iTween Error: AudioFrom requires an AudioSource.");
- return;
- }
- }
-
- //set tempAudioProperties:
- tempAudioProperties.x=fromAudioProperties.x=tempAudioSource.volume;
- tempAudioProperties.y=fromAudioProperties.y=tempAudioSource.pitch;
-
- //set augmented fromAudioProperties:
- if(args.Contains("volume")){
- fromAudioProperties.x=(float)args["volume"];
- }
- if(args.Contains("pitch")){
- fromAudioProperties.y=(float)args["pitch"];
- }
-
- //apply fromAudioProperties:
- tempAudioSource.volume=fromAudioProperties.x;
- tempAudioSource.pitch=fromAudioProperties.y;
-
- //set new volume and pitch args:
- args["volume"]=tempAudioProperties.x;
- args["pitch"]=tempAudioProperties.y;
-
- //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable:
- if (!args.Contains("easetype")) {
- args.Add("easetype",EaseType.linear);
- }
-
- //establish iTween:
- args["type"]="audio";
- args["method"]="to";
- Launch(target,args);
- }
- /// <summary>
- /// Fades volume and pitch of an AudioSource with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation which holds the AudioSource to be changed.
- /// </param>
- /// <param name="volume"> for the target level of volume.
- /// A <see cref="System.Single"/>
- /// </param>
- /// <param name="pitch"> for the target pitch.
- /// A <see cref="System.Single"/>
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void AudioTo(GameObject target, float volume, float pitch, float time){
- AudioTo(target,Hash("volume",volume,"pitch",pitch,"time",time));
- }
-
- /// <summary>
- /// Fades volume and pitch of an AudioSource with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied.
- /// </summary>
- /// <param name="audiosource">
- /// A <see cref="AudioSource"/> for which AudioSource to use.
- /// </param>
- /// <param name="volume">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target level of volume.
- /// </param>
- /// <param name="pitch">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target pitch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void AudioTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable:
- if (!args.Contains("easetype")) {
- args.Add("easetype",EaseType.linear);
- }
-
- //establish iTween:
- args["type"]="audio";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Plays an AudioClip once based on supplied volume and pitch and following any delay with MINIMUM customization options. AudioSource is optional as iTween will provide one.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation which holds the AudioSource to be utilized.
- /// </param>
- /// <param name="audioclip">
- /// A <see cref="AudioClip"/> for a reference to the AudioClip to be played.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> for the time in seconds the action will wait before beginning.
- /// </param>
- public static void Stab(GameObject target, AudioClip audioclip, float delay){
- Stab(target,Hash("audioclip",audioclip,"delay",delay));
- }
-
- /// <summary>
- /// Plays an AudioClip once based on supplied volume and pitch and following any delay with FULL customization options. AudioSource is optional as iTween will provide one.
- /// </summary>
- /// <param name="audioclip">
- /// A <see cref="AudioClip"/> for a reference to the AudioClip to be played.
- /// </param>
- /// <param name="audiosource">
- /// A <see cref="AudioSource"/> for which AudioSource to use
- /// </param>
- /// <param name="volume">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target level of volume.
- /// </param>
- /// <param name="pitch">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target pitch.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the action will wait before beginning.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void Stab(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="stab";
- Launch(target,args);
- }
-
- /// <summary>
- /// Instantly rotates a GameObject to look at the supplied Vector3 then returns it to it's starting rotation over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> to be the Vector3 that the target will look towards.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void LookFrom(GameObject target, Vector3 looktarget, float time){
- LookFrom(target,Hash("looktarget",looktarget,"time",time));
- }
-
- /// <summary>
- /// Instantly rotates a GameObject to look at a supplied Transform or Vector3 then returns it to it's starting rotation over time with FULL customization options.
- /// </summary>
- /// <param name="looktarget">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void LookFrom(GameObject target, Hashtable args){
- Vector3 tempRotation;
- Vector3 tempRestriction;
-
- //clean args:
- args = iTween.CleanArgs(args);
-
- //set look:
- tempRotation=target.transform.eulerAngles;
- if (args["looktarget"].GetType() == typeof(Transform)) {
- //target.transform.LookAt((Transform)args["looktarget"]);
- target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up);
- }else if(args["looktarget"].GetType() == typeof(Vector3)){
- //target.transform.LookAt((Vector3)args["looktarget"]);
- target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up);
- }
-
- //axis restriction:
- if(args.Contains("axis")){
- tempRestriction=target.transform.eulerAngles;
- switch((string)args["axis"]){
- case "x":
- tempRestriction.y=tempRotation.y;
- tempRestriction.z=tempRotation.z;
- break;
- case "y":
- tempRestriction.x=tempRotation.x;
- tempRestriction.z=tempRotation.z;
- break;
- case "z":
- tempRestriction.x=tempRotation.x;
- tempRestriction.y=tempRotation.y;
- break;
- }
- target.transform.eulerAngles=tempRestriction;
- }
-
- //set new rotation:
- args["rotation"] = tempRotation;
-
- //establish iTween
- args["type"]="rotate";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Rotates a GameObject to look at the supplied Vector3 over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> to be the Vector3 that the target will look towards.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void LookTo(GameObject target, Vector3 looktarget, float time){
- LookTo(target,Hash("looktarget",looktarget,"time",time));
- }
-
- /// <summary>
- /// Rotates a GameObject to look at a supplied Transform or Vector3 over time with FULL customization options.
- /// </summary>
- /// <param name="looktarget">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void LookTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //additional property to ensure ConflictCheck can work correctly since Transforms are refrences:
- if(args.Contains("looktarget")){
- if (args["looktarget"].GetType() == typeof(Transform)) {
- Transform transform = (Transform)args["looktarget"];
- args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z);
- args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z);
- }
- }
-
- //establish iTween
- args["type"]="look";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Changes a GameObject's position over time to a supplied destination with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="position">
- /// A <see cref="Vector3"/> for the destination Vector3.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void MoveTo(GameObject target, Vector3 position, float time){
- MoveTo(target,Hash("position",position,"time",time));
- }
-
- /// <summary>
- /// Changes a GameObject's position over time to a supplied destination with FULL customization options.
- /// </summary>
- /// <param name="position">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space the GameObject will animate to.
- /// </param>
- /// <param name="path">
- /// A <see cref="Transform[]"/> or <see cref="Vector3[]"/> for a list of points to draw a Catmull-Rom through for a curved animation path.
- /// </param>
- /// <param name="movetopath">
- /// A <see cref="System.Boolean"/> for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="lookahead">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how much of a percentage to look ahead on a path to influence how strict "orientopath" is.
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void MoveTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //additional property to ensure ConflictCheck can work correctly since Transforms are refrences:
- if(args.Contains("position")){
- if (args["position"].GetType() == typeof(Transform)) {
- Transform transform = (Transform)args["position"];
- args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z);
- args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z);
- args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z);
- }
- }
-
- //establish iTween:
- args["type"]="move";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="position">
- /// A <see cref="Vector3"/> for the destination Vector3.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void MoveFrom(GameObject target, Vector3 position, float time){
- MoveFrom(target,Hash("position",position,"time",time));
- }
-
- /// <summary>
- /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with FULL customization options.
- /// </summary>
- /// <param name="position">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space the GameObject will animate to.
- /// </param>
- /// <param name="path">
- /// A <see cref="Transform[]"/> or <see cref="Vector3[]"/> for a list of points to draw a Catmull-Rom through for a curved animation path.
- /// </param>
- /// <param name="movetopath">
- /// A <see cref="System.Boolean"/> for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="lookahead">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for how much of a percentage to look ahead on a path to influence how strict "orientopath" is.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void MoveFrom(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- bool tempIsLocal;
-
- //set tempIsLocal:
- if(args.Contains("islocal")){
- tempIsLocal = (bool)args["islocal"];
- }else{
- tempIsLocal = Defaults.isLocal;
- }
-
- if(args.Contains("path")){
- Vector3[] fromPath;
- Vector3[] suppliedPath;
- if(args["path"].GetType() == typeof(Vector3[])){
- Vector3[] temp = (Vector3[])args["path"];
- suppliedPath=new Vector3[temp.Length];
- Array.Copy(temp,suppliedPath, temp.Length);
- }else{
- Transform[] temp = (Transform[])args["path"];
- suppliedPath = new Vector3[temp.Length];
- for (int i = 0; i < temp.Length; i++) {
- suppliedPath[i]=temp[i].position;
- }
- }
- if(suppliedPath[suppliedPath.Length-1] != target.transform.position){
- fromPath= new Vector3[suppliedPath.Length+1];
- Array.Copy(suppliedPath,fromPath,suppliedPath.Length);
- if(tempIsLocal){
- fromPath[fromPath.Length-1] = target.transform.localPosition;
- target.transform.localPosition=fromPath[0];
- }else{
- fromPath[fromPath.Length-1] = target.transform.position;
- target.transform.position=fromPath[0];
- }
- args["path"]=fromPath;
- }else{
- if(tempIsLocal){
- target.transform.localPosition=suppliedPath[0];
- }else{
- target.transform.position=suppliedPath[0];
- }
- args["path"]=suppliedPath;
- }
- }else{
- Vector3 tempPosition;
- Vector3 fromPosition;
-
- //set tempPosition and base fromPosition:
- if(tempIsLocal){
- tempPosition=fromPosition=target.transform.localPosition;
- }else{
- tempPosition=fromPosition=target.transform.position;
- }
-
- //set augmented fromPosition:
- if(args.Contains("position")){
- if (args["position"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["position"];
- fromPosition=trans.position;
- }else if(args["position"].GetType() == typeof(Vector3)){
- fromPosition=(Vector3)args["position"];
- }
- }else{
- if (args.Contains("x")) {
- fromPosition.x=(float)args["x"];
- }
- if (args.Contains("y")) {
- fromPosition.y=(float)args["y"];
- }
- if (args.Contains("z")) {
- fromPosition.z=(float)args["z"];
- }
- }
-
- //apply fromPosition:
- if(tempIsLocal){
- target.transform.localPosition = fromPosition;
- }else{
- target.transform.position = fromPosition;
- }
-
- //set new position arg:
- args["position"]=tempPosition;
- }
-
- //establish iTween:
- args["type"]="move";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Translates a GameObject's position over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of change in position to move the GameObject.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void MoveAdd(GameObject target, Vector3 amount, float time){
- MoveAdd(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Translates a GameObject's position over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of change in position to move the GameObject.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> or <see cref="System.String"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void MoveAdd(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="move";
- args["method"]="add";
- Launch(target,args);
- }
-
- /// <summary>
- /// Adds the supplied coordinates to a GameObject's postion with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of change in position to move the GameObject.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void MoveBy(GameObject target, Vector3 amount, float time){
- MoveBy(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Adds the supplied coordinates to a GameObject's position with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of change in position to move the GameObject.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> or <see cref="System.String"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void MoveBy(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="move";
- args["method"]="by";
- Launch(target,args);
- }
-
- /// <summary>
- /// Changes a GameObject's scale over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="scale">
- /// A <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleTo(GameObject target, Vector3 scale, float time){
- ScaleTo(target,Hash("scale",scale,"time",time));
- }
-
- /// <summary>
- /// Changes a GameObject's scale over time with FULL customization options.
- /// </summary>
- /// <param name="scale">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ScaleTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //additional property to ensure ConflictCheck can work correctly since Transforms are refrences:
- if(args.Contains("scale")){
- if (args["scale"].GetType() == typeof(Transform)) {
- Transform transform = (Transform)args["scale"];
- args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z);
- args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z);
- args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z);
- }
- }
-
- //establish iTween:
- args["type"]="scale";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="scale">
- /// A <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleFrom(GameObject target, Vector3 scale, float time){
- ScaleFrom(target,Hash("scale",scale,"time",time));
- }
-
- /// <summary>
- /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with FULL customization options.
- /// </summary>
- /// <param name="scale">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ScaleFrom(GameObject target, Hashtable args){
- Vector3 tempScale;
- Vector3 fromScale;
-
- //clean args:
- args = iTween.CleanArgs(args);
-
- //set base fromScale:
- tempScale=fromScale=target.transform.localScale;
-
- //set augmented fromScale:
- if(args.Contains("scale")){
- if (args["scale"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["scale"];
- fromScale=trans.localScale;
- }else if(args["scale"].GetType() == typeof(Vector3)){
- fromScale=(Vector3)args["scale"];
- }
- }else{
- if (args.Contains("x")) {
- fromScale.x=(float)args["x"];
- }
- if (args.Contains("y")) {
- fromScale.y=(float)args["y"];
- }
- if (args.Contains("z")) {
- fromScale.z=(float)args["z"];
- }
- }
-
- //apply fromScale:
- target.transform.localScale = fromScale;
-
- //set new scale arg:
- args["scale"]=tempScale;
-
- //establish iTween:
- args["type"]="scale";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Adds to a GameObject's scale over time with FULL customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of scale to be added to the GameObject's current scale.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleAdd(GameObject target, Vector3 amount, float time){
- ScaleAdd(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Adds to a GameObject's scale over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount to be added to the GameObject's current scale.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ScaleAdd(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="scale";
- args["method"]="add";
- Launch(target,args);
- }
-
- /// <summary>
- /// Multiplies a GameObject's scale over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of scale to be multiplied by the GameObject's current scale.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleBy(GameObject target, Vector3 amount, float time){
- ScaleBy(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Multiplies a GameObject's scale over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount to be multiplied to the GameObject's current scale.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ScaleBy(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="scale";
- args["method"]="by";
- Launch(target,args);
- }
-
- /// <summary>
- /// Rotates a GameObject to the supplied Euler angles in degrees over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="rotation">
- /// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateTo(GameObject target, Vector3 rotation, float time){
- RotateTo(target,Hash("rotation",rotation,"time",time));
- }
-
- /// <summary>
- /// Rotates a GameObject to the supplied Euler angles in degrees over time with FULL customization options.
- /// </summary>
- /// <param name="rotation">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler angles in degrees to rotate to.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void RotateTo(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //additional property to ensure ConflictCheck can work correctly since Transforms are refrences:
- if(args.Contains("rotation")){
- if (args["rotation"].GetType() == typeof(Transform)) {
- Transform transform = (Transform)args["rotation"];
- args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z);
- args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z);
- args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z);
- }
- }
-
- //establish iTween
- args["type"]="rotate";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="rotation">
- /// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate from.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateFrom(GameObject target, Vector3 rotation, float time){
- RotateFrom(target,Hash("rotation",rotation,"time",time));
- }
-
- /// <summary>
- /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with FULL customization options.
- /// </summary>
- /// <param name="rotation">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler angles in degrees to rotate to.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void RotateFrom(GameObject target, Hashtable args){
- Vector3 tempRotation;
- Vector3 fromRotation;
- bool tempIsLocal;
-
- //clean args:
- args = iTween.CleanArgs(args);
-
- //set tempIsLocal:
- if(args.Contains("islocal")){
- tempIsLocal = (bool)args["islocal"];
- }else{
- tempIsLocal = Defaults.isLocal;
- }
- //set tempRotation and base fromRotation:
- if(tempIsLocal){
- tempRotation=fromRotation=target.transform.localEulerAngles;
- }else{
- tempRotation=fromRotation=target.transform.eulerAngles;
- }
-
- //set augmented fromRotation:
- if(args.Contains("rotation")){
- if (args["rotation"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["rotation"];
- fromRotation=trans.eulerAngles;
- }else if(args["rotation"].GetType() == typeof(Vector3)){
- fromRotation=(Vector3)args["rotation"];
- }
- }else{
- if (args.Contains("x")) {
- fromRotation.x=(float)args["x"];
- }
- if (args.Contains("y")) {
- fromRotation.y=(float)args["y"];
- }
- if (args.Contains("z")) {
- fromRotation.z=(float)args["z"];
- }
- }
-
- //apply fromRotation:
- if(tempIsLocal){
- target.transform.localEulerAngles = fromRotation;
- }else{
- target.transform.eulerAngles = fromRotation;
- }
-
- //set new rotation arg:
- args["rotation"]=tempRotation;
-
- //establish iTween:
- args["type"]="rotate";
- args["method"]="to";
- Launch(target,args);
- }
-
- /// <summary>
- /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of Euler angles in degrees to add to the current rotation of the GameObject.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateAdd(GameObject target, Vector3 amount, float time){
- RotateAdd(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount of Euler angles in degrees to add to the current rotation of the GameObject.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> or <see cref="System.String"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void RotateAdd(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween:
- args["type"]="rotate";
- args["method"]="add";
- Launch(target,args);
- }
-
- /// <summary>
- /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount to be multiplied by 360 to rotate the GameObject.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateBy(GameObject target, Vector3 amount, float time){
- RotateBy(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the amount to be multiplied by 360 to rotate the GameObject.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> or <see cref="System.String"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="speed">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used instead of time to allow animation based on speed
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="easetype">
- /// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of the easing curve applied to the animation.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed.
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void RotateBy(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="rotate";
- args["method"]="by";
- Launch(target,args);
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's position by a diminishing amount over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ShakePosition(GameObject target, Vector3 amount, float time){
- ShakePosition(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's position by a diminishing amount over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ShakePosition(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="shake";
- args["method"]="position";
- Launch(target,args);
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's scale by a diminishing amount over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ShakeScale(GameObject target, Vector3 amount, float time){
- ShakeScale(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's scale by a diminishing amount over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ShakeScale(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="shake";
- args["method"]="scale";
- Launch(target,args);
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's rotation by a diminishing amount over time with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ShakeRotation(GameObject target, Vector3 amount, float time){
- ShakeRotation(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Randomly shakes a GameObject's rotation by a diminishing amount over time with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void ShakeRotation(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="shake";
- args["method"]="rotation";
- Launch(target,args);
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of the punch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void PunchPosition(GameObject target, Vector3 amount, float time){
- PunchPosition(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget".
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void PunchPosition(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="punch";
- args["method"]="position";
- args["easetype"]=EaseType.punch;
- Launch(target,args);
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of the punch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void PunchRotation(GameObject target, Vector3 amount, float time){
- PunchRotation(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="space">
- /// A <see cref="Space"/> for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void PunchRotation(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="punch";
- args["method"]="rotation";
- args["easetype"]=EaseType.punch;
- Launch(target,args);
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with MINIMUM customization options.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of the punch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void PunchScale(GameObject target, Vector3 amount, float time){
- PunchScale(target,Hash("amount",amount,"time",time));
- }
-
- /// <summary>
- /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with FULL customization options.
- /// </summary>
- /// <param name="amount">
- /// A <see cref="Vector3"/> for the magnitude of shake.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x magnitude.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y magnitude.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z magnitude.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="delay">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will wait before beginning.
- /// </param>
- /// <param name="looptype">
- /// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches)
- /// </param>
- /// <param name="onstart">
- /// A <see cref="System.String"/> for the name of a function to launch at the beginning of the animation.
- /// </param>
- /// <param name="onstarttarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onstart" method.
- /// </param>
- /// <param name="onstartparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onstart" method.
- /// </param>
- /// <param name="onupdate">
- /// A <see cref="System.String"/> for the name of a function to launch on every step of the animation.
- /// </param>
- /// <param name="onupdatetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "onupdate" method.
- /// </param>
- /// <param name="onupdateparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "onupdate" method.
- /// </param>
- /// <param name="oncomplete">
- /// A <see cref="System.String"/> for the name of a function to launch at the end of the animation.
- /// </param>
- /// <param name="oncompletetarget">
- /// A <see cref="GameObject"/> for a reference to the GameObject that holds the "oncomplete" method.
- /// </param>
- /// <param name="oncompleteparams">
- /// A <see cref="System.Object"/> for arguments to be sent to the "oncomplete" method.
- /// </param>
- public static void PunchScale(GameObject target, Hashtable args){
- //clean args:
- args = iTween.CleanArgs(args);
-
- //establish iTween
- args["type"]="punch";
- args["method"]="scale";
- args["easetype"]=EaseType.punch;
- Launch(target,args);
- }
-
- #endregion
-
- #region #2 Generate Method Targets
-
- //call correct set target method and set tween application delegate:
- void GenerateTargets(){
- switch (type) {
- case "value":
- switch (method) {
- case "float":
- GenerateFloatTargets();
- apply = new ApplyTween(ApplyFloatTargets);
- break;
- case "vector2":
- GenerateVector2Targets();
- apply = new ApplyTween(ApplyVector2Targets);
- break;
- case "vector3":
- GenerateVector3Targets();
- apply = new ApplyTween(ApplyVector3Targets);
- break;
- case "color":
- GenerateColorTargets();
- apply = new ApplyTween(ApplyColorTargets);
- break;
- case "rect":
- GenerateRectTargets();
- apply = new ApplyTween(ApplyRectTargets);
- break;
- }
- break;
- case "color":
- switch (method) {
- case "to":
- GenerateColorToTargets();
- apply = new ApplyTween(ApplyColorToTargets);
- break;
- }
- break;
- case "audio":
- switch (method) {
- case "to":
- GenerateAudioToTargets();
- apply = new ApplyTween(ApplyAudioToTargets);
- break;
- }
- break;
- case "move":
- switch (method) {
- case "to":
- //using a path?
- if(tweenArguments.Contains("path")){
- GenerateMoveToPathTargets();
- apply = new ApplyTween(ApplyMoveToPathTargets);
- }else{ //not using a path?
- GenerateMoveToTargets();
- apply = new ApplyTween(ApplyMoveToTargets);
- }
- break;
- case "by":
- case "add":
- GenerateMoveByTargets();
- apply = new ApplyTween(ApplyMoveByTargets);
- break;
- }
- break;
- case "scale":
- switch (method){
- case "to":
- GenerateScaleToTargets();
- apply = new ApplyTween(ApplyScaleToTargets);
- break;
- case "by":
- GenerateScaleByTargets();
- apply = new ApplyTween(ApplyScaleToTargets);
- break;
- case "add":
- GenerateScaleAddTargets();
- apply = new ApplyTween(ApplyScaleToTargets);
- break;
- }
- break;
- case "rotate":
- switch (method) {
- case "to":
- GenerateRotateToTargets();
- apply = new ApplyTween(ApplyRotateToTargets);
- break;
- case "add":
- GenerateRotateAddTargets();
- apply = new ApplyTween(ApplyRotateAddTargets);
- break;
- case "by":
- GenerateRotateByTargets();
- apply = new ApplyTween(ApplyRotateAddTargets);
- break;
- }
- break;
- case "shake":
- switch (method) {
- case "position":
- GenerateShakePositionTargets();
- apply = new ApplyTween(ApplyShakePositionTargets);
- break;
- case "scale":
- GenerateShakeScaleTargets();
- apply = new ApplyTween(ApplyShakeScaleTargets);
- break;
- case "rotation":
- GenerateShakeRotationTargets();
- apply = new ApplyTween(ApplyShakeRotationTargets);
- break;
- }
- break;
- case "punch":
- switch (method) {
- case "position":
- GeneratePunchPositionTargets();
- apply = new ApplyTween(ApplyPunchPositionTargets);
- break;
- case "rotation":
- GeneratePunchRotationTargets();
- apply = new ApplyTween(ApplyPunchRotationTargets);
- break;
- case "scale":
- GeneratePunchScaleTargets();
- apply = new ApplyTween(ApplyPunchScaleTargets);
- break;
- }
- break;
- case "look":
- switch (method) {
- case "to":
- GenerateLookToTargets();
- apply = new ApplyTween(ApplyLookToTargets);
- break;
- }
- break;
- case "stab":
- GenerateStabTargets();
- apply = new ApplyTween(ApplyStabTargets);
- break;
- }
- }
-
- #endregion
-
- #region #3 Generate Specific Targets
-
- void GenerateRectTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- rects=new Rect[3];
-
- //from and to values:
- rects[0]=(Rect)tweenArguments["from"];
- rects[1]=(Rect)tweenArguments["to"];
- }
-
- void GenerateColorTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- colors=new Color[1,3];
-
- //from and to values:
- colors[0,0]=(Color)tweenArguments["from"];
- colors[0,1]=(Color)tweenArguments["to"];
- }
-
- void GenerateVector3Targets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from and to values:
- vector3s[0]=(Vector3)tweenArguments["from"];
- vector3s[1]=(Vector3)tweenArguments["to"];
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateVector2Targets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector2s=new Vector2[3];
-
- //from and to values:
- vector2s[0]=(Vector2)tweenArguments["from"];
- vector2s[1]=(Vector2)tweenArguments["to"];
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- Vector3 fromV3 = new Vector3(vector2s[0].x,vector2s[0].y,0);
- Vector3 toV3 = new Vector3(vector2s[1].x,vector2s[1].y,0);
- float distance = Math.Abs(Vector3.Distance(fromV3,toV3));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateFloatTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- floats=new float[3];
-
- //from and to values:
- floats[0]=(float)tweenArguments["from"];
- floats[1]=(float)tweenArguments["to"];
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(floats[0] - floats[1]);
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateColorToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- //colors = new Color[3];
-
- //from and init to values:
- if(GetComponent(typeof(GUITexture))){
- colors = new Color[1,3];
- colors[0,0] = colors[0,1] = GetComponent<GUITexture>().color;
- }else if(GetComponent(typeof(GUIText))){
- colors = new Color[1,3];
- colors[0,0] = colors[0,1] = GetComponent<GUIText>().material.color;
- }else if(GetComponent<Renderer>()){
- colors = new Color[GetComponent<Renderer>().materials.Length,3];
- for (int i = 0; i < GetComponent<Renderer>().materials.Length; i++) {
- colors[i,0]=GetComponent<Renderer>().materials[i].GetColor(namedcolorvalue.ToString());
- colors[i,1]=GetComponent<Renderer>().materials[i].GetColor(namedcolorvalue.ToString());
- }
- //colors[0] = colors[1] = renderer.material.color;
- }else if(GetComponent<Light>()){
- colors = new Color[1,3];
- colors[0,0] = colors[0,1] = GetComponent<Light>().color;
- }else{
- colors = new Color[1,3]; //empty placeholder incase the GO is perhaps an empty holder or something similar
- }
-
- //to values:
- if (tweenArguments.Contains("color")) {
- //colors[1]=(Color)tweenArguments["color"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1]=(Color)tweenArguments["color"];
- }
- }else{
- if (tweenArguments.Contains("r")) {
- //colors[1].r=(float)tweenArguments["r"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].r=(float)tweenArguments["r"];
- }
- }
- if (tweenArguments.Contains("g")) {
- //colors[1].g=(float)tweenArguments["g"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].g=(float)tweenArguments["g"];
- }
- }
- if (tweenArguments.Contains("b")) {
- //colors[1].b=(float)tweenArguments["b"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].b=(float)tweenArguments["b"];
- }
- }
- if (tweenArguments.Contains("a")) {
- //colors[1].a=(float)tweenArguments["a"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].a=(float)tweenArguments["a"];
- }
- }
- }
-
- //alpha or amount?
- if(tweenArguments.Contains("amount")){
- //colors[1].a=(float)tweenArguments["amount"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].a=(float)tweenArguments["amount"];
- }
- }else if(tweenArguments.Contains("alpha")){
- //colors[1].a=(float)tweenArguments["alpha"];
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,1].a=(float)tweenArguments["alpha"];
- }
- }
- }
-
- void GenerateAudioToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector2s=new Vector2[3];
-
- //set audioSource:
- if(tweenArguments.Contains("audiosource")){
- audioSource=(AudioSource)tweenArguments["audiosource"];
- }else{
- if(GetComponent(typeof(AudioSource))){
- audioSource=GetComponent<AudioSource>();
- }else{
- //throw error if no AudioSource is available:
- Debug.LogError("iTween Error: AudioTo requires an AudioSource.");
- Dispose();
- }
- }
-
- //from values and default to values:
- vector2s[0]=vector2s[1]=new Vector2(audioSource.volume,audioSource.pitch);
-
- //to values:
- if (tweenArguments.Contains("volume")) {
- vector2s[1].x=(float)tweenArguments["volume"];
- }
- if (tweenArguments.Contains("pitch")) {
- vector2s[1].y=(float)tweenArguments["pitch"];
- }
- }
-
- void GenerateStabTargets(){
- //set audioSource:
- if(tweenArguments.Contains("audiosource")){
- audioSource=(AudioSource)tweenArguments["audiosource"];
- }else{
- if(GetComponent(typeof(AudioSource))){
- audioSource=GetComponent<AudioSource>();
- }else{
- //add and populate AudioSource if one doesn't exist:
- gameObject.AddComponent(typeof(AudioSource));
- audioSource=GetComponent<AudioSource>();
- audioSource.playOnAwake=false;
-
- }
- }
-
- //populate audioSource's clip:
- audioSource.clip=(AudioClip)tweenArguments["audioclip"];
-
- //set audio's pitch and volume if requested:
- if(tweenArguments.Contains("pitch")){
- audioSource.pitch=(float)tweenArguments["pitch"];
- }
- if(tweenArguments.Contains("volume")){
- audioSource.volume=(float)tweenArguments["volume"];
- }
-
- //set run time based on length of clip after pitch is augmented
- time=audioSource.clip.length/audioSource.pitch;
- }
-
- void GenerateLookToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- vector3s[0]=transform.eulerAngles;
-
- //set look:
- if(tweenArguments.Contains("looktarget")){
- if (tweenArguments["looktarget"].GetType() == typeof(Transform)) {
- //transform.LookAt((Transform)tweenArguments["looktarget"]);
- transform.LookAt((Transform)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up);
- }else if(tweenArguments["looktarget"].GetType() == typeof(Vector3)){
- //transform.LookAt((Vector3)tweenArguments["looktarget"]);
- transform.LookAt((Vector3)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up);
- }
- }else{
- Debug.LogError("iTween Error: LookTo needs a 'looktarget' property!");
- Dispose();
- }
- //to values:
- vector3s[1]=transform.eulerAngles;
- transform.eulerAngles=vector3s[0];
-
- //axis restriction:
- if(tweenArguments.Contains("axis")){
- switch((string)tweenArguments["axis"]){
- case "x":
- vector3s[1].y=vector3s[0].y;
- vector3s[1].z=vector3s[0].z;
- break;
- case "y":
- vector3s[1].x=vector3s[0].x;
- vector3s[1].z=vector3s[0].z;
- break;
- case "z":
- vector3s[1].x=vector3s[0].x;
- vector3s[1].y=vector3s[0].y;
- break;
- }
- }
-
- //shortest distance:
- vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1));
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateMoveToPathTargets(){
- Vector3[] suppliedPath;
-
- //create and store path points:
- if(tweenArguments["path"].GetType() == typeof(Vector3[])){
- Vector3[] temp = (Vector3[])tweenArguments["path"];
- //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value:
- if(temp.Length==1){
- Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!");
- Dispose();
- }
- suppliedPath=new Vector3[temp.Length];
- Array.Copy(temp,suppliedPath, temp.Length);
- }else{
- Transform[] temp = (Transform[])tweenArguments["path"];
- //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value:
- if(temp.Length==1){
- Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!");
- Dispose();
- }
- suppliedPath = new Vector3[temp.Length];
- for (int i = 0; i < temp.Length; i++) {
- suppliedPath[i]=temp[i].position;
- }
- }
-
- //do we need to plot a path to get to the beginning of the supplied path?
- bool plotStart;
- int offset;
- if(transform.position != suppliedPath[0]){
- if(!tweenArguments.Contains("movetopath") || (bool)tweenArguments["movetopath"]==true){
- plotStart=true;
- offset=3;
- }else{
- plotStart=false;
- offset=2;
- }
- }else{
- plotStart=false;
- offset=2;
- }
- //build calculated path:
- vector3s = new Vector3[suppliedPath.Length+offset];
- if(plotStart){
- vector3s[1]=transform.position;
- offset=2;
- }else{
- offset=1;
- }
-
- //populate calculate path;
- Array.Copy(suppliedPath,0,vector3s,offset,suppliedPath.Length);
-
- //populate start and end control points:
- //vector3s[0] = vector3s[1] - vector3s[2];
- vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]);
- vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]);
-
- //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline!
- if(vector3s[1] == vector3s[vector3s.Length-2]){
- Vector3[] tmpLoopSpline = new Vector3[vector3s.Length];
- Array.Copy(vector3s,tmpLoopSpline,vector3s.Length);
- tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3];
- tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2];
- vector3s=new Vector3[tmpLoopSpline.Length];
- Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length);
- }
-
- //create Catmull-Rom path:
- path = new CRSpline(vector3s);
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = PathLength(vector3s);
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateMoveToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- if (isLocal) {
- vector3s[0]=vector3s[1]=transform.localPosition;
- }else{
- vector3s[0]=vector3s[1]=transform.position;
- }
-
- //to values:
- if (tweenArguments.Contains("position")) {
- if (tweenArguments["position"].GetType() == typeof(Transform)){
- Transform trans = (Transform)tweenArguments["position"];
- vector3s[1]=trans.position;
- }else if(tweenArguments["position"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)tweenArguments["position"];
- }
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
-
- //handle orient to path request:
- if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){
- tweenArguments["looktarget"] = vector3s[1];
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateMoveByTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in, [5] for dial in location:
- vector3s=new Vector3[6];
-
- //grab starting rotation:
- vector3s[4] = transform.eulerAngles;
-
- //from values:
- vector3s[0]=vector3s[1]=vector3s[3]=transform.position;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=vector3s[0] + (Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=vector3s[0].x + (float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=vector3s[0].y +(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=vector3s[0].z + (float)tweenArguments["z"];
- }
- }
-
- //calculation for dial in:
- transform.Translate(vector3s[1],space);
- vector3s[5] = transform.position;
- transform.position=vector3s[0];
-
- //handle orient to path request:
- if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){
- tweenArguments["looktarget"] = vector3s[1];
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateScaleToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- vector3s[0]=vector3s[1]=transform.localScale;
- //to values:
- if (tweenArguments.Contains("scale")) {
- if (tweenArguments["scale"].GetType() == typeof(Transform)){
- Transform trans = (Transform)tweenArguments["scale"];
- vector3s[1]=trans.localScale;
- }else if(tweenArguments["scale"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)tweenArguments["scale"];
- }
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateScaleByTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- vector3s[0]=vector3s[1]=transform.localScale;
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=Vector3.Scale(vector3s[1],(Vector3)tweenArguments["amount"]);
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x*=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y*=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z*=(float)tweenArguments["z"];
- }
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateScaleAddTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- vector3s[0]=vector3s[1]=transform.localScale;
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]+=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x+=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y+=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z+=(float)tweenArguments["z"];
- }
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateRotateToTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- if (isLocal) {
- vector3s[0]=vector3s[1]=transform.localEulerAngles;
- }else{
- vector3s[0]=vector3s[1]=transform.eulerAngles;
- }
-
- //to values:
- if (tweenArguments.Contains("rotation")) {
- if (tweenArguments["rotation"].GetType() == typeof(Transform)){
- Transform trans = (Transform)tweenArguments["rotation"];
- vector3s[1]=trans.eulerAngles;
- }else if(tweenArguments["rotation"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)tweenArguments["rotation"];
- }
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
-
- //shortest distance:
- vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1));
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateRotateAddTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization:
- vector3s=new Vector3[5];
-
- //from values:
- vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]+=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x+=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y+=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z+=(float)tweenArguments["z"];
- }
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateRotateByTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization:
- vector3s=new Vector3[4];
-
- //from values:
- vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]+=Vector3.Scale((Vector3)tweenArguments["amount"],new Vector3(360,360,360));
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x+=360 * (float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y+=360 * (float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z+=360 * (float)tweenArguments["z"];
- }
- }
-
- //need for speed?
- if(tweenArguments.Contains("speed")){
- float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1]));
- time = distance/(float)tweenArguments["speed"];
- }
- }
-
- void GenerateShakePositionTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] original rotation to make sure look requests don't interfere with the direction object should move in:
- vector3s=new Vector3[4];
-
- //grab starting rotation:
- vector3s[3] = transform.eulerAngles;
-
- //root:
- vector3s[0]=transform.position;
-
- //amount:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- void GenerateShakeScaleTargets(){
- //values holder [0] root value, [1] amount, [2] generated amount:
- vector3s=new Vector3[3];
-
- //root:
- vector3s[0]=transform.localScale;
-
- //amount:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- void GenerateShakeRotationTargets(){
- //values holder [0] root value, [1] amount, [2] generated amount:
- vector3s=new Vector3[3];
-
- //root:
- vector3s[0]=transform.eulerAngles;
-
- //amount:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- void GeneratePunchPositionTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in:
- vector3s=new Vector3[5];
-
- //grab starting rotation:
- vector3s[4] = transform.eulerAngles;
-
- //from values:
- vector3s[0]=transform.position;
- vector3s[1]=vector3s[3]=Vector3.zero;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- void GeneratePunchRotationTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization:
- vector3s=new Vector3[4];
-
- //from values:
- vector3s[0]=transform.eulerAngles;
- vector3s[1]=vector3s[3]=Vector3.zero;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- void GeneratePunchScaleTargets(){
- //values holder [0] from, [1] to, [2] calculated value from ease equation:
- vector3s=new Vector3[3];
-
- //from values:
- vector3s[0]=transform.localScale;
- vector3s[1]=Vector3.zero;
-
- //to values:
- if (tweenArguments.Contains("amount")) {
- vector3s[1]=(Vector3)tweenArguments["amount"];
- }else{
- if (tweenArguments.Contains("x")) {
- vector3s[1].x=(float)tweenArguments["x"];
- }
- if (tweenArguments.Contains("y")) {
- vector3s[1].y=(float)tweenArguments["y"];
- }
- if (tweenArguments.Contains("z")) {
- vector3s[1].z=(float)tweenArguments["z"];
- }
- }
- }
-
- #endregion
-
- #region #4 Apply Targets
-
- void ApplyRectTargets(){
- //calculate:
- rects[2].x = ease(rects[0].x,rects[1].x,percentage);
- rects[2].y = ease(rects[0].y,rects[1].y,percentage);
- rects[2].width = ease(rects[0].width,rects[1].width,percentage);
- rects[2].height = ease(rects[0].height,rects[1].height,percentage);
-
- //apply:
- tweenArguments["onupdateparams"]=rects[2];
-
- //dial in:
- if(percentage==1){
- tweenArguments["onupdateparams"]=rects[1];
- }
- }
-
- void ApplyColorTargets(){
- //calculate:
- colors[0,2].r = ease(colors[0,0].r,colors[0,1].r,percentage);
- colors[0,2].g = ease(colors[0,0].g,colors[0,1].g,percentage);
- colors[0,2].b = ease(colors[0,0].b,colors[0,1].b,percentage);
- colors[0,2].a = ease(colors[0,0].a,colors[0,1].a,percentage);
-
- //apply:
- tweenArguments["onupdateparams"]=colors[0,2];
-
- //dial in:
- if(percentage==1){
- tweenArguments["onupdateparams"]=colors[0,1];
- }
- }
-
- void ApplyVector3Targets(){
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- tweenArguments["onupdateparams"]=vector3s[2];
-
- //dial in:
- if(percentage==1){
- tweenArguments["onupdateparams"]=vector3s[1];
- }
- }
-
- void ApplyVector2Targets(){
- //calculate:
- vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage);
- vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage);
-
- //apply:
- tweenArguments["onupdateparams"]=vector2s[2];
-
- //dial in:
- if(percentage==1){
- tweenArguments["onupdateparams"]=vector2s[1];
- }
- }
-
- void ApplyFloatTargets(){
- //calculate:
- floats[2] = ease(floats[0],floats[1],percentage);
-
- //apply:
- tweenArguments["onupdateparams"]=floats[2];
-
- //dial in:
- if(percentage==1){
- tweenArguments["onupdateparams"]=floats[1];
- }
- }
-
- void ApplyColorToTargets(){
- //calculate:
- for (int i = 0; i < colors.GetLength(0); i++) {
- colors[i,2].r = ease(colors[i,0].r,colors[i,1].r,percentage);
- colors[i,2].g = ease(colors[i,0].g,colors[i,1].g,percentage);
- colors[i,2].b = ease(colors[i,0].b,colors[i,1].b,percentage);
- colors[i,2].a = ease(colors[i,0].a,colors[i,1].a,percentage);
- }
- /*
- colors[2].r = ease(colors[0].r,colors[1].r,percentage);
- colors[2].g = ease(colors[0].g,colors[1].g,percentage);
- colors[2].b = ease(colors[0].b,colors[1].b,percentage);
- colors[2].a = ease(colors[0].a,colors[1].a,percentage);
- */
-
- //apply:
- if(GetComponent(typeof(GUITexture))){
- //guiTexture.color=colors[2];
- GetComponent<GUITexture>().color=colors[0,2];
- }else if(GetComponent(typeof(GUIText))){
- //guiText.material.color=colors[2];
- GetComponent<GUIText>().material.color=colors[0,2];
- }else if(GetComponent<Renderer>()){
- //renderer.material.color=colors[2];
- for (int i = 0; i < colors.GetLength(0); i++) {
- GetComponent<Renderer>().materials[i].SetColor(namedcolorvalue.ToString(),colors[i,2]);
- }
- }else if(GetComponent<Light>()){
- //light.color=colors[2];
- GetComponent<Light>().color=colors[0,2];
- }
-
- //dial in:
- if(percentage==1){
- if(GetComponent(typeof(GUITexture))){
- //guiTexture.color=colors[1];
- GetComponent<GUITexture>().color=colors[0,1];
- }else if(GetComponent(typeof(GUIText))){
- //guiText.material.color=colors[1];
- GetComponent<GUIText>().material.color=colors[0,1];
- }else if(GetComponent<Renderer>()){
- //renderer.material.color=colors[1];
- for (int i = 0; i < colors.GetLength(0); i++) {
- GetComponent<Renderer>().materials[i].SetColor(namedcolorvalue.ToString(),colors[i,1]);
- }
- }else if(GetComponent<Light>()){
- //light.color=colors[1];
- GetComponent<Light>().color=colors[0,1];
- }
- }
- }
-
- void ApplyAudioToTargets(){
- //calculate:
- vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage);
- vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage);
-
- //apply:
- audioSource.volume=vector2s[2].x;
- audioSource.pitch=vector2s[2].y;
-
- //dial in:
- if(percentage==1){
- audioSource.volume=vector2s[1].x;
- audioSource.pitch=vector2s[1].y;
- }
- }
-
- void ApplyStabTargets(){
- //unnecessary but here just in case
- }
-
- void ApplyMoveToPathTargets(){
- preUpdate = transform.position;
- float t = ease(0,1,percentage);
- float lookAheadAmount;
-
- //clamp easing equation results as "back" will fail since overshoots aren't handled in the Catmull-Rom interpolation:
- if(isLocal){
- transform.localPosition=path.Interp(Mathf.Clamp(t,0,1));
- }else{
- transform.position=path.Interp(Mathf.Clamp(t,0,1));
- }
-
- //handle orient to path request:
- if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){
-
- //plot a point slightly ahead in the interpolation by pushing the percentage forward using the default lookahead value:
- float tLook;
- if(tweenArguments.Contains("lookahead")){
- lookAheadAmount = (float)tweenArguments["lookahead"];
- }else{
- lookAheadAmount = Defaults.lookAhead;
- }
- //tLook = ease(0,1,percentage+lookAheadAmount);
- tLook = ease(0,1, Mathf.Min(1f, percentage+lookAheadAmount));
-
- //locate new leading point with a clamp as stated above:
- //Vector3 lookDistance = path.Interp(Mathf.Clamp(tLook,0,1)) - transform.position;
- tweenArguments["looktarget"] = path.Interp(Mathf.Clamp(tLook,0,1));
- }
-
- //need physics?
- postUpdate=transform.position;
- if(physics){
- transform.position=preUpdate;
- GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
-
- void ApplyMoveToTargets(){
- //record current:
- preUpdate=transform.position;
-
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- if (isLocal) {
- transform.localPosition=vector3s[2];
- }else{
- transform.position=vector3s[2];
- }
-
- //dial in:
- if(percentage==1){
- if (isLocal) {
- transform.localPosition=vector3s[1];
- }else{
- transform.position=vector3s[1];
- }
- }
-
- //need physics?
- postUpdate=transform.position;
- if(physics){
- transform.position=preUpdate;
- GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
-
- void ApplyMoveByTargets(){
- preUpdate = transform.position;
-
- //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation
- Vector3 currentRotation = new Vector3();
-
- if(tweenArguments.Contains("looktarget")){
- currentRotation = transform.eulerAngles;
- transform.eulerAngles = vector3s[4];
- }
-
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- transform.Translate(vector3s[2]-vector3s[3],space);
-
- //record:
- vector3s[3]=vector3s[2];
-
- //reset rotation:
- if(tweenArguments.Contains("looktarget")){
- transform.eulerAngles = currentRotation;
- }
-
- /*
- //dial in:
- if(percentage==1){
- transform.position=vector3s[5];
- }
- */
-
- //need physics?
- postUpdate=transform.position;
- if(physics){
- transform.position=preUpdate;
- GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
-
- void ApplyScaleToTargets(){
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- transform.localScale=vector3s[2];
-
- //dial in:
- if(percentage==1){
- transform.localScale=vector3s[1];
- }
- }
-
- void ApplyLookToTargets(){
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- if (isLocal) {
- transform.localRotation = Quaternion.Euler(vector3s[2]);
- }else{
- transform.rotation = Quaternion.Euler(vector3s[2]);
- };
- }
-
- void ApplyRotateToTargets(){
- preUpdate=transform.eulerAngles;
-
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- if (isLocal) {
- transform.localRotation = Quaternion.Euler(vector3s[2]);
- }else{
- transform.rotation = Quaternion.Euler(vector3s[2]);
- };
-
- //dial in:
- if(percentage==1){
- if (isLocal) {
- transform.localRotation = Quaternion.Euler(vector3s[1]);
- }else{
- transform.rotation = Quaternion.Euler(vector3s[1]);
- };
- }
-
- //need physics?
- postUpdate=transform.eulerAngles;
- if(physics){
- transform.eulerAngles=preUpdate;
- GetComponent<Rigidbody>().MoveRotation(Quaternion.Euler(postUpdate));
- }
- }
-
- void ApplyRotateAddTargets(){
- preUpdate = transform.eulerAngles;
-
- //calculate:
- vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage);
- vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage);
- vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage);
-
- //apply:
- transform.Rotate(vector3s[2]-vector3s[3],space);
- //record:
- vector3s[3]=vector3s[2];
-
- //need physics?
- postUpdate=transform.eulerAngles;
- if(physics){
- transform.eulerAngles=preUpdate;
- GetComponent<Rigidbody>().MoveRotation(Quaternion.Euler(postUpdate));
- }
- }
-
- void ApplyShakePositionTargets(){
- //preUpdate = transform.position;
- if (isLocal) {
- preUpdate = transform.localPosition;
- }else{
- preUpdate = transform.position;
- }
-
- //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation
- Vector3 currentRotation = new Vector3();
-
- if(tweenArguments.Contains("looktarget")){
- currentRotation = transform.eulerAngles;
- transform.eulerAngles = vector3s[3];
- }
-
- //impact:
- if (percentage==0) {
- transform.Translate(vector3s[1],space);
- }
-
- //transform.position=vector3s[0];
- //reset:
- if (isLocal) {
- transform.localPosition=vector3s[0];
- }else{
- transform.position=vector3s[0];
- }
-
- //generate:
- float diminishingControl = 1-percentage;
- vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl);
- vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl);
- vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl);
- //apply:
- //transform.Translate(vector3s[2],space);
- if (isLocal) {
- transform.localPosition+=vector3s[2];
- }else{
- transform.position+=vector3s[2];
- }
-
- //reset rotation:
- if(tweenArguments.Contains("looktarget")){
- transform.eulerAngles = currentRotation;
- }
-
- //need physics?
- postUpdate=transform.position;
- if(physics){
- transform.position=preUpdate;
- GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
-
- void ApplyShakeScaleTargets(){
- //impact:
- if (percentage==0) {
- transform.localScale=vector3s[1];
- }
-
- //reset:
- transform.localScale=vector3s[0];
-
- //generate:
- float diminishingControl = 1-percentage;
- vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl);
- vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl);
- vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl);
- //apply:
- transform.localScale+=vector3s[2];
- }
-
- void ApplyShakeRotationTargets(){
- preUpdate = transform.eulerAngles;
-
- //impact:
- if (percentage==0) {
- transform.Rotate(vector3s[1],space);
- }
-
- //reset:
- transform.eulerAngles=vector3s[0];
-
- //generate:
- float diminishingControl = 1-percentage;
- vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl);
- vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl);
- vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl);
- //apply:
- transform.Rotate(vector3s[2],space);
-
- //need physics?
- postUpdate=transform.eulerAngles;
- if(physics){
- transform.eulerAngles=preUpdate;
- GetComponent<Rigidbody>().MoveRotation(Quaternion.Euler(postUpdate));
- }
- }
-
- void ApplyPunchPositionTargets(){
- preUpdate = transform.position;
-
- //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation
- Vector3 currentRotation = new Vector3();
-
- if(tweenArguments.Contains("looktarget")){
- currentRotation = transform.eulerAngles;
- transform.eulerAngles = vector3s[4];
- }
-
- //calculate:
- if(vector3s[1].x>0){
- vector3s[2].x = punch(vector3s[1].x,percentage);
- }else if(vector3s[1].x<0){
- vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage);
- }
- if(vector3s[1].y>0){
- vector3s[2].y=punch(vector3s[1].y,percentage);
- }else if(vector3s[1].y<0){
- vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage);
- }
- if(vector3s[1].z>0){
- vector3s[2].z=punch(vector3s[1].z,percentage);
- }else if(vector3s[1].z<0){
- vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage);
- }
-
- //apply:
- transform.Translate(vector3s[2]-vector3s[3],space);
- //record:
- vector3s[3]=vector3s[2];
-
- //reset rotation:
- if(tweenArguments.Contains("looktarget")){
- transform.eulerAngles = currentRotation;
- }
-
- //dial in:
- /*
- if(percentage==1){
- transform.position=vector3s[0];
- }
- */
-
- //need physics?
- postUpdate=transform.position;
- if(physics){
- transform.position=preUpdate;
- GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
-
- void ApplyPunchRotationTargets(){
- preUpdate = transform.eulerAngles;
-
- //calculate:
- if(vector3s[1].x>0){
- vector3s[2].x = punch(vector3s[1].x,percentage);
- }else if(vector3s[1].x<0){
- vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage);
- }
- if(vector3s[1].y>0){
- vector3s[2].y=punch(vector3s[1].y,percentage);
- }else if(vector3s[1].y<0){
- vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage);
- }
- if(vector3s[1].z>0){
- vector3s[2].z=punch(vector3s[1].z,percentage);
- }else if(vector3s[1].z<0){
- vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage);
- }
-
- //apply:
- transform.Rotate(vector3s[2]-vector3s[3],space);
- //record:
- vector3s[3]=vector3s[2];
-
- //dial in:
- /*
- if(percentage==1){
- transform.eulerAngles=vector3s[0];
- }
- */
-
- //need physics?
- postUpdate=transform.eulerAngles;
- if(physics){
- transform.eulerAngles=preUpdate;
- GetComponent<Rigidbody>().MoveRotation(Quaternion.Euler(postUpdate));
- }
- }
-
- void ApplyPunchScaleTargets(){
- //calculate:
- if(vector3s[1].x>0){
- vector3s[2].x = punch(vector3s[1].x,percentage);
- }else if(vector3s[1].x<0){
- vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage);
- }
- if(vector3s[1].y>0){
- vector3s[2].y=punch(vector3s[1].y,percentage);
- }else if(vector3s[1].y<0){
- vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage);
- }
- if(vector3s[1].z>0){
- vector3s[2].z=punch(vector3s[1].z,percentage);
- }else if(vector3s[1].z<0){
- vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage);
- }
-
- //apply:
- transform.localScale=vector3s[0]+vector3s[2];
-
- //dial in:
- /*
- if(percentage==1){
- transform.localScale=vector3s[0];
- }
- */
- }
-
- #endregion
-
- #region #5 Tween Steps
-
- IEnumerator TweenDelay(){
- delayStarted = Time.time;
- yield return new WaitForSeconds (delay);
- if(wasPaused){
- wasPaused=false;
- TweenStart();
- }
- }
-
- void TweenStart(){
- CallBack("onstart");
-
- if(!loop){//only if this is not a loop
- ConflictCheck();
- GenerateTargets();
- }
-
- //run stab:
- if(type == "stab"){
- audioSource.PlayOneShot(audioSource.clip);
- }
-
- //toggle isKinematic for iTweens that may interfere with physics:
- if (type == "move" || type=="scale" || type=="rotate" || type=="punch" || type=="shake" || type=="curve" || type=="look") {
- EnableKinematic();
- }
-
- isRunning = true;
- }
-
- IEnumerator TweenRestart(){
- if(delay > 0){
- delayStarted = Time.time;
- yield return new WaitForSeconds (delay);
- }
- loop=true;
- TweenStart();
- }
-
- void TweenUpdate(){
- apply();
- CallBack("onupdate");
- UpdatePercentage();
- }
-
- void TweenComplete(){
- isRunning=false;
-
- //dial in percentage to 1 or 0 for final run:
- if(percentage>.5f){
- percentage=1f;
- }else{
- percentage=0;
- }
-
- //apply dial in and final run:
- apply();
- if(type == "value"){
- CallBack("onupdate"); //CallBack run for ValueTo since it only calculates and applies in the update callback
- }
-
- //loop or dispose?
- if(loopType==LoopType.none){
- Dispose();
- }else{
- TweenLoop();
- }
-
- CallBack("oncomplete");
- }
-
- void TweenLoop(){
- DisableKinematic(); //give physics control again
- switch(loopType){
- case LoopType.loop:
- //rewind:
- percentage=0;
- runningTime=0;
- apply();
-
- //replay:
- StartCoroutine("TweenRestart");
- break;
- case LoopType.pingPong:
- reverse = !reverse;
- runningTime=0;
-
- //replay:
- StartCoroutine("TweenRestart");
- break;
- }
- }
-
- #endregion
-
- #region #6 Update Callable
-
- /// <summary>
- /// Returns a Rect that is eased between a current and target value by the supplied speed.
- /// </summary>
- /// <returns>
- /// A <see cref="Rect"/
- /// </returns>
- /// <param name='currentValue'>
- /// A <see cref="Rect"/> the starting or initial value
- /// </param>
- /// <param name='targetValue'>
- /// A <see cref="Rect"/> the target value that the current value will be eased to.
- /// </param>
- /// <param name='speed'>
- /// A <see cref="System.Single"/> to be used as rate of speed (larger number equals faster animation)
- /// </param>
- public static Rect RectUpdate(Rect currentValue, Rect targetValue, float speed){
- Rect diff = new Rect(FloatUpdate(currentValue.x, targetValue.x, speed), FloatUpdate(currentValue.y, targetValue.y, speed), FloatUpdate(currentValue.width, targetValue.width, speed), FloatUpdate(currentValue.height, targetValue.height, speed));
- return (diff);
- }
-
- /// <summary>
- /// Returns a Vector3 that is eased between a current and target value by the supplied speed.
- /// </summary>
- /// <returns>
- /// A <see cref="Vector3"/>
- /// </returns>
- /// <param name='currentValue'>
- /// A <see cref="Vector3"/> the starting or initial value
- /// </param>
- /// <param name='targetValue'>
- /// A <see cref="Vector3"/> the target value that the current value will be eased to.
- /// </param>
- /// <param name='speed'>
- /// A <see cref="System.Single"/> to be used as rate of speed (larger number equals faster animation)
- /// </param>
- public static Vector3 Vector3Update(Vector3 currentValue, Vector3 targetValue, float speed){
- Vector3 diff = targetValue - currentValue;
- currentValue += (diff * speed) * Time.deltaTime;
- return (currentValue);
- }
-
- /// <summary>
- /// Returns a Vector2 that is eased between a current and target value by the supplied speed.
- /// </summary>
- /// <returns>
- /// A <see cref="Vector2"/>
- /// </returns>
- /// <param name='currentValue'>
- /// A <see cref="Vector2"/> the starting or initial value
- /// </param>
- /// <param name='targetValue'>
- /// A <see cref="Vector2"/> the target value that the current value will be eased to.
- /// </param>
- /// <param name='speed'>
- /// A <see cref="System.Single"/> to be used as rate of speed (larger number equals faster animation)
- /// </param>
- public static Vector2 Vector2Update(Vector2 currentValue, Vector2 targetValue, float speed){
- Vector2 diff = targetValue - currentValue;
- currentValue += (diff * speed) * Time.deltaTime;
- return (currentValue);
- }
-
- /// <summary>
- /// Returns a float that is eased between a current and target value by the supplied speed.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Single"/>
- /// </returns>
- /// <param name='currentValue'>
- /// A <see cref="System.Single"/> the starting or initial value
- /// </param>
- /// <param name='targetValue'>
- /// A <see cref="System.Single"/> the target value that the current value will be eased to.
- /// </param>
- /// <param name='speed'>
- /// A <see cref="System.Single"/> to be used as rate of speed (larger number equals faster animation)
- /// </param>
- public static float FloatUpdate(float currentValue, float targetValue, float speed){
- float diff = targetValue - currentValue;
- currentValue += (diff * speed) * Time.deltaTime;
- return (currentValue);
- }
-
- /// <summary>
- /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void FadeUpdate(GameObject target, Hashtable args){
- args["a"]=args["alpha"];
- ColorUpdate(target,args);
- }
-
- /// <summary>
- /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="alpha">
- /// A <see cref="System.Single"/> for the final alpha value of the animation.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void FadeUpdate(GameObject target, float alpha, float time){
- FadeUpdate(target,Hash("alpha",alpha,"time",time));
- }
-
- /// <summary>
- /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="r">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color red.
- /// </param>
- /// <param name="g">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="b">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the color green.
- /// </param>
- /// <param name="a">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="namedcolorvalue">
- /// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the individual setting of the alpha.
- /// </param>
- /// <param name="includechildren">
- /// A <see cref="System.Boolean"/> for whether or not to include children of this GameObject. True by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ColorUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- float time;
- Color[] colors = new Color[4];
-
- //handle children:
- if(!args.Contains("includechildren") || (bool)args["includechildren"]){
- foreach(Transform child in target.transform){
- ColorUpdate(child.gameObject,args);
- }
- }
-
- //set smooth time:
- if(args.Contains("time")){
- time=(float)args["time"];
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
-
- //init values:
- if(target.GetComponent(typeof(GUITexture))){
- colors[0] = colors[1] = target.GetComponent<GUITexture>().color;
- }else if(target.GetComponent(typeof(GUIText))){
- colors[0] = colors[1] = target.GetComponent<GUIText>().material.color;
- }else if(target.GetComponent<Renderer>()){
- colors[0] = colors[1] = target.GetComponent<Renderer>().material.color;
- }else if(target.GetComponent<Light>()){
- colors[0] = colors[1] = target.GetComponent<Light>().color;
- }
-
- //to values:
- if (args.Contains("color")) {
- colors[1]=(Color)args["color"];
- }else{
- if (args.Contains("r")) {
- colors[1].r=(float)args["r"];
- }
- if (args.Contains("g")) {
- colors[1].g=(float)args["g"];
- }
- if (args.Contains("b")) {
- colors[1].b=(float)args["b"];
- }
- if (args.Contains("a")) {
- colors[1].a=(float)args["a"];
- }
- }
-
- //calculate:
- colors[3].r=Mathf.SmoothDamp(colors[0].r,colors[1].r,ref colors[2].r,time);
- colors[3].g=Mathf.SmoothDamp(colors[0].g,colors[1].g,ref colors[2].g,time);
- colors[3].b=Mathf.SmoothDamp(colors[0].b,colors[1].b,ref colors[2].b,time);
- colors[3].a=Mathf.SmoothDamp(colors[0].a,colors[1].a,ref colors[2].a,time);
-
- //apply:
- if(target.GetComponent(typeof(GUITexture))){
- target.GetComponent<GUITexture>().color=colors[3];
- }else if(target.GetComponent(typeof(GUIText))){
- target.GetComponent<GUIText>().material.color=colors[3];
- }else if(target.GetComponent<Renderer>()){
- target.GetComponent<Renderer>().material.color=colors[3];
- }else if(target.GetComponent<Light>()){
- target.GetComponent<Light>().color=colors[3];
- }
- }
-
- /// <summary>
- /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/> to change the GameObject's color to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ColorUpdate(GameObject target, Color color, float time){
- ColorUpdate(target,Hash("color",color,"time",time));
- }
-
- /// <summary>
- /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="audiosource">
- /// A <see cref="AudioSource"/> for which AudioSource to use.
- /// </param>
- /// <param name="volume">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target level of volume.
- /// </param>
- /// <param name="pitch">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the target pitch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void AudioUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- AudioSource audioSource;
- float time;
- Vector2[] vector2s = new Vector2[4];
-
- //set smooth time:
- if(args.Contains("time")){
- time=(float)args["time"];
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
- //set audioSource:
- if(args.Contains("audiosource")){
- audioSource=(AudioSource)args["audiosource"];
- }else{
- if(target.GetComponent(typeof(AudioSource))){
- audioSource=target.GetComponent<AudioSource>();
- }else{
- //throw error if no AudioSource is available:
- Debug.LogError("iTween Error: AudioUpdate requires an AudioSource.");
- return;
- }
- }
-
- //from values:
- vector2s[0] = vector2s[1] = new Vector2(audioSource.volume,audioSource.pitch);
-
- //set to:
- if(args.Contains("volume")){
- vector2s[1].x=(float)args["volume"];
- }
- if(args.Contains("pitch")){
- vector2s[1].y=(float)args["pitch"];
- }
-
- //calculate:
- vector2s[3].x=Mathf.SmoothDampAngle(vector2s[0].x,vector2s[1].x,ref vector2s[2].x,time);
- vector2s[3].y=Mathf.SmoothDampAngle(vector2s[0].y,vector2s[1].y,ref vector2s[2].y,time);
-
- //apply:
- audioSource.volume=vector2s[3].x;
- audioSource.pitch=vector2s[3].y;
- }
-
- /// <summary>
- /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="volume">
- /// A <see cref="System.Single"/> for the target level of volume.
- /// </param>
- /// <param name="pitch">
- /// A <see cref="System.Single"/> for the target pitch.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void AudioUpdate(GameObject target, float volume, float pitch, float time){
- AudioUpdate(target,Hash("volume",volume,"pitch",pitch,"time",time));
- }
-
- /// <summary>
- /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="rotation">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler angles in degrees to rotate to.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- bool isLocal;
- float time;
- Vector3[] vector3s = new Vector3[4];
- Vector3 preUpdate = target.transform.eulerAngles;
-
- //set smooth time:
- if(args.Contains("time")){
- time=(float)args["time"];
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
-
- //set isLocal:
- if(args.Contains("islocal")){
- isLocal = (bool)args["islocal"];
- }else{
- isLocal = Defaults.isLocal;
- }
-
- //from values:
- if(isLocal){
- vector3s[0] = target.transform.localEulerAngles;
- }else{
- vector3s[0] = target.transform.eulerAngles;
- }
-
- //set to:
- if(args.Contains("rotation")){
- if (args["rotation"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["rotation"];
- vector3s[1]=trans.eulerAngles;
- }else if(args["rotation"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)args["rotation"];
- }
- }
-
- //calculate:
- vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time);
- vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time);
- vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time);
-
- //apply:
- if(isLocal){
- target.transform.localEulerAngles=vector3s[3];
- }else{
- target.transform.eulerAngles=vector3s[3];
- }
-
- //need physics?
- if(target.GetComponent<Rigidbody>() != null){
- Vector3 postUpdate=target.transform.eulerAngles;
- target.transform.eulerAngles=preUpdate;
- target.GetComponent<Rigidbody>().MoveRotation(Quaternion.Euler(postUpdate));
- }
- }
-
- /// <summary>
- /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="rotation">
- /// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void RotateUpdate(GameObject target, Vector3 rotation, float time){
- RotateUpdate(target,Hash("rotation",rotation,"time",time));
- }
-
- /// <summary>
- /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="scale">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- float time;
- Vector3[] vector3s = new Vector3[4];
-
- //set smooth time:
- if(args.Contains("time")){
- time=(float)args["time"];
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
-
- //init values:
- vector3s[0] = vector3s[1] = target.transform.localScale;
-
- //to values:
- if (args.Contains("scale")) {
- if (args["scale"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["scale"];
- vector3s[1]=trans.localScale;
- }else if(args["scale"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)args["scale"];
- }
- }else{
- if (args.Contains("x")) {
- vector3s[1].x=(float)args["x"];
- }
- if (args.Contains("y")) {
- vector3s[1].y=(float)args["y"];
- }
- if (args.Contains("z")) {
- vector3s[1].z=(float)args["z"];
- }
- }
-
- //calculate:
- vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time);
- vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time);
- vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time);
-
- //apply:
- target.transform.localScale=vector3s[3];
- }
-
- /// <summary>
- /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="scale">
- /// A <see cref="Vector3"/> for the final scale.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void ScaleUpdate(GameObject target, Vector3 scale, float time){
- ScaleUpdate(target,Hash("scale",scale,"time",time));
- }
-
- /// <summary>
- /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="position">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space the GameObject will animate to.
- /// </param>
- /// <param name="x">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the x axis.
- /// </param>
- /// <param name="y">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the y axis.
- /// </param>
- /// <param name="z">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the individual setting of the z axis.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- /// <param name="islocal">
- /// A <see cref="System.Boolean"/> for whether to animate in world space or relative to the parent. False by default.
- /// </param>
- /// <param name="orienttopath">
- /// A <see cref="System.Boolean"/> for whether or not the GameObject will orient to its direction of travel. False by default.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="looktime">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the object will take to look at either the "looktarget" or "orienttopath".
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- public static void MoveUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- float time;
- Vector3[] vector3s = new Vector3[4];
- bool isLocal;
- Vector3 preUpdate = target.transform.position;
-
- //set smooth time:
- if(args.Contains("time")){
- time=(float)args["time"];
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
-
- //set isLocal:
- if(args.Contains("islocal")){
- isLocal = (bool)args["islocal"];
- }else{
- isLocal = Defaults.isLocal;
- }
-
- //init values:
- if(isLocal){
- vector3s[0] = vector3s[1] = target.transform.localPosition;
- }else{
- vector3s[0] = vector3s[1] = target.transform.position;
- }
-
- //to values:
- if (args.Contains("position")) {
- if (args["position"].GetType() == typeof(Transform)){
- Transform trans = (Transform)args["position"];
- vector3s[1]=trans.position;
- }else if(args["position"].GetType() == typeof(Vector3)){
- vector3s[1]=(Vector3)args["position"];
- }
- }else{
- if (args.Contains("x")) {
- vector3s[1].x=(float)args["x"];
- }
- if (args.Contains("y")) {
- vector3s[1].y=(float)args["y"];
- }
- if (args.Contains("z")) {
- vector3s[1].z=(float)args["z"];
- }
- }
-
- //calculate:
- vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time);
- vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time);
- vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time);
-
- //handle orient to path:
- if(args.Contains("orienttopath") && (bool)args["orienttopath"]){
- args["looktarget"] = vector3s[3];
- }
-
- //look applications:
- if(args.Contains("looktarget")){
- iTween.LookUpdate(target,args);
- }
-
- //apply:
- if(isLocal){
- target.transform.localPosition = vector3s[3];
- }else{
- target.transform.position=vector3s[3];
- }
-
- //need physics?
- if(target.GetComponent<Rigidbody>() != null){
- Vector3 postUpdate=target.transform.position;
- target.transform.position=preUpdate;
- target.GetComponent<Rigidbody>().MovePosition(postUpdate);
- }
- }
- /// <summary>
- /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="position">
- /// A <see cref="Vector3"/> for a point in space the GameObject will animate to.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void MoveUpdate(GameObject target, Vector3 position, float time){
- MoveUpdate(target,Hash("position",position,"time",time));
- }
-
- /// <summary>
- /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="looktarget">
- /// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="axis">
- /// A <see cref="System.String"/>. Restricts rotation to the supplied axis only.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void LookUpdate(GameObject target, Hashtable args){
- CleanArgs(args);
-
- float time;
- Vector3[] vector3s = new Vector3[5];
-
- //set smooth time:
- if(args.Contains("looktime")){
- time=(float)args["looktime"];
- time*=Defaults.updateTimePercentage;
- }else if(args.Contains("time")){
- time=(float)args["time"]*.15f;
- time*=Defaults.updateTimePercentage;
- }else{
- time=Defaults.updateTime;
- }
-
- //from values:
- vector3s[0] = target.transform.eulerAngles;
-
- //set look:
- if(args.Contains("looktarget")){
- if (args["looktarget"].GetType() == typeof(Transform)) {
- //target.transform.LookAt((Transform)args["looktarget"]);
- target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up);
- }else if(args["looktarget"].GetType() == typeof(Vector3)){
- //target.transform.LookAt((Vector3)args["looktarget"]);
- target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up);
- }
- }else{
- Debug.LogError("iTween Error: LookUpdate needs a 'looktarget' property!");
- return;
- }
-
- //to values and reset look:
- vector3s[1]=target.transform.eulerAngles;
- target.transform.eulerAngles=vector3s[0];
-
- //calculate:
- vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time);
- vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time);
- vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time);
-
- //apply:
- target.transform.eulerAngles=vector3s[3];
-
- //axis restriction:
- if(args.Contains("axis")){
- vector3s[4]=target.transform.eulerAngles;
- switch((string)args["axis"]){
- case "x":
- vector3s[4].y=vector3s[0].y;
- vector3s[4].z=vector3s[0].z;
- break;
- case "y":
- vector3s[4].x=vector3s[0].x;
- vector3s[4].z=vector3s[0].z;
- break;
- case "z":
- vector3s[4].x=vector3s[0].x;
- vector3s[4].y=vector3s[0].y;
- break;
- }
-
- //apply axis restriction:
- target.transform.eulerAngles=vector3s[4];
- }
- }
-
- /// <summary>
- /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType.
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/> to be the target of the animation.
- /// </param>
- /// <param name="looktarget">
- /// A <see cref="Vector3"/> for a target the GameObject will look at.
- /// </param>
- /// <param name="time">
- /// A <see cref="System.Single"/> for the time in seconds the animation will take to complete.
- /// </param>
- public static void LookUpdate(GameObject target, Vector3 looktarget, float time){
- LookUpdate(target,Hash("looktarget",looktarget,"time",time));
- }
- #endregion
-
- #region #7 External Utilities
-
- /// <summary>
- /// Returns the length of a curved path drawn through the provided array of Transforms.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Single"/>
- /// </returns>
- /// <param name='path'>
- /// A <see cref="Transform[]"/>
- /// </param>
- public static float PathLength(Transform[] path){
- Vector3[] suppliedPath = new Vector3[path.Length];
- float pathLength = 0;
-
- //create and store path points:
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- Vector3[] vector3s = PathControlPointGenerator(suppliedPath);
-
- //Line Draw:
- Vector3 prevPt = Interp(vector3s,0);
- int SmoothAmount = path.Length*20;
- for (int i = 1; i <= SmoothAmount; i++) {
- float pm = (float) i / SmoothAmount;
- Vector3 currPt = Interp(vector3s,pm);
- pathLength += Vector3.Distance(prevPt,currPt);
- prevPt = currPt;
- }
-
- return pathLength;
- }
-
- /// <summary>
- /// Returns the length of a curved path drawn through the provided array of Vector3s.
- /// </summary>
- /// <returns>
- /// The length.
- /// </returns>
- /// <param name='path'>
- /// A <see cref="Vector3[]"/>
- /// </param>
- public static float PathLength(Vector3[] path){
- float pathLength = 0;
-
- Vector3[] vector3s = PathControlPointGenerator(path);
-
- //Line Draw:
- Vector3 prevPt = Interp(vector3s,0);
- int SmoothAmount = path.Length*20;
- for (int i = 1; i <= SmoothAmount; i++) {
- float pm = (float) i / SmoothAmount;
- Vector3 currPt = Interp(vector3s,pm);
- pathLength += Vector3.Distance(prevPt,currPt);
- prevPt = currPt;
- }
-
- return pathLength;
- }
-
- /// <summary>
- /// Creates and returns a full-screen Texture2D for use with CameraFade.
- /// </summary>
- /// <returns>
- /// Texture2D
- /// </returns>
- /// <param name='color'>
- /// Color
- /// </param>
- public static Texture2D CameraTexture(Color color){
- Texture2D texture = new Texture2D(Screen.width,Screen.height,TextureFormat.ARGB32, false);
- Color[] colors = new Color[Screen.width*Screen.height];
- for (int i = 0; i < colors.Length; i++) {
- colors[i]=color;
- }
- texture.SetPixels(colors);
- texture.Apply();
- return(texture);
- }
-
- /// <summary>
- /// Puts a GameObject on a path at the provided percentage
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/>
- /// </param>
- /// <param name="path">
- /// A <see cref="Vector3[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- public static void PutOnPath(GameObject target, Vector3[] path, float percent){
- target.transform.position=Interp(PathControlPointGenerator(path),percent);
- }
-
- /// <summary>
- /// Puts a GameObject on a path at the provided percentage
- /// </summary>
- /// <param name="target">
- /// A <see cref="Transform"/>
- /// </param>
- /// <param name="path">
- /// A <see cref="Vector3[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- public static void PutOnPath(Transform target, Vector3[] path, float percent){
- target.position=Interp(PathControlPointGenerator(path),percent);
- }
-
- /// <summary>
- /// Puts a GameObject on a path at the provided percentage
- /// </summary>
- /// <param name="target">
- /// A <see cref="GameObject"/>
- /// </param>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- public static void PutOnPath(GameObject target, Transform[] path, float percent){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
- target.transform.position=Interp(PathControlPointGenerator(suppliedPath),percent);
- }
-
- /// <summary>
- /// Puts a GameObject on a path at the provided percentage
- /// </summary>
- /// <param name="target">
- /// A <see cref="Transform"/>
- /// </param>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- public static void PutOnPath(Transform target, Transform[] path, float percent){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
- target.position=Interp(PathControlPointGenerator(suppliedPath),percent);
- }
-
- /// <summary>
- /// Returns a Vector3 position on a path at the provided percentage
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- /// <returns>
- /// A <see cref="Vector3"/>
- /// </returns>
- public static Vector3 PointOnPath(Transform[] path, float percent){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
- return(Interp(PathControlPointGenerator(suppliedPath),percent));
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s.
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawLine(Vector3[] line) {
- if(line.Length>0){
- DrawLineHelper(line,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s.
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLine(Vector3[] line, Color color) {
- if(line.Length>0){
- DrawLineHelper(line,color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms.
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawLine(Transform[] line) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
- DrawLineHelper(suppliedLine,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms.
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLine(Transform[] line,Color color) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
-
- DrawLineHelper(suppliedLine, color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawLineGizmos(Vector3[] line) {
- if(line.Length>0){
- DrawLineHelper(line,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLineGizmos(Vector3[] line, Color color) {
- if(line.Length>0){
- DrawLineHelper(line,color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Transforms with Gizmos.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawLineGizmos(Transform[] line) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
- DrawLineHelper(suppliedLine,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Transforms with Gizmos.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLineGizmos(Transform[] line,Color color) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
-
- DrawLineHelper(suppliedLine, color,"gizmos");
- }
- }
- /// <summary>
- /// Draws a line through the provided array of Vector3s with Handles.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawLineHandles(Vector3[] line) {
- if(line.Length>0){
- DrawLineHelper(line,Defaults.color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Vector3s with Handles.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLineHandles(Vector3[] line, Color color) {
- if(line.Length>0){
- DrawLineHelper(line,color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Transforms with Handles.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawLineHandles(Transform[] line) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
- DrawLineHelper(suppliedLine,Defaults.color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a line through the provided array of Transforms with Handles.DrawLine().
- /// </summary>
- /// <param name="line">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawLineHandles(Transform[] line,Color color) {
- if(line.Length>0){
- //create and store line points:
- Vector3[] suppliedLine = new Vector3[line.Length];
- for (int i = 0; i < line.Length; i++) {
- suppliedLine[i]=line[i].position;
- }
-
- DrawLineHelper(suppliedLine, color,"handles");
- }
- }
-
- /// <summary>
- /// Returns a Vector3 position on a path at the provided percentage
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3[]"/>
- /// </param>
- /// <param name="percent">
- /// A <see cref="System.Single"/>
- /// </param>
- /// <returns>
- /// A <see cref="Vector3"/>
- /// </returns>
- public static Vector3 PointOnPath(Vector3[] path, float percent){
- return(Interp(PathControlPointGenerator(path),percent));
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s.
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawPath(Vector3[] path) {
- if(path.Length>0){
- DrawPathHelper(path,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s.
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPath(Vector3[] path, Color color) {
- if(path.Length>0){
- DrawPathHelper(path, color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms.
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawPath(Transform[] path) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms.
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPath(Transform[] path,Color color) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath, color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawPathGizmos(Vector3[] path) {
- if(path.Length>0){
- DrawPathHelper(path,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPathGizmos(Vector3[] path, Color color) {
- if(path.Length>0){
- DrawPathHelper(path, color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawPathGizmos(Transform[] path) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath,Defaults.color,"gizmos");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPathGizmos(Transform[] path,Color color) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath, color,"gizmos");
- }
- }
- /// <summary>
- /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- public static void DrawPathHandles(Vector3[] path) {
- if(path.Length>0){
- DrawPathHelper(path,Defaults.color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Vector3s[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPathHandles(Vector3[] path, Color color) {
- if(path.Length>0){
- DrawPathHelper(path, color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Transforms with Handles.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- public static void DrawPathHandles(Transform[] path) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath,Defaults.color,"handles");
- }
- }
-
- /// <summary>
- /// Draws a curved path through the provided array of Transforms with Handles.DrawLine().
- /// </summary>
- /// <param name="path">
- /// A <see cref="Transform[]"/>
- /// </param>
- /// <param name="color">
- /// A <see cref="Color"/>
- /// </param>
- public static void DrawPathHandles(Transform[] path,Color color) {
- if(path.Length>0){
- //create and store path points:
- Vector3[] suppliedPath = new Vector3[path.Length];
- for (int i = 0; i < path.Length; i++) {
- suppliedPath[i]=path[i].position;
- }
-
- DrawPathHelper(suppliedPath, color,"handles");
- }
- }
-
- /// <summary>
- /// Changes a camera fade's texture.
- /// </summary>
- /// <param name="depth">
- /// A <see cref="System.Int32"/>
- /// </param>
- public static void CameraFadeDepth(int depth){
- if(cameraFade){
- cameraFade.transform.position=new Vector3(cameraFade.transform.position.x,cameraFade.transform.position.y,depth);
- }
- }
-
- /// <summary>
- /// Removes and destroyes a camera fade.
- /// </summary>
- public static void CameraFadeDestroy(){
- if(cameraFade){
- Destroy(cameraFade);
- }
- }
-
- /// <summary>
- /// Changes a camera fade's texture.
- /// </summary>
- /// <param name='texture'>
- /// A <see cref="Texture2D"/>
- /// </param>
- public static void CameraFadeSwap(Texture2D texture){
- if(cameraFade){
- cameraFade.GetComponent<GUITexture>().texture=texture;
- }
- }
-
- /// <summary>
- /// Creates a GameObject (if it doesn't exist) at the supplied depth that can be used to simulate a camera fade.
- /// </summary>
- /// <param name='texture'>
- /// A <see cref="Texture2D"/>
- /// </param>
- /// <param name='depth'>
- /// A <see cref="System.Int32"/>
- /// </param>
- /// <returns>
- /// A <see cref="GameObject"/> for a reference to the CameraFade.
- /// </returns>
- public static GameObject CameraFadeAdd(Texture2D texture, int depth){
- if(cameraFade){
- return null;
- }else{
- //establish colorFade object:
- cameraFade = new GameObject("iTween Camera Fade");
- cameraFade.transform.position= new Vector3(.5f,.5f,depth);
- cameraFade.AddComponent<GUITexture>();
- cameraFade.GetComponent<GUITexture>().texture=texture;
- cameraFade.GetComponent<GUITexture>().color = new Color(.5f,.5f,.5f,0);
- return cameraFade;
- }
- }
-
- /// <summary>
- /// Creates a GameObject (if it doesn't exist) at the default depth that can be used to simulate a camera fade.
- /// </summary>
- /// <param name='texture'>
- /// A <see cref="Texture2D"/>
- /// </param>
- /// <returns>
- /// A <see cref="GameObject"/> for a reference to the CameraFade.
- /// </returns>
- public static GameObject CameraFadeAdd(Texture2D texture){
- if(cameraFade){
- return null;
- }else{
- //establish colorFade object:
- cameraFade = new GameObject("iTween Camera Fade");
- cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth);
- cameraFade.AddComponent<GUITexture>();
- cameraFade.GetComponent<GUITexture>().texture=texture;
- cameraFade.GetComponent<GUITexture>().color = new Color(.5f,.5f,.5f,0);
- return cameraFade;
- }
- }
-
- /// <summary>
- /// Creates a GameObject (if it doesn't exist) at the default depth filled with black that can be used to simulate a camera fade.
- /// </summary>
- /// <returns>
- /// A <see cref="GameObject"/> for a reference to the CameraFade.
- /// </returns>
- public static GameObject CameraFadeAdd(){
- if(cameraFade){
- return null;
- }else{
- //establish colorFade object:
- cameraFade = new GameObject("iTween Camera Fade");
- cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth);
- cameraFade.AddComponent<GUITexture>();
- cameraFade.GetComponent<GUITexture>().texture=CameraTexture(Color.black);
- cameraFade.GetComponent<GUITexture>().color = new Color(.5f,.5f,.5f,0);
- return cameraFade;
- }
- }
-
-
- //#################################
- //# RESUME UTILITIES AND OVERLOADS #
- //#################################
-
- /// <summary>
- /// Resume all iTweens on a GameObject.
- /// </summary>
- public static void Resume(GameObject target){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- item.enabled=true;
- }
- }
-
- /// <summary>
- /// Resume all iTweens on a GameObject including its children.
- /// </summary>
- public static void Resume(GameObject target, bool includechildren){
- Resume(target);
- if(includechildren){
- foreach(Transform child in target.transform){
- Resume(child.gameObject,true);
- }
- }
- }
-
- /// <summary>
- /// Resume all iTweens on a GameObject of a particular type.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Resume(GameObject target, string type){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.enabled=true;
- }
- }
- }
-
- /// <summary>
- /// Resume all iTweens on a GameObject of a particular type including its children.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Resume(GameObject target, string type, bool includechildren){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.enabled=true;
- }
- }
- if(includechildren){
- foreach(Transform child in target.transform){
- Resume(child.gameObject,type,true);
- }
- }
- }
-
- /// <summary>
- /// Resume all iTweens in scene.
- /// </summary>
- public static void Resume(){
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- Resume(target);
- }
- }
-
- /// <summary>
- /// Resume all iTweens in scene of a particular type.
- /// </summary>
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Resume(string type){
- ArrayList resumeArray = new ArrayList();
-
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- resumeArray.Insert(resumeArray.Count,target);
- }
-
- for (int i = 0; i < resumeArray.Count; i++) {
- Resume((GameObject)resumeArray[i],type);
- }
- }
-
- //#################################
- //# PAUSE UTILITIES AND OVERLOADS #
- //#################################
- /// <summary>
- /// Pause all iTweens on a GameObject.
- /// </summary>
- public static void Pause(GameObject target){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- if(item.delay>0){
- item.delay-=Time.time-item.delayStarted;
- item.StopCoroutine("TweenDelay");
- }
- item.isPaused=true;
- item.enabled=false;
- }
- }
-
- /// <summary>
- /// Pause all iTweens on a GameObject including its children.
- /// </summary>
- public static void Pause(GameObject target, bool includechildren){
- Pause(target);
- if(includechildren){
- foreach(Transform child in target.transform){
- Pause(child.gameObject,true);
- }
- }
- }
-
- /// <summary>
- /// Pause all iTweens on a GameObject of a particular type.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Pause(GameObject target, string type){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- if(item.delay>0){
- item.delay-=Time.time-item.delayStarted;
- item.StopCoroutine("TweenDelay");
- }
- item.isPaused=true;
- item.enabled=false;
- }
- }
- }
-
- /// <summary>
- /// Pause all iTweens on a GameObject of a particular type including its children.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Pause(GameObject target, string type, bool includechildren){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- if(item.delay>0){
- item.delay-=Time.time-item.delayStarted;
- item.StopCoroutine("TweenDelay");
- }
- item.isPaused=true;
- item.enabled=false;
- }
- }
- if(includechildren){
- foreach(Transform child in target.transform){
- Pause(child.gameObject,type,true);
- }
- }
- }
-
- /// <summary>
- /// Pause all iTweens in scene.
- /// </summary>
- public static void Pause(){
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- Pause(target);
- }
- }
-
- /// <summary>
- /// Pause all iTweens in scene of a particular type.
- /// </summary>
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Pause(string type){
- ArrayList pauseArray = new ArrayList();
-
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- pauseArray.Insert(pauseArray.Count,target);
- }
-
- for (int i = 0; i < pauseArray.Count; i++) {
- Pause((GameObject)pauseArray[i],type);
- }
- }
-
- //#################################
- //# COUNT UTILITIES AND OVERLOADS #
- //#################################
-
- /// <summary>
- /// Count all iTweens in current scene.
- /// </summary>
- public static int Count(){
- return(tweens.Count);
- }
-
- /// <summary>
- /// Count all iTweens in current scene of a particular type.
- /// </summary>
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static int Count(string type){
- int tweenCount = 0;
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- string targetType = (string)currentTween["type"]+(string)currentTween["method"];
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- tweenCount++;
- }
- }
-
- return(tweenCount);
- }
- /// <summary>
- /// Count all iTweens on a GameObject.
- /// </summary>
- public static int Count(GameObject target){
- Component[] tweens = target.GetComponents(typeof(iTween));
- return(tweens.Length);
- }
-
- /// <summary>
- /// Count all iTweens on a GameObject of a particular type.
- /// </summary>
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to count. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static int Count(GameObject target, string type){
- int tweenCount = 0;
- Component[] tweens = target.GetComponents(typeof(iTween));foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- tweenCount++;
- }
- }
- return(tweenCount);
- }
-
- //################################
- //# STOP UTILITIES AND OVERLOADS #
- //################################
-
- /// <summary>
- /// Stop and destroy all Tweens in current scene.
- /// </summary>
- public static void Stop(){
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- Stop(target);
- }
- tweens.Clear();
- }
-
- /// <summary>
- /// Stop and destroy all iTweens in current scene of a particular type.
- /// </summary>
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Stop(string type){
- ArrayList stopArray = new ArrayList();
-
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- stopArray.Insert(stopArray.Count,target);
- }
-
- for (int i = 0; i < stopArray.Count; i++) {
- Stop((GameObject)stopArray[i],type);
- }
- }
-
- /* GFX47 MOD START */
- /// <summary>
- /// Stop and destroy all iTweens in current scene of a particular name.
- /// </summary>
- /// <param name="name">
- /// The <see cref="System.String"/> name of iTween you would like to stop.
- /// </param>
- public static void StopByName(string name){
- ArrayList stopArray = new ArrayList();
-
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable currentTween = (Hashtable)tweens[i];
- GameObject target = (GameObject)currentTween["target"];
- stopArray.Insert(stopArray.Count,target);
- }
-
- for (int i = 0; i < stopArray.Count; i++) {
- StopByName((GameObject)stopArray[i],name);
- }
- }
- /* GFX47 MOD END */
-
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject.
- /// </summary>
- public static void Stop(GameObject target){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- item.Dispose();
- }
- }
-
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject including its children.
- /// </summary>
- public static void Stop(GameObject target, bool includechildren){
- Stop(target);
- if(includechildren){
- foreach(Transform child in target.transform){
- Stop(child.gameObject,true);
- }
- }
- }
-
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject of a particular type.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Stop(GameObject target, string type){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.Dispose();
- }
- }
- }
-
- /* GFX47 MOD START */
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject of a particular name.
- /// </summar
- /// <param name="name">
- /// The <see cref="System.String"/> name of iTween you would like to stop.
- /// </param>
- public static void StopByName(GameObject target, string name){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- /*string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.Dispose();
- }*/
- if(item._name == name){
- item.Dispose();
- }
- }
- }
- /* GFX47 MOD END */
-
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject of a particular type including its children.
- /// </summar
- /// <param name="type">
- /// A <see cref="System.String"/> name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
- /// </param>
- public static void Stop(GameObject target, string type, bool includechildren){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.Dispose();
- }
- }
- if(includechildren){
- foreach(Transform child in target.transform){
- Stop(child.gameObject,type,true);
- }
- }
- }
-
- /* GFX47 MOD START */
- /// <summary>
- /// Stop and destroy all iTweens on a GameObject of a particular name including its children.
- /// </summar
- /// <param name="name">
- /// The <see cref="System.String"/> name of iTween you would like to stop.
- /// </param>
- public static void StopByName(GameObject target, string name, bool includechildren){
- Component[] tweens = target.GetComponents(typeof(iTween));
- foreach (iTween item in tweens){
- /*string targetType = item.type+item.method;
- targetType=targetType.Substring(0,type.Length);
- if(targetType.ToLower() == type.ToLower()){
- item.Dispose();
- }*/
- if(item._name == name){
- item.Dispose();
- }
- }
- if(includechildren){
- foreach(Transform child in target.transform){
- //Stop(child.gameObject,type,true);
- StopByName(child.gameObject,name,true);
- }
- }
- }
- /* GFX47 MOD END */
- /// <summary>
- /// Universal interface to help in the creation of Hashtables. Especially useful for C# users.
- /// </summary>
- /// <param name="args">
- /// A <see cref="System.Object[]"/> of alternating name value pairs. For example "time",1,"delay",2...
- /// </param>
- /// <returns>
- /// A <see cref="Hashtable"/>
- /// </returns>
- public static Hashtable Hash(params object[] args){
- Hashtable hashTable = new Hashtable(args.Length/2);
- if (args.Length %2 != 0) {
- Debug.LogError("Tween Error: Hash requires an even number of arguments!");
- return null;
- }else{
- int i = 0;
- while(i < args.Length - 1) {
- hashTable.Add(args[i], args[i+1]);
- i += 2;
- }
- return hashTable;
- }
- }
-
- #endregion
- #region Component Segments
-
- void Awake(){
- RetrieveArgs();
- lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay
- }
-
- IEnumerator Start(){
- if(delay > 0){
- yield return StartCoroutine("TweenDelay");
- }
- TweenStart();
- }
-
- //non-physics
- void Update(){
- if(isRunning && !physics && !useFixedUpdate){
- if(!reverse){
- if(percentage<1f){
- TweenUpdate();
- }else{
- TweenComplete();
- }
- }else{
- if(percentage>0){
- TweenUpdate();
- }else{
- TweenComplete();
- }
- }
- }
- }
-
- //physics
- void FixedUpdate(){
- if(isRunning && (physics || useFixedUpdate )){
- if(!reverse){
- if(percentage<1f){
- TweenUpdate();
- }else{
- TweenComplete();
- }
- }else{
- if(percentage>0){
- TweenUpdate();
- }else{
- TweenComplete();
- }
- }
- }
- }
- void LateUpdate(){
- //look applications:
- if(tweenArguments.Contains("looktarget") && isRunning){
- if(type =="move" || type =="shake" || type=="punch"){
- LookUpdate(gameObject,tweenArguments);
- }
- }
- }
-
- void OnEnable(){
- if(isRunning){
- EnableKinematic();
- }
-
- //resume delay:
- if(isPaused){
- isPaused=false;
- if(delay > 0){
- wasPaused=true;
- ResumeDelay();
- }
- }
- }
- void OnDisable(){
- DisableKinematic();
- }
-
- #endregion
-
- #region Internal Helpers
-
- private static void DrawLineHelper(Vector3[] line, Color color, string method){
- Gizmos.color=color;
- for (int i = 0; i < line.Length-1; i++) {
- if(method == "gizmos"){
- Gizmos.DrawLine(line[i], line[i+1]);;
- }else if(method == "handles"){
- Debug.LogError("iTween Error: Drawing a line with Handles is temporarily disabled because of compatability issues with Unity 2.6!");
- //UnityEditor.Handles.DrawLine(line[i], line[i+1]);
- }
- }
- }
-
- private static void DrawPathHelper(Vector3[] path, Color color, string method){
- Vector3[] vector3s = PathControlPointGenerator(path);
-
- //Line Draw:
- Vector3 prevPt = Interp(vector3s,0);
- Gizmos.color=color;
- int SmoothAmount = path.Length;
- for (int i = 1; i <= SmoothAmount; i++) {
- float pm = (float) i / SmoothAmount;
- Vector3 currPt = Interp(vector3s,pm);
- if(method == "gizmos"){
- Gizmos.DrawLine(currPt, prevPt);
- }else if(method == "handles"){
- Debug.LogError("iTween Error: Drawing a path with Handles is temporarily disabled because of compatability issues with Unity 2.6!");
- //UnityEditor.Handles.DrawLine(currPt, prevPt);
- }
- prevPt = currPt;
- }
- }
-
- private static Vector3[] PathControlPointGenerator(Vector3[] path){
- Vector3[] suppliedPath;
- Vector3[] vector3s;
-
- //create and store path points:
- suppliedPath = path;
- //populate calculate path;
- int offset = 2;
- vector3s = new Vector3[suppliedPath.Length+offset];
- Array.Copy(suppliedPath,0,vector3s,1,suppliedPath.Length);
-
- //populate start and end control points:
- //vector3s[0] = vector3s[1] - vector3s[2];
- vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]);
- vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]);
-
- //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline!
- if(vector3s[1] == vector3s[vector3s.Length-2]){
- Vector3[] tmpLoopSpline = new Vector3[vector3s.Length];
- Array.Copy(vector3s,tmpLoopSpline,vector3s.Length);
- tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3];
- tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2];
- vector3s=new Vector3[tmpLoopSpline.Length];
- Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length);
- }
-
- return(vector3s);
- }
-
- //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ):
- private static Vector3 Interp(Vector3[] pts, float t){
- int numSections = pts.Length - 3;
- int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1);
- float u = t * (float) numSections - (float) currPt;
-
- Vector3 a = pts[currPt];
- Vector3 b = pts[currPt + 1];
- Vector3 c = pts[currPt + 2];
- Vector3 d = pts[currPt + 3];
-
- return .5f * (
- (-a + 3f * b - 3f * c + d) * (u * u * u)
- + (2f * a - 5f * b + 4f * c - d) * (u * u)
- + (-a + c) * u
- + 2f * b
- );
- }
-
- //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ):
- private class CRSpline {
- public Vector3[] pts;
-
- public CRSpline(params Vector3[] pts) {
- this.pts = new Vector3[pts.Length];
- Array.Copy(pts, this.pts, pts.Length);
- }
-
-
- public Vector3 Interp(float t) {
- int numSections = pts.Length - 3;
- int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1);
- float u = t * (float) numSections - (float) currPt;
- Vector3 a = pts[currPt];
- Vector3 b = pts[currPt + 1];
- Vector3 c = pts[currPt + 2];
- Vector3 d = pts[currPt + 3];
- return .5f*((-a+3f*b-3f*c+d)*(u*u*u)+(2f*a-5f*b+4f*c-d)*(u*u)+(-a+c)*u+2f*b);
- }
- }
-
- //catalog new tween and add component phase of iTween:
- static void Launch(GameObject target, Hashtable args){
- if(!args.Contains("id")){
- args["id"] = GenerateID();
- }
- if(!args.Contains("target")){
- args["target"] = target;
- }
- tweens.Insert(0,args);
- target.AddComponent<iTween>();
- }
-
- //cast any accidentally supplied doubles and ints as floats as iTween only uses floats internally and unify parameter case:
- static Hashtable CleanArgs(Hashtable args){
- Hashtable argsCopy = new Hashtable(args.Count);
- Hashtable argsCaseUnified = new Hashtable(args.Count);
-
- foreach (DictionaryEntry item in args) {
- argsCopy.Add(item.Key, item.Value);
- }
-
- foreach (DictionaryEntry item in argsCopy) {
- if(item.Value.GetType() == typeof(System.Int32)){
- int original = (int)item.Value;
- float casted = (float)original;
- args[item.Key] = casted;
- }
- if(item.Value.GetType() == typeof(System.Double)){
- double original = (double)item.Value;
- float casted = (float)original;
- args[item.Key] = casted;
- }
- }
-
- //unify parameter case:
- foreach (DictionaryEntry item in args) {
- argsCaseUnified.Add(item.Key.ToString().ToLower(), item.Value);
- }
-
- //swap back case unification:
- args = argsCaseUnified;
-
- return args;
- }
-
- //random ID generator:
- static string GenerateID(){
- int strlen = 15;
- char[] chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8'};
- int num_chars = chars.Length - 1;
- string randomChar = "";
- for (int i = 0; i < strlen; i++) {
- randomChar += chars[(int)Mathf.Floor(UnityEngine.Random.Range(0,num_chars))];
- }
- return randomChar;
- }
-
- //grab and set generic, neccesary iTween arguments:
- void RetrieveArgs(){
- foreach (Hashtable item in tweens) {
- if((GameObject)item["target"] == gameObject){
- tweenArguments=item;
- break;
- }
- }
-
- id=(string)tweenArguments["id"];
- type=(string)tweenArguments["type"];
- /* GFX47 MOD START */
- _name=(string)tweenArguments["name"];
- /* GFX47 MOD END */
- method=(string)tweenArguments["method"];
-
- if(tweenArguments.Contains("time")){
- time=(float)tweenArguments["time"];
- }else{
- time=Defaults.time;
- }
-
- //do we need to use physics, is there a rigidbody?
- if(GetComponent<Rigidbody>() != null){
- physics=true;
- }
- //AV PATCH
- if (tweenArguments.Contains("usefixedupdate"))
- {
- useFixedUpdate = true;
- }
- //END AV PATCH
-
- if(tweenArguments.Contains("delay")){
- delay=(float)tweenArguments["delay"];
- }else{
- delay=Defaults.delay;
- }
-
- if(tweenArguments.Contains("namedcolorvalue")){
- //allows namedcolorvalue to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability:
- if(tweenArguments["namedcolorvalue"].GetType() == typeof(NamedValueColor)){
- namedcolorvalue=(NamedValueColor)tweenArguments["namedcolorvalue"];
- }else{
- try {
- namedcolorvalue=(NamedValueColor)Enum.Parse(typeof(NamedValueColor),(string)tweenArguments["namedcolorvalue"],true);
- } catch {
- Debug.LogWarning("iTween: Unsupported namedcolorvalue supplied! Default will be used.");
- namedcolorvalue = iTween.NamedValueColor._Color;
- }
- }
- }else{
- namedcolorvalue=Defaults.namedColorValue;
- }
-
- if(tweenArguments.Contains("looptype")){
- //allows loopType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability:
- if(tweenArguments["looptype"].GetType() == typeof(LoopType)){
- loopType=(LoopType)tweenArguments["looptype"];
- }else{
- try {
- loopType=(LoopType)Enum.Parse(typeof(LoopType),(string)tweenArguments["looptype"],true);
- } catch {
- Debug.LogWarning("iTween: Unsupported loopType supplied! Default will be used.");
- loopType = iTween.LoopType.none;
- }
- }
- }else{
- loopType = iTween.LoopType.none;
- }
-
- if(tweenArguments.Contains("easetype")){
- //allows easeType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability:
- if(tweenArguments["easetype"].GetType() == typeof(EaseType)){
- easeType=(EaseType)tweenArguments["easetype"];
- }else{
- try {
- easeType=(EaseType)Enum.Parse(typeof(EaseType),(string)tweenArguments["easetype"],true);
- } catch {
- Debug.LogWarning("iTween: Unsupported easeType supplied! Default will be used.");
- easeType=Defaults.easeType;
- }
- }
- }else{
- easeType=Defaults.easeType;
- }
-
- if(tweenArguments.Contains("space")){
- //allows space to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability:
- if(tweenArguments["space"].GetType() == typeof(Space)){
- space=(Space)tweenArguments["space"];
- }else{
- try {
- space=(Space)Enum.Parse(typeof(Space),(string)tweenArguments["space"],true);
- } catch {
- Debug.LogWarning("iTween: Unsupported space supplied! Default will be used.");
- space = Defaults.space;
- }
- }
- }else{
- space = Defaults.space;
- }
-
- if(tweenArguments.Contains("islocal")){
- isLocal = (bool)tweenArguments["islocal"];
- }else{
- isLocal = Defaults.isLocal;
- }
- // Added by PressPlay
- if (tweenArguments.Contains("ignoretimescale"))
- {
- useRealTime = (bool)tweenArguments["ignoretimescale"];
- }
- else
- {
- useRealTime = Defaults.useRealTime;
- }
- //instantiates a cached ease equation reference:
- GetEasingFunction();
- }
-
- //instantiates a cached ease equation refrence:
- void GetEasingFunction(){
- switch (easeType){
- case EaseType.easeInQuad:
- ease = new EasingFunction(easeInQuad);
- break;
- case EaseType.easeOutQuad:
- ease = new EasingFunction(easeOutQuad);
- break;
- case EaseType.easeInOutQuad:
- ease = new EasingFunction(easeInOutQuad);
- break;
- case EaseType.easeInCubic:
- ease = new EasingFunction(easeInCubic);
- break;
- case EaseType.easeOutCubic:
- ease = new EasingFunction(easeOutCubic);
- break;
- case EaseType.easeInOutCubic:
- ease = new EasingFunction(easeInOutCubic);
- break;
- case EaseType.easeInQuart:
- ease = new EasingFunction(easeInQuart);
- break;
- case EaseType.easeOutQuart:
- ease = new EasingFunction(easeOutQuart);
- break;
- case EaseType.easeInOutQuart:
- ease = new EasingFunction(easeInOutQuart);
- break;
- case EaseType.easeInQuint:
- ease = new EasingFunction(easeInQuint);
- break;
- case EaseType.easeOutQuint:
- ease = new EasingFunction(easeOutQuint);
- break;
- case EaseType.easeInOutQuint:
- ease = new EasingFunction(easeInOutQuint);
- break;
- case EaseType.easeInSine:
- ease = new EasingFunction(easeInSine);
- break;
- case EaseType.easeOutSine:
- ease = new EasingFunction(easeOutSine);
- break;
- case EaseType.easeInOutSine:
- ease = new EasingFunction(easeInOutSine);
- break;
- case EaseType.easeInExpo:
- ease = new EasingFunction(easeInExpo);
- break;
- case EaseType.easeOutExpo:
- ease = new EasingFunction(easeOutExpo);
- break;
- case EaseType.easeInOutExpo:
- ease = new EasingFunction(easeInOutExpo);
- break;
- case EaseType.easeInCirc:
- ease = new EasingFunction(easeInCirc);
- break;
- case EaseType.easeOutCirc:
- ease = new EasingFunction(easeOutCirc);
- break;
- case EaseType.easeInOutCirc:
- ease = new EasingFunction(easeInOutCirc);
- break;
- case EaseType.linear:
- ease = new EasingFunction(linear);
- break;
- case EaseType.spring:
- ease = new EasingFunction(spring);
- break;
- /* GFX47 MOD START */
- /*case EaseType.bounce:
- ease = new EasingFunction(bounce);
- break;*/
- case EaseType.easeInBounce:
- ease = new EasingFunction(easeInBounce);
- break;
- case EaseType.easeOutBounce:
- ease = new EasingFunction(easeOutBounce);
- break;
- case EaseType.easeInOutBounce:
- ease = new EasingFunction(easeInOutBounce);
- break;
- /* GFX47 MOD END */
- case EaseType.easeInBack:
- ease = new EasingFunction(easeInBack);
- break;
- case EaseType.easeOutBack:
- ease = new EasingFunction(easeOutBack);
- break;
- case EaseType.easeInOutBack:
- ease = new EasingFunction(easeInOutBack);
- break;
- /* GFX47 MOD START */
- /*case EaseType.elastic:
- ease = new EasingFunction(elastic);
- break;*/
- case EaseType.easeInElastic:
- ease = new EasingFunction(easeInElastic);
- break;
- case EaseType.easeOutElastic:
- ease = new EasingFunction(easeOutElastic);
- break;
- case EaseType.easeInOutElastic:
- ease = new EasingFunction(easeInOutElastic);
- break;
- /* GFX47 MOD END */
- }
- }
-
- //calculate percentage of tween based on time:
- void UpdatePercentage(){
- // Added by PressPlay
- if (useRealTime)
- {
- runningTime += (Time.realtimeSinceStartup - lastRealTime);
- }
- else
- {
- runningTime += Time.deltaTime;
- }
- if(reverse){
- percentage = 1 - runningTime/time;
- }else{
- percentage = runningTime/time;
- }
- lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay
- }
-
- void CallBack(string callbackType){
- if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) {
- //establish target:
- GameObject target;
- if (tweenArguments.Contains(callbackType+"target")) {
- target=(GameObject)tweenArguments[callbackType+"target"];
- }else{
- target=gameObject;
- }
-
- //throw an error if a string wasn't passed for callback:
- if (tweenArguments[callbackType].GetType() == typeof(System.String)) {
- target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver);
- }else{
- Debug.LogError("iTween Error: Callback method references must be passed as a String!");
- Destroy (this);
- }
- }
- }
-
- void Dispose(){
- for (int i = 0; i < tweens.Count; i++) {
- Hashtable tweenEntry = (Hashtable)tweens[i];
- if ((string)tweenEntry["id"] == id){
- tweens.RemoveAt(i);
- break;
- }
- }
- Destroy(this);
- }
-
- void ConflictCheck(){//if a new iTween is about to run and is of the same type as an in progress iTween this will destroy the previous if the new one is NOT identical in every way or it will destroy the new iTween if they are:
- Component[] tweens = GetComponents(typeof(iTween));
- foreach (iTween item in tweens) {
- if(item.type == "value"){
- return;
- }else if(item.isRunning && item.type==type){
- //cancel out if this is a shake or punch variant:
- if (item.method != method) {
- return;
- }
-
- //step 1: check for length first since it's the fastest:
- if(item.tweenArguments.Count != tweenArguments.Count){
- item.Dispose();
- return;
- }
-
- //step 2: side-by-side check to figure out if this is an identical tween scenario to handle Update usages of iTween:
- foreach (DictionaryEntry currentProp in tweenArguments) {
- if(!item.tweenArguments.Contains(currentProp.Key)){
- item.Dispose();
- return;
- }else{
- if(!item.tweenArguments[currentProp.Key].Equals(tweenArguments[currentProp.Key]) && (string)currentProp.Key != "id"){//if we aren't comparing ids and something isn't exactly the same replace the running iTween:
- item.Dispose();
- return;
- }
- }
- }
-
- //step 3: prevent a new iTween addition if it is identical to the currently running iTween
- Dispose();
- //Destroy(this);
- }
- }
- }
-
- void EnableKinematic(){
- /*
- if(gameObject.GetComponent(typeof(Rigidbody))){
- if(!rigidbody.isKinematic){
- kinematic=true;
- rigidbody.isKinematic=true;
- }
- }
- */
- }
-
- void DisableKinematic(){
- /*
- if(kinematic && rigidbody.isKinematic==true){
- kinematic=false;
- rigidbody.isKinematic=false;
- }
- */
- }
-
- void ResumeDelay(){
- StartCoroutine("TweenDelay");
- }
-
- #endregion
-
- #region Easing Curves
-
- private float linear(float start, float end, float value){
- return Mathf.Lerp(start, end, value);
- }
-
- private float clerp(float start, float end, float value){
- float min = 0.0f;
- float max = 360.0f;
- float half = Mathf.Abs((max - min) / 2.0f);
- float retval = 0.0f;
- float diff = 0.0f;
- if ((end - start) < -half){
- diff = ((max - start) + end) * value;
- retval = start + diff;
- }else if ((end - start) > half){
- diff = -((max - end) + start) * value;
- retval = start + diff;
- }else retval = start + (end - start) * value;
- return retval;
- }
- private float spring(float start, float end, float value){
- value = Mathf.Clamp01(value);
- value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value)));
- return start + (end - start) * value;
- }
- private float easeInQuad(float start, float end, float value){
- end -= start;
- return end * value * value + start;
- }
- private float easeOutQuad(float start, float end, float value){
- end -= start;
- return -end * value * (value - 2) + start;
- }
- private float easeInOutQuad(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return end / 2 * value * value + start;
- value--;
- return -end / 2 * (value * (value - 2) - 1) + start;
- }
- private float easeInCubic(float start, float end, float value){
- end -= start;
- return end * value * value * value + start;
- }
- private float easeOutCubic(float start, float end, float value){
- value--;
- end -= start;
- return end * (value * value * value + 1) + start;
- }
- private float easeInOutCubic(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return end / 2 * value * value * value + start;
- value -= 2;
- return end / 2 * (value * value * value + 2) + start;
- }
- private float easeInQuart(float start, float end, float value){
- end -= start;
- return end * value * value * value * value + start;
- }
- private float easeOutQuart(float start, float end, float value){
- value--;
- end -= start;
- return -end * (value * value * value * value - 1) + start;
- }
- private float easeInOutQuart(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return end / 2 * value * value * value * value + start;
- value -= 2;
- return -end / 2 * (value * value * value * value - 2) + start;
- }
- private float easeInQuint(float start, float end, float value){
- end -= start;
- return end * value * value * value * value * value + start;
- }
- private float easeOutQuint(float start, float end, float value){
- value--;
- end -= start;
- return end * (value * value * value * value * value + 1) + start;
- }
- private float easeInOutQuint(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return end / 2 * value * value * value * value * value + start;
- value -= 2;
- return end / 2 * (value * value * value * value * value + 2) + start;
- }
- private float easeInSine(float start, float end, float value){
- end -= start;
- return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start;
- }
- private float easeOutSine(float start, float end, float value){
- end -= start;
- return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start;
- }
- private float easeInOutSine(float start, float end, float value){
- end -= start;
- return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start;
- }
- private float easeInExpo(float start, float end, float value){
- end -= start;
- return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start;
- }
- private float easeOutExpo(float start, float end, float value){
- end -= start;
- return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start;
- }
- private float easeInOutExpo(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start;
- value--;
- return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start;
- }
- private float easeInCirc(float start, float end, float value){
- end -= start;
- return -end * (Mathf.Sqrt(1 - value * value) - 1) + start;
- }
- private float easeOutCirc(float start, float end, float value){
- value--;
- end -= start;
- return end * Mathf.Sqrt(1 - value * value) + start;
- }
- private float easeInOutCirc(float start, float end, float value){
- value /= .5f;
- end -= start;
- if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start;
- value -= 2;
- return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start;
- }
- /* GFX47 MOD START */
- private float easeInBounce(float start, float end, float value){
- end -= start;
- float d = 1f;
- return end - easeOutBounce(0, end, d-value) + start;
- }
- /* GFX47 MOD END */
- /* GFX47 MOD START */
- //private float bounce(float start, float end, float value){
- private float easeOutBounce(float start, float end, float value){
- value /= 1f;
- end -= start;
- if (value < (1 / 2.75f)){
- return end * (7.5625f * value * value) + start;
- }else if (value < (2 / 2.75f)){
- value -= (1.5f / 2.75f);
- return end * (7.5625f * (value) * value + .75f) + start;
- }else if (value < (2.5 / 2.75)){
- value -= (2.25f / 2.75f);
- return end * (7.5625f * (value) * value + .9375f) + start;
- }else{
- value -= (2.625f / 2.75f);
- return end * (7.5625f * (value) * value + .984375f) + start;
- }
- }
- /* GFX47 MOD END */
- /* GFX47 MOD START */
- private float easeInOutBounce(float start, float end, float value){
- end -= start;
- float d = 1f;
- if (value < d/2) return easeInBounce(0, end, value*2) * 0.5f + start;
- else return easeOutBounce(0, end, value*2-d) * 0.5f + end*0.5f + start;
- }
- /* GFX47 MOD END */
- private float easeInBack(float start, float end, float value){
- end -= start;
- value /= 1;
- float s = 1.70158f;
- return end * (value) * value * ((s + 1) * value - s) + start;
- }
- private float easeOutBack(float start, float end, float value){
- float s = 1.70158f;
- end -= start;
- value = (value / 1) - 1;
- return end * ((value) * value * ((s + 1) * value + s) + 1) + start;
- }
- private float easeInOutBack(float start, float end, float value){
- float s = 1.70158f;
- end -= start;
- value /= .5f;
- if ((value) < 1){
- s *= (1.525f);
- return end / 2 * (value * value * (((s) + 1) * value - s)) + start;
- }
- value -= 2;
- s *= (1.525f);
- return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start;
- }
- private float punch(float amplitude, float value){
- float s = 9;
- if (value == 0){
- return 0;
- }
- if (value == 1){
- return 0;
- }
- float period = 1 * 0.3f;
- s = period / (2 * Mathf.PI) * Mathf.Asin(0);
- return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period));
- }
-
- /* GFX47 MOD START */
- private float easeInElastic(float start, float end, float value){
- end -= start;
-
- float d = 1f;
- float p = d * .3f;
- float s = 0;
- float a = 0;
-
- if (value == 0) return start;
-
- if ((value /= d) == 1) return start + end;
-
- if (a == 0f || a < Mathf.Abs(end)){
- a = end;
- s = p / 4;
- }else{
- s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
- }
-
- return -(a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
- }
- /* GFX47 MOD END */
- /* GFX47 MOD START */
- //private float elastic(float start, float end, float value){
- private float easeOutElastic(float start, float end, float value){
- /* GFX47 MOD END */
- //Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween
- end -= start;
-
- float d = 1f;
- float p = d * .3f;
- float s = 0;
- float a = 0;
-
- if (value == 0) return start;
-
- if ((value /= d) == 1) return start + end;
-
- if (a == 0f || a < Mathf.Abs(end)){
- a = end;
- s = p / 4;
- }else{
- s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
- }
-
- return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start);
- }
-
- /* GFX47 MOD START */
- private float easeInOutElastic(float start, float end, float value){
- end -= start;
-
- float d = 1f;
- float p = d * .3f;
- float s = 0;
- float a = 0;
-
- if (value == 0) return start;
-
- if ((value /= d/2) == 2) return start + end;
-
- if (a == 0f || a < Mathf.Abs(end)){
- a = end;
- s = p / 4;
- }else{
- s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
- }
-
- if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
- return a * Mathf.Pow(2, -10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start;
- }
- /* GFX47 MOD END */
-
- #endregion
-
- #region Deprecated and Renamed
- /*
- public static void audioFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioFrom() has been renamed to AudioFrom().");}
- public static void audioTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioTo() has been renamed to AudioTo().");}
- public static void colorFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorFrom() has been renamed to ColorFrom().");}
- public static void colorTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorTo() has been renamed to ColorTo().");}
- public static void fadeFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeFrom() has been renamed to FadeFrom().");}
- public static void fadeTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeTo() has been renamed to FadeTo().");}
- public static void lookFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFrom() has been renamed to LookFrom().");}
- public static void lookFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFromWorld() has been deprecated. Please investigate LookFrom().");}
- public static void lookTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookTo() has been renamed to LookTo().");}
- public static void lookToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdate() has been renamed to LookUpdate().");}
- public static void lookToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdateWorld() has been deprecated. Please investigate LookUpdate().");}
- public static void moveAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAdd() has been renamed to MoveAdd().");}
- public static void moveAddWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");}
- public static void moveBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveBy() has been renamed to MoveBy().");}
- public static void moveByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");}
- public static void moveFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFrom() has been renamed to MoveFrom().");}
- public static void moveFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFromWorld() has been deprecated. Please investigate MoveFrom().");}
- public static void moveTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveTo() has been renamed to MoveTo().");}
- public static void moveToBezier(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezier() has been deprecated. Please investigate MoveTo() and the "path" property.");}
- public static void moveToBezierWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezierWorld() has been deprecated. Please investigate MoveTo() and the "path" property.");}
- public static void moveToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdate() has been renamed to MoveUpdate().");}
- public static void moveToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdateWorld() has been deprecated. Please investigate MoveUpdate().");}
- public static void moveToWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToWorld() has been deprecated. Please investigate MoveTo().");}
- public static void punchPosition(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchPosition().");}
- public static void punchPositionWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPositionWorld() has been deprecated. Please investigate PunchPosition().");}
- public static void punchRotation(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchRotation().");}
- public static void punchRotationWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchRotationWorld() has been deprecated. Please investigate PunchRotation().");}
- public static void punchScale(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchScale() has been renamed to PunchScale().");}
- public static void rotateAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateAdd() has been renamed to RotateAdd().");}
- public static void rotateBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateBy() has been renamed to RotateBy().");}
- public static void rotateByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateByWorld() has been deprecated. Please investigate RotateBy().");}
- public static void rotateFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateFrom() has been renamed to RotateFrom().");}
- public static void rotateTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateTo() has been renamed to RotateTo().");}
- public static void scaleAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleAdd() has been renamed to ScaleAdd().");}
- public static void scaleBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleBy() has been renamed to ScaleBy().");}
- public static void scaleFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleFrom() has been renamed to ScaleFrom().");}
- public static void scaleTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleTo() has been renamed to ScaleTo().");}
- public static void shake(GameObject target, Hashtable args){Debug.LogError("iTween Error: scale() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");}
- public static void shakeWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: shakeWorld() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");}
- public static void stab(GameObject target, Hashtable args){Debug.LogError("iTween Error: stab() has been renamed to Stab().");}
- public static void stop(GameObject target, Hashtable args){Debug.LogError("iTween Error: stop() has been renamed to Stop().");}
- public static void stopType(GameObject target, Hashtable args){Debug.LogError("iTween Error: stopType() has been deprecated. Please investigate Stop().");}
- public static void tweenCount(GameObject target, Hashtable args){Debug.LogError("iTween Error: tweenCount() has been deprecated. Please investigate Count().");}
- */
- #endregion
- }
|