Skip to content

Instantly share code, notes, and snippets.

@ArieLeo
ArieLeo / LICENSE
Created October 10, 2021 12:40 — forked from JohannesMP/LICENSE
[Unity3D] A Reliable, user-friendly way to reference SceneAssets by script.
/*******************************************************************************
* Don't Be a Jerk: The Open Source Software License.
* Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
*******************************************************************************
* _I_ am the software author - JohannesMP on Github.
* _You_ are the user of this software. You might be a _we_, and that's OK!
*
* This is free, open source software. I will never charge you to use,
* license, or obtain this software. Doing so would make me a jerk.
*
@ArieLeo
ArieLeo / FlyCamera.cs
Created October 5, 2021 16:04 — forked from FreyaHolmer/FlyCamera.cs
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
using UnityEngine;
[RequireComponent( typeof(Camera) )]
public class FlyCamera : MonoBehaviour {
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LabelDrawer : MonoBehaviour
{
struct Label3D
{
public readonly string text;
public readonly Vector3 position;
/// FloatPlotter, plots values on screen
/// by Nothke
///
/// How to use:
///
/// 1. Add this script to your main camera
/// 2. Create a FloatPlot object like:
/// FloatPlot plot = new FloatPlot(minimumValue, maximumValue, RectOnScreen);
/// 2b. Optional: you can set plot.color and plot.backgroundColor
/// 3. Push values to it, for example every Update or FixedUpdate
@ArieLeo
ArieLeo / Flicker.cs
Created June 16, 2021 05:31 — forked from LotteMakesStuff/Flicker.cs
Quake/Halflife style light flicker
using UnityEngine;
public class Flicker : MonoBehaviour
{
public string LightStyle = "mmamammmmammamamaaamammma";
private Light light;
public float loopTime = 2f;
[SerializeField]
private int currentIndex = 0;
@ArieLeo
ArieLeo / Tex2DArrayCreator.cs
Created April 3, 2021 16:34 — forked from Cyanilux/Tex2DArrayCreator.cs
EditorWindow for creating & editing Texture 2D Arrays. Note : All textures must have same width/height, mipmap count and format/compression type! (Place in an "Editor" folder inside assets, go to Window -> "Create Texture2DArray")
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.IO;
public class Tex2DArrayCreator : EditorWindow {
private string fileName;
private List<Texture2D> textures = new List<Texture2D>();
@ArieLeo
ArieLeo / SkinnedMeshObjectPreviewExample.cs
Created February 7, 2021 15:33 — forked from radiatoryang/SkinnedMeshObjectPreviewExample.cs
An example of a custom ObjectPreview rendering out a SkinnedMesh for Unity Editor C#... I used it for facial expressions and blendshape editing, you might want to use it for something else. I hereby place it under MIT License. Full write-up here: http://www.blog.radiator.debacle.us/2016/06/working-with-custom-objectpreviews-and.html
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
[CustomPreview(typeof(YourCustomScriptableObject))] // THIS IS VERY IMPORTANT, this is so the editor knows what this is supposed to be previewing at all
public class SkinnedMeshObjectPreviewExample : ObjectPreview {
PreviewRenderUtility m_PreviewUtility;
@ArieLeo
ArieLeo / InstancePrefab.cs
Created November 2, 2020 11:16 — forked from reveriejake/InstancePrefab.cs
Simplified 'prefab' that allows you to draw thousands of objects to the screen. Many thanks to Mike from toqoz.fyi for his help in solving some issues I had. This code is Inspired by his blog from https://toqoz.fyi/thousands-of-meshes.html
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Rendering;
namespace PicoGames.Prototype
{
[System.Serializable]
public class InstancePrefab
{
public GameObject prefab;
@ArieLeo
ArieLeo / Texture2DArraySurface.Shader
Created October 9, 2020 10:11 — forked from unitycoder/Texture2DArraySurface.Shader
GPU Instancing + Texture2DArray
Shader "Custom/Texture2DArraySurfaceShader"
{
Properties
{
_Textures("Textures", 2DArray) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
@ArieLeo
ArieLeo / TwistBoneBehaviour.cs
Created October 7, 2020 08:45
Twist Bone Controller for unity
public class TwistBoneBehaviour : MonoBehaviour
{
public Transform sourceFrom; // BTW: Arm
public Transform sourceTo; // BTW: Elbow
public bool isDebugResetInterlock;
[System.Serializable]
public struct Target
{