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 / 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 / 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 / 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 / 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 / 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
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