Skip to content

Instantly share code, notes, and snippets.

S. Tarık Çetin starikcetin

View GitHub Profile
@starikcetin
starikcetin / MainThreadDispatcher.cs
Last active July 27, 2022 16:45
Main thread dispatcher for Unity.
using System;
using System.Threading;
// TODO: Make sure Singleton implementation is also thread-safe.
/// <summary>
/// Provides means of executing code on the main Unity thread while in other threads.
/// </summary>
public class MainThreadDispatcher
{
@starikcetin
starikcetin / CanvasPositioningExtensions.cs
Created August 19, 2021 18:53 — forked from FlaShG/CanvasPositioningExtensions.cs
A small Unity helper class to convert viewport, screen or world positions to canvas space.
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>
@starikcetin
starikcetin / QuaternionUtil.cs
Created August 13, 2021 10:37 — forked from maxattack/QuaternionUtil.cs
Some Helper Methods for Quaternions in Unity3D
using UnityEngine;
/*
Copyright 2016 Max Kaufmann ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@starikcetin
starikcetin / ssh-connect-test.ps1
Created August 10, 2021 01:51
ssh setup scripts for windows
#############################################################################################################
#
# SSH connect test for Github, Gitlab, and Bitbucket.
#
# Copyright (c) 2021, S. Tarık Çetin.
# MIT licence.
#
#############################################################################################################
Write-Host "`n"
@starikcetin
starikcetin / Unity3D_character_To_KeyCode.cs
Created August 7, 2021 22:05 — forked from b-cancel/Unity3D_character_To_KeyCode.cs
UNITY 3D => Unity Key Codes to Characters (for MOST keys that display a character when pressed)
//NOTE: This is only a DICTIONARY with MOST character to keycode bindings... it is NOT a working cs file
//ITS USEFUL: when you are reading in your control scheme from a file
//NOTE: some characters SHOULD map to multiple keycodes (but this is impossible)
//since this is a dictionary, only 1 character is bound to 1 keycode
//EX: * from the keyboard will be read the same as * from the keypad... because they produce the same character in a text file
Dictionary<char, KeyCode> chartoKeycode = new Dictionary<char, KeyCode>()
{
//-------------------------LOGICAL mappings-------------------------
@starikcetin
starikcetin / NamespaceFillerAssetProcessor.cs
Last active November 7, 2019 19:21
NamespaceFillerAssetProcessor : Fills in #NAMESPACE# variables in Unity script templates. Source: https://stackoverflow.com/a/52395369/6301627
using System;
using UnityEditor;
using UnityEngine;
public class NamespaceFillerAssetProcessor : UnityEditor.AssetModificationProcessor
{
public static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
var index = path.LastIndexOf(".", StringComparison.Ordinal);
@starikcetin
starikcetin / Instantiator.cs
Last active October 22, 2019 01:31
Unity Edtor-time Prefab Instantiator For Context Menu
using UnityEditor;
using UnityEngine;
internal class Instantiator : ScriptableObject
{
private static Instantiator _instance;
private static Instantiator Instance
{
get
{
// container component
// a constructor is automatically generated for a component that has the same order with field declaration
// for example, for position component following ctor is generated: (x, y, z)
component position
float x
float y
float z
// component with single field
@starikcetin
starikcetin / LICENSE
Created September 3, 2019 15:46 — forked from JohannesMP/LICENSE
[Unity3D] A Reliable, user-friendly way to reference SceneAssets by script.
/*******************************************************************************
* Don't Be a Jerk: The Open Source Software License.
* Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
*******************************************************************************
* _I_ am the software author - JohannesMP on Github.
* _You_ are the user of this software. You might be a _we_, and that's OK!
*
* This is free, open source software. I will never charge you to use,
* license, or obtain this software. Doing so would make me a jerk.
*
@starikcetin
starikcetin / CallbackAggregator.cs
Created June 18, 2019 02:17
Callback aggregator
using System;
using System.Diagnostics.Contracts;
using UnityEngine;
using UnityEngine.Assertions;
namespace starikcetin
{
public class CallbackAggregator
{
private int JobCount { get; set; }