Skip to content

Instantly share code, notes, and snippets.

@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 April 22, 2024 15:29
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 November 14, 2024 09:11
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: