Skip to content

Instantly share code, notes, and snippets.

View michael811125's full-sized avatar

MichaelO michael811125

View GitHub Profile
@michael811125
michael811125 / MultiLayerBar.cs
Last active August 24, 2023 04:02
Multi-Layer Bar for Unity
using UnityEngine;
using UnityEngine.UI;
using MyBox;
using System;
using System.Linq;
public class MultiLayerBar : MonoBehaviour
{
public enum ProgressType
{
@michael811125
michael811125 / IsometricRenderer.cs
Last active July 8, 2023 02:34
Isometric baseline to control z-index for all renderers in Unity
using UnityEngine;
public class IsometricRenderer : MonoBehaviour
{
[SerializeField, Tooltip("For static GameObject (just init once).")] private bool _isStatic = false;
[SerializeField, Tooltip("If checked will always update for renderer to keeps size of bounds is newest.")] private bool _isUpdate = false;
[SerializeField, Tooltip("Bounds offset (X and Y).")] private Vector2 _offsetBounds = Vector2.zero;
[SerializeField, Tooltip("Baseline for Z-Index")] private float _floorHeight;
[SerializeField, Tooltip("Adjust scale for height")] private float _heightScale = 1;
@michael811125
michael811125 / ExtensionHelps.cs
Last active July 9, 2023 14:06
ExtensionHelps for Unity
using Cysharp.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OxGKit.Utilities.Button;
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.Universal;
using UnityEngine.UI;
@michael811125
michael811125 / InputFieldPlaceholderController.cs
Last active July 18, 2023 05:45
Control input field placeholder show and hide in Unity
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class InputFieldPlaceholderController : MonoBehaviour
{
private InputField _inputField;
private TMP_InputField _tmpInputField;
private void Awake()
@michael811125
michael811125 / AutoOverlayUICamera.cs
Last active July 8, 2023 02:32
Auto set URP base camera with UICamera in Unity
using MyBox;
using UnityEngine;
public class AutoOverlayUICamera : MonoBehaviour
{
public string castCameraTag = "CastCamera";
public string overlayUICameraTag = "UICamera";
public bool autoOverlay = false;
[ConditionalField(nameof(autoOverlay))]
public int autoByDepth = 0;
@michael811125
michael811125 / RectTransformTools.cs
Created June 27, 2023 03:00 — forked from YashVakil96/RectTransformTools.cs
Set Custom Anchor Position of the UI Element | Unity
using UnityEngine;
using UnityEditor;
public class RectTransformTools {
[MenuItem("GameObject/Adjust RectTransform Anchors &a")]
static void Adjust()
{
foreach(GameObject gameObject in Selection.gameObjects){
adjustRectTransform(gameObject);
@michael811125
michael811125 / ScreenRecorder.cs
Created May 29, 2023 09:28 — forked from DashW/ScreenRecorder.cs
ScreenRecorder - High Performance Unity Video Capture Script
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
class BitmapEncoder
{
public static void WriteBitmap(Stream stream, int width, int height, byte[] imageData)
@michael811125
michael811125 / CryptoUtil.cs
Created March 19, 2023 20:11 — forked from enif-lee/CryptoUtil.cs
C# AES256 encryption and decryption example for using easily.
public class CryptoUtil
{
public static byte[] EncryptAes256(byte[] bytes, byte[] key)
{
using var aes = new RijndaelManaged
{
Key = CreateDeriveBytes(key, 32),
};
aes.GenerateIV();
@michael811125
michael811125 / PlayerLoop.cs
Created January 31, 2023 03:28 — forked from LotteMakesStuff/PlayerLoop.cs
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;