iTween.LookFrom C# (CSharp) Method

LookFrom() public static method

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.
public static LookFrom ( GameObject target, Hashtable args ) : void
target GameObject
args Hashtable
return void
    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);
    }

Same methods

iTween::LookFrom ( GameObject target, Vector3 looktarget, float time ) : void
iTween