Skip to content

Instantly share code, notes, and snippets.

@mathiassoeholm
mathiassoeholm / DelayedComponent.tsx
Last active March 30, 2019 11:43
DelayedComponent for React
import React, { Component, ReactNode } from "react"
interface Props {
delayMs: number,
children: ReactNode,
}
interface State {
enabled: boolean,
}
@mathiassoeholm
mathiassoeholm / MainPage.xaml
Created August 9, 2017 08:40
CarouselView problem
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
xmlns:local="clr-namespace:StackLayoutBug"
x:Class="StackLayoutBug.MainPage"
SizeChanged="OnPageSizeChanged">
<Grid ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@mathiassoeholm
mathiassoeholm / TubeRenderer.cs
Last active May 7, 2024 11:54
Similar to Unity's LineRenderer, but renders a cylindrical mesh.
// Author: Mathias Soeholm
// Date: 05/10/2016
// No license, do whatever you want with this script
using UnityEngine;
using UnityEngine.Serialization;
[ExecuteInEditMode]
public class TubeRenderer : MonoBehaviour
{
[SerializeField] Vector3[] _positions;
@mathiassoeholm
mathiassoeholm / DancePad.cs
Created February 12, 2014 22:56
Unity dance pad input
using System;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;
namespace DancePadInput
{
public enum Player
{
Any,
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
public static Singleton Instance { get { return instance; } }
static Singleton() {}
private Singleton() {}
}
@mathiassoeholm
mathiassoeholm / LinqTest.cs
Created November 6, 2013 12:17
More complicated Linq test, Average failed on iOS
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class LinqTest : MonoBehaviour
{
public class MyClass
{
public Vector3 MyVector;
}
using UnityEditor;
using UnityEngine;
public static class NGUIResizeCollider
{
[MenuItem("Kiloo/NGUI Tools/Resize Collider")]
private static void ResizeCollider()
{
if (Selection.activeGameObject != null && (Selection.activeGameObject.collider as BoxCollider) != null)
{
@mathiassoeholm
mathiassoeholm / GetComponentExample.cs
Last active August 13, 2023 12:56
Example of how to access another GameObject's component
using UnityEngine;
public class GetComponentExample : MonoBehaviour
{
// First we need a reference to the other gameobject
// You can make a public field and assign a prefab in the inspector
public GameObject somePrefab;
// Or you can search for a gameobject and assign it to a variable
private GameObject gameObjectFoundBySearch;
@mathiassoeholm
mathiassoeholm / FizzBuzz.cs
Last active December 14, 2015 22:49
FizzBuzz in one line
using System;
using System.Linq;
class FizzBuzz
{
static void Main()
{
Console.WriteLine(
String.Join(
Environment.NewLine,