Skip to content

Instantly share code, notes, and snippets.

View jbertra's full-sized avatar

Jeff Bertrand jbertra

  • Clemson University Center for Workforce Development
  • Clemson, SC
View GitHub Profile
@unitycoder
unitycoder / LineDrawer.cs
Created November 5, 2021 20:09
Drawing a line with Unity UI Toolkit
// Drawing a line with UITK https://forum.unity.com/threads/drawing-a-line-with-uitk.1193470/
public class LineDrawer : VisualElement
{
private Vector3 startPos, endPos;
private float thickness;
public LineDrawer(Vector3 pos1, Vector3 pos2, float width)
{
startPos = pos1;
endPos = pos2;
@pbhogan
pbhogan / AspectRatioPanel.cs
Last active November 15, 2024 20:02
Unity UI-Toolkit Aspect Ratio Preserving Panel
/*
This is free and unencumbered software released into the public
domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
@botamochi6277
botamochi6277 / PIDController.cs
Last active May 20, 2024 04:52
Unity PID controller for position and rotation
using System.Collections;
using System.Collections.Generic;
// using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Serialization;
namespace BotaLab
{
/**
* @brief A Unity Component to control position and rotation with PID controller
@Tymski
Tymski / ScreenCaptureEditor.cs
Last active September 24, 2021 13:36
Unity make a screenshot from editor
using System.IO;
using UnityEditor;
using UnityEngine;
public class ScreenCaptureEditor : EditorWindow
{
private static string directory = "Screenshots/Capture/";
private static string latestScreenshotPath = "";
private bool initDone = false;
@Srfigie
Srfigie / .gitattributes
Created February 2, 2020 14:30 — forked from nemotoo/.gitattributes
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
@karljj1
karljj1 / SelectorScr.cs
Last active December 2, 2022 20:33
Multiple Display Ray casting example
using UnityEngine;
using UnityEngine.UI;
public class SelectorScr : MonoBehaviour
{
public Camera myCam;
private RaycastHit hit;
private Ray ray;
public Text selectedGOName;
@SimonDarksideJ
SimonDarksideJ / MakeA3DObjectDraggable.cs
Created May 9, 2018 19:31 — forked from rstecca/MakeA3DObjectDraggable.cs
How to make a 3D object draggable in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
MAKE A 3D OBJECT DRAGGABLE
Riccardo Stecca
http://www.riccardostecca.net
@paulhayes
paulhayes / Sun.cs
Last active May 10, 2025 09:18
Rotates a Unity directional light based on location and time. Includes time scale, and frame stepping for continuous use.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Entropedia
{
[RequireComponent(typeof(Light))]
[ExecuteInEditMode]