Skip to content

Instantly share code, notes, and snippets.

View dyguests's full-sized avatar
:octocat:
٩(˃̶͈̀௰˂̶͈́)و

fanhl dyguests

:octocat:
٩(˃̶͈̀௰˂̶͈́)و
  • ChengDu.China
View GitHub Profile
@dyguests
dyguests / launchTry.kt
Created June 6, 2024 02:11
kotlin CoroutineScope.launchTry{}.catch{}
package com.dyguests.util
import androidx.annotation.CheckResult
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
/**
* Launch a coroutine with error handling support.
@dyguests
dyguests / CommonInput.cs
Created June 2, 2024 12:44
CommonInput.cs
using UnityEngine;
namespace Inputs
{
public abstract class CommonInput : MonoBehaviour
{
protected InputActions InputActions { get; private set; }
protected virtual void Awake()
{
@dyguests
dyguests / Singleton.cs
Last active May 11, 2024 22:04 — forked from luke161/Singleton.cs
Unity MonoBehaviour Singleton. Base class for creating a singleton in Unity, handles searching for an existing instance, useful if you've created the instance inside a scene. Also handles cleaning up of multiple singleton instances in Awake.
// ReSharper disable once InvalidXmlDocComment
/**
* Singleton.cs
* Author: Luke Holland (http://lukeholland.me/)
*/
using System;
using UnityEngine;
namespace Koyou.Commons
@dyguests
dyguests / CustomAndroidPreprocessBuild.cs
Created December 21, 2023 04:05
Unity set Android JAVA_HOME
using System;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
public class CustomAndroidPreprocessBuild : IPreprocessBuildWithReport
{
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
@dyguests
dyguests / .gitignore
Last active May 25, 2024 07:47
unity.gitignore
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
# Uncomment this line if you wish to ignore the asset store tools plugin
# [Aa]ssets/AssetStoreTools*
@dyguests
dyguests / ObjectEx.cs
Created November 1, 2022 14:38
ObjectEx, Let, Also, C#
namespace Plugins.FanhlCores.Scripts.Tools
{
public static class ObjectEx
{
// Kotlin: fun <T, R> T.let(block: (T) -> R): R
public static R Let<T, R>(this T self, Func<T, R> block)
{
return block(self);
}
@dyguests
dyguests / LogGui.cs
Created October 18, 2022 13:51
LogGui, Unity log on screen, Screen Log.
using System.Collections.Generic;
using UnityEngine;
namespace Plugins.FanhlCores.Tools
{
public class LogGui : MonoBehaviour
{
private const int MaxChars = 10000;
private static LogGui sInstance;
@dyguests
dyguests / EnumerableEx.cs
Created October 16, 2022 13:36
EnumerableEx, Enumerable Extension.
using System.Collections.Generic;
namespace Cores.Tools
{
public static class EnumerableEx
{
public static bool Unanimous<T>(this IEnumerable<T> enumerable)
{
using var enumerator = enumerable.GetEnumerator();
if (enumerator.MoveNext())
@dyguests
dyguests / BufferHandler.cs
Last active October 17, 2022 14:05
BufferHandler, BufferedHandler, SpoolHandler, 缓存处理, 多个操作连续处理
using System;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using JetBrains.Annotations;
namespace Plugins.FanhlCores.Tools
{
public class BufferHandler<T>
{
private readonly Queue<T> items = new();
@dyguests
dyguests / IObserver.cs
Created September 18, 2022 07:18
C#, Unity, 观察者模式, 审查者模式, 观察者模式变体, ISubject, IObserver
namespace Tools
{
public interface IObserver<out T>
{
T Updater { get; }
}
}