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);
}