Skip to content

Instantly share code, notes, and snippets.

View ertanturan's full-sized avatar
:shipit:
Happy

Ertan Turan ertanturan

:shipit:
Happy
View GitHub Profile
@ertanturan
ertanturan / git_lfs_track_command
Created July 10, 2023 22:14
Git LFS Track command for most common file types used in Unity
git lfs track "*.unity" "*.prefab" "*.mat" "*.asset" "*.fbx" "*.wav" "*.tga" "*.psd" "*.cs" "*.png" "*.jpg" "*.jpeg" "*.bmp" "*.tif" "*.tiff" "*.exr" "*.hdr" "*.fbx" "*.blend" "*.obj" "*.dae" "*.3ds" "*.stl" "*.ply" "*.glb" "*.gltf" "*.wav" "*.mp3" "*.ogg" "*.flac" "*.aac" "*.mp4" "*.mov" "*.avi" "*.mkv" "*.psd" "*.tga" "*.exr" "*.hdr" "*.zip" "*.rar" "*.7z" "*.tar" "*.gz" "*.dll" "*.so" "*.dylib" "*.apk" "*.ipa" "*.ttf" "*.otf" "*.pdf" "*.doc" "*.xls" "*.ppt" "*.csv" "*.mov" "*.avi" "*.mkv" "*.ogg" "*.ogv" "*.webm" "*.flv" "*.swf" "*.psd" "*.ai" "*.sketch" "*.mp3" "*.ogg" "*.wav" "*.aif" "*.aac" "*.fbx" "*.prefab" "*.mat" "*.asset" "*.controller" "*.unitypackage"
@ertanturan
ertanturan / Curve.cs
Last active July 5, 2023 16:48
Basic/Primitive Curve maker and viewer for Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
[Serializable]
public class Curve
{
public Vector3[] points;
public int generateCount;
@ertanturan
ertanturan / StringExtensions.cs
Last active December 2, 2022 21:43
case insensitive contains and equals in the least garbage-making way possible
public static class StringExtensions
{
/// <summary>
/// Check if a string contains another case insensitively.
/// </summary>
/// <param name="text">string to search in</param>
/// <param name="value">string to search for</param>
/// <param name="stringComparison">comparison option enum</param>
/// <returns></returns>
public static bool CaseInsensitiveContains(this string text, string value,
@ertanturan
ertanturan / PointTransformation.cs
Last active December 2, 2022 21:46
Scaled and Unscaled point transformations
using UnityEngine;
public class PointTransformation{
public static Vector3 TransformPoint(this Transform targetTransform, Vector3 vectorToChange)
{
return targetTransform.localToWorldMatrix.MultiplyPoint3x4(vectorToChange);
}
public static Vector3 InverseTransformPoint(this Transform targetTransform, Vector3 vectorToInverse)
@ertanturan
ertanturan / FindMissingScriptsRecursively.cs
Last active September 8, 2022 09:23
Find the missinc scripts in scene
using UnityEngine;
using UnityEditor;
public class FindMissingScriptsRecursively
{
private static void FindInGameObject(GameObject g)
{
Component[] components = g.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
@ertanturan
ertanturan / MaterialController.cs
Last active September 22, 2022 09:54
Change Surface type and Blendmode of materials at runtime when using LWRP or HDRP
using System;
using UnityEngine;
using UnityEngine.Rendering;
public class MaterialController : MonoBehaviour
{
public enum BlendMode
{
Alpha,
Premultiply,
@ertanturan
ertanturan / ReflectionUtilityExtension.cs
Last active May 13, 2022 11:41
Copy Properties and/or Fields of a class to another
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public static class ReflectionUtilityExtension
{
public static void CopyPropertiesTo<T, U>(this T source, U dest)
{
List<PropertyInfo> sourceProps = typeof(T).GetProperties().Where(x => x.CanRead).ToList();
List<PropertyInfo> destProps = typeof(U).GetProperties()
@ertanturan
ertanturan / Singleton.cs
Created February 9, 2022 15:36
Unity Scene Singleton Base Class
using UnityEngine;
public class Singleton<T> : MonoBehaviour where T : Component
{
[Header("Singletion Properties")]
public bool DontDestroyOnLoading = false;
public static T Instance
{
get
@ertanturan
ertanturan / UVAnimation
Last active February 9, 2022 15:37
Real-Time Unity UV Traffic Animation
using UnityEngine;
using System.Collections;
public class UVAnimation : MonoBehaviour {
public int uvTileY = 4; // texture sheet columns
public int uvTileX = 4; // texture sheet rows
public int fps = 30;
private int index;
@ertanturan
ertanturan / AnchorRealtime.cs
Created February 7, 2022 11:55
Unity UI Real-time anchoring
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class AnchorRealtime
{
//------------Top-------------------
public static void TopLeft(RectTransform uitransform)
{