iTween.MoveFrom C# (CSharp) Method

MoveFrom() public static method

Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with FULL customization options.
public static MoveFrom ( GameObject target, Hashtable args ) : void
target GameObject
args Hashtable
return void
    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);
    }

Same methods

iTween::MoveFrom ( GameObject target, Vector3 position, float time ) : void
iTween