Skip to content

Instantly share code, notes, and snippets.

View brunomikoski's full-sized avatar
🛹

Bruno Mikoski brunomikoski

🛹
View GitHub Profile
@yasirkula
yasirkula / SnapRectTransformAnchorsToCorners.cs
Created May 28, 2024 18:20
Snap a RectTransform's anchors to its corner points in Unity
using UnityEditor;
using UnityEngine;
public class SnapRectTransformAnchorsToCorners : MonoBehaviour
{
[MenuItem("CONTEXT/RectTransform/Snap Anchors To Corners", priority = 50)]
private static void Execute(MenuCommand command)
{
RectTransform rectTransform = command.context as RectTransform;
RectTransform parent = rectTransform.parent as RectTransform;
@FreyaHolmer
FreyaHolmer / AssetCopyUtils.cs
Last active June 12, 2024 07:25
Adds context menu items to assets: Copy/Paste import settings & Copy GUID. Put this script in any Editor/ folder in your project and recompile!
// written by https://github.com/FreyaHolmer so use at your own risk c:
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
/// <summary>Utility functions to copy GUIDs, as well as Copy/Paste import settings</summary>
public static class AssetCopyUtils {
const int CTX_MENU_LOCATION = 70;
@antonkudin
antonkudin / pipeGenerator.cs
Created September 26, 2023 13:48
Generates pipe mesh from mesh segments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipeGenerator : MonoBehaviour
{
[SerializeField] Mesh straightMesh;
[SerializeField] Mesh elbowMesh;
[Space]
[SerializeField] Vector3[] pathPoints;
@ScottJDaley
ScottJDaley / Outline.shader
Last active July 24, 2024 06:04
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@karljj1
karljj1 / ChangePlayerLoop.cs
Created February 1, 2021 15:33
Change the particle system update so that LateUpdate is taken into account
using System.Linq;
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
using static UnityEngine.PlayerLoop.PreLateUpdate;
public class ChangePlayerLoop : MonoBehaviour
{
public bool defaultLoop = true;
@karljj1
karljj1 / gist:fb2d61a9ea72c6cd9eff705220810d94
Created January 15, 2021 18:39
An example of how a UI Toolkit TextField Suggestion field could be created
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class TextEditorWindow : EditorWindow
{
VisualElement m_Suggestion;
TextField m_TextField;
[MenuItem("Test/Window")]
@karljj1
karljj1 / Display.RelativeMouseAt.cs
Created September 16, 2020 10:32
Emulate multiple display input using GameViews
Vector3 RelativeMouseAt()
{
var mouseOverWindow = EditorWindow.mouseOverWindow;
System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
Type type = assembly.GetType("UnityEditor.GameView");
int displayID = 0;
if (type.IsInstanceOfType(mouseOverWindow))
{
var displayField = type.GetField("m_TargetDisplay", BindingFlags.NonPublic | BindingFlags.Instance);
using UnityEngine;
namespace Giacomelli.Framework
{
public class FrameworkSettings : ScriptableObject
{
[SerializeField]
bool _entityLogEnabled;
[SerializeField]
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active November 17, 2024 11:21
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
using System;
using UnityEditor;
public class CopyPasteValues
{
const string kBufferName = "json-copy-buffer";
const string kTypeName = "json-copy-type";
[MenuItem("CONTEXT/Component/Copy Values With Json")]
static void Copy(MenuCommand command)