Skip to content

Instantly share code, notes, and snippets.

@edwios
edwios / Events & Delegates in Unity C#
Created March 13, 2023 07:54 — forked from dylanfries/Events & Delegates in Unity C#
Events and Delegates for Unity (C#)
Events & Delegates
------------------
Events and Delegates were something I struggled with when I was first learning how they worked. Once I figured it out it became one of the most useful and powerful techniques for games. Its especially useful for helping to decouple classes while allowing for messaging.
Delegates - Simply a container for a function that can be used as a variable.
Events - Allows you to specify a delegate that gets called when some event in your code is triggered.
Overview
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFt8ACUBEADGde8BPTcDRFv6vZ356aEiq6YKZhrQCgzlXdrdJh6lXENPKEmN
5PBz/xjubNoLff4zlusaSKso2L6xG0PkSqXanLYAQUIB8TfML01gaBtmO+tIkHZP
o+yvBbtS9679T+twHDCT+t4kkt9FqsHzOSNvSEsqYEZ9/76YRqL0ijAlUOkwawAA
rBu217MEsrCvvsC94V3F6+6hgu+glDSuFPjfBjFIeM5uDJF9al2nB/UFoxwu0l3a
8Jmq6X92X16u0bXyzTxF7nfzhg8Vncp6LPZJteJGrx2OKvLaG8zzqq8bi3IjfJ2l
MVXlK7H9+t+1z2qCvRcu96maI4qrXjAgjja9lSRaTX23ZuhCqtz7egIH+cJgcMQe
zdMAvGSr3lpkQAuFQkIvxqoSg/4qVyzivMQ2ckjJ0IcLrCIy/1SCrgOCgv8XECzz
AJ3pXYkBV+YVWyin/l9W/qMmfVK5SNfGyU0YXkRS+TWcEwaKfa3D7VqM4RcL7Cq/
@edwios
edwios / iOS Backup to Ext HD.md
Created April 4, 2022 09:35
iOS Backup to Ext HD

To summarise the above:

  1. Very important, go to System Preferences -> Security. Click on the Privacy tab and choose Full Disk Access. Click 🔒 at the lower left hand corner to unlock. Then √ the Terminal.app.
  2. In Finder, choose from the menu Go -> Go to folder, then paste the following line: ~/Library/Application Support/MobileSync
  3. You should then see a folder called Backup. Copy this folder to the external hard disk.
  4. Optional: Create a folder called Backup somewhere else on your external harddisk.
  5. Open Terminal app then type: sudo -s When asked, type your Mac login password.
@edwios
edwios / Server.py
Last active June 25, 2021 09:56 — forked from kristoferjoseph/Server.py
A simper python http server can handle mime type properly
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
@edwios
edwios / mbpbattmgr.sh
Created May 31, 2021 08:35
Script to optimise MBP battery life
#!/bin/bash
sleeptime=60
BatteryAlert(){
percentage=$(pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f1 -d';' | sed 's/%//' | bc)
charging=`pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f2 -d';' | tr -d ' \n'`
alertlevel=10
chargelevel=75
prefchargelevel=85
person
bicycle
car
motorcycle
airplane
bus
train
truck
boat
traffic light
sudo apt-get update
sudo apt-get install libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev -y
wget www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
tar xvf bluez-5.50.tar.xz && cd bluez-5.50
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental
make -j4
sudo make install
sudo reboot
bluetoothctl -v
@edwios
edwios / ARObjectHitDetect.cs
Last active April 14, 2020 05:52
Example to how to place a game object in AR mobile
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
[RequireComponent(typeof(ARRaycastManager))]
public class ARObjectHitDetect : MonoBehaviour
{
@edwios
edwios / .gitignore
Created April 9, 2020 07:45
GitIgnore file for Cocoon
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
@edwios
edwios / iwct-patches.md
Last active January 31, 2020 09:08
IWCT for iOS

IWCT (Unity-IBM) Patches

There are a number of fatal exceptions that will throw when IWCT is compiled under iOS. Followings are the changes required for IWCT to work on the iOS.

Patch InstantPreview.cs

Path: /Assets/GoogleVR/Scripts/InstantPreview/Internal/InstantPreview.cs


private static void RunCommand(string fileName, string arguments, out string output, out string errors)