Skip to content

Instantly share code, notes, and snippets.

View Anthelmed's full-sized avatar

Anthelme Dumont Anthelmed

View GitHub Profile
@Anthelmed
Anthelmed / Searchbar
Created March 10, 2022 21:40
Searchbar code example for the medium article on UIToolkit
@Anthelmed
Anthelmed / Router.cs
Created April 26, 2022 22:09
Router example
using System;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Router
{
public static class SceneRouter
{
public enum SceneType
@Anthelmed
Anthelmed / WorldSpaceUIDocument.cs
Last active April 29, 2024 09:31
Until Unity decide to make it official, this is a custom WorldSpaceUIDocument component. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem.UI;
#endif
#if UNITY_EDITOR
using UnityEditor;
@Anthelmed
Anthelmed / UIToolkitAutoReferencesPostprocessor.cs
Last active May 12, 2023 19:20
Automatically generate for you a MonoBehavior script containing reference to all the VisualElements that have the "auto-reference" uss class, this is updating every time you add or remove an "auto-reference" uss class inside your UXML file. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine.UIElements;
namespace Postprocessors
@Anthelmed
Anthelmed / UIAnimationsUtils.cs
Last active April 28, 2023 13:22
A simple utils for fading in and out VisualElements. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
using System;
using UnityEngine.UIElements;
using UnityEngine.UIElements.Experimental;
public static class UIAnimationsUtils
{
public static ValueAnimation<float> FadeIn(VisualElement visualElement, int durationMS, Func<float, float> easing, Action callback = null, bool disabledWhenInvisible = true)
{
var fromOpacity = visualElement.style.opacity.value;