- Home /
Question by
danny7 · Jan 22, 2016 at 04:57 AM ·
javascripttransformrecttransform
How to translate RectTransform to Transform
I am using iTween to move and ease my UI, but I cannot find a way to translate the RectTransform's position to a transform.position.
Here's my example script:
#pragma strict
private var rt : RectTransform;
var uiButton : UI.Button;
var vector3 : Vector3;
function Start ()
{
rt = uiButton.GetComponent(typeof (RectTransform)) as RectTransform;
}
function Update ()
{
if(Input.GetKeyDown(KeyCode.Space))
{
iTween.MoveAdd(uiButton.gameObject, iTween.Hash("y", vector3.y, "time", 2, "easeType", iTween.EaseType.easeInOutQuad));
}
}
I set the vector3 variable as 100 and it goes to the world space 100, not the recttransform 100.
Comment
I don't know iTween, but I think the first parameter should be rt and not gameobject, or am I wrong? I mean how does iTween know what to change if you pass in a whole gameobject?
Your answer
Follow this Question
Related Questions
Best Way to make a character move 1 Answer
How to make the player turn left or right only in desired places o edges and not everywhere ???? 0 Answers
Slower Ladder 2 Answers
clamp limit variables trouble 1 Answer
Simple Instantiate gameObject problem 3 Answers