Skip to content

Instantly share code, notes, and snippets.

@Wolfos
Wolfos / Meshcombiner.cs
Created June 15, 2024 13:26
Static mesh combiner for Unity. Very basic. Ignores meshes that have multiple materials.
using System.Collections.Generic;
using System.Linq;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Rendering;
public class MeshCombiner : MonoBehaviour
{
[SerializeField, HideInInspector] private MeshRenderer[] meshRenderers;
[SerializeField, HideInInspector] private List<GameObject> combinedObjects;
using FlaxEngine;
namespace Game
{
/// <summary>
/// PlayerMovement Script.
/// </summary>
public class PlayerMovement : Script
{
[Serialize, ShowInEditor] private float _maxWalkSpeed;
function doo
{
param([int]$amount=8)
for($j=0; $j -lt $amount; $j++) {
Write-Host "doo " -NoNewLine
}
Write-Output ""
}
function printVerse
{
using System.Collections.Generic;
public static class ServiceRegistry
{
// This is a Dictionary (a type of list) of all objects currently registered, by their type
private static Dictionary<System.Type, object> _services = new();
// Usage: ServiceRegistry.Register(this)
// Please only register one instance of each type
using UnityEngine;
public static class Collider2DExtension
{
/// <summary>
/// Return the closest point on a Collider2D relative to point
/// </summary>
public static Vector2 ClosestPoint(this Collider2D col, Vector2 point)
{
GameObject go = new GameObject("tempCollider");
syntax: glob
.DS_Store
*.sln
*.userprefs
*.csproj
*.pidb
*.unitypackage
obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
obj/
Shader "Unlit/NewUnlitShader"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1, 1, 1, 1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
_AlphaCutoff("Alpha Cutoff", Range(0.01, 1.0)) = 0.1
}
// Put this file in Assets/Editor/
using UnityEngine;
using UnityEditor;
public class KeywordReplace : UnityEditor.AssetModificationProcessor
{
public static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
int index = path.LastIndexOf(".");
// Put this file in C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates and remove this comment line
// Requires https://gist.github.com/Wolfos/3eb651879e92cf86c2881243f7f74632 (Remove this comment line too ;)
/*
#SCRIPTNAME#.cs
Created #CREATIONDATE#
Project #PROJECTNAME# by #DEVELOPERS#
*/
using UnityEngine;
namespace #NAMESPACE#
using UnityEngine;
public class RigidbodyExtrapolator : MonoBehaviour
{
public new Rigidbody rigidbody;
void FixedUpdate()
{
transform.Translate(-rigidbody.velocity * Time.fixedDeltaTime, Space.World); // Cancel out the force applied by the rigidbody
}