Skip to content

Instantly share code, notes, and snippets.

View beardordie's full-sized avatar

Beard or Die beardordie

View GitHub Profile
@MarcelvanDuijnDev
MarcelvanDuijnDev / Movement_Camera.cs
Last active August 29, 2022 07:15
Unity Camera Movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement_Camera : MonoBehaviour
{
private enum CameraOptionsPos { None, Follow }
private enum CameraOptionsRot { None, Follow }
[Header("Options")]
@MarcelvanDuijnDev
MarcelvanDuijnDev / Movement_CC_TopDown.cs
Created January 8, 2022 14:29
Unity Simple Top Down Movement for Character Controller
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class Movement_CC_TopDown : MonoBehaviour
{
//Movement
[Header("Settings Camera")]
[SerializeField] private Camera _Camera;
using System;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
public class RaycastCommandRaycaster: IDisposable
{
NativeArray<RaycastCommand> commands;
NativeArray<RaycastHit> results;
@SiarheiPilat
SiarheiPilat / NewObjectBottomOfHierarchy.cs
Created October 30, 2020 18:25
Move a prefab instance to the bottom of the hierarchy whenever you drag and drop it to the scene.
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public static class NewObjectBottomOfHierarchy
{
static NewObjectBottomOfHierarchy()
{
@SiarheiPilat
SiarheiPilat / ObjectShaker.cs
Created October 20, 2020 19:06
Object shaker utilising a coroutine. Suitable for shaking all kinds of objects, but also VERY suitable for camera shake effect.
using System.Collections;
using UnityEngine;
// Taken from: https://stackoverflow.com/questions/39380901/shake-an-object-back-and-forth-with-easing-at-the-end
public class ObjectShaker : MonoBehaviour
{
public GameObject GameObjectToShake;
bool shaking = false;
@SiarheiPilat
SiarheiPilat / RandomiseInsideCollider.cs
Created October 20, 2020 15:44
Spawn objects (or randomise their position) inside an area defined by a 2D collider.
using UnityEngine;
public class RandomiseInsideCollider : MonoBehaviour
{
public Collider2D AreaPolygonCollider;
Bounds Bounds;
Vector3 BoundX1, BoundX2, BoundY1, BoundY2;
Vector3 randomPos;
public Transform go;
using UnityEngine;
/// <summary>
/// Drawing a Maurer Rose With Unity - http://diegogiacomelli.com.br/drawing-a-maurer-rose-with-unity
/// </summary>
[RequireComponent(typeof(LineRenderer))]
public class MaurerRoseLineRenderer : MonoBehaviour
{
const int PointsCount = 361;
@Awkwardnaut
Awkwardnaut / gist:8a8dafd6e8b01ee222c765deed6c1f14
Created June 20, 2020 13:33
C# Unity set the center of mass of your rigidbodies
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class CenterOfMass : MonoBehaviour
{
public Vector3 _localCenterOfMass;
private void Awake()
{
SetCenterOfMass();
@SiarheiPilat
SiarheiPilat / AutofillAttribute.cs
Last active December 27, 2021 06:50
Custom attribute that adds a button in front of a variable in the Inspector, pressing which performs an attempt to fill in the object reference with corresponding object that is sitting on the inspected game object.
using UnityEngine;
using UnityEditor;
// REMEMBER that for custom attributes with property drawers, the attribute script should be in normal folder, while the drawer script - in the editor folder
public class AutofillAttribute : PropertyAttribute { }
[CustomPropertyDrawer(typeof(AutofillAttribute))]
public class AutofillAttributeDrawer : PropertyDrawer
{
@Froghut
Froghut / OdinWatchWindow.cs
Last active August 4, 2024 10:25
Odin Watch Window
#if ODIN_INSPECTOR
using System;
using System.Collections.Generic;
using System.Linq;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;