- Home /
What is the name of .color propert for new Unity UI Image?
Before new UI I've been creating my own UI using SpiteRenderer and sprites and have used GoKit to tween color, size and other stuff of the UI. Since I've finished old project I've decided to start using new UI on next project and I'm having difficulties to get the name of the color property so i can pass it to .colorProp of the GoTweenConfig() of GoKit. I've tried to see the declaration of the Image class but I can't seem to find Color property anywhere there.
How can i get what is the name of that property variable?
Thank you in advance!
Answer by saschandroid · Feb 09, 2015 at 04:26 PM
GetComponent<UnityEngine.UI.Image>().color
I think you haven't used the Go$$anonymous$$it. I need the actual name of the variable like in renderer component name of the color is something like _Color. The method takes name of the variable and then concludes what type is it, but I cant seem to find the declared color property in the Image class. I know i can get component or put a reference of the actual image.
I found out yesterday that the name of the color parameter is "color". And yes you need to pass image component, I've already had public field in my script for referencing it.
thanx anyway
Answer by Hohusen · Feb 09, 2015 at 11:35 PM
Hey, Darkwing. I had the same problem earlier today. You need to pass the uGUI Image to the tween.
Image uiImage = gameObject.GetComponent<Image>();
GoTweenConfig colorConfig = new GoTweenConfig().colorProp( "color", new Vector4( 1, 0, 0, 1) ).setEaseType(GoEaseType.SineIn);
GoTween colorTween = new GoTween(uiImage, 1.0f, colorConfig);
Go.addTween( colorTween );
Make sure you've imported UI scripts via using UnityEngine.UI; at the top of your class.
Answer by DanSuperGP · Feb 09, 2015 at 11:32 PM
It inherits it from **http://docs.unity3d.com/460/Documentation/ScriptReference/UI.Graphic.html**
Your answer
Follow this Question
Related Questions
How should I generate an image of a model? 1 Answer
Matching the size of UI elements with that of world objects 0 Answers
GUI looks Awful! 0 Answers