Skip to content

Instantly share code, notes, and snippets.

@Chaosed0
Chaosed0 / DelegateEventUnit.cs
Created September 8, 2020 19:03
Bolt unit for running a flow when a delegate is called. Only supports no-argument delegates.
using UnityEngine;
using System.Collections.Generic;
using Bolt;
using Ludiq;
[UnitTitle("Delegate Event")]
[SpecialUnit]
public class DelegateEventUnit : Unit, IEventUnit, IGraphEventListener, IGraphElementWithData
{
public class Data : IGraphElementData
@Chaosed0
Chaosed0 / ModifyColor.cs
Last active April 17, 2019 06:17
Component to pass color to shader through property
using UnityEngine;
using System.Collections.Generic;
[ExecuteInEditMode]
public class ModifyColor : MonoBehaviour
{
private static MaterialPropertyBlock materialPropertyBlock = null;
[SerializeField]
private string propertyName = "_Color";
@Chaosed0
Chaosed0 / Rimlight.shader
Created April 17, 2019 01:54
Simple rim light shader
Shader "Custom/Rimlight" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_RimValue ("Rim value", Range(0, 1)) = 0.5
}
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
CGPROGRAM
#pragma surface surf Lambert alpha
Shader "Projector/Solid Projector" {
Properties{
_Color("Tint Color", Color) = (1,1,1,1)
_ShadowTex("Cookie", 2D) = "gray" {}
}
Subshader
{
Tags {"Queue" = "Transparent" "RenderType" = "Transparent"}
Pass
{
@Chaosed0
Chaosed0 / LowFovCameraUtilityEditor.cs
Created April 8, 2019 01:05
A Unity Editor utility for cameras with extremely low FOV.
using UnityEngine;
using UnityEditor;
using Cinemachine;
using System.Collections.Generic;
// To make this work, create an empty MonoBehaviour called "LowFovCameraUtility".
// Then, attach that script to your Cinemachine virtual cameras.
// If you don't want to use Cinemachine virtual cameras this script should work too,
// you'll just need to modify the components and variable names.
[CustomEditor(typeof(LowFovCameraUtility))]
#include "Callbacks.h"
void CallbackMap::setCallback(const std::string& callbackName, Callback callback)
{
map[callbackName] = callback;
}
CallbackMap::Error CallbackMap::call(const std::string& callbackName, const std::string& args)
{
auto iter = map.find(callbackName);
@Chaosed0
Chaosed0 / UE4WallSconce.cpp
Last active May 16, 2020 04:11
Example AActor-derived class for Unreal Engine 4
/* An example UE4 class derived from AActor. It plays a
* sound when an actor enters the bounding box, and lets
* the player turn a PointLight on and off using the "Use"
* key. It originally existed as a blueprint. */
/* WallSconceCpp.h */
#pragma once
#include "GameFramework/Actor.h"