Skip to content

Instantly share code, notes, and snippets.

@atteneder
atteneder / StreamExtension.cs
Created October 1, 2021 13:52
Write a NativeArray to a stream without a temporary, managed array
// Copyright 2021 Andreas Atteneder
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@atteneder
atteneder / axis_conversion.py
Created November 17, 2020 02:35
Coordinate Space Axis Conversion Matrix from Blender
# Run this in Blender's Python Console (in Scripting Workspace)
import bpy_extras
# change parameters accordingly
conv_matrix = bpy_extras.io_utils.axis_conversion(from_forward='Y', from_up='Z', to_forward='-Z', to_up='Y')
## conv_matrix:
# Matrix(((1.0, 0.0, 0.0),
# (0.0, 0.0, 1.0),
@atteneder
atteneder / Matrix4x4Extension.cs
Last active November 1, 2022 09:05
Matrix Decomposition (more robust than Matrix4x4.rotation/Matrix4x4.lossyScale)
// Copyright 2020-2022 Andreas Atteneder
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@atteneder
atteneder / print_unity_version.sh
Created May 28, 2020 08:55
Extract a Unity project's version (found in Player settings) from command line (macOS/Linux)
#!/bin/sh
# The current working directory has to be the root of the project
cd /path/to/UnityProject
# Extract into variable via sed
PROJECT_VERSION=$(sed -nE 's/bundleVersion: (.+)/\1/p' ProjectSettings/ProjectSettings.asset)
# Put it to use
echo $PROJECT_VERSION
@atteneder
atteneder / AmbientLightingHelper.cs
Created January 15, 2018 11:38
Unity Editor Tool that prints the spherical harmonics values of the current scene to the console. Useful to retrieve the values for use in other engines.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Text;
using UnityEngine.Rendering;
public class AmbientLightingHelper : MonoBehaviour {
[MenuItem("Tools/Print Ambient Probe Values")]
public static void GetLighting() {