Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / ResetDraggable.cs
Created May 7, 2024 12:21
Reset Draggable object, unless its placed on socket
using System.Collections;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class ResetDraggable : MonoBehaviour
{
XRGrabInteractable grabInteractable;
Vector3 origPos;
Quaternion origRot;
@unitycoder
unitycoder / SetCardPosition.cs
Created May 6, 2024 12:04
align cards on circle edge
// https://discussions.unity.com/t/need-help-with-positioning-while-object-is-rotated/344542/2
private void SetCardPosition(int index)
{
//The angle is based on how far the card is from the midpoint of the hand.
//Note that the midpoint will either be a whole number or x.5
float midpoint = (cards.Count-1) / 2f;
float angle = angleDelta * (midpoint - index);
//Positive angles rotate counterclockwise, negative angles rotate clockwise
cards[index].transform.eulerAngles = new Vector3(0, 0, angle);
@unitycoder
unitycoder / ReelBack.cs
Created April 29, 2024 04:47
Reel Line made from points back
// https://forum.unity.com/threads/coding-a-2d-extendable-and-retractable-fishline.1586673/#post-9801981
private void ReelBack(List<Vector3> points, float reelValue)
{
    if (reelValue <= 0)
        return;
 
    Vector3 origin = points[0];
    float reel = reelValue;
 
    // find cut point
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// This is to take any continuous quantity and change it from one value
// to another over time. This code is for floats. It can be adapted to work for:
//
// Vector2, Vector3, Vector3
@unitycoder
unitycoder / TriangleTexturePlugin.cs
Created April 28, 2024 09:17 — forked from daniel-ilett/TriangleTexturePlugin.cs
A Unity editor script which takes a mesh and generates a texture based on the UVs where each triangle is assigned a random greyscale color (place the script inside a folder named Editor).
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;
// Based on: https://forum.unity.com/threads/save-rendertexture-or-texture2d-as-image-file-utility.1325130/
public class TriangleTexturePluginWindow : EditorWindow
@unitycoder
unitycoder / pip.md
Last active April 24, 2024 12:32
pip install errors python linux

(Unity) vertex color importer for MeshLab's OBJ files

@unitycoder
unitycoder / block_tik_tok.txt
Created April 23, 2024 13:34 — forked from RupGautam/block_tik_tok.txt
TikTok domains to DNSBL Feeds
api30.tiktokv.com
api21.tiktokv.com
webcast21.tiktokv.com
api31.tiktokv.com
api-t1.tiktokv.com
webcast1.tiktokv.com
api32.tiktokv.com
api30-h2.tiktokv.com
api21-h2.tiktokv.com
api-s1-h2.tiktokv.com
@unitycoder
unitycoder / BoxColliderFitChildren.cs
Created April 23, 2024 08:38
fit box collider to children
// https://github.com/UnityCommunity/UnityLibrary/blob/master/Assets/Scripts/Editor/ContextMenu/BoxColliderFitChildren.cs
// Adjust Box Collider to fit child meshes inside
// Usage: You have empty parent transform, with child meshes inside, add box collider to parent then use this
// NOTE: Doesnt work if root transform is rotated
using UnityEngine;
using UnityEditor;
namespace UnityLibrary