Skip to content

Instantly share code, notes, and snippets.

View JacekWozniak12's full-sized avatar

Jacek Woźniak JacekWozniak12

  • Poland, Małopolska
View GitHub Profile
@JacekWozniak12
JacekWozniak12 / Unity_ScreenHelper.cs
Last active November 10, 2022 08:22
Create screenshots of entry points from multiple scenes.
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Unity_ScreenHelper : MonoBehaviour
{
// Here is container with scenes.
// Assuming that SceneName property of element
// contains name of scene.
// IMPORTANT: add scene to build first.
@JacekWozniak12
JacekWozniak12 / Unity_UIElements.cs
Created April 5, 2022 20:41
Little boiler plate that packs creation and members setting into one function extension.
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public static class UIElements
{
/// <summary>
/// Creates layout element and sets the corresponding
/// size values to the members if
/// those values does not equal 0
@JacekWozniak12
JacekWozniak12 / C#__Loop.cs
Created January 2, 2021 23:46
Simple functions that handles looping between min and max. Useful for selecting items via mouse scroll (FPS weapons for example).
public static class MathL
{
/// <summary>
/// Sets value from min to max, when value exceeds min, then it is set to max and vice versa
/// </summary>
public static int Loop(int value, int min, int max)
{
if (value < min) value = max;
else if (value > max) value = min;
return value;
@JacekWozniak12
JacekWozniak12 / Unity__GetAssets.cs
Last active January 4, 2021 08:45
Simple generic function that makes getting Assets from AssetDatabase quick and easy.
using System.Collections.Generic;
using UnityEditor;
public static class Unity__GetAssets
{
/// <summary>Return unfiltered list of objects of type T, gets from default path.</summary>
/// <returns>Array of objects of type T where T is type of UnityEngine.Object</returns>
public static List<T> GetAssets<T>() where T : UnityEngine.Object
{
List<T> assets = new List<T>();
string[] AssetsGUID = AssetDatabase.FindAssets($"t:{typeof(T).Name}");