Skip to content

Instantly share code, notes, and snippets.

View alisahanyalcin's full-sized avatar
👨‍💻

Ali Şahan Yalçın alisahanyalcin

👨‍💻
View GitHub Profile
@alisahanyalcin
alisahanyalcin / imgui_node_graph_test.cpp
Created March 13, 2024 13:50 — forked from ocornut/imgui_node_graph_test.cpp
Node graph editor basic demo for ImGui
// Creating a node graph editor for Dear ImGui
// Quick sample, not production code!
// This is quick demo I crafted in a few hours in 2015 showcasing how to use Dear ImGui to create custom stuff,
// which ended up feeding a thread full of better experiments.
// See https://github.com/ocornut/imgui/issues/306 for details
// Fast forward to 2023, see e.g. https://github.com/ocornut/imgui/wiki/Useful-Extensions#node-editors
// Changelog
// - v0.05 (2023-03): fixed for renamed api: AddBezierCurve()->AddBezierCubic().
@alisahanyalcin
alisahanyalcin / AssetCopyUtils.cs
Created November 27, 2023 16:22 — forked from FreyaHolmer/AssetCopyUtils.cs
Adds context menu items to assets: Copy/Paste import settings & Copy GUID. Put this script in any Editor/ folder in your project and recompile!
// written by https://github.com/FreyaHolmer so use at your own risk c:
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
/// <summary>Utility functions to copy GUIDs, as well as Copy/Paste import settings</summary>
public static class AssetCopyUtils {
const int CTX_MENU_LOCATION = 70;
@alisahanyalcin
alisahanyalcin / ScrollViewFocusFunctions.cs
Created May 28, 2023 10:54 — forked from yasirkula/ScrollViewFocusFunctions.cs
Focus/center Scroll View to the specified point/item in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@alisahanyalcin
alisahanyalcin / PaddingIgnoringImage.cs
Created May 28, 2023 10:53 — forked from yasirkula/PaddingIgnoringImage.cs
Modified version of Image component that ignores the sprite's padding in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;
@alisahanyalcin
alisahanyalcin / LocalizeDropdown.cs
Created April 24, 2023 09:06
Unity Localize Dropdown Component
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using TMPro;
using UnityEditor;
public class LocalizeDropdown : MonoBehaviour
{
[SerializeField] private List<LocalizedString> dropdownOptions;
@alisahanyalcin
alisahanyalcin / Randomizer.cs
Created February 20, 2023 06:32
Create a dropdown to prefabs array
using UnityEngine;
using UnityEditor;
using Random = UnityEngine.Random;
namespace Randomizer
{
public class Randomizer : MonoBehaviour
{
public GameObject[] prefabs;
}
@alisahanyalcin
alisahanyalcin / CameraShake.cs
Last active August 22, 2021 16:56
Unity Camera Shake
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraShake : MonoBehaviour
{
const float maxAngle = 10f;
IEnumerator currentShakeCoroutine;
public void StartShake(Properties properties)
@alisahanyalcin
alisahanyalcin / PlayerGun.cs
Last active August 22, 2021 13:10
Unity Random Sound Play
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerGun : MonoBehaviour
{
public AudioSource hitSFX;
public void Shoot()
{
hitSFX.GetComponent<AudioSource>().GetComponent<RandomSound>().ShuffleSound();