- Home /
pixelInset to Move a GUITexture C#
I need to move a GUITexture using pixelInset, easy. The hard part is that I need the GUITexture to move on the Y axis -46 down smoothly, in amount 1 to 2 seconds. When finished I need it to go back to its original spot of -274. There's other code handling the fading so by them time it goes back to -274 it will be 100% transparent.
Written in C#.
So I have:
medalSpeedCalculator = -274;
medalSpeedTime -= -.5f;
medalSpeed = medalSpeedCalculator - medalSpeedTime;
MultiplierMedal.pixelInset = new Rect(266, medalSpeed, 75, 75);
if (medalSpeed >= -310)
{
medalSpeed = 0;
}
The problem is that the medalSpeed value will always be the pixelInset Y value. So I need a way to go from point A to point B then restart. The medalSpeed seems to always keep its climbing value and exceeds -310. This process is repeated so the value needs to be reset each time. This is all in an if statement.
This sounds like it could be done using a lerp, but I'm not sure how I would do it. I'm new to C# as I only program with js and I'm not familiar with pixelInset or GUITexture coding wise.
There's no easy way to explain this and I hope I gave enough info. If anyone needs more info just let me know.
Thanks in advance!
I would recommend you to use ITween for such effects like moving, fading etc. It makes such tasks super easy.
Your answer
Follow this Question
Related Questions
Moving gui texture 1 Answer
Repositioning remote GUI Texture 1 Answer
How to move a texture created from GUI.DrawTexture 1 Answer
Make more buttons appear, on button click. 1 Answer
Null reference exception[SOLVED] 1 Answer