Skip to content

Instantly share code, notes, and snippets.

using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMesh : IDisposable
{
public NativeArray<float3> VertexBuffer;
public NativeArray<float3> NormalBuffer;
@capnslipp
capnslipp / DisableWhenAttribute.cs
Last active June 18, 2023 19:47
ShowWhen, HideWhen, EnableWhen, & DisableWhen Attributes for #Unity3D
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: Shows a field as disabled in Unity's Inspector only when a different method/property/field in the same MonoBehaviour returns/is-equal-to a given value or values.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Add `[DisableWhen(typeof(«MonoBehaviour-sub-type-name»), "«trigger-member-name»", «value-that-the-trigger-member-returns»)]` attribute to a (serializable public) field on your `MonoBehaviour`-class.
/// @intended project path: Assets/Plugins/EditorUtils/DisableWhenAttribute.cs
/// @interwebsouce: https://gist.github.com/capnslipp/9b99f83aa7b80dfb589a5b23e8e0cfa0
using System;
using UnityEngine;
@ffeu
ffeu / main.dart
Created December 13, 2018 12:35
ReorderableListSimple demo (requires flutter 1.0.0, flutter_reorderable_list 0.1.1) For ReorderableListSimple , see this gist: https://gist.github.com/ffeu/127c2b76d891fa12c9e2c831def785c4
import 'package:flutter/material.dart';
import 'reorderable_list_simple.dart';
const title = "ReorderableListSimple demo";
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
@ffeu
ffeu / reorderable_list_simple.dart
Last active February 15, 2024 03:32
An easy to replace Widget to make easier to migrate from flutter/ReorderableListView to knopp/ReorderableList . (flutter 1.0.0 and flutter_reorderable_list 0.1.1)
import 'package:flutter/material.dart';
import 'package:flutter_reorderable_list/flutter_reorderable_list.dart';
enum ReorderableListSimpleSide {Right, Left}
class ReorderableListSimple extends StatefulWidget {
ReorderableListSimple({
@required this.children,
@required this.onReorder,
this.allowReordering = true,
@quizcanners
quizcanners / Unity Fragment Shader Cheat Sheet .cs
Last active October 3, 2024 16:58
To keep snippets of code for Shaders. Just some stuff that I often use but also often forget because brain=poo
//https://neginfinity.bitbucket.io/ - a blog where I found how to do shadows for raymarched/raytraced primitives.
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/CGIncludes/UnityCG.cginc - Most interesting stuff ;)
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/tree/master/CGIncludes
//https://docs.unity3d.com/Manual/SL-Shader.html
//http://developer.download.nvidia.com/CgTutorial/cg_tutorial_appendix_e.html
//https://unity3d.com/how-to/shader-profiling-and-optimization-tips
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
//http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html
//http://www.iquilezles.org/blog/
@msklywenn
msklywenn / BatchBuilderSettings.cs
Last active May 18, 2022 14:32
Unity Batch Builder
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2004 Sam Hocevar <[email protected]>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@yuiwong
yuiwong / PrePlayOption.cs
Created July 31, 2018 15:19
random editor scripts, @note: my advise is don't use editor scriptings, garbage shithole in design.
using UnityEditor;
using UnityEngine;
// allow do something before/after playmode
[InitializeOnLoad]
public static class PrePlayOptions
{
static PrePlayOptions()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChange;
@bricevdm
bricevdm / StandardCurved.shader
Created June 6, 2018 00:00
Standard Unity Surface Shader modification with distance-based quadratic curvature applied in world space
Shader "Custom/StandardCurved" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Curvature ("Curvature", Range(0, 0.1)) = 0.01
}
SubShader {
Tags { "RenderType"="Opaque" }
@Split82
Split82 / UnityShadersCheatSheet.shader
Created April 17, 2018 10:07
Unity Shaders Cheat Sheet
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@LotteMakesStuff
LotteMakesStuff / 1.md
Last active January 2, 2025 21:54
UPM: How to make a custom package

UPM: How to make a custom package So, Unity has this shiny new package manager, and you have code you want to share between projects - wouldn't it be great if we could bundle up our shared code and plug it into all the projects that need it? Let's figure out how to make our own Package!


Todo

  • Modify the project manifest
  • Make a package manifest
  • Package the manifest up with some test code
  • Try it out in Unity!