Skip to content

Instantly share code, notes, and snippets.

View James-Frowen's full-sized avatar

James Frowen James-Frowen

View GitHub Profile
@James-Frowen
James-Frowen / SingletonScriptableObject.cs
Created February 15, 2018 13:32
Weird implementation of Singleton for ScriptableObjects
using UnityEngine;
namespace JamesFrowen.Variables
{
public abstract class SingletonScriptableObject<T> : ScriptableObject where T : ScriptableObject
{
protected static T _instance;
public static T Instance
{
get
@James-Frowen
James-Frowen / IMonoBehaviour.cs
Last active March 25, 2019 16:04
Interface including useful methods of MonoBehaviour
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IMonoBehaviour
{
// Object
string name { get; }
// Component
@James-Frowen
James-Frowen / SerializedEditorWindow.cs
Last active March 25, 2019 16:43
Base Class for editor windows in Unity3d
using UnityEditor;
using UnityEngine;
namespace EditorScripts
{
public abstract class SerializedEditorWindow : EditorWindow
{
/// <summary>
/// Serialization target, can be overridden to allow target to be something other than this editor window
/// </summary>
@James-Frowen
James-Frowen / ScriptableObjectReferenceExample.cs
Last active June 26, 2020 21:09
Unity3d ScriptableObject Reference Example, concept from https://youtu.be/raQ3iHhE_Kk
/*
GameObject A would have PlayerControler and SetPlayerReference.
GameObject B would have WantsToUsePlayer.
SetPlayerReference and WantsToUsePlayer have same PlayerReference set via the inspector.
WantsToUsePlayer will be able to use PlayerReference to have reference to PlayerControler. Even if GameObject A is spawned from a prefab after the game starts.
*/
@James-Frowen
James-Frowen / FixedDistanceMove.cs
Last active June 26, 2020 21:11
Move script for fixed distance moving, Useful when moving between spaces on a grid
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FixedDistanceMove : MonoBehaviour
{
private bool moving = false;
public void StartMove(Vector3 target, float travelTime)
{
@James-Frowen
James-Frowen / SendImage.cs
Last active June 26, 2020 21:17
Script to send image over multiple packets
using System;
using System.Collections;
using System.IO;
using Mirror;
using UnityEngine;
namespace ScreenShotDemo
{
public class SendImage : MonoBehaviour
{
@James-Frowen
James-Frowen / TelepathyTransportWithLag.cs
Last active June 26, 2020 23:22
TelepathyTransport for mirror but with an array of queues to store message for `framesOfLag` frames before being processed by mirror. `chanceToSkip` can be used to add random delay to some frames skipping an extra frames before they are read/processed
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Net.Sockets;
using Telepathy;
using UnityEngine;
using UnityEngine.Serialization;
namespace Mirror
public abstract class AssetSet : ScriptableObject { }
public abstract class AssetSet<T> : AssetSet where T : Object
{
[SerializeField] protected List<T> _items = new List<T>();
private Dictionary<string, T> _dictionary;
public string TypeName => typeof(T).Name;
public const string CAN_NOT_FIND_WARNING = "{0} could not find {1}";
using System.IO;
using UnityEditor;
using UnityEngine;
namespace JamesFrowen.EditorScripts
{
public static class SpriteMaker
{
[MenuItem("Tools/Sprite Maker/Make Circle 256x256")]
public static void MakeCircle()
@James-Frowen
James-Frowen / ChildNetworkBehaviours.cs
Last active August 31, 2020 11:17
Allows syncing of NetworkBehaviours in child objects.
using System;
using System.Linq;
using Mirror;
using UnityEngine;
namespace JamesFrowen.MirrorExamples
{
/// <summary>
/// Sync NetworkBehviours in chuld objects
/// </summary>