Answers for "4 or 5 Making a button transparent"http://answers.unity3d.com/questions/801928/46-ui-making-a-button-transparent.html
The latest answers for the question "4 or 5 Making a button transparent"Answer by elich11http://answers.unity3d.com/answers/1352137/view.html
Currently you can use the editor.
Click on the button image, select color, use the alpha slider to change it.
![alt text][1]
[1]: /storage/temp/93907-capture.pngThu, 11 May 2017 14:59:12 GMTelich11Answer by Rcocuzzo8http://answers.unity3d.com/answers/1177499/view.html
The answers above are close, but not working because the button DOES NOT WORK once you delete or take out the invisible button.
**Steps to having a WORKING invisible button**:
1. Create the button as a UI Button
2. Delete the Text property that the button has assigned to it
3. Go to the Button's "Image (Script)", change the sprite to UIMask. UIMask is used as a placeholder to hide elements but they **will still be there**
I hope this helps sum things up.Wed, 27 Apr 2016 13:31:01 GMTRcocuzzo8Answer by greg-hardinghttp://answers.unity3d.com/answers/1165070/view.html
Updated @_bcristian_ 's Touchable for Unity 5.3+
// Touchable.cs
using UnityEngine;
namespace UnityEngine.UI {
public class Touchable : Graphic {
public override bool Raycast(Vector2 sp, Camera eventCamera) {
return true;
}
protected override void OnPopulateMesh(VertexHelper vh) {
vh.Clear();
}
}
}
// TouchableEditor.cs
using UnityEngine;
using UnityEditor;
namespace UnityEngine.UI {
[CustomEditor(typeof(Touchable))]
public class TouchableEditor : Editor {
public override void OnInspectorGUI() {}
}
}Mon, 04 Apr 2016 00:32:26 GMTgreg-hardingAnswer by _bcristian_http://answers.unity3d.com/answers/883972/view.html
As already mentioned - DO NOT use transparent images or similar tricks. A fully transparent image still renders at exactly the same cost as a regular one, so it's a very bad idea.
Improving on the answer by SignalZak, there are 2 options. For both of them, use the EventTrigger component to handle events.
- the lazy one, no coding required: Create a Text object with no text and set the rectangle to the desired size.
- the proper one (just a few lines of code): Create a custom UI control, derived from UnityEngine.UI.Graphic, and override Raycast to always return true (testing against the rect bounds was done already), and also OnFillVBO to do nothing (the default implementation creates a white opaque quad to fill the rectangle).
public class Touchable : Graphic
{
public override bool Raycast(Vector2 sp, Camera eventCamera)
{
//return base.Raycast(sp, eventCamera);
return true;
}
protected override void OnFillVBO(List<UIVertex> vbo)
{
//base.OnFillVBO(vbo);
}
}
[CustomEditor(typeof(Touchable))]
public class TouchableEditor : Editor
{
public override void OnInspectorGUI()
{
// nothing
}
}Fri, 23 Jan 2015 16:58:59 GMT_bcristian_Answer by SignalZakhttp://answers.unity3d.com/answers/851816/view.html
We ran into the same problem, how to provide a touchable, invisible area. We tried a fully-alpha'd image with no sprite attached, but you still get the overdraw (which is an issue on handhelds).
We tried implementing various UnityEngine.UI & EventSystem interfaces to see how the touch detection worked (and inheriting from various UI components) before settling on creating a Touchable component that inherits from Text (since Text detects touch outside of its rendered area and has no overdraw).
This script is called Touchable.cs Quite simply,
1. make a Button in the normal way
2. simply eliminate the "text" object which comes below a Button as standard
3. simply delete the "Image" which comes on a Button as standard
4. Simply drop this script, Touchable.cs, on to the button - you're done.
**You now have a perfect invisible button.** Also, say you have perhaps a compicated image or panel. You can drop an invisible button like this "inside" it, and just set the RectTransform to expand all ways. It then "makes that thing become" a perfect button. This is exactly how you can make any unusual or dynamic object in to a button.
// Touchable component
using UnityEngine;
using UnityEngine.UI;
public class Touchable : Text
{
protected override void Awake()
{
base.Awake();
}
}
// Touchable_Editor component, to prevent treating the component as a Text object.
using UnityEditor;
[CustomEditor(typeof(Touchable))]
public class Touchable_Editor : Editor
{
public override void OnInspectorGUI ()
{
// Do nothing
}
}
That's the whole script. There's only one script (there's no separate Editor script or anything like that.)Thu, 11 Dec 2014 03:42:02 GMTSignalZakAnswer by BoredMormonhttp://answers.unity3d.com/answers/801960/view.html
Simply attach a button component to an empty GameObject
Rendering transparent items is expensive. If the button is to be invisible do away with the image component altogether.
Remember, UI elements are just GameObjects. GameObjects are defined by the attached components. You can combine components in any way you like to produce the behaviour you are after. There is nothing forcing you to stick with the defaults from the Create->UI menu, and in many cases sticking to the default is a bad idea.Thu, 02 Oct 2014 18:32:33 GMTBoredMormon