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 / 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 / ExampleInterface.cs
Last active July 20, 2023 15:07
Unity3d, How to show an interface field in Inspector
namespace JamesFrowen
{
public interface ISomeInterface
{
void SomeMethod();
}
[System.Serializable]
public class SomeInterfaceWrapper : InterfaceWrapper<ISomeInterface>
{
@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 / 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 / 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 / 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