Skip to content

Instantly share code, notes, and snippets.

@kurtdekker
Last active April 18, 2025 20:25
Show Gist options
  • Save kurtdekker/043891a1d27b0e7df6f3f064da6d70ad to your computer and use it in GitHub Desktop.
Save kurtdekker/043891a1d27b0e7df6f3f064da6d70ad to your computer and use it in GitHub Desktop.
// From: https://answers.unity.com/questions/801928/46-ui-making-a-button-transparent.html?childToView=851816
//
// @kurtdekker
//
// Touchable invisible non-drawing Graphic (usable with Buttons too):
//
// To make an invisible Button:
//
// 1. make a Button in the normal way
// 2. delete the "Text" GameObject which comes below a Button as standard
// 3. delete the "Image" which comes on a Button as standard
// 4. drop this script on the Button, which lets the Button get touched
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class InvisibleGraphic : Graphic
{
public override bool Raycast(Vector2 sp, Camera eventCamera)
{
//return base.Raycast(sp, eventCamera);
return true;
}
protected override void OnPopulateMesh(VertexHelper vh)
{
// We don't want to draw anything
vh.Clear();
}
#if UNITY_EDITOR
[CustomEditor(typeof(InvisibleGraphic))]
public class InvisibleGraphicEditor : Editor
{
public override void OnInspectorGUI()
{
// nothing
}
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy