Hi - I’m using unity pro 4.6.
I’m following this tutorial (masking an image for GUI)
http://blogs.unity3d.com/2014/05/28/overview-of-the-new-ui-system/
…at 15m30s the tutor uses an ‘image mask’ component however I don’t have this pre-made component/script.
On startup I’ve checked the boxes for all scripts to be brought in but do I need to download extra GUI resources from somewhere else…any help would be great.
The component has changed and is now simply called “Mask”.
Its an default GUI component.
Thanks - i’ve got it working - perhaps you can help me with a query (I have searched the forum and online with no luck). I want to make a dynamic mask - one that will increase in height based on the incoming value from an external sensor). As it stands if I scale the mask it also scales the orignal image as one is a child of the other…how can I retain the masking but leave the scale attributes separate ?
If this is not possible I had thought of using an animated sprite sequence as the mask and increasing/decreasing the keyframe based on sensor input - this method seems a bit inefficient though.
Any advice would be great.
You should use the width and hight values of the rect transform the change the size of the mask and not the scale parameter.
If you anchor your mask content to the middle and do not the anchor mode to scale you objects inside the mask will not change if you change the width or hight of the mask.
Not my favorite way but it works.
thanks. …very last question…
I have a mask that is decreasing in height based on a countdown timer (energy value). This works fine.
If the user triggers a sensor (flex value - passed in from another script) I want the energy value to increase and also increase the mask height. The sensor readings are working fine but for some reason its not impacting on the ‘energy’ value. Have you any idea why - if you don’t have time or if its not your area I can check on the scripting forum - thanks for all your help.
float energy = 100.0f;
public void Update()
{
if (JoeysInput.flex <= 0) {
energy -= 10 * (Time.deltaTime);
}
if (JoeysInput.flex >= 2) {
energy += 20;
}
RectTransform rTrans = (RectTransform) transform.GetComponent();
rTrans.sizeDelta = new Vector2(20, energy);
fixed it - please ignore last post
