Skip to content

Instantly share code, notes, and snippets.

View phamtanlong's full-sized avatar

Pham Tan Long phamtanlong

View GitHub Profile
@prodigga
prodigga / SSE_Download_Handler.md
Last active January 27, 2025 15:35
SSE's (Server-Sent Events) Download Handler

Whats this?

This is a custom UnityWebRequest Download Handler to support SSE's (Server-Sent Events) in Unity!

How to use it

Simply inhert SseDownloadHandlerBase and supply your own logic (Deserialise incoming lines, expose events, etc).

Then set the download handler to be an instance of your class.

webRequest.downloadHandler = new LogSseExampleDownloadHandler();
@desmondfernando
desmondfernando / DisableHWStats.cs
Last active June 3, 2024 01:44
Code snippet to disable HW statistics reporting. NOTE only works in the Editor not for runtime! Unity Pro only
var type = Type.GetType( "UnityEditor.PlayerSettings,UnityEditor" );
if ( type != null )
{
var propertyInfo = type.GetProperty( "submitAnalytics", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static );
if ( propertyInfo != null )
{
{
var value = (bool)propertyInfo.GetValue( null, null );
Debug.LogFormat( "PlayerSettings.submitAnalytics {0}", value );
}
@elringus
elringus / BlendModes.c
Last active March 11, 2024 11:32
Popular blend mode algorithms implemented in Nvidia's Cg. https://elringus.me/blend-modes-in-unity/
fixed3 Darken (fixed3 a, fixed3 b)
{
return min(a, b);
}
fixed3 Multiply (fixed3 a, fixed3 b)
{
return a * b;
}