Skip to content

Instantly share code, notes, and snippets.

View HarukaKajita's full-sized avatar

HarukaKajita HarukaKajita

View GitHub Profile
@fuqunaga
fuqunaga / SerializedPropertyExtensions.cs
Last active August 8, 2024 01:59
Get actual object of SerializedProperty
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
public static class SerializedPropertyExtensions
@shivaduke28
shivaduke28 / UnityPointLight.hlsl
Created October 21, 2023 07:55
Unity PointLight range and attenuation
#include "AutoLight.cginc"
#if defined(POINT)
// 1/range*range for Unity's PointLight
float UnityPointLightRangeInvSqr()
{
float3 unitLS = float3(unity_WorldToLight._m00, unity_WorldToLight._m01, unity_WorldToLight._m02);
return dot(unitLS, unitLS);
}
// https://forum.unity.com/threads/light-dist ance-in-shader.509306/#post-3326818
@isuzu-shiranui
isuzu-shiranui / ShaderPropertiesGenerator.cs
Created March 27, 2023 16:27
シェーダーのPropertiesから定義部分を生成させるやつ
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
public class ShaderPropertiesGenerator : EditorWindow
{
@brianasu
brianasu / hexTileUnity.shader
Last active August 31, 2022 13:07
Hex tiling
Shader "Custom/hex tiling surface"
{
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
_RotStrength ("Rot Strength", FLOAT) = 0
_FalloffContrast ("Falloff Contrast", FLOAT) = 0.6
Shader "Unlit/EmissonTestShader"
{
Properties
{
[HDR]
_EmissionColor("Emission Color",Color) = (0,0,0,0)
}
SubShader
{
Tags { "RenderType"="Opaque" }
@gatosyocora
gatosyocora / GatoMaterialPropertyDrawer.cs
Last active April 20, 2023 08:41
ShaderLabのCustomMaterialPropertyDrawerのサンプル(区切り線, Texture2Dの1行表示, foldout)
using UnityEngine;
using UnityEditor;
using System;
namespace GatoMaterialPropertyDrawer
{
internal class LineDecorator : MaterialPropertyDrawer
{
private float spaceSize;
@HarukaKajita
HarukaKajita / Noise.cginc
Last active June 5, 2020 16:12
ノイズ関数のまとめ
//関数内で大量に変数を定義するとGPU時間がめちゃ遅くなるのでスコープを使って書き直している部分があるので可読性が少し落ちている。ので注意。
///ret : 0.0 - <1.0
float rand(float n)
{
return frac(sin(n) * 63452.5453123);
}
///ret : 0.0 - <1.0
float rand(float2 co)
{
@deebrol
deebrol / ShowWhenAttribute.cs
Last active August 29, 2024 18:07
Property Drawer for Unity used to show or hide the Field depending on certain conditions
// DONT PUT IN EDITOR FOLDER
using System;
using UnityEngine;
/// <summary>
/// Attribute used to show or hide the Field depending on certain conditions
/// </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ShowWhenAttribute : PropertyAttribute {
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Experimental.AssetImporters;
using System.IO;
using UnityEditor;
using UnityEngine.Assertions;
using System.Linq;
[ScriptedImporter(1, "cube")]
@douduck08
douduck08 / README.md
Last active August 18, 2024 14:03
The general GetValue extension of SerializedProperty in Unity Editor.

Unity's SerializedProperty not support custom type value setting. This extension use Reflection to get target instance of SerializedProperty in Custom Editor, made value setting of general type is posible.