Skip to content

Instantly share code, notes, and snippets.

View achimmihca's full-sized avatar

Andreas achimmihca

View GitHub Profile
@achimmihca
achimmihca / add-text-to-files.py
Created January 12, 2022 14:39
Add (prepend or append) text to files in a given folder. Thereby, file name and folder path are available as placeholders.
import glob
import os
import re
import ntpath
import sys
import argparse
from typing import List
# Example how this script can be called:
# python this-script.py --fileExtensions "txt" --prepend --onlyIfNew --ignorePathRegEx ".*ignore-me.*" --text "Hello {filename}!{newline}"
@achimmihca
achimmihca / SceneListEditorWindow.cs
Created December 28, 2020 14:52
[Unity3D] Show list of available scenes in a dedicated window
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEditor.SceneManagement;
using System.Linq;
using System;
using System.Globalization;
public class SceneListEditorWindow : EditorWindow
@achimmihca
achimmihca / CountFilesRecursive.java
Created September 30, 2020 07:07
Count files recursive. Show file count per extension for folder and sub-folders
import java.io.File;
import java.util.HashMap;
import java.util.stream.Collectors;
/**
* Execute via `java --source 11 "CountFilesRecursive.java" "path/to/folder"`
*/
public class CountFilesRecursive {
private static final String DEFAULT_FOLDER_PATH = "C:/Users/andi/Desktop";
@achimmihca
achimmihca / MoveParentWithoutAffectingChildren.cs
Created June 8, 2020 21:18
Unity3D Unity UI Move Parent RectTransform without affecting position and size (width, height) of child RectTransform
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
// Editor Script to move parent RectTransform without affecting position and size (width / height) of child RectTransforms
// Note however that (in this version of the script) the anchor positions are lost.
// Tested with Unity 2019.02
[InitializeOnLoad]
public static class MoveParentWithoutAffectingChildren
@achimmihca
achimmihca / MoveCornersToAnchors.cs
Created November 20, 2019 17:38
Unity3D Editor script that adds some MenuItem to move the corners of a RectTransform to its anchors.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public static class CornersToAnchorsMenuItems
{
// Hotkey: Alt+C
[MenuItem("Tools/Corners to Anchors (RectTransform)/Width and Height and Position &c")]
@achimmihca
achimmihca / AnchorsToCornersMenuItems.cs
Last active May 25, 2024 18:25
Unity3D Editor script that adds MenuItem to move the anchors of a RectTransform to its corners.
using UnityEditor;
using UnityEngine;
public static class AnchorsToCornersMenuItems
{
// Hotkey: Alt+A
[MenuItem("Tools/Anchors to Corners (RectTransform)/Width and Height &a")]
public static void MoveAnchorsToCorners()
{
EditorUtils.GetSelectedComponents<RectTransform>().ForEach(it =>
@achimmihca
achimmihca / RectTransformHelper.cs
Created November 20, 2019 17:26
Helper script to set values of a Unity3D RectTransform directly in the Inspector (e.g. size, sizeDelta, anchoredPosition)
using UnityEngine;
// Mimics several fields of a RectTransform for easier editing in the Inspector.
// Some of these fields are sometimes unavailable in the normal Inspector for a RectTransform.
// Notably the absolute size of a RectTransform can be set much more easily with this helper.
[RequireComponent(typeof(RectTransform))]
[ExecuteInEditMode]
public class RectTransformHelper : MonoBehaviour
{
// Fields of the RectTransform