Skip to content

Instantly share code, notes, and snippets.

View LaserKaspar's full-sized avatar

Felix Kaspar LaserKaspar

View GitHub Profile
@LaserKaspar
LaserKaspar / PlayerController.cs
Last active April 29, 2023 12:15
(UnityEngine) Simple Physics-Based Character Controller
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private Transform camera;
[SerializeField] private float velocity;
@LaserKaspar
LaserKaspar / QuitGame.cs
Created November 30, 2021 10:05
(UnityEngine) Quit a running game.
public void QuitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
@LaserKaspar
LaserKaspar / MouseOrbit.cs
Created November 4, 2021 20:43
(UnityEngine) Short and simple camera orbit script with zoom.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseOrbit : MonoBehaviour
{
public float sensivity;
// Update is called once per frame
void Update()
@LaserKaspar
LaserKaspar / MaterialHelper.cs
Created November 4, 2021 20:41
(UnityEngine) Quickly create materials. Can be extended to work with other types of materials. (currently: Universal Render Pipeline/Lit)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class MaterialHelper : EditorWindow
{
public string path = "Materials/";
public string materialName;
@LaserKaspar
LaserKaspar / SceneSwitcher.cs
Created November 4, 2021 20:38
(UnityEngine) Window for quickly switching between scenes added to your build settings.
using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
public class SceneSwitcher : EditorWindow
{
[MenuItem("Tools/SceneSwitcher")]
@LaserKaspar
LaserKaspar / ReplaceWithPrefab.cs
Created November 4, 2021 20:37
(UnityEngine) Replaces object with specified prefab (Keeps transform). Useful for prototyping.
using UnityEngine;
using UnityEditor;
public class ReplaceWithPrefab : EditorWindow
{
[SerializeField] private int lenght;
public int Lenght
{
get => lenght;
set
@LaserKaspar
LaserKaspar / GroupUnityObjects.cs
Created November 4, 2021 20:35
(UnityEngine) Adds Ctrl+G to group selected objects in inspector. Creates empty objects and set the parent of the objects to a new empty.
using UnityEngine;
using UnityEditor;
[ExecuteInEditMode]
public class GroupUnityObjects : Editor
{
[MenuItem("Edit/Group %g", false)]
public static void Group()
{
if (Selection.transforms.Length > 0)
@LaserKaspar
LaserKaspar / BuildSceneProcessor.cs
Created November 4, 2021 20:32
(UnityEngine) Automatically adds a newly created unity scene to your build settings.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
// docs: https://docs.unity3d.com/ScriptReference/AssetModificationProcessor.OnWillSaveAssets.html
public class BuildSceneProcessor : UnityEditor.AssetModificationProcessor
{
private const string DIALOG_TITLE = "Add to Build Settings?";
private const string DIALOG_MSG = "Add to build settings for inclusion in future builds?";
/*
ChangeVoicemeeterProfile.ahk - AHKscript Changing Presets for VoicemeeterBanana
======================================================================
Based On:
---------
PTT_for_Voicemeeter.ahk
https://gist.github.com/pprince/f42c8c9d06e54f8adbb6
*/
/*