Skip to content

Instantly share code, notes, and snippets.

View YashVakil96's full-sized avatar
🎯
Focusing

Yash Vakil YashVakil96

🎯
Focusing
  • Rajkot
View GitHub Profile
@YashVakil96
YashVakil96 / UnitySerializedDictionaty.cs
Created December 11, 2024 10:53
Serialized Dictionary
using System.Collections.Generic;
using UnityEngine;
public abstract class UnitySerializedDictionaty<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
{
[SerializeField] private List<KeyValueData> keyValueData = new List<KeyValueData>();
public void OnBeforeSerialize()
{
keyValueData.Clear();
@YashVakil96
YashVakil96 / one-page-gdd.md
Created October 24, 2024 09:36 — forked from dlweatherhead/one-page-gdd.md
One Page GDD in Markdown [credit BiteMe Games]
@YashVakil96
YashVakil96 / UIContentCarousel.cs
Created October 11, 2024 05:58
Auto Image Carousal Unity
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UIContentCarousel : MonoBehaviour, IEndDragHandler, IBeginDragHandler
{
[Header("Important Information")]
[Tooltip("Ensure that a GridLayoutGroup is assigned to CONTENT. The correct layout group is crucial for the proper functioning of the carousel.")]
[TextArea(3, 5)]
public string layoutGroupWarning;
@YashVakil96
YashVakil96 / GetSelectedObject.cs
Created September 13, 2023 06:43
Get Selected Object In Hierarchy in Script
using UnityEditor;
using UnityEngine;
public class GetSelectedObject : MonoBehaviour
{
public static GameObject a;
[MenuItem("Tools/Select Object &a")]
static void SelectObject()
{
@YashVakil96
YashVakil96 / InspectorLockToggle.cs
Created September 12, 2023 11:12
Inspector Lock and Clear Console Shortcut key For Unity
using System;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using System.Collections;
using Object = UnityEngine.Object;
public class InspectorLockToggle
{
@YashVakil96
YashVakil96 / EditorMenus.cs
Last active September 18, 2023 17:38
Unity Inspector Lock Shortcut For Unity
using UnityEditor;
static class EditorMenus
{
// taken from: http://answers.unity3d.com/questions/282959/set-inspector-lock-by-code.html
[MenuItem("Tools/Toggle Inspector Lock %l")] // Ctrl + L
static void ToggleInspectorLock()
{
ActiveEditorTracker.sharedTracker.isLocked = !ActiveEditorTracker.sharedTracker.isLocked;
ActiveEditorTracker.sharedTracker.ForceRebuild();
@YashVakil96
YashVakil96 / Singleton.cs
Created September 7, 2023 04:30
Creates SingleTon of a given Class
using UnityEngine;
/// <summary>
/// Be aware this will not prevent a non singleton constructor
/// such as `T myT = new T();`
/// To prevent that, add `protected T () {}` to your singleton class.
///
/// As a note, this is made as MonoBehaviour because we need Coroutines.
/// </summary>
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
@YashVakil96
YashVakil96 / ScreenSize.cs
Last active September 7, 2023 04:31
Get Screen Size
using UnityEngine;
public class ScreenSize
{
public static float GetScreenToWorldHeight
{
get
{
Vector2 topRightCorner = new Vector2(1, 1);
Vector2 edgeVector = Camera.main.ViewportToWorldPoint(topRightCorner);
var height = edgeVector.y * 2;
@YashVakil96
YashVakil96 / FPSScript.cs
Created July 18, 2022 07:28
Show FPS counter
using TMPro;
using UnityEngine;
public class FPSScript : MonoBehaviour
{
/// <summary>
/// Delta time
/// </summary>
float deltaTime = 0.0f;
@YashVakil96
YashVakil96 / RectTransformTools.cs
Last active September 7, 2023 04:35
Set Custom Anchor Position of the UI Element | Unity
using UnityEngine;
using UnityEditor;
public class RectTransformTools {
[MenuItem("GameObject/Adjust RectTransform Anchors &a")]
static void Adjust()
{
foreach(GameObject gameObject in Selection.gameObjects){
adjustRectTransform(gameObject);