Skip to content

Instantly share code, notes, and snippets.

View longde123's full-sized avatar
:octocat:
Working from home

paling longde123

:octocat:
Working from home
View GitHub Profile
@longde123
longde123 / DrawGrass.cs
Created November 9, 2021 13:14 — forked from Cyanilux/DrawGrass.cs
Experiments with DrawMeshInstanced and DrawMeshInstancedIndirect for drawing grass (over terrain)
// https://twitter.com/Cyanilux/status/1396848736022802435
// Requires a specific shader to read the _PerInstanceData buffer at SV_InstanceID
// I use a shader made in Shader Graph, See : https://gist.github.com/Cyanilux/4046e7bf3725b8f64761bf6cf54a16eb
// Also note, there's no frustum culling involved in this example. Typically a compute shader is used for this.
using UnityEngine;
public class DrawGrass : MonoBehaviour {
@longde123
longde123 / TreeReplacerS.cs
Created October 19, 2021 06:44 — forked from st4rdog/TreeReplacerS.cs
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 {
@longde123
longde123 / ColliderGizmo.cs
Created September 25, 2021 09:49
Draw gizmo for colliders
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MyBox
{
public class ColliderGizmo : MonoBehaviour
@longde123
longde123 / EdgeDetectNormals.shader
Created July 8, 2021 04:42 — forked from MattRix/EdgeDetectNormals.shader
Unity edge detect normals shader for reference
Shader "Hidden/EdgeDetect" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
@Cyanilux
Cyanilux / DrawGrass.cs
Last active January 27, 2024 07:55
Experiments with DrawMeshInstanced and DrawMeshInstancedIndirect for drawing grass (over terrain)
// https://twitter.com/Cyanilux/status/1396848736022802435
// Requires a specific shader to read the _PerInstanceData buffer at SV_InstanceID
// I use a shader made in Shader Graph, See : https://gist.github.com/Cyanilux/4046e7bf3725b8f64761bf6cf54a16eb
// Also note, there's no frustum culling involved in this example. Typically a compute shader is used for this.
using UnityEngine;
public class DrawGrass : MonoBehaviour {
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using UnityEngine.AddressableAssets;
@runette
runette / FlyingCam.cs
Created April 14, 2020 11:28
Movement and Interaction script
//https://stackoverflow.com/questions/58328209/how-to-make-a-free-fly-camera-script-in-unity-with-acceleration-and-decceleratio
// copyright Runette Software Ltd, 2020. All rights reserved
using UnityEngine;
using UnityEngine.InputSystem;
using Zinnia.Pointer;
using Zinnia.Cast;
public class FlyingCam : MonoBehaviour
{
[Header("Constants")]
@favoyang
favoyang / BuildAddressables.cs
Last active August 14, 2023 06:29
Build addressable bundles when clicking the build button
/// <summary>
/// The script gives you choice to whether to build addressable bundles when clicking the build button.
/// For custom build script, call PreExport method yourself.
/// For cloud build, put BuildAddressablesProcessor.PreExport as PreExport command.
/// Discussion: https://forum.unity.com/threads/how-to-trigger-build-player-content-when-build-unity-project.689602/
///
/// License: The MIT License https://opensource.org/licenses/MIT
/// </summary>
using UnityEditor;
using UnityEditor.AddressableAssets;
@MangelMaxime
MangelMaxime / Async.hx
Last active February 3, 2021 10:14
Demonstrate how to use native async/await from JavaScript with haxe.
package async;
#if macro
import haxe.macro.Context;
#end
class Async {
public static macro function async(expr:haxe.macro.Expr) {
expr = Context.storeTypedExpr(Context.typeExpr(expr));
return macro untyped __js__("(async {0})", ${expr})();
@SachinGanesh
SachinGanesh / QualityManager.cs
Created May 31, 2018 06:57
Unity3D Dynamic Quality Settings based on FPS. Runtime reduction of quality based on device performance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QualityManager : Singleton<QualityManager> {
private int QUALITY_INDEX = 0;
public int MIN_FPS = 28;
public Text qualityUIText;