Skip to content

Instantly share code, notes, and snippets.

View dev-fredericfox's full-sized avatar

Frederic Fox dev-fredericfox

View GitHub Profile
@dev-fredericfox
dev-fredericfox / FloatingDamageText.cs
Last active January 28, 2023 22:57
Unity: Positioning a UI Toolkit VisualElement relative to a GameObject
// the gameObject.transform.position for example, in my case a empty gameObject positioned over the character
Vector2 gameObjectToScreenPosition = Camera.main.WorldToScreenPoint(position);
Vector2 screenToUIToolkitPosition = RuntimePanelUtils.ScreenToPanel(_root.panel, gameObjectToScreenPosition);
Label combatText = new Label(text);
// set the label's text
combatText.text = text;
// set the label's color
combatText.style.color = color;
// Absolute
Shader "CustomRenderTexture/FOWLightNoSmoothing"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_Tex("InputTex", 2D) = "white" {}
}
SubShader
{