Skip to content

Instantly share code, notes, and snippets.

View codehoose's full-sized avatar

Sloan Kelly codehoose

View GitHub Profile
[Serializable]
public class MyComponentData
{
public Vector3 pos;
public string name;
}
public class MyComponent : MonoBehaviour
{
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(Slider))]
public class SliderMenu : MonoBehaviour
{
Slider _slider;
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class CountdownController : MonoBehaviour
{
public int seconds = 10;
public Text countdown;
@codehoose
codehoose / SaveDropdownValue.cs
Created July 15, 2018 19:28
Code from the video https://youtu.be/3NzNIsJO2Hs. Saves the dropdown's selected item to playerprefs & reloads the value when the game restarts.
[RequireComponent(typeof(Dropdown))]
public class SaveDropdownValue : MonoBehaviour
{
const string PrefName = "optionvalue";
private Dropdown _dropdown;
void Awake()
{
_dropdown = GetComponent<Dropdown>();
@codehoose
codehoose / gist:63eef427cc9e7403f695b3a76f0975fc
Last active July 24, 2018 18:39 — forked from fairinrenish/gist:da233147657e563d45ac3f7a8ffde398
Slider Volume updation after returning to main menu from a different scene
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SliderVolumeValue : MonoBehaviour
{
const float DefaultVolume = 1f;
// Reference to Audio Source component
private AudioSource audioSrc;
@codehoose
codehoose / CardClass.cs
Created August 9, 2018 01:01 — forked from StuWookie/CardClass.cs
CSV to Dictionary - All credit to Sloane Kelly
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Card
{
public int CardID { get; set; }
public int CardLvl { get; set; }
public bool CardPlayed { get; set; }
using UnityEngine;
/// <summary>
/// Aspect ratio controller. Must be attached to the main camera.
/// </summary>
[RequireComponent(typeof(Camera))]
public class AspectRatio : MonoBehaviour
{
[Tooltip("The idea ratio that you want the world rendered at")]
public float perfectRatio = 16f / 9f;
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <string>
using namespace std;
@codehoose
codehoose / bbclient.cpp
Created November 10, 2018 23:56
Barebones TCP client for Linux
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <string>
using namespace std;
@codehoose
codehoose / GameSystems.cs
Created December 11, 2018 02:25
The `GameSystems` MonoBehaviour is the singleton and contains code to access the systems in the game from one location.
public class GameSystems : MonoBehaviour
{
private static GameSystems _instance;
public static GameSystems Instance
{
get
{
if (_instance == null)
{