Skip to content

Instantly share code, notes, and snippets.

-- a cloud chamber by nothke
-- with an accidental colorful spread
-- see "ACCIDENT"
function _init()
cls();
end
function _update()
-- unused
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AeroSurface : MonoBehaviour
{
public Rigidbody rb;
void Start()
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class GridNoiseCells : MonoBehaviour
{
[Header("Starting cell offset")]
public int currentX = 0;
public int currentY = 0;
using UnityEngine;
using UnityEditor;
public class SerializedPropTrick : MonoBehaviour
{
// (the dummy class
[System.Serializable]
public class SomeClass
{
using UnityEngine;
public static class GameObjectExtensions
{
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
{
T component = gameObject.GetComponent<T>();
if (component == null) component = gameObject.AddComponent<T>();
return (T)component;
/// Normalmap exporter for Unity
///
/// IMPORTANT: Must be put into Editor folder to work
///
/// Right click on a texture in assets window and click on 'Export Normalmap...'
/// Can only export normal maps as it shifts channels
///
/// Original script by Eric5h5
/// Rewritten to C# and updated by Nothke
///
public Transform CreatePreview(Transform prefab, Material previewMaterial)
{
// Instantiate the prefab
Transform t = Instantiate(prefab);
// Set all materials to preview material
foreach (var renderer in t.GetComponentsInChildren<Renderer>(true))
renderer.sharedMaterial = previewMaterial;
// Destroy all other non-rendering related components
using UnityEngine;
public class HoverAtPointInSpaceExample : MonoBehaviour
{
public VectorPid pid = new VectorPid(10, 5, 5);
public Vector3 target = new Vector3(0, 2, 0);
Rigidbody _rb;
Rigidbody rb { get { if (!_rb) _rb = GetComponent<Rigidbody>(); return _rb; } }
@nothke
nothke / ThreadingExample.cs
Last active February 16, 2018 14:53
Threading example for Unity
using System.Collections;
using UnityEngine;
using System.Threading;
public class ThreadingExample : MonoBehaviour
{
Thread myThread;
// This is where we'll put the value of threading result
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RandomRomanianNam : MonoBehaviour
{
public Text text;