Skip to content

Instantly share code, notes, and snippets.

View hman278's full-sized avatar
🎯
Focusing

Sargis hman278

🎯
Focusing
  • Cassette
  • Yerevan
View GitHub Profile
@hman278
hman278 / main.dart
Created January 29, 2022 13:34
Simple Bloc Counter App Flutter
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
void main() {
runApp(const MyApp());
}
abstract class CounterEvent extends Equatable {
@override
@hman278
hman278 / main.dart
Last active February 7, 2022 12:05
navigation
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends MaterialApp {
const MyApp({Key? key}) : super(home: const TextPage(), key: key);
}
@hman278
hman278 / main.dart
Last active February 7, 2022 12:04
calculator on flutter
import 'package:flutter/material.dart';
import 'package:flutter_layout_grid/flutter_layout_grid.dart';
import 'package:math_expressions/math_expressions.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@hman278
hman278 / UnoptimizedTVNoise.cs
Created December 29, 2023 14:06
I made this on accident, maybe someone finds the useful (Use RenderMeshIndirect for speed)
using System.Collections;
using UnityEngine;
public class NoInstancing : MonoBehaviour
{
private struct MeshData
{
public Vector3 offset;
public Quaternion rotation;
public Color color;
@hman278
hman278 / ScreenshotTool.cs
Created February 2, 2024 13:28
Take a screenshot using a specified camera in-game in Unity
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using Directory = UnityEngine.Windows.Directory;
public class ScreenshotTool : MonoBehaviour
{
[SerializeField] private Camera _targetCamera;
[SerializeField] private Vector2Int _targetResolution = new Vector2Int(1000, 1000);
@hman278
hman278 / DominantTerrainLayer.cs
Created February 23, 2024 12:29
Get the most dominant terrain layer at a certain position
private void GetColorAtPosition(ref Vector2Int position)
{
float[,,] alphamaps = _terrainData.GetAlphamaps(position.x, position.y, 1, 1);
int dominantLayer = 0;
// Represents the most dense terrain layer applied at the supplied position
float maxDensity = 0f;
for (int i = 0; i < alphamaps.GetLength(2); ++i)
{
if (alphamaps[0, 0, i] > maxDensity)
@hman278
hman278 / TextureNoTile.hlsl
Created May 26, 2024 08:12
Shader function for Unity to randomize texture tiling using hashing
// Credit: https://www.shadertoy.com/view/lt2GDd
half4 hash4(float2 p)
{
return frac(sin(float4(1.0 + dot(p, float2(37.0, 17.0)),
2.0 + dot(p, float2(11.0, 47.0)),
3.0 + dot(p, float2(41.0, 29.0)),
4.0 + dot(p, float2(23.0, 31.0)))) * 103.0);
}
half4 HashedTextureNoTile(
@hman278
hman278 / Tracer.cs
Created August 15, 2024 13:25
Opsive UltimateCharacterController Tracer
using Cysharp.Threading.Tasks;
using Opsive.Shared.Game;
using UnityEngine;
/// <summary>
/// This custom tracer will show a Trail Renderer that will travel from
/// start point to end point.
/// </summary>
public class Tracer : MonoBehaviour
{