Skip to content

Instantly share code, notes, and snippets.

View hasantarhan's full-sized avatar

Hasan Tarhan hasantarhan

View GitHub Profile
@hasantarhan
hasantarhan / CardRigidbody.cs
Created December 29, 2024 12:08
Card Rigidbody for Unity UI
using UnityEngine;
public class CardRigidbody : MonoBehaviour
{
public float rotationAmount = 10f;
public float maxRotationAngle = 360f;
public float springStiffness = 100f;
public float springDamping = 10f;
public float mass = 3f;
@hasantarhan
hasantarhan / InstancedDrawer.cs
Last active September 12, 2023 12:37
InstancedDrawer
public class InstancedDrawer : MonoBehaviour
{
public Mesh mesh;
public Material material;
public int count = 50;
public float minScale = 1;
public float maxScale = 1;
private Matrix4x4[][] matrices;
[Space]
@hasantarhan
hasantarhan / VelocityUtil.cs
Created January 25, 2023 10:54
Velocity Util
using UnityEngine;
public class VelocityUtil
{
private readonly Transform _transform;
private Vector3 lastPosition;
public Vector3 Motion { get; private set; }
public float speed;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Serialization;
public class Ball : MonoBehaviour
{
private bool isActive;
[SerializeField] private Vector3 gravity = new Vector3(0, -9.81f, 0);
@hasantarhan
hasantarhan / tuberenderer.cs
Created September 19, 2019 12:44
TubeRenderer
// Date: 05/10/2016
// No license, do whatever you want with this script
using UnityEngine;
using UnityEngine.Serialization;
public class TubeRenderer : MonoBehaviour
{
[SerializeField] Vector3[] _positions;
[SerializeField] int _sides;
@hasantarhan
hasantarhan / TargetController.cs
Created August 20, 2019 21:04
TargetController
using UnityEngine;
using System.Collections;
public class TargetController : Singleton<TargetController>
{
public GameObject target;
public bool isMouseDrag;
public Vector3 screenPosition;
public float speed = 10;
public Vector3 offset;
public Task FetchDataAsync()
{
Debug.Log("Fetching data...");
Task fetchTask = Firebase.RemoteConfig.FirebaseRemoteConfig.FetchAsync(
TimeSpan.Zero);
return fetchTask.ContinueWithOnMainThread(FetchComplete);
}
void FetchComplete(Task fetchTask)
{
@hasantarhan
hasantarhan / FirebaseRemoteHandler.cs
Last active July 23, 2019 19:48
Firebase Remote Handler
using Firebase.Extensions;
using System;
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using Firebase.RemoteConfig;
using UnityEngine.SceneManagement;
using Firebase;
public class FirebaseRemoteHandler : MonoBehaviour
@hasantarhan
hasantarhan / PoolSystem.cs
Last active September 3, 2019 16:37
PoolSystem-Unity
using System;
using System.Collections.Generic;
public class PoolSystem<T> where T : UnityEngine.Object
{
private Stack<T> _stack;
public PoolSystem(IEnumerable<T> objects)
{
_stack = new Stack<T>();
foreach (var item in objects)
@hasantarhan
hasantarhan / EfRepositoryBase.cs
Last active June 8, 2023 15:52
EfRepositoryBase
public class EfEntityRepositoryBase<TEntity, TContext> : IEntityRepository<TEntity> where TContext : DbContext, new()
where TEntity : class, new()
{
public virtual void Add(TEntity entity)
{
using (TContext context = new TContext())
{
context.Entry(entity).State = EntityState.Added;
context.SaveChanges();//ASYNC