Skip to content

Instantly share code, notes, and snippets.

@Emanx140
Emanx140 / Utils_Perf.cs
Created April 15, 2021 12:55 — forked from Guendeli/Utils_Perf.cs
Performance Utility variables with no accessor functions and bybe by byte string comparison
/// <summary>
/// Performance utility code
/// </summary>
public class Utils_Perf
{
/// <summary>
/// Static values with no accessor functions to slow them down.
/// Actually calling Vector3.zero is like calling New Vector3(0,0,0)
/// About 4x faster than Vector3.zero
@Emanx140
Emanx140 / TextureCache.cs
Created April 15, 2021 12:37 — forked from Guendeli/TextureCache.cs
Unity offer no method to Load from file or Download besides AssetBundles, here is a class to Cache stuff into the persistent file path, then check if it exists before calling a WWW to download.
using UnityEngine;
using System;
using System.Collections;
using System.IO;
/// <summary>
///
/// </summary>
public class TextureCache
{
@Emanx140
Emanx140 / Global Event System.cs
Created April 15, 2021 12:35 — forked from Guendeli/Global Event System.cs
a non-generic abstract base class which serves only the purpose of storing all the generic subclasses inside a common list
using System;
using System.Collections.Generic;
//----------------------------
// Some interesting shit is going on here
// We have a non-generic abstract base class which serves only the purpose of storing all the generic
// subclasses inside a common list (you'll see one in the GlobalEventSystemMaitenance class).
// Different events inside the EventSystem.Events namespace (and folder) are just statically typed
// entities used to differentiate the events one from another
//----------------------------
@Emanx140
Emanx140 / MemoryTips.cs
Created April 15, 2021 12:35 — forked from Guendeli/MemoryTips.cs
Memory Conservation tips for Unity
// Let's talk about memory conservation
// If a Unity API returns an array, it allocates a new copy.
// Every time it is accessed, Even if the values do not change.
// Bad Sample 1: this code allocate too many Arrays
for ( int i = 0;i < Input.touches.Length; i++ ) // Get() accessor call + creating copy
{
Touch touch = Input.touches[i]; // Creating copy
// …
}