Skip to content

Instantly share code, notes, and snippets.

View Arlorean's full-sized avatar

Adam Davidson Arlorean

View GitHub Profile
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Created October 24, 2014 07:14
Extension methods for working with Configurable Joints for Unity
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
anonymous
anonymous / KenneySpriteSheetBuilder.cs
Created July 27, 2015 19:04
KenneySpriteSheetBuilder.cs
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
using UnityEditor;
using UnityEngine;
class KenneySpriteSheetBuilder : AssetPostprocessor
{
@nathancorvussolis
nathancorvussolis / wix-bootstrap-download-vcredist-sample.wxs
Last active February 24, 2025 16:45
Visual C++ 2015-2022 Redistributable - 14.36.32532
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle
Name="Example Product"
Version="1.2.3.4"
Manufacturer="John Doe"
Copyright="© 2023 John Doe"
@valryon
valryon / Extruder.cs
Created November 18, 2016 13:25
Extrude a 2D sprite to a mesh from a Polygon Collider in Unity3D
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
///
/// </summary>
/// <remarks>Source: https://forum.unity3d.com/threads/trying-extrude-a-2d-polygon-to-create-a-mesh.102629/ </remarks>
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer), typeof(PolygonCollider2D))]
public class ExtrudeSprite : MonoBehaviour
@FlaShG
FlaShG / CanvasPositioningExtensions.cs
Last active July 12, 2024 20:51
A small Unity helper class to convert viewport, screen or world positions to canvas space.
using UnityEngine;
/// <summary>
/// Small helper class to convert viewport, screen or world positions to canvas space.
/// Only works with screen space canvases.
/// </summary>
/// <example>
/// <code>
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position);
/// </code>
@pbhogan
pbhogan / AspectRatioPanel.cs
Last active November 15, 2024 20:02
Unity UI-Toolkit Aspect Ratio Preserving Panel
/*
This is free and unencumbered software released into the public
domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
@tattyd
tattyd / Shadow.cs
Last active April 1, 2025 08:26
Soft shadow control for Unity UI Toolkit
/* MIT License
Copyright (c) 2022 David Tattersall
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kraj0t
kraj0t / UsingCsCodeInHLSL.cs
Last active January 5, 2025 14:34
How to include C# code in an HLSL file - useful for sharing code between CPU and shader without duplicating any files
// Share code between HLSL (shaders) and C#
//
// Limitations:
// - Cannot use #include
// - Must use defines to hide certain keywords, such as public, private, protected, or any other object-oriented programming keywords
// - Use defines to convert half or fixed to your desired C# equivalent
// - Must always write f after float literals
// - Use #if !MY_DEFINE instead of #ifndef MY_DEFINE
// - #define cannot be used with a value in C#, not even inside an '#if SHADER_TARGET' block. Therefore, you have two options for declaring valued constants:
// a. Declare each constant separately in HLSL (using 'static const float MyConstant = 1.0f') and in C# (using 'const float MyConstant = 1.0f'). C# does not support 'static const'.