Skip to content

Instantly share code, notes, and snippets.

View Occuros's full-sized avatar

Roger Küng Occuros

View GitHub Profile
@SanderMertens
SanderMertens / bevy_bench.rs
Last active August 15, 2024 16:14
Bevy benchmark
use bevy_ecs::prelude::*;
use bevy_hierarchy::*;
use bevy_ecs::world::CommandQueue;
use std::hint::black_box;
use rand;
use std::time::{Instant};
#[derive(Component)]
@rctlmk
rctlmk / Cargo.toml
Created May 10, 2023 17:00
egui pie charts
[package]
name = "egui-pie-chart"
version = "0.1.0"
edition = "2021"
[dependencies]
egui = "0.21"
egui_extras = "0.21"
eframe = "0.21"
@juancampa
juancampa / egui_centerer.rs
Created March 16, 2023 13:50
Centering arbitrary UIs in egui
// Helper function to center arbitrary widgets. It works by measuring the width of the widgets after rendering, and
// then using that offset on the next frame.
fn centerer(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui)) {
ui.horizontal(|ui| {
let id = ui.id().with("_centerer");
let last_width: Option<f32> = ui.memory_mut(|mem| mem.data.get_temp(id));
if let Some(last_width) = last_width {
ui.add_space((ui.available_width() - last_width) / 2.0);
}
let res = ui
@FreyaHolmer
FreyaHolmer / FlyCamera.cs
Last active January 9, 2025 06:10
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
using UnityEngine;
[RequireComponent( typeof(Camera) )]
public class FlyCamera : MonoBehaviour {
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable
@maxweisel
maxweisel / FloatQueue.cs
Created October 29, 2019 23:44
Oculus Platform Microphone Test
#region Copyright & License
/*************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Roman Atachiants ([email protected])
* 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
@StagPoint
StagPoint / QuaternionCompression.cs
Last active December 2, 2024 07:38
C# - Use "smallest three" compression for transmitting Quaternion rotations in Unity's UNET networking, from 16 bytes to 7 bytes.
// Copyright (c) 2016 StagPoint Software
namespace StagPoint.Networking
{
using System;
using UnityEngine;
using UnityEngine.Networking;
/// <summary>
/// Provides some commonly-used functions for transferring compressed data over the network using