Skip to content

Instantly share code, notes, and snippets.

View DashW's full-sized avatar

Richard Copperwaite DashW

View GitHub Profile
@DashW
DashW / EditorValidatorBase.h
Created November 4, 2020 12:50
Class definition for Unreal's Base Editor Validator. All code belongs to Epic Games and is available from their GitHub.
/*
* The EditorValidatorBase is a class which verifies that an asset meets a specific ruleset.
* It should be used when checking engine-level classes, as UObject::IsDataValid requires
* overriding the base class. You can create project-specific version of the validator base,
* with custom logging and enabled logic.
*
* C++ and Blueprint validators will be gathered on editor start, while python validators need
* to register themselves
*/
UCLASS(Abstract, Blueprintable, meta = (ShowWorldContextPin))
@DashW
DashW / EditorValidatorConcrete.py
Last active November 4, 2020 12:44
Unreal Editor Validator Concrete Implementation in Python
import unreal
@unreal.uclass()
class EditorValidatorConcrete(ue.EditorValidatorBase):
def __init__(self, *arg, **kwds):
super(EditorValidatorConcrete, self).__init__(*arg, **kwds)
@unreal.ufunction(override=True)
def validate_loaded_asset(self, asset, validation_errors):
self.asset_fails(asset, "asset failed", validation_errors)
@DashW
DashW / EditorValidatorBase.py
Created November 4, 2020 12:31
Unreal EditorValidatorBase Python API extracted from unreal.py
class EditorValidatorBase(Object):
r"""
* The EditorValidatorBase is a class which verifies that an asset meets a specific ruleset.
* It should be used when checking engine-level classes, as UObject::IsDataValid requires
* overriding the base class. You can create project-specific version of the validator base,
* with custom logging and enabled logic.
*
* C++ and Blueprint validators will be gathered on editor start, while python validators need
* to register themselves
@DashW
DashW / RecenterResetter.cs
Last active July 21, 2023 15:44
Unity Behaviour to counteract 're-centering' on the Oculus Quest and keep the camera centered relative to the Guardian Boundaries
using UnityEngine;
// This behaviour disables 're-centering' on the Oculus Quest,
// instead forcing the camera origin to remain centered and
// facing the same direction within the Guardian boundaries,
// even between app restarts.
public class RecenterResetter : MonoBehaviour
{
public OVRCameraRig CameraRig = null;
@DashW
DashW / PlayableVideoAsset.cs
Created October 24, 2018 15:46
Scrubbable Video Player Track for Unity Timeline
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Video;
public class PlayableVideoAsset : PlayableAsset
{
public ExposedReference<VideoClip> Clip = new ExposedReference<VideoClip>();
public float Offset;
private double _duration;
@DashW
DashW / TriplanarNormal.shader
Created October 19, 2016 14:31
Unity Normal-Mapped Triplanar Texturing Shader
Shader "Tri-Planar World Normal" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_Side("Side", 2D) = "gray" {}
_Top("Top", 2D) = "gray" {}
_Bottom("Bottom", 2D) = "gray" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
_BottomScale("Bottom Scale", Float) = 2
_BumpMapSide("Side Normal Map", 2D) = "bump" {}
@DashW
DashW / ScreenRecorder.cs
Last active October 30, 2024 20:05
ScreenRecorder - High Performance Unity Video Capture Script
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
class BitmapEncoder
{
public static void WriteBitmap(Stream stream, int width, int height, byte[] imageData)