Skip to content

Instantly share code, notes, and snippets.

View RiskyWilhelm's full-sized avatar
😃

Yunus Yıldız RiskyWilhelm

😃
View GitHub Profile
@davidfowl
davidfowl / gist:3173128
Created July 24, 2012 22:36 — forked from jmangelo/gist:3173109
MethodInfo.Invoke is slow... open instance delegate to the rescue
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
@DmitriyYukhanov
DmitriyYukhanov / ObjectTools.cs
Created March 21, 2017 11:18
Updated code to get a Unity object id.
#define UNITY_5_PLUS
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
#undef UNITY_5_PLUS
#endif
using UnityEngine;
using System.Reflection;
using UnityEditor;
namespace CodeStage.Maintainer.Tools
@mminer
mminer / VerticallyFlipRenderTexture.cs
Created February 18, 2021 21:39
Unity function to vertically flip a render texture.
/// <summary>
/// Vertically flips a render texture in-place.
/// </summary>
/// <param name="target">Render texture to flip.</param>
public static void VerticallyFlipRenderTexture(RenderTexture target)
{
var temp = RenderTexture.GetTemporary(target.descriptor);
Graphics.Blit(target, temp, new Vector2(1, -1), new Vector2(0, 1));
Graphics.Blit(temp, target);
RenderTexture.ReleaseTemporary(temp);
@nailuj05
nailuj05 / GetOrAddComponent.cs
Last active October 19, 2024 08:41
A simple extension method for Unity C# this gets or adds a given Component. (SphereCollider coll = gameObject.GetOrAddComponent<SphereCollider>();)
public static class Extensions
{
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
{
if(gameObject.TryGetComponent<T>(out T t))
{
return t;
}
else
{