(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
using System.Collections; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public static class ScrollViewFocusFunctions | |
{ | |
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint ) | |
{ | |
Vector2 contentSize = scrollView.content.rect.size; | |
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size; |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEditor.Callbacks; | |
using UnityEngine; | |
namespace Maz.Unity.EditorExtensions | |
{ | |
[InitializeOnLoad] | |
public class EditorModeOnly | |
{ |
import androidx.annotation.NonNull; | |
import androidx.lifecycle.LiveData; | |
import androidx.lifecycle.MediatorLiveData; | |
import androidx.lifecycle.Observer; | |
import java.util.function.BiFunction; | |
public class CombinedLiveData<T, K, S> extends MediatorLiveData<S> { |
using UnityEngine; | |
/// <summary> | |
/// Resizes a UI element with a RectTransform to respect the safe areas of the current device. | |
/// This is particularly useful on an iPhone X, where we have to avoid the notch and the screen | |
/// corners. | |
/// | |
/// The easiest way to use it is to create a root Canvas object, attach this script to a game object called "SafeAreaContainer" | |
/// that is the child of the root canvas, and then layout the UI elements within the SafeAreaContainer, which | |
/// will adjust size appropriately for the current device./// </summary> |
using System.Collections.Generic; | |
using UnityEngine; | |
namespace Gists | |
{ | |
// The algorithm is from the "Fast Poisson Disk Sampling in Arbitrary Dimensions" paper by Robert Bridson. | |
// https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf | |
public static class FastPoissonDiskSampling | |
{ |
using UnityEngine; | |
/// <summary> | |
/// Small helper class to convert viewport, screen or world positions to canvas space. | |
/// Only works with screen space canvases. | |
/// </summary> | |
/// <example> | |
/// <code> | |
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position); | |
/// </code> |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package com.cesarferreira.asynctaskcallback; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.widget.Toast; | |
public class MainActivity extends Activity { | |
@Override |