This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEngine; | |
[ExecuteInEditMode] | |
[RequireComponent(typeof(Camera))] | |
public class RealFramerate : MonoBehaviour { | |
public int framerate { get { return _framerate; } } | |
private int _framerate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The 'unmanaged' keyword was added in C# 7.3, to allow type restriction for unmanaged types (it checks if type has references recursively) | |
// https://docs.microsoft.com/fr-fr/dotnet/csharp/whats-new/csharp-7-3 | |
#define CSHARP_7_3_OR_ABOVE | |
// Marshal.SizeOf(Type) was changed for Marshal.SizeOf<T>() in .NET 4.5.1, and the first constructor became obsolete in NET Standard. | |
// https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.sizeof?view=netframework-4.5 | |
#define NET_4_5_1_OR_ABOVE | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Security; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Mesh CreateMeshFromBounds(Vector3 center, Vector3 extends) { | |
var xm_ym_zm = new Vector3(center.x - extends.x, center.y - extends.y, center.z - extends.z); | |
var xp_ym_zm = new Vector3(center.x + extends.x, center.y - extends.y, center.z - extends.z); | |
var xm_yp_zm = new Vector3(center.x - extends.x, center.y + extends.y, center.z - extends.z); | |
var xp_yp_zm = new Vector3(center.x + extends.x, center.y + extends.y, center.z - extends.z); | |
var xm_ym_zp = new Vector3(center.x - extends.x, center.y - extends.y, center.z + extends.z); | |
var xp_ym_zp = new Vector3(center.x + extends.x, center.y - extends.y, center.z + extends.z); | |
var xm_yp_zp = new Vector3(center.x - extends.x, center.y + extends.y, center.z + extends.z); | |
var xp_yp_zp = new Vector3(center.x + extends.x, center.y + extends.y, center.z + extends.z); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
[RequireComponent(typeof(Image))] | |
[RequireComponent(typeof(AspectRatioFitter))] | |
public class CameraImage : MonoBehaviour { | |
private WebCamTexture cameraTexture; | |
private Image image; | |
private AspectRatioFitter fit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ProjectReferences<T> : ScriptableObject where T : ScriptableObject | |
{ | |
private static T instance; | |
public static T Instance { | |
get { | |
if (instance == null) { | |
instance = Resources.Load<T>(typeof(T).Name); | |
if (instance == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
public static class Profiling { | |
private static Dictionary<string, Stopwatch> stopwatches = new Dictionary<string, Stopwatch>(); | |
public static void Start(string key) { | |
if (!stopwatches.ContainsKey(key)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Concurrent; | |
using System.Linq; | |
using UnityEngine; | |
using UnityEngine.Events; | |
[ExecuteInEditMode] | |
public sealed class MonoContext : MonoBehaviour { | |
public static UnityEvent OnUpdate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Concurrent; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using UnityEditor; | |
using UnityEngine; | |
using UnityEngine.Experimental.LowLevel; | |
#pragma warning disable CS1998 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class TransformExtensions { | |
private static void GetTRS(this Matrix4x4 matrix, out Vector3 translation, out Quaternion rotation, out Vector3 scale) | |
{ | |
float det = matrix.GetDeterminant(); | |
// Scale | |
scale.x = matrix.MultiplyVector(new Vector3(1, 0, 0)).magnitude; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public static class Screenshot | |
{ | |
static Screenshot() | |
{ | |
EditorApplication.delayCall += () => { |
OlderNewer