Skip to content

Instantly share code, notes, and snippets.

@calderarchinuk
calderarchinuk / UnityAssistant.cs
Last active December 8, 2023 09:50
Unity Editor Assistant. Adds a context-sensitive right-click menu, automatically disables auto-generate lightmaps
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using UnityEditor.SceneManagement;
[InitializeOnLoad]
public class UnityAssistant
{
@calderarchinuk
calderarchinuk / PackageCreatorWindow.cs
Last active August 21, 2023 00:56
A simple Unity editor window that will create the folders and files for a upm package
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
//this script creates the folder structure and critical files to define a unity UPM package
//it also includes basic script templates for testing and editor tools
//just throw this into Assets/Editor folder and select Tools/Package Creator Window
//for a more fully featured package creation script, try https://github.com/jeffcampbellmakesgames/unity-package-tools
@calderarchinuk
calderarchinuk / WorldSpaceUV.shader
Created February 6, 2018 03:42
world space uv shader
Shader "Custom/World Space UV" {
Properties {
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
//_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_Scale ("Texture Scale", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" }
@calderarchinuk
calderarchinuk / blender-to-unity-fbx-exporter-multi.py
Last active November 29, 2020 23:31
fork of https://github.com/EdyJ/blender-to-unity-fbx-exporter. added option to export each object to a separate file
bl_info = {
"name": "Unity FBX format",
"author": "Angel ""Edy"" Garcia (@VehiclePhysics)",
"version": (1, 2, 3),
"blender": (2, 80, 0),
"location": "File > Export > Unity FBX",
"description": "FBX exporter compatible with Unity's coordinate and scaling system.",
"warning": "",
"wiki_url": "",
"category": "Import-Export",
@calderarchinuk
calderarchinuk / AssetBrowser.cs
Last active November 4, 2020 05:30
window to import common local files into project
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
//TODO asset tags
//TODO asset dependencies (auto import)
//TEST manifest.json gets generated correctly
@calderarchinuk
calderarchinuk / AddScenesToBuild.cs
Created January 3, 2018 04:50
add all scene files in project to build settings
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public partial class BonusMenuItems
{
[MenuItem("Tools/Add All Scenes to Build")]
static void AddAllScenesToBuild()
@calderarchinuk
calderarchinuk / ArcRender.cs
Created February 8, 2018 03:06
calculate and render an arc affected by gravity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArcRender : MonoBehaviour
{
public int Count = 10;
public float PowerMultiplier = 2;
public Transform handle;
@calderarchinuk
calderarchinuk / UnrealCameraMovement.cs
Created January 16, 2020 02:09
unreal camera controls in unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
//TODO clamp pitch rotation
//TODO y axis rotation is offset forward slightly, not at scene camera position
//TODO sometimes doesn't register mouse up/down events. should poll every frame? for mouse button state
public class UnrealCameraMovement : EditorWindow
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
//sorts children in selected transform in alphabetical order
public class SortChildrenMenuItem
{
@calderarchinuk
calderarchinuk / ShakeInputEvent.cs
Last active November 13, 2019 05:51
invokes event when a mobile device is shaken
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//https://stackoverflow.com/questions/31389598/how-can-i-detect-a-shake-motion-on-a-mobile-device-using-unity3d-c-sharp
public class ShakeInputEvent : MonoBehaviour
{
public delegate void onShakeInput();
/// when the phone is shaken