Skip to content

Instantly share code, notes, and snippets.

@st4rdog
st4rdog / MipMapBiasAdjusterS.cs
Created November 16, 2017 20:00
Sharpen blurry mipmaps in Unity
using UnityEngine;
using System.Collections;
public class MipMapBiasAdjusterS : MonoBehaviour {
[Header("Settings")]
[Tooltip("A positive bias makes a texture appear extra blurry, while a negative bias sharpens the texture. Note that using large negative bias can reduce performance, so it's not recommended to use more than -0.5 negative bias.)")]
public float _target = -2f;
[Tooltip("Adjust all textures found in scene?")]
public bool _allTexturesOnStart;
using UnityEngine;
using System.Collections;
public class LightmapPixelPicker : MonoBehaviour {
public Color surfaceColor;
public float brightness1; // http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
public float brightness2; // http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
public LayerMask layerMask;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Vectrosity;
public class BlinkScript : MonoBehaviour {
public bool bLogStateChanges;
public enum State
@st4rdog
st4rdog / TreeReplacerS.cs
Created March 14, 2019 06:38
Replaces trees on a terrain with prefab.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
// Replaces Unity terrain trees with prefab GameObject.
// http://answers.unity3d.com/questions/723266/converting-all-terrain-trees-to-gameobjects.html
[ExecuteInEditMode]
public class TreeReplacerS : EditorWindow {
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
//http://wiki.unity3d.com/index.php?title=Floating_Origin
public class FloatingPointOriginMoveS : MonoBehaviour {
[Header("Settings")]
[Tooltip("When Target's position reaches this magnitude/distance, Target and Scene Root transforms will be moved.")]
using UnityEngine;
using System.Collections;
public class ShakeTransformS : MonoBehaviour
{
[Header("Info")]
private Vector3 _startPos;
private float _timer;
private Vector3 _randomPos;
[CustomEditor(typeof(Test))]
public class TestEditor : Editor
{
public override VisualElement CreateInspectorGUI()
{
var container = new VisualElement();
container.Add(new IMGUIContainer(OnInspectorGUI));
container.Add(new Label("Test"));
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
namespace UIGradient
{
[AddComponentMenu("UI/Effects/Gradient")]
public class Gradient : BaseMeshEffect
{
@st4rdog
st4rdog / Messaging.cs
Created December 20, 2021 01:23
Event/Messaging system for C# - strongly typed
// Created by lordofduct - https://forum.unity.com/threads/recommended-event-system.856294/#post-5644981
//
// Usage example:
//
// public delegate void OnDiedEvent(GameObject go);
//
// Messaging<OnDiedEvent>.Trigger?.Invoke(gameObject);
//
// Messaging<OnDiedEvent>.Register(go => {
// Debug.Log($"{go.name} died.");
@st4rdog
st4rdog / SmoothMouseLook.cs
Last active October 14, 2022 21:59
Unity - Smoothed mouse look for an FPS
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SmoothMouseLook : MonoBehaviour
{
private List<float> _xBuffer = new List<float>();
private List<float> _yBuffer = new List<float>();
private int _bufferIndex;