chrisgregan
10 years ago
6 changed files with 227 additions and 7 deletions
@ -0,0 +1,49 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
[CommandInfo("iTween", |
||||||
|
"Look From", |
||||||
|
"Instantly rotates a GameObject to look at the supplied Vector3 then returns it to it's starting rotation over time.")] |
||||||
|
public class LookFrom : iTweenCommand |
||||||
|
{ |
||||||
|
public Transform fromTransform; |
||||||
|
public Vector3 fromPosition; |
||||||
|
public iTweenAxis axis; |
||||||
|
|
||||||
|
public override void DoTween() |
||||||
|
{ |
||||||
|
Hashtable tweenParams = new Hashtable(); |
||||||
|
tweenParams.Add("name", tweenName); |
||||||
|
if (fromTransform == null) |
||||||
|
{ |
||||||
|
tweenParams.Add("looktarget", fromPosition); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
tweenParams.Add("looktarget", fromTransform); |
||||||
|
} |
||||||
|
switch (axis) |
||||||
|
{ |
||||||
|
case iTweenAxis.X: |
||||||
|
tweenParams.Add("axis", "x"); |
||||||
|
break; |
||||||
|
case iTweenAxis.Y: |
||||||
|
tweenParams.Add("axis", "y"); |
||||||
|
break; |
||||||
|
case iTweenAxis.Z: |
||||||
|
tweenParams.Add("axis", "z"); |
||||||
|
break; |
||||||
|
} |
||||||
|
tweenParams.Add("time", duration); |
||||||
|
tweenParams.Add("easetype", easeType); |
||||||
|
tweenParams.Add("looptype", loopType); |
||||||
|
tweenParams.Add("oncomplete", "OnComplete"); |
||||||
|
tweenParams.Add("oncompletetarget", gameObject); |
||||||
|
tweenParams.Add("oncompleteparams", this); |
||||||
|
iTween.LookFrom(target, tweenParams); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 433657382cf894ff2973ee118eed40ea |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
@ -0,0 +1,49 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
[CommandInfo("iTween", |
||||||
|
"Look To", |
||||||
|
"Rotates a GameObject to look at a supplied Transform or Vector3 over time.")] |
||||||
|
public class LookTo : iTweenCommand |
||||||
|
{ |
||||||
|
public Transform toTransform; |
||||||
|
public Vector3 toPosition; |
||||||
|
public iTweenAxis axis; |
||||||
|
|
||||||
|
public override void DoTween() |
||||||
|
{ |
||||||
|
Hashtable tweenParams = new Hashtable(); |
||||||
|
tweenParams.Add("name", tweenName); |
||||||
|
if (toTransform == null) |
||||||
|
{ |
||||||
|
tweenParams.Add("looktarget", toPosition); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
tweenParams.Add("looktarget", toTransform); |
||||||
|
} |
||||||
|
switch (axis) |
||||||
|
{ |
||||||
|
case iTweenAxis.X: |
||||||
|
tweenParams.Add("axis", "x"); |
||||||
|
break; |
||||||
|
case iTweenAxis.Y: |
||||||
|
tweenParams.Add("axis", "y"); |
||||||
|
break; |
||||||
|
case iTweenAxis.Z: |
||||||
|
tweenParams.Add("axis", "z"); |
||||||
|
break; |
||||||
|
} |
||||||
|
tweenParams.Add("time", duration); |
||||||
|
tweenParams.Add("easetype", easeType); |
||||||
|
tweenParams.Add("looptype", loopType); |
||||||
|
tweenParams.Add("oncomplete", "OnComplete"); |
||||||
|
tweenParams.Add("oncompletetarget", gameObject); |
||||||
|
tweenParams.Add("oncompleteparams", this); |
||||||
|
iTween.LookTo(target, tweenParams); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 3ec82c445301b4e9fb9b89cb2eb6a666 |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
Loading…
Reference in new issue