Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / Examples.cs
Created August 31, 2021 08:20
get unity window handle
// https://forum.unity.com/threads/how-to-get-unity3d-game-exe-window-handle.377663/#post-6798698
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
[DllImport("user32.dll", EntryPoint = "SetWindowText")]
public static extern bool SetWindowText(System.IntPtr hwnd, System.String lpString);
@unitycoder
unitycoder / PlanarReflections.cs
Created August 27, 2021 16:27
Unity Boat Race URP Underwater Surface Flip & Reflections
// find line
Vector3 normal = Vector3.up;
// replace with
Vector3 normal = realCamera.transform.position.y < 0 ? -Vector3.up : Vector3.up;
@unitycoder
unitycoder / FixFullScreenResolution.cs
Created August 25, 2021 08:48
unity fix full screen resolution aspect ratio (alt+enter)
// fix window resolution/aspect ratio for fullscreen, and revert back to previous window resolution after exit fullscreen
// because if user has resizable window, then going full screen with alt+tab keeps that window aspect ratio (causes letterboxing, black borders)
// this script takes highest available monitor resolution for full screen mode
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityLibrary
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
/// <summary>
/// A simple free camera to be added to a Unity game object.
///
/// Keys:
@unitycoder
unitycoder / Whats wrong with Discord.md
Last active March 3, 2024 19:22
Whats wrong with Discord (Features, UX, UI)

UX

  • Scrollbar is ~1px width and almost fully transparent! Bit hard to use.
  • You cannot see channel names (have to know what icon is for each server)
  • You cannot search with channel name (hard to find specific channel, especially if you have grouped channels to folders)
  • You cannot see which channel has the message!(red notification on notification bar, have to manually mark channels unread one by one, until the red dot disappears)
  • Cannot double click user to open chat (instead, have to type that into that small box)
  • Searching messages has buttons "new" and "old" what does that mean? and why it searches again for same results? maybe it means sort by age? dunno.
  • Quite difficult to find hangup call/close meeting button always, same for screen sharing on/off
  • If you enter channel from weblink to discord desktop, you cannot see which server you are int (from left side server list!) or maybe it happens if you cannot join any more servers, there is no error message..
  • Cannot copy your username in set
@unitycoder
unitycoder / ImageTrackingLibrarySwitch.cs
Created August 19, 2021 05:57
unity AR how to change the library image at runtime
// https://forum.unity.com/threads/ar-foundation-using-reference-image-library-during-runtime.1015801/#post-6586150
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
 
 
public class ImageTrackingLibrarySwitch : MonoBehaviour {
    [SerializeField] XRReferenceImageLibrary firstLibrary = null;
    [SerializeField] XRReferenceImageLibrary secondLibrary = null;
    [SerializeField] ARTrackedImageManager manager = null;
@unitycoder
unitycoder / MouseInputManager.cs
Created August 13, 2021 07:59
Raw Input Multiple Mouse Unity
// https://pastebin.com/4h3CqpYy
// Unity PINVOKE interface for pastebin.com/0Szi8ga6
// Handles multiple cursors
// License: CC0
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System;
@unitycoder
unitycoder / Unity Games Modding Mods.md
Created August 9, 2021 10:47
Unity Games Modding Mods
@unitycoder
unitycoder / BuildDisplayer.cs
Created August 4, 2021 10:35 — forked from llamacademy/BuildDisplayer.cs
Build Incrementor Scripts from https://www.youtube.com/watch?v=PbFE0m9UMtE. If you get value from LlamAcademy, consider becoming a Patreon supporter at https://www.patreon.com/llamacademy
using TMPro;
using UnityEngine;
[RequireComponent(typeof(TextMeshProUGUI))]
public class BuildDisplayer : MonoBehaviour
{
private TextMeshProUGUI Text;
private void Awake()
{
@unitycoder
unitycoder / CaptureScreen.cs
Created July 18, 2021 20:30
Capture Screenshot Async
// https://forum.unity.com/threads/resulting-screenshot-image-in-game-is-upside-down-and-not-correctly-positioned.848230/
using UnityEngine;
using UnityEngine.Rendering;
using Unity.Collections;
using System;
using System.IO;
using System.Collections;
 
public class CaptureScreen : MonoBehaviour
{