Skip to content

Instantly share code, notes, and snippets.

View smkplus's full-sized avatar
😍
Curios

Seyed Morteza Kamali smkplus

😍
Curios
View GitHub Profile
using UnityEngine;
public class Human : Observer
{
public string Name;
public override void OnNotify()
{
SayHello();
}
using System;
using UnityEngine;
public class Subject : MonoBehaviour
{
//delegate that stores the list of methods
public static Action onNotify;
private void Start()
{
namespace System
{
public delegate void Action();
}
using System;
using UnityEngine;
public class Human : MonoBehaviour
{
public string Name;
private void Awake()
{
Subject.OnNotify += SayHello;
using UnityEngine;
public class Subject : MonoBehaviour
{
//delegate that stores the list of methods
public delegate void Observer();
public static Observer OnNotify;
private void Start()
{
using UnityEngine;
public abstract class Observer : MonoBehaviour
{
public abstract void OnNotify();
}
@smkplus
smkplus / Subject.cs
Last active April 5, 2020 18:12
Observer
using System.Collections.Generic;
using UnityEngine;
//Invokes the notificaton method
public class Subject : MonoBehaviour
{
//A list with observers that are waiting for something to happen
public List<Observer> observers = new List<Observer>();
private void Start()
@smkplus
smkplus / Texture2DArraySurface.Shader
Created February 11, 2020 14:52 — forked from unitycoder/Texture2DArraySurface.Shader
GPU Instancing + Texture2DArray
Shader "Custom/Texture2DArraySurfaceShader"
{
Properties
{
_Textures("Textures", 2DArray) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
@smkplus
smkplus / texarray.md
Created February 10, 2020 19:18 — forked from aras-p/texarray.md
Possible texture array syntax

Unity shader side:

UNITY_DECLARE_TEX2DARRAY(name)
UNITY_SAMPLE_TEX2DARRAY(name,coord) // coord is float3

On DX11-like systems (DX11, and I'd assume XB1/PS4) the macros expand to:

#define UNITY_DECLARE_TEX2DARRAY(name) Texture2DArray(name); SamplerState sampler##name
#define UNITY_SAMPLE_TEX2DARRAY(name,coord) name.Sample(coord)
// Used to generate Texture Array asset
// Menu button is available in GameObject > Create Texture Array
// See CHANGEME in the file
using UnityEngine;
using UnityEditor;
public class TextureArray : MonoBehaviour {
[MenuItem("GameObject/Create Texture Array")]
static void Create()