Skip to content

Instantly share code, notes, and snippets.

View phosphoer's full-sized avatar

David Evans phosphoer

View GitHub Profile
@phosphoer
phosphoer / CameraControllerPhoto.cs
Created April 13, 2024 03:13
Camera Mouse Movement
using UnityEngine;
public class CameraControllerPhoto : CameraControllerBase
{
public float Sensitivity = 1.5f;
public float MaxPitch = 45.0f;
public float MoveSpeed = 10;
public float MaxDistance = 30.0f;
public float MinDistToGeometry = 2.0f;
public float MinDistToTerrain = 5.0f;
@phosphoer
phosphoer / SimpleGeo.cs
Last active March 28, 2024 22:24
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// 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:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
@phosphoer
phosphoer / BlendTreeEditorExtensions.cs
Created October 25, 2019 18:25
Useful utilities for working with blend trees in Unity, drop this in an Editor/ folder.
using UnityEditor;
using UnityEditor.Animations;
public class BlendTreeEditorExtensions
{
private static BlendTree copiedBlendTree;
[MenuItem("Assets/Copy Blend Tree")]
private static void CopyBlendTree()
{
@phosphoer
phosphoer / EpicGameClient.cs
Last active January 12, 2024 21:21
Epic Game SDK Unity Integration
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if BUILD_EPIC
using PlayEveryWare.EpicOnlineServices;
using Epic.OnlineServices;
using Epic.OnlineServices.Achievements;
using Epic.OnlineServices.Auth;
using Epic.OnlineServices.Presence;
@phosphoer
phosphoer / EditorSelectionHistory.cs
Created December 6, 2023 22:20
A custom window for Unity that displays a drag and droppable object selection history
// The MIT License (MIT)
// Copyright (c) 2023 David Evans @festivevector
// 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:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@phosphoer
phosphoer / Mathfx.cs
Last active December 3, 2023 04:21
My own version of the Unity Wiki Mathfx
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// 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:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@phosphoer
phosphoer / AssetScratchpad.cs
Last active November 27, 2023 20:47
A drag and droppable 'scratchpad' for unity objects, useful as a palette or a quick select window.
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
public class AssetScratchpad : EditorWindow
{
private List<Object> _referenceList = new();
private Vector2 _scrollPosition;
[MenuItem("Window/Asset Scratchpad")]
@phosphoer
phosphoer / ControllerIconMapDefinition.cs
Last active June 8, 2023 09:33
Rewired Glyph Mappings
using UnityEngine;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "new-controller-icon-mapping", menuName = "Controller Icon Mapping")]
public class ControllerIconMapDefinition : ScriptableObject
{
[SerializeField]
private InputIconMapDefinition gamepadMap = null;
[SerializeField]
@phosphoer
phosphoer / GravityItem.cs
Last active May 27, 2023 19:54
Mario Galaxy Gravity for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// 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:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
@phosphoer
phosphoer / Tween.cs
Last active February 15, 2023 15:49
Simple set of coroutine helpers and tweening functions
using UnityEngine;
using System.Collections;
public static class Tween
{
public static IEnumerator Tween(float duration, System.Action<float> tweenFunc)
{
for (float timer = 0; timer < duration; timer += Time.deltaTime)
{
tweenFunc?.Invoke(timer / duration);