Skip to content

Instantly share code, notes, and snippets.

View stramit's full-sized avatar

Tim Cooper stramit

View GitHub Profile
@stramit
stramit / CustomEvents.cs
Created September 4, 2014 06:16
Sending Custom Events via the EvenSystem
using System;
using System.Collections.Generic;
using UnityEngine.Events;
// interface you implement in your MB to receive events
public interface ICustomHandler : IEventSystemHandler
{
void OnCustomCode(CustomEventData eventData);
}
using System.Collections.Generic;
using System.Reflection;
namespace UnityEngine.EventSystems
{
[AddComponentMenu("Event/Standalone Input Module")]
public class StandaloneInputModule : PointerInputModule
{
private float m_NextAction;
@stramit
stramit / GraphicRaycaster.cs
Created June 25, 2014 08:12
GraphicRaycaster
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.EventSystems;
namespace UnityEngine.UI
{
[AddComponentMenu("Event/Graphic Raycaster")]
[RequireComponent(typeof(Canvas))]
public class GraphicRaycaster : BaseRaycaster, ISerializationCallbackReceiver
@stramit
stramit / TouchInputModule.cs
Created September 23, 2014 09:48
TouchInputModule (b19)
using System.Text;
namespace UnityEngine.EventSystems
{
[AddComponentMenu("Event/Touch Input Module")]
public class TouchInputModule : PointerInputModule
{
protected TouchInputModule()
{}
#if ENABLE_HYBRID_RENDERER_V2 && URP_9_0_0_OR_NEWER
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using UnityEngine;
using UnityEngine.Rendering;
namespace Unity.Rendering
{
using System;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine.UI.CoroutineTween;
namespace UnityEngine.UI
{
/// <summary>
/// Base class for all UI components that should be derived from when creating new Graphic types.
/// </summary>
@stramit
stramit / InputField.cs
Last active January 14, 2020 14:17
uGUI InputField (rc1)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
@stramit
stramit / UnityMethodValidator.cs
Last active June 10, 2019 16:16
Unity Method Validator
//Enable this if you want it to work in NUNIT, see the test example at the bottom
//#define UNIT_TESTING
/**
*
* https://i.imgur.com/GoH9rkv.png
*
* One of the frustrating things about Unity is that there are a spate of magic methods that can be
* called from the runtime. They do not have an interface defined, which by itself is pretty frustrating,
* but it can allow some valid c# that is bad Unity mojo. Consider a private 'OnEnable' function unity
@stramit
stramit / ControllerInputModule.cs
Last active December 27, 2018 18:20
ControllerInputModule.cs
using UnityEngine;
using UnityEngine.EventSystems;
[AddComponentMenu("Event/Controller Input Module")]
public class ControllerInputModule : BaseInputModule
{
private float m_NextAction;
protected ControllerInputModule()
{}
@stramit
stramit / SpecialEventClass.cs
Last active November 21, 2018 06:36
SpecialEventClass
/*
* When developing the UI system we came across a bunch of things we were not happy
* with with regards to how certain events and calls could be sent in a loosely coupled
* way. We had this requirement because with a UI you tend to implement widgets that receive
* certain events, but you don't really want to have lots of glue code to manage them
* and keep track of them. The eventing interfaces we developed helped with this. One of
* the interesting things, is that they are not justfor the UI system! You can use this as
* a type-safe, fast, and simple alternative to SendMessage (never use SendMessage!).
* So how does it all work?